mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
First attempt at update policies / modes.
This commit is contained in:
parent
4ea1ca7350
commit
f5f70da342
23 changed files with 999 additions and 49 deletions
|
@ -3,4 +3,5 @@ output.. = bin/
|
|||
bin.includes = META-INF/,\
|
||||
plugin.xml,\
|
||||
about.html,\
|
||||
.
|
||||
.,\
|
||||
icons/
|
||||
|
|
BIN
plugins/org.eclipse.dd.dsf.debug.ui/icons/refresh.gif
Normal file
BIN
plugins/org.eclipse.dd.dsf.debug.ui/icons/refresh.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 385 B |
|
@ -50,6 +50,157 @@
|
|||
verticalRulerPreferenceValue="true">
|
||||
</specification>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.ui.popupMenus">
|
||||
<viewerContribution
|
||||
id="org.eclipse.dd.dsf.debug.ui.update.UpdatePopup"
|
||||
targetID="org.eclipse.debug.ui.RegisterView">
|
||||
<menu
|
||||
id="org.eclipse.dd.dsf.debug.ui.update.UpdateModeSubMenu"
|
||||
label="Update Mode"
|
||||
path="additions">
|
||||
<groupMarker
|
||||
name="content">
|
||||
</groupMarker>
|
||||
<separator
|
||||
name="additions">
|
||||
</separator>
|
||||
</menu>
|
||||
<action
|
||||
class="org.eclipse.dd.dsf.debug.ui.viewmodel.update.actions.RefreshManualActionDelegate"
|
||||
id="org.eclipse.dd.dsf.debug.ui.update.registers.RefreshManual"
|
||||
label="Manual"
|
||||
menubarPath="org.eclipse.dd.dsf.debug.ui.update.UpdateModeSubMenu/content"
|
||||
style="radio">
|
||||
</action>
|
||||
<action
|
||||
class="org.eclipse.dd.dsf.debug.ui.viewmodel.update.actions.RefreshOnBreakActionDelegate"
|
||||
id="org.eclipse.dd.dsf.debug.ui.update.registers.RefreshOnBreak"
|
||||
label="On Breakpoint Hit"
|
||||
menubarPath="org.eclipse.dd.dsf.debug.ui.update.UpdateModeSubMenu/content"
|
||||
style="radio">
|
||||
</action>
|
||||
<action
|
||||
class="org.eclipse.dd.dsf.debug.ui.viewmodel.update.actions.RefreshAlwaysActionDelegate"
|
||||
definitionId="org.eclipse.debug.ui.RegisterView"
|
||||
id="org.eclipse.dd.dsf.debug.ui.update.registers.RefreshAlways"
|
||||
label="Always"
|
||||
menubarPath="org.eclipse.dd.dsf.debug.ui.update.UpdateModeSubMenu/content"
|
||||
state="true"
|
||||
style="radio">
|
||||
</action>
|
||||
</viewerContribution>
|
||||
<viewerContribution
|
||||
id="org.eclipse.dd.dsf.debug.ui.update.UpdatePopup"
|
||||
targetID="org.eclipse.debug.ui.ExpressionView">
|
||||
<menu
|
||||
id="org.eclipse.dd.dsf.debug.ui.update.UpdateModeSubMenu"
|
||||
label="Update Mode"
|
||||
path="additions">
|
||||
<groupMarker
|
||||
name="content">
|
||||
</groupMarker>
|
||||
<separator
|
||||
name="additions">
|
||||
</separator>
|
||||
</menu>
|
||||
<action
|
||||
class="org.eclipse.dd.dsf.debug.ui.viewmodel.update.actions.RefreshManualActionDelegate"
|
||||
id="org.eclipse.dd.dsf.debug.ui.update.registers.RefreshManual"
|
||||
label="Manual"
|
||||
menubarPath="org.eclipse.dd.dsf.debug.ui.update.UpdateModeSubMenu/content"
|
||||
style="radio">
|
||||
</action>
|
||||
<action
|
||||
class="org.eclipse.dd.dsf.debug.ui.viewmodel.update.actions.RefreshOnBreakActionDelegate"
|
||||
id="org.eclipse.dd.dsf.debug.ui.update.registers.RefreshOnBreak"
|
||||
label="On Breakpoint Hit"
|
||||
menubarPath="org.eclipse.dd.dsf.debug.ui.update.UpdateModeSubMenu/content"
|
||||
style="radio">
|
||||
</action>
|
||||
<action
|
||||
class="org.eclipse.dd.dsf.debug.ui.viewmodel.update.actions.RefreshAlwaysActionDelegate"
|
||||
id="org.eclipse.dd.dsf.debug.ui.update.registers.RefreshAlways"
|
||||
label="Always"
|
||||
menubarPath="org.eclipse.dd.dsf.debug.ui.update.UpdateModeSubMenu/content"
|
||||
state="true"
|
||||
style="radio">
|
||||
</action>
|
||||
</viewerContribution>
|
||||
<viewerContribution
|
||||
id="org.eclipse.dd.dsf.debug.ui.update.UpdatePopup"
|
||||
targetID="org.eclipse.debug.ui.VariableView">
|
||||
<menu
|
||||
id="org.eclipse.dd.dsf.debug.ui.update.UpdateModeSubMenu"
|
||||
label="Update Mode"
|
||||
path="additions">
|
||||
<groupMarker
|
||||
name="content">
|
||||
</groupMarker>
|
||||
<separator
|
||||
name="additions">
|
||||
</separator>
|
||||
</menu>
|
||||
<action
|
||||
class="org.eclipse.dd.dsf.debug.ui.viewmodel.update.actions.RefreshManualActionDelegate"
|
||||
id="org.eclipse.dd.dsf.debug.ui.update.registers.RefreshManual"
|
||||
label="Manual"
|
||||
menubarPath="org.eclipse.dd.dsf.debug.ui.update.UpdateModeSubMenu/content"
|
||||
style="radio">
|
||||
</action>
|
||||
<action
|
||||
class="org.eclipse.dd.dsf.debug.ui.viewmodel.update.actions.RefreshOnBreakActionDelegate"
|
||||
id="org.eclipse.dd.dsf.debug.ui.update.registers.RefreshOnBreak"
|
||||
label="On Breakpoint Hit"
|
||||
menubarPath="org.eclipse.dd.dsf.debug.ui.update.UpdateModeSubMenu/content"
|
||||
style="radio">
|
||||
</action>
|
||||
<action
|
||||
class="org.eclipse.dd.dsf.debug.ui.viewmodel.update.actions.RefreshAlwaysActionDelegate"
|
||||
id="org.eclipse.dd.dsf.debug.ui.update.registers.RefreshAlways"
|
||||
label="Always"
|
||||
menubarPath="org.eclipse.dd.dsf.debug.ui.update.UpdateModeSubMenu/content"
|
||||
state="true"
|
||||
style="radio">
|
||||
</action>
|
||||
</viewerContribution>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.ui.viewActions">
|
||||
<viewContribution
|
||||
id="org.eclipse.dd.dsf.debug.ui.viewmodel.update.Refresh"
|
||||
targetID="org.eclipse.debug.ui.RegisterView">
|
||||
<action
|
||||
class="org.eclipse.dd.dsf.debug.ui.viewmodel.update.actions.RefreshActionDelegate"
|
||||
icon="icons/refresh.gif"
|
||||
id="org.eclipse.dd.dsf.debug.ui.viewmodel.update.actions.Refresh"
|
||||
label="Refresh"
|
||||
toolbarPath="additions">
|
||||
</action>
|
||||
</viewContribution>
|
||||
<viewContribution
|
||||
id="org.eclipse.dd.dsf.debug.ui.viewmodel.update.Refresh"
|
||||
targetID="org.eclipse.debug.ui.VariableView">
|
||||
<action
|
||||
class="org.eclipse.dd.dsf.debug.ui.viewmodel.update.actions.RefreshActionDelegate"
|
||||
icon="icons/refresh.gif"
|
||||
id="org.eclipse.dd.dsf.debug.ui.viewmodel.update.actions.Refresh"
|
||||
label="Refresh"
|
||||
toolbarPath="additions">
|
||||
</action>
|
||||
</viewContribution>
|
||||
<viewContribution
|
||||
id="org.eclipse.dd.dsf.debug.ui.viewmodel.update.Refresh"
|
||||
targetID="org.eclipse.debug.ui.ExpressionView">
|
||||
<action
|
||||
class="org.eclipse.dd.dsf.debug.ui.viewmodel.update.actions.RefreshActionDelegate"
|
||||
icon="icons/refresh.gif"
|
||||
id="org.eclipse.dd.dsf.debug.ui.viewmodel.update.actions.Refresh"
|
||||
label="Refresh"
|
||||
toolbarPath="additions">
|
||||
</action>
|
||||
</viewContribution>
|
||||
</extension>
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.eclipse.dd.dsf.ui.viewmodel.AbstractVMAdapter;
|
|||
import org.eclipse.dd.dsf.ui.viewmodel.IVMContext;
|
||||
import org.eclipse.dd.dsf.ui.viewmodel.IVMLayoutNode;
|
||||
import org.eclipse.dd.dsf.ui.viewmodel.IVMRootLayoutNode;
|
||||
import org.eclipse.dd.dsf.ui.viewmodel.dm.AbstractDMVMProvider;
|
||||
import org.eclipse.dd.dsf.ui.viewmodel.dm.AbstractDMVMProviderWithCache;
|
||||
import org.eclipse.debug.core.DebugPlugin;
|
||||
import org.eclipse.debug.core.IExpressionsListener;
|
||||
import org.eclipse.debug.core.model.IExpression;
|
||||
|
@ -35,7 +35,7 @@ import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationCont
|
|||
*
|
||||
*/
|
||||
@SuppressWarnings("restriction")
|
||||
public class ExpressionVMProvider extends AbstractDMVMProvider
|
||||
public class ExpressionVMProvider extends AbstractDMVMProviderWithCache
|
||||
implements IExpressionsListener, IFormattedValuePreferenceStore
|
||||
{
|
||||
private String fDefaultFormatId = IFormattedValues.HEX_FORMAT;
|
||||
|
|
|
@ -43,6 +43,7 @@ import org.eclipse.dd.dsf.ui.viewmodel.AbstractVMProvider;
|
|||
import org.eclipse.dd.dsf.ui.viewmodel.IVMContext;
|
||||
import org.eclipse.dd.dsf.ui.viewmodel.VMDelta;
|
||||
import org.eclipse.dd.dsf.ui.viewmodel.dm.AbstractDMVMLayoutNode;
|
||||
import org.eclipse.dd.dsf.ui.viewmodel.update.VMCacheManager;
|
||||
import org.eclipse.debug.core.DebugException;
|
||||
import org.eclipse.debug.core.ILaunch;
|
||||
import org.eclipse.debug.core.model.IDebugTarget;
|
||||
|
@ -236,8 +237,9 @@ public class RegisterBitFieldLayoutNode extends AbstractExpressionLayoutNode<IBi
|
|||
*/
|
||||
FormattedValueDMContext valueDmc = regService.getFormattedValue(dmc, finalFormatId);
|
||||
|
||||
regService.getModelData(
|
||||
valueDmc,
|
||||
VMCacheManager.getVMCacheManager().getCache(update.getPresentationContext())
|
||||
.getModelData(regService,
|
||||
valueDmc,
|
||||
new DataRequestMonitor<FormattedValueDMData>(getSession().getExecutor(), null) {
|
||||
@Override
|
||||
public void handleCompleted() {
|
||||
|
@ -259,7 +261,8 @@ public class RegisterBitFieldLayoutNode extends AbstractExpressionLayoutNode<IBi
|
|||
}
|
||||
update.done();
|
||||
}
|
||||
}
|
||||
},
|
||||
getExecutor()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -280,7 +283,8 @@ public class RegisterBitFieldLayoutNode extends AbstractExpressionLayoutNode<IBi
|
|||
|
||||
final IBitFieldDMContext dmc = findDmcInPath(update.getElementPath(), IRegisters.IBitFieldDMContext.class);
|
||||
|
||||
((IDMService)getServicesTracker().getService(null, dmc.getServiceFilter())).getModelData(
|
||||
VMCacheManager.getVMCacheManager().getCache(update.getPresentationContext())
|
||||
.getModelData((IDMService)getServicesTracker().getService(null, dmc.getServiceFilter()),
|
||||
dmc,
|
||||
new DataRequestMonitor<IBitFieldDMData>(getSession().getExecutor(), null) {
|
||||
@Override
|
||||
|
@ -341,7 +345,8 @@ public class RegisterBitFieldLayoutNode extends AbstractExpressionLayoutNode<IBi
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
getExecutor()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ import org.eclipse.dd.dsf.ui.viewmodel.AbstractVMProvider;
|
|||
import org.eclipse.dd.dsf.ui.viewmodel.IVMContext;
|
||||
import org.eclipse.dd.dsf.ui.viewmodel.VMDelta;
|
||||
import org.eclipse.dd.dsf.ui.viewmodel.dm.AbstractDMVMLayoutNode;
|
||||
import org.eclipse.dd.dsf.ui.viewmodel.update.VMCacheManager;
|
||||
import org.eclipse.debug.core.DebugException;
|
||||
import org.eclipse.debug.core.ILaunch;
|
||||
import org.eclipse.debug.core.model.IDebugTarget;
|
||||
|
@ -57,7 +58,9 @@ import org.eclipse.jface.viewers.CellEditor;
|
|||
import org.eclipse.jface.viewers.ICellModifier;
|
||||
import org.eclipse.jface.viewers.TextCellEditor;
|
||||
import org.eclipse.jface.viewers.TreePath;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
|
||||
@SuppressWarnings("restriction")
|
||||
public class RegisterLayoutNode extends AbstractExpressionLayoutNode<IRegisterDMData>
|
||||
|
@ -231,25 +234,37 @@ public class RegisterLayoutNode extends AbstractExpressionLayoutNode<IRegisterDM
|
|||
/*
|
||||
* Format has been validated. Get the formatted value.
|
||||
*/
|
||||
FormattedValueDMContext valueDmc = regService.getFormattedValue(dmc, finalFormatId);
|
||||
final FormattedValueDMContext valueDmc = regService.getFormattedValue(dmc, finalFormatId);
|
||||
|
||||
regService.getModelData(
|
||||
valueDmc,
|
||||
new DataRequestMonitor<FormattedValueDMData>(getSession().getExecutor(), null) {
|
||||
@Override
|
||||
public void handleCompleted() {
|
||||
if (!getStatus().isOK()) {
|
||||
handleFailedUpdate(update);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Fill the label/column with the properly formatted data value.
|
||||
*/
|
||||
update.setLabel(getData().getFormattedValue(), labelIndex);
|
||||
update.done();
|
||||
}
|
||||
}
|
||||
VMCacheManager.getVMCacheManager().getCache(RegisterLayoutNode.this.getVMProvider().getPresentationContext())
|
||||
.getModelData(regService,
|
||||
valueDmc,
|
||||
new DataRequestMonitor<FormattedValueDMData>(getSession().getExecutor(), null) {
|
||||
@Override
|
||||
public void handleCompleted() {
|
||||
if (!getStatus().isOK()) {
|
||||
handleFailedUpdate(update);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Fill the label/column with the properly formatted data value.
|
||||
*/
|
||||
update.setLabel(getData().getFormattedValue(), labelIndex);
|
||||
|
||||
// color based on change history
|
||||
FormattedValueDMData oldData = (FormattedValueDMData) VMCacheManager.getVMCacheManager()
|
||||
.getCache(RegisterLayoutNode.this.getVMProvider().getPresentationContext())
|
||||
.getArchivedModelData(valueDmc);
|
||||
if(oldData != null && oldData.getFormattedValue().equals(getData().getFormattedValue()))
|
||||
update.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK).getRGB(), labelIndex);
|
||||
else
|
||||
update.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED).getRGB(), labelIndex);
|
||||
|
||||
update.done();
|
||||
}
|
||||
},
|
||||
getSession().getExecutor()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -270,9 +285,10 @@ public class RegisterLayoutNode extends AbstractExpressionLayoutNode<IRegisterDM
|
|||
final IRegisterDMContext dmc = findDmcInPath(update.getElementPath(), IRegisters.IRegisterDMContext.class);
|
||||
if (!checkDmc(dmc, update) || !checkService(null, dmc.getServiceFilter(), update)) return;
|
||||
|
||||
((IDMService)getServicesTracker().getService(null, dmc.getServiceFilter())).getModelData(
|
||||
dmc,
|
||||
new DataRequestMonitor<IRegisterDMData>(getSession().getExecutor(), null) {
|
||||
VMCacheManager.getVMCacheManager().getCache(update.getPresentationContext())
|
||||
.getModelData((IDMService)getServicesTracker().getService(null, dmc.getServiceFilter()),
|
||||
dmc,
|
||||
new DataRequestMonitor<IRegisterDMData>(getSession().getExecutor(), null) {
|
||||
@Override
|
||||
protected void handleCompleted() {
|
||||
/*
|
||||
|
@ -332,7 +348,8 @@ public class RegisterLayoutNode extends AbstractExpressionLayoutNode<IRegisterDM
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
getSession().getExecutor()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ import org.eclipse.dd.dsf.service.DsfSession;
|
|||
import org.eclipse.dd.dsf.ui.viewmodel.AbstractVMAdapter;
|
||||
import org.eclipse.dd.dsf.ui.viewmodel.IVMLayoutNode;
|
||||
import org.eclipse.dd.dsf.ui.viewmodel.IVMRootLayoutNode;
|
||||
import org.eclipse.dd.dsf.ui.viewmodel.dm.AbstractDMVMProvider;
|
||||
import org.eclipse.dd.dsf.ui.viewmodel.dm.AbstractDMVMProviderWithCache;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentation;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
|
||||
|
||||
|
@ -25,7 +25,7 @@ import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationCont
|
|||
* Provides the VIEW MODEL for the DEBUG MODEL REGISTER view.
|
||||
*/
|
||||
@SuppressWarnings("restriction")
|
||||
public class RegisterVMProvider extends AbstractDMVMProvider implements IFormattedValuePreferenceStore
|
||||
public class RegisterVMProvider extends AbstractDMVMProviderWithCache implements IFormattedValuePreferenceStore
|
||||
{
|
||||
/*
|
||||
* Current default for register formatting.
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 Wind River Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Ted R Williams (Wind River Systems, Inc.) - initial implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.dd.dsf.debug.ui.viewmodel.update;
|
||||
|
||||
import org.eclipse.dd.dsf.datamodel.IDMEvent;
|
||||
import org.eclipse.dd.dsf.debug.service.IRunControl;
|
||||
import org.eclipse.dd.dsf.ui.viewmodel.update.VMCache;
|
||||
|
||||
|
||||
public class VMCacheRefreshAlways extends VMCache
|
||||
{
|
||||
|
||||
@Override
|
||||
public void handleEvent(IDMEvent event) {
|
||||
if(event instanceof IRunControl.ISuspendedDMEvent)
|
||||
flush(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean useCache() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 Wind River Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Ted R Williams (Wind River Systems, Inc.) - initial implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.dd.dsf.debug.ui.viewmodel.update;
|
||||
|
||||
import org.eclipse.dd.dsf.datamodel.IDMEvent;
|
||||
import org.eclipse.dd.dsf.ui.viewmodel.update.VMCache;
|
||||
|
||||
public class VMCacheRefreshManual extends VMCache
|
||||
{
|
||||
|
||||
@Override
|
||||
public void handleEvent(IDMEvent event) {
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 Wind River Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Ted R Williams (Wind River Systems, Inc.) - initial implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.dd.dsf.debug.ui.viewmodel.update;
|
||||
|
||||
import org.eclipse.dd.dsf.datamodel.IDMEvent;
|
||||
import org.eclipse.dd.dsf.debug.service.IRunControl;
|
||||
import org.eclipse.dd.dsf.debug.service.IRunControl.StateChangeReason;
|
||||
import org.eclipse.dd.dsf.ui.viewmodel.update.VMCache;
|
||||
|
||||
public class VMCacheRefreshOnBreak extends VMCache
|
||||
{
|
||||
@Override
|
||||
public void handleEvent(IDMEvent event) {
|
||||
if(event instanceof IRunControl.ISuspendedDMEvent)
|
||||
{
|
||||
if(((IRunControl.ISuspendedDMEvent) event).getReason().equals(StateChangeReason.BREAKPOINT))
|
||||
flush(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 Wind River Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Ted R Williams (Wind River Systems, Inc.) - initial implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.dd.dsf.debug.ui.viewmodel.update.actions;
|
||||
|
||||
import org.eclipse.dd.dsf.ui.viewmodel.update.VMCacheManager;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.TreeModelViewer;
|
||||
import org.eclipse.debug.ui.AbstractDebugView;
|
||||
import org.eclipse.jface.action.IAction;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.ui.IViewActionDelegate;
|
||||
import org.eclipse.ui.IViewPart;
|
||||
|
||||
public class RefreshActionDelegate implements IViewActionDelegate {
|
||||
|
||||
protected IViewPart fView;
|
||||
|
||||
public void init(IViewPart view) {
|
||||
fView = view;
|
||||
}
|
||||
|
||||
public void run(IAction action) {
|
||||
VMCacheManager.getVMCacheManager().flush(getContext());
|
||||
}
|
||||
|
||||
public void selectionChanged(IAction action, ISelection selection) {
|
||||
|
||||
}
|
||||
|
||||
private Object getContext()
|
||||
{
|
||||
return ((TreeModelViewer) ((AbstractDebugView) fView).getViewer())
|
||||
.getPresentationContext();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 Wind River Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Ted R Williams (Wind River Systems, Inc.) - initial implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.dd.dsf.debug.ui.viewmodel.update.actions;
|
||||
|
||||
import org.eclipse.dd.dsf.debug.ui.viewmodel.update.VMCacheRefreshAlways;
|
||||
import org.eclipse.dd.dsf.ui.viewmodel.update.VMCache;
|
||||
import org.eclipse.dd.dsf.ui.viewmodel.update.actions.AbstractRefreshActionDelegate;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.TreeModelViewer;
|
||||
import org.eclipse.debug.ui.AbstractDebugView;
|
||||
|
||||
public class RefreshAlwaysActionDelegate extends AbstractRefreshActionDelegate
|
||||
{
|
||||
|
||||
public Object getContext()
|
||||
{
|
||||
return ((TreeModelViewer) ((AbstractDebugView) fView).getViewer())
|
||||
.getPresentationContext();
|
||||
}
|
||||
|
||||
public VMCache createCache()
|
||||
{
|
||||
return new VMCacheRefreshAlways();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 Wind River Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Ted R Williams (Wind River Systems, Inc.) - initial implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.dd.dsf.debug.ui.viewmodel.update.actions;
|
||||
|
||||
import org.eclipse.dd.dsf.debug.ui.viewmodel.update.VMCacheRefreshManual;
|
||||
import org.eclipse.dd.dsf.ui.viewmodel.update.VMCache;
|
||||
import org.eclipse.dd.dsf.ui.viewmodel.update.actions.AbstractRefreshActionDelegate;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.TreeModelViewer;
|
||||
import org.eclipse.debug.ui.AbstractDebugView;
|
||||
|
||||
public class RefreshManualActionDelegate extends AbstractRefreshActionDelegate
|
||||
{
|
||||
|
||||
public Object getContext()
|
||||
{
|
||||
return ((TreeModelViewer) ((AbstractDebugView) fView).getViewer())
|
||||
.getPresentationContext();
|
||||
}
|
||||
|
||||
public VMCache createCache()
|
||||
{
|
||||
return new VMCacheRefreshManual();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 Wind River Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Ted R Williams (Wind River Systems, Inc.) - initial implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.dd.dsf.debug.ui.viewmodel.update.actions;
|
||||
|
||||
import org.eclipse.dd.dsf.debug.ui.viewmodel.update.VMCacheRefreshOnBreak;
|
||||
import org.eclipse.dd.dsf.ui.viewmodel.update.VMCache;
|
||||
import org.eclipse.dd.dsf.ui.viewmodel.update.actions.AbstractRefreshActionDelegate;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.TreeModelViewer;
|
||||
import org.eclipse.debug.ui.AbstractDebugView;
|
||||
|
||||
public class RefreshOnBreakActionDelegate extends AbstractRefreshActionDelegate
|
||||
{
|
||||
|
||||
public Object getContext()
|
||||
{
|
||||
return ((TreeModelViewer) ((AbstractDebugView) fView).getViewer())
|
||||
.getPresentationContext();
|
||||
}
|
||||
|
||||
public VMCache createCache()
|
||||
{
|
||||
return new VMCacheRefreshOnBreak();
|
||||
}
|
||||
|
||||
}
|
|
@ -42,6 +42,7 @@ import org.eclipse.dd.dsf.service.IDsfService;
|
|||
import org.eclipse.dd.dsf.ui.viewmodel.AbstractVMProvider;
|
||||
import org.eclipse.dd.dsf.ui.viewmodel.IVMContext;
|
||||
import org.eclipse.dd.dsf.ui.viewmodel.VMDelta;
|
||||
import org.eclipse.dd.dsf.ui.viewmodel.update.VMCacheManager;
|
||||
import org.eclipse.debug.core.DebugException;
|
||||
import org.eclipse.debug.core.ILaunch;
|
||||
import org.eclipse.debug.core.model.IDebugTarget;
|
||||
|
@ -168,8 +169,9 @@ public class VariableLocalsLayoutNode extends AbstractExpressionLayoutNode<IExpr
|
|||
|
||||
final IExpressionDMContext dmc = findDmcInPath(update.getElementPath(), IExpressions.IExpressionDMContext.class);
|
||||
|
||||
((IDMService)getServicesTracker().getService(null, dmc.getServiceFilter())).getModelData(
|
||||
dmc,
|
||||
VMCacheManager.getVMCacheManager().getCache(update.getPresentationContext())
|
||||
.getModelData((IDMService)getServicesTracker().getService(null, dmc.getServiceFilter()),
|
||||
dmc,
|
||||
new DataRequestMonitor<IExpressionDMData>(getSession().getExecutor(), null) {
|
||||
@Override
|
||||
protected void handleCompleted() {
|
||||
|
@ -221,7 +223,8 @@ public class VariableLocalsLayoutNode extends AbstractExpressionLayoutNode<IExpr
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
getExecutor()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -293,7 +296,8 @@ public class VariableLocalsLayoutNode extends AbstractExpressionLayoutNode<IExpr
|
|||
*/
|
||||
FormattedValueDMContext valueDmc = expressionService.getFormattedValue(dmc, finalFormatId);
|
||||
|
||||
expressionService.getModelData(
|
||||
VMCacheManager.getVMCacheManager().getCache(update.getPresentationContext())
|
||||
.getModelData(expressionService,
|
||||
valueDmc,
|
||||
new DataRequestMonitor<FormattedValueDMData>(getSession().getExecutor(), null) {
|
||||
@Override
|
||||
|
@ -309,7 +313,8 @@ public class VariableLocalsLayoutNode extends AbstractExpressionLayoutNode<IExpr
|
|||
update.setLabel(getData().getFormattedValue(), labelIndex);
|
||||
update.done();
|
||||
}
|
||||
}
|
||||
},
|
||||
getExecutor()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ import org.eclipse.dd.dsf.ui.viewmodel.AbstractVMProvider;
|
|||
import org.eclipse.dd.dsf.ui.viewmodel.IVMLayoutNode;
|
||||
import org.eclipse.dd.dsf.ui.viewmodel.VMDelta;
|
||||
import org.eclipse.dd.dsf.ui.viewmodel.dm.AbstractDMVMLayoutNode;
|
||||
import org.eclipse.dd.dsf.ui.viewmodel.update.VMCacheManager;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenUpdate;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.ILabelUpdate;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta;
|
||||
|
@ -72,7 +73,8 @@ public class VariableSubExpressionsLayoutNode extends AbstractDMVMLayoutNode<IEx
|
|||
|
||||
final IExpressionDMContext dmc = findDmcInPath(update.getElementPath(), IExpressions.IExpressionDMContext.class);
|
||||
|
||||
((IDMService)getServicesTracker().getService(null, dmc.getServiceFilter())).getModelData(
|
||||
VMCacheManager.getVMCacheManager().getCache(update.getPresentationContext())
|
||||
.getModelData((IDMService)getServicesTracker().getService(null, dmc.getServiceFilter()),
|
||||
dmc,
|
||||
new DataRequestMonitor<IExpressionDMData>(getSession().getExecutor(), null) {
|
||||
@Override
|
||||
|
@ -123,7 +125,8 @@ public class VariableSubExpressionsLayoutNode extends AbstractDMVMLayoutNode<IEx
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
getExecutor()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -195,8 +198,9 @@ public class VariableSubExpressionsLayoutNode extends AbstractDMVMLayoutNode<IEx
|
|||
*/
|
||||
FormattedValueDMContext valueDmc = expressionService.getFormattedValue(dmc, finalFormatId);
|
||||
|
||||
expressionService.getModelData(
|
||||
valueDmc,
|
||||
VMCacheManager.getVMCacheManager().getCache(update.getPresentationContext())
|
||||
.getModelData(expressionService,
|
||||
valueDmc,
|
||||
new DataRequestMonitor<FormattedValueDMData>(getSession().getExecutor(), null) {
|
||||
@Override
|
||||
public void handleCompleted() {
|
||||
|
@ -211,7 +215,8 @@ public class VariableSubExpressionsLayoutNode extends AbstractDMVMLayoutNode<IEx
|
|||
update.setLabel(getData().getFormattedValue(), labelIndex);
|
||||
update.done();
|
||||
}
|
||||
}
|
||||
},
|
||||
getExecutor()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,13 +15,13 @@ import org.eclipse.dd.dsf.service.DsfSession;
|
|||
import org.eclipse.dd.dsf.ui.viewmodel.AbstractVMAdapter;
|
||||
import org.eclipse.dd.dsf.ui.viewmodel.IVMLayoutNode;
|
||||
import org.eclipse.dd.dsf.ui.viewmodel.IVMRootLayoutNode;
|
||||
import org.eclipse.dd.dsf.ui.viewmodel.dm.AbstractDMVMProvider;
|
||||
import org.eclipse.dd.dsf.ui.viewmodel.dm.AbstractDMVMProviderWithCache;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentation;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentationFactory;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
|
||||
|
||||
@SuppressWarnings("restriction")
|
||||
public class VariableVMProvider extends AbstractDMVMProvider implements
|
||||
public class VariableVMProvider extends AbstractDMVMProviderWithCache implements
|
||||
IColumnPresentationFactory, IFormattedValuePreferenceStore {
|
||||
|
||||
private String defaultFormatId = IFormattedValues.NATURAL_FORMAT;
|
||||
|
|
|
@ -11,7 +11,9 @@ Require-Bundle: org.eclipse.ui,
|
|||
org.eclipse.dd.dsf,
|
||||
org.eclipse.debug.ui
|
||||
Eclipse-LazyStart: true
|
||||
Export-Package: org.eclipse.dd.dsf.ui.viewmodel,
|
||||
Export-Package: org.eclipse.dd.dsf.ui.concurrent,
|
||||
org.eclipse.dd.dsf.ui.viewmodel,
|
||||
org.eclipse.dd.dsf.ui.viewmodel.dm,
|
||||
org.eclipse.dd.dsf.ui.concurrent
|
||||
org.eclipse.dd.dsf.ui.viewmodel.update,
|
||||
org.eclipse.dd.dsf.ui.viewmodel.update.actions
|
||||
Bundle-RequiredExecutionEnvironment: J2SE-1.5
|
||||
|
|
|
@ -34,6 +34,7 @@ import org.eclipse.dd.dsf.ui.viewmodel.AbstractVMProvider;
|
|||
import org.eclipse.dd.dsf.ui.viewmodel.IVMContext;
|
||||
import org.eclipse.dd.dsf.ui.viewmodel.IVMLayoutNode;
|
||||
import org.eclipse.dd.dsf.ui.viewmodel.VMDelta;
|
||||
import org.eclipse.dd.dsf.ui.viewmodel.update.VMCacheManager;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenCountUpdate;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenUpdate;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentationFactory;
|
||||
|
@ -319,8 +320,9 @@ abstract public class AbstractDMVMLayoutNode<V extends IDMData> extends Abstract
|
|||
final IDMContext<V> dmc = findDmcInPath(update.getElementPath(), fDMCClassType);
|
||||
if (!checkDmc(dmc, update) || !checkService(null, dmc.getServiceFilter(), update)) return;
|
||||
|
||||
((IDMService)getServicesTracker().getService(null, dmc.getServiceFilter())).getModelData(
|
||||
dmc,
|
||||
VMCacheManager.getVMCacheManager().getCache(update.getPresentationContext())
|
||||
.getModelData((IDMService)getServicesTracker().getService(null, dmc.getServiceFilter()),
|
||||
dmc,
|
||||
new DataRequestMonitor<V>(getSession().getExecutor(), null) {
|
||||
@Override
|
||||
protected void handleCompleted() {
|
||||
|
@ -350,7 +352,8 @@ abstract public class AbstractDMVMLayoutNode<V extends IDMData> extends Abstract
|
|||
}
|
||||
update.done();
|
||||
}
|
||||
});
|
||||
},
|
||||
getExecutor());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 Wind River Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Ted R Williams (Wind River Systems, Inc.) - initial implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.dd.dsf.ui.viewmodel.dm;
|
||||
|
||||
import org.eclipse.dd.dsf.datamodel.IDMEvent;
|
||||
import org.eclipse.dd.dsf.service.DsfSession;
|
||||
import org.eclipse.dd.dsf.ui.viewmodel.AbstractVMAdapter;
|
||||
import org.eclipse.dd.dsf.ui.viewmodel.update.VMCacheManager;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenCountUpdate;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenUpdate;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IHasChildrenUpdate;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.ModelDelta;
|
||||
import org.eclipse.dd.dsf.service.DsfServiceEventHandler;
|
||||
|
||||
public abstract class AbstractDMVMProviderWithCache extends AbstractDMVMProvider
|
||||
implements VMCacheManager.CacheListener
|
||||
{
|
||||
@DsfServiceEventHandler
|
||||
public void eventDispatched(IDMEvent<?> event) {
|
||||
VMCacheManager.getVMCacheManager().getCache(getPresentationContext()).handleEvent(event);
|
||||
super.eventDispatched(event);
|
||||
}
|
||||
|
||||
public void cacheFlushed(Object context) {
|
||||
if(getPresentationContext().equals(context))
|
||||
getModelProxy().fireModelChanged(new ModelDelta(this.getRootLayoutNode().getRootObject(),IModelDelta.CONTENT));
|
||||
}
|
||||
|
||||
public AbstractDMVMProviderWithCache(AbstractVMAdapter adapter, IPresentationContext presentationContext, DsfSession session) {
|
||||
super(adapter, presentationContext, session);
|
||||
|
||||
VMCacheManager.getVMCacheManager().addCacheListener(getPresentationContext(), this);
|
||||
}
|
||||
|
||||
public void update(IHasChildrenUpdate[] updates) {
|
||||
super.update(VMCacheManager.getVMCacheManager().getCache(getPresentationContext()).update(updates));
|
||||
}
|
||||
|
||||
public void update(IChildrenCountUpdate[] updates) {
|
||||
super.update(VMCacheManager.getVMCacheManager().getCache(getPresentationContext()).update(updates));
|
||||
}
|
||||
|
||||
public void update(final IChildrenUpdate[] updates) {
|
||||
super.update(VMCacheManager.getVMCacheManager().getCache(getPresentationContext()).update(updates));
|
||||
}
|
||||
|
||||
public void dispose()
|
||||
{
|
||||
VMCacheManager.getVMCacheManager().removeCacheListener(getPresentationContext(), this);
|
||||
super.dispose();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,315 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 Wind River Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Ted R Williams (Wind River Systems, Inc.) - initial implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.dd.dsf.ui.viewmodel.update;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Vector;
|
||||
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.dd.dsf.concurrent.DataRequestMonitor;
|
||||
import org.eclipse.dd.dsf.concurrent.DsfExecutor;
|
||||
import org.eclipse.dd.dsf.datamodel.IDMContext;
|
||||
import org.eclipse.dd.dsf.datamodel.IDMData;
|
||||
import org.eclipse.dd.dsf.datamodel.IDMEvent;
|
||||
import org.eclipse.dd.dsf.datamodel.IDMService;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenCountUpdate;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenUpdate;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IHasChildrenUpdate;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
|
||||
import org.eclipse.jface.viewers.TreePath;
|
||||
|
||||
public abstract class VMCache
|
||||
{
|
||||
protected HashMap<Object, Integer> fChildrenCounts = new HashMap<Object, Integer>();
|
||||
|
||||
class ChildData
|
||||
{
|
||||
Object child;
|
||||
int offset;
|
||||
|
||||
public ChildData(Object child, int offset)
|
||||
{
|
||||
this.child = child;
|
||||
this.offset = offset;
|
||||
}
|
||||
}
|
||||
|
||||
protected HashMap<Object, ChildData[]> fChildren = new HashMap<Object, ChildData[]>();
|
||||
|
||||
protected HashMap<Object, Boolean> fHasChildren = new HashMap<Object, Boolean>();
|
||||
|
||||
protected HashMap<IDMContext<?>, IDMData> fData = new HashMap<IDMContext<?>, IDMData>();
|
||||
|
||||
protected HashMap<IDMContext<?>, IDMData> fDataArchive = fData;
|
||||
|
||||
protected void flush(boolean archive)
|
||||
{
|
||||
if(archive)
|
||||
fDataArchive = fData;
|
||||
fData = new HashMap<IDMContext<?>, IDMData>();
|
||||
fChildrenCounts.clear();
|
||||
fChildren.clear();
|
||||
fChildrenCounts.clear();
|
||||
}
|
||||
|
||||
protected boolean useCache()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public IHasChildrenUpdate[] update(IHasChildrenUpdate[] updates) {
|
||||
Vector<IHasChildrenUpdate> missVector = new Vector<IHasChildrenUpdate>();
|
||||
for(IHasChildrenUpdate update : updates)
|
||||
{
|
||||
if(fHasChildren.containsKey(update.getElement()) && useCache())
|
||||
{
|
||||
update.setHasChilren(fHasChildren.get(update.getElement()).booleanValue());
|
||||
update.done();
|
||||
}
|
||||
else
|
||||
{
|
||||
missVector.addElement(update);
|
||||
}
|
||||
}
|
||||
|
||||
updates = new IHasChildrenUpdate[missVector.size()];
|
||||
for(int i = 0; i < updates.length; i++)
|
||||
{
|
||||
final IHasChildrenUpdate update = missVector.elementAt(i);
|
||||
updates[i] = new IHasChildrenUpdate()
|
||||
{
|
||||
private boolean fIsHasChildren;
|
||||
|
||||
public void setHasChilren(boolean hasChildren) {
|
||||
fIsHasChildren = hasChildren;
|
||||
update.setHasChilren(hasChildren);
|
||||
}
|
||||
|
||||
public void cancel() {
|
||||
update.cancel();
|
||||
}
|
||||
|
||||
public void done() {
|
||||
fHasChildren.put(getElement(), Boolean.valueOf(fIsHasChildren));
|
||||
update.done();
|
||||
}
|
||||
|
||||
public IStatus getStatus() {
|
||||
return update.getStatus();
|
||||
}
|
||||
|
||||
public boolean isCanceled() {
|
||||
return update.isCanceled();
|
||||
}
|
||||
|
||||
public void setStatus(IStatus status) {
|
||||
update.setStatus(status);
|
||||
}
|
||||
|
||||
public Object getElement() {
|
||||
return update.getElement();
|
||||
}
|
||||
|
||||
public TreePath getElementPath() {
|
||||
return update.getElementPath();
|
||||
}
|
||||
|
||||
public IPresentationContext getPresentationContext() {
|
||||
return update.getPresentationContext();
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
return updates;
|
||||
}
|
||||
|
||||
public IChildrenCountUpdate[] update(IChildrenCountUpdate[] updates)
|
||||
{
|
||||
Vector<IChildrenCountUpdate> missVector = new Vector<IChildrenCountUpdate>();
|
||||
for(IChildrenCountUpdate update : updates)
|
||||
{
|
||||
if(fChildrenCounts.containsKey(update.getElement()) && useCache())
|
||||
{
|
||||
update.setChildCount(fChildrenCounts.get(update.getElement()));
|
||||
update.done();
|
||||
}
|
||||
else
|
||||
{
|
||||
missVector.addElement(update);
|
||||
}
|
||||
}
|
||||
|
||||
updates = new IChildrenCountUpdate[missVector.size()];
|
||||
for(int i = 0; i < updates.length; i++)
|
||||
{
|
||||
final IChildrenCountUpdate update = missVector.elementAt(i);
|
||||
updates[i] = new IChildrenCountUpdate()
|
||||
{
|
||||
private int fChildCount;
|
||||
|
||||
public void cancel() {
|
||||
update.cancel();
|
||||
}
|
||||
|
||||
public void done() {
|
||||
fChildrenCounts.put(getElement(), fChildCount);
|
||||
update.done();
|
||||
}
|
||||
|
||||
public IStatus getStatus() {
|
||||
return update.getStatus();
|
||||
}
|
||||
|
||||
public boolean isCanceled() {
|
||||
return update.isCanceled();
|
||||
}
|
||||
|
||||
public void setStatus(IStatus status) {
|
||||
update.setStatus(status);
|
||||
}
|
||||
|
||||
public void setChildCount(int numChildren) {
|
||||
fChildCount = numChildren;
|
||||
update.setChildCount(numChildren);
|
||||
}
|
||||
|
||||
public Object getElement() {
|
||||
return update.getElement();
|
||||
}
|
||||
|
||||
public TreePath getElementPath() {
|
||||
return update.getElementPath();
|
||||
}
|
||||
|
||||
public IPresentationContext getPresentationContext() {
|
||||
return update.getPresentationContext();
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
return updates;
|
||||
}
|
||||
|
||||
public IChildrenUpdate[] update(IChildrenUpdate[] updates) {
|
||||
Vector<IChildrenUpdate> missVector = new Vector<IChildrenUpdate>();
|
||||
for(IChildrenUpdate update : updates)
|
||||
{
|
||||
if(fChildren.containsKey(update.getElement()) && useCache())
|
||||
{
|
||||
ChildData childData[] = fChildren.get(update.getElement());
|
||||
for(ChildData data : childData)
|
||||
update.setChild(data.child, data.offset);
|
||||
update.done();
|
||||
}
|
||||
else
|
||||
{
|
||||
missVector.addElement(update);
|
||||
}
|
||||
}
|
||||
|
||||
updates = new IChildrenUpdate[missVector.size()];
|
||||
for(int i = 0; i < updates.length; i++)
|
||||
{
|
||||
final IChildrenUpdate update = missVector.elementAt(i);
|
||||
updates[i] = new IChildrenUpdate()
|
||||
{
|
||||
Vector<ChildData> fChilds = new Vector<ChildData>();
|
||||
|
||||
public int getLength() {
|
||||
return update.getLength();
|
||||
}
|
||||
|
||||
public int getOffset() {
|
||||
return update.getOffset();
|
||||
}
|
||||
|
||||
public void setChild(Object child, int offset) {
|
||||
fChilds.addElement(new ChildData(child, offset));
|
||||
update.setChild(child, offset);
|
||||
}
|
||||
|
||||
public void cancel() {
|
||||
update.cancel();
|
||||
}
|
||||
|
||||
public void done() {
|
||||
// FIXME synchronize with events?
|
||||
fChildren.put(getElement(), fChilds.toArray(new ChildData[fChilds.size()]));
|
||||
update.done();
|
||||
}
|
||||
|
||||
public IStatus getStatus() {
|
||||
return update.getStatus();
|
||||
}
|
||||
|
||||
public boolean isCanceled() {
|
||||
return update.isCanceled();
|
||||
}
|
||||
|
||||
public void setStatus(IStatus status) {
|
||||
update.setStatus(status);
|
||||
}
|
||||
|
||||
public Object getElement() {
|
||||
return update.getElement();
|
||||
}
|
||||
|
||||
public TreePath getElementPath() {
|
||||
return update.getElementPath();
|
||||
}
|
||||
|
||||
public IPresentationContext getPresentationContext() {
|
||||
return update.getPresentationContext();
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
return updates;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void getModelData(IDMService service, final IDMContext dmc, final DataRequestMonitor rm, DsfExecutor executor)
|
||||
{
|
||||
if(fData.containsKey(dmc) && useCache())
|
||||
{
|
||||
rm.setData( fData.get(dmc));
|
||||
rm.done();
|
||||
}
|
||||
else
|
||||
{
|
||||
service.getModelData(dmc,
|
||||
new DataRequestMonitor<IDMData>(executor, null) {
|
||||
@Override
|
||||
public void handleCompleted() {
|
||||
fData.put(dmc, getData());
|
||||
rm.setData(getData());
|
||||
rm.done();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public IDMData getArchivedModelData(IDMContext dmc)
|
||||
{
|
||||
return fDataArchive.get(dmc);
|
||||
}
|
||||
|
||||
public abstract void handleEvent(IDMEvent event);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,105 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 Wind River Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Ted R Williams (Wind River Systems, Inc.) - initial implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.dd.dsf.ui.viewmodel.update;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Vector;
|
||||
|
||||
import org.eclipse.dd.dsf.datamodel.IDMEvent;
|
||||
|
||||
|
||||
public class VMCacheManager
|
||||
{
|
||||
private static VMCacheManager fInstance = null;
|
||||
|
||||
private HashMap<Object, VMCache> fAssociations = new HashMap<Object, VMCache>();
|
||||
|
||||
public interface CacheListener
|
||||
{
|
||||
public void cacheFlushed(Object context);
|
||||
}
|
||||
|
||||
private HashMap<Object, Vector<CacheListener>> fListeners = new HashMap<Object, Vector<CacheListener>>();
|
||||
|
||||
public VMCacheManager()
|
||||
{
|
||||
}
|
||||
|
||||
public static VMCacheManager getVMCacheManager()
|
||||
{
|
||||
if(fInstance == null)
|
||||
fInstance = new VMCacheManager();
|
||||
|
||||
return fInstance;
|
||||
}
|
||||
|
||||
public VMCache getCache(Object context)
|
||||
{
|
||||
if(!fAssociations.containsKey(context))
|
||||
fAssociations.put(context, new VMCache()
|
||||
{
|
||||
@Override
|
||||
public void handleEvent(IDMEvent event) {
|
||||
flush(true);
|
||||
}
|
||||
|
||||
public boolean readFromCache()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
return fAssociations.get(context);
|
||||
}
|
||||
|
||||
public void registerCache(Object context, VMCache cache)
|
||||
{
|
||||
fAssociations.put(context, cache);
|
||||
}
|
||||
|
||||
public void addCacheListener(Object context, CacheListener listener)
|
||||
{
|
||||
if(!fListeners.containsKey(context))
|
||||
fListeners.put(context, new Vector<CacheListener>());
|
||||
|
||||
fListeners.get(context).addElement(listener);
|
||||
}
|
||||
|
||||
public void removeCacheListener(Object context, CacheListener listener)
|
||||
{
|
||||
if(!fListeners.containsKey(context))
|
||||
{
|
||||
fListeners.get(context).removeElement(listener);
|
||||
if(fListeners.get(context).isEmpty())
|
||||
fListeners.remove(context);
|
||||
}
|
||||
}
|
||||
|
||||
private void fireCacheFlushed(Object context)
|
||||
{
|
||||
if(fListeners.containsKey(context))
|
||||
{
|
||||
for(CacheListener listener : fListeners.get(context))
|
||||
listener.cacheFlushed(context);
|
||||
}
|
||||
}
|
||||
|
||||
public void flush(Object context)
|
||||
{
|
||||
getCache(context).flush(false);
|
||||
fireCacheFlushed(context);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 Wind River Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Ted R Williams (Wind River Systems, Inc.) - initial implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.dd.dsf.ui.viewmodel.update.actions;
|
||||
|
||||
import org.eclipse.dd.dsf.ui.viewmodel.update.VMCache;
|
||||
import org.eclipse.dd.dsf.ui.viewmodel.update.VMCacheManager;
|
||||
import org.eclipse.jface.action.IAction;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.ui.IViewActionDelegate;
|
||||
import org.eclipse.ui.IViewPart;
|
||||
|
||||
public abstract class AbstractRefreshActionDelegate implements IViewActionDelegate {
|
||||
|
||||
protected IViewPart fView;
|
||||
|
||||
public void init(IViewPart view) {
|
||||
fView = view;
|
||||
}
|
||||
|
||||
public void run(IAction action) {
|
||||
VMCacheManager.getVMCacheManager().registerCache(getContext(), createCache());
|
||||
}
|
||||
|
||||
public void selectionChanged(IAction action, ISelection selection) {
|
||||
}
|
||||
|
||||
protected abstract Object getContext();
|
||||
|
||||
protected abstract VMCache createCache();
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue