Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Barnes2005-11-07 17:48:54 -0500
committerKevin Barnes2005-11-07 17:48:54 -0500
commit2ba2d568d064ef4df39df29f763218eed768f7c6 (patch)
tree4455ae3313c02a012fb6555b8dd66118697f12a2 /org.eclipse.debug.ui
parentb7aff882959393a9d808cb214795b5c22894683d (diff)
downloadeclipse.platform.debug-2ba2d568d064ef4df39df29f763218eed768f7c6.tar.gz
eclipse.platform.debug-2ba2d568d064ef4df39df29f763218eed768f7c6.tar.xz
eclipse.platform.debug-2ba2d568d064ef4df39df29f763218eed768f7c6.zip
merging Asynchronous viewer branch
Diffstat (limited to 'org.eclipse.debug.ui')
-rw-r--r--org.eclipse.debug.ui/META-INF/MANIFEST.MF5
-rw-r--r--org.eclipse.debug.ui/plugin.xml86
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java7
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DelegatingModelPresentation.java10
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/IInternalDebugUIConstants.java48
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/LazyModelPresentation.java4
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/AbstractListenerActionDelegate.java120
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/CollapseAllAction.java10
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/CopyToClipboardActionDelegate.java32
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/DebugContextManager.java135
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/DebugWindowContextService.java261
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/IDebugContextService.java69
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/LaunchSuspendTrigger.java108
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/SuspendTriggerAdapterFactory.java43
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/AbstractDebugContextActionDelegate.java462
-rwxr-xr-x[-rw-r--r--]org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/AbstractRemoveActionDelegate.java (renamed from org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/AbstractRemoveActionDelegate.java)4
-rwxr-xr-x[-rw-r--r--]org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/AbstractRemoveAllActionDelegate.java (renamed from org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/AbstractRemoveAllActionDelegate.java)4
-rwxr-xr-x[-rw-r--r--]org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/DisconnectActionDelegate.java (renamed from org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/DisconnectActionDelegate.java)29
-rwxr-xr-x[-rw-r--r--]org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/DropToFrameActionDelegate.java (renamed from org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/DropToFrameActionDelegate.java)25
-rwxr-xr-x[-rw-r--r--]org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/FindVariableAction.java (renamed from org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/FindVariableAction.java)70
-rwxr-xr-x[-rw-r--r--]org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/FindVariableDialog.java (renamed from org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/FindVariableDialog.java)7
-rwxr-xr-x[-rw-r--r--]org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/RemoveAllBreakpointsAction.java (renamed from org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RemoveAllBreakpointsAction.java)5
-rwxr-xr-x[-rw-r--r--]org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/RemoveAllExpressionsAction.java (renamed from org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RemoveAllExpressionsAction.java)2
-rwxr-xr-x[-rw-r--r--]org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/RemoveAllTerminatedAction.java (renamed from org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RemoveAllTerminatedAction.java)37
-rwxr-xr-x[-rw-r--r--]org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/RemoveBreakpointAction.java (renamed from org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RemoveBreakpointAction.java)9
-rwxr-xr-x[-rw-r--r--]org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/RemoveExpressionAction.java (renamed from org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RemoveExpressionAction.java)45
-rwxr-xr-x[-rw-r--r--]org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/ResumeActionDelegate.java (renamed from org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ResumeActionDelegate.java)24
-rwxr-xr-x[-rw-r--r--]org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/SelectAllAction.java (renamed from org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/SelectAllAction.java)19
-rwxr-xr-x[-rw-r--r--]org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/SelectAllBreakpointsAction.java (renamed from org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/SelectAllBreakpointsAction.java)22
-rwxr-xr-x[-rw-r--r--]org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/SelectAllExpressionsAction.java (renamed from org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/SelectAllExpressionsAction.java)8
-rwxr-xr-x[-rw-r--r--]org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/SelectAllVariablesAction.java (renamed from org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/SelectAllVariablesAction.java)34
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/StepActionDelegate.java (renamed from org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/StepActionDelegate.java)21
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/StepIntoActionDelegate.java (renamed from org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/StepIntoActionDelegate.java)7
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/StepOverActionDelegate.java (renamed from org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/StepOverActionDelegate.java)5
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/StepReturnActionDelegate.java (renamed from org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/StepReturnActionDelegate.java)4
-rwxr-xr-x[-rw-r--r--]org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/SuspendActionDelegate.java (renamed from org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/SuspendActionDelegate.java)25
-rwxr-xr-x[-rw-r--r--]org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/TerminateActionDelegate.java (renamed from org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/TerminateActionDelegate.java)22
-rwxr-xr-x[-rw-r--r--]org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/TerminateAllAction.java (renamed from org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/TerminateAllAction.java)4
-rwxr-xr-x[-rw-r--r--]org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/TerminateAndRelaunchAction.java (renamed from org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/TerminateAndRelaunchAction.java)5
-rwxr-xr-x[-rw-r--r--]org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/TerminateAndRemoveActionDelegate.java (renamed from org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/TerminateAndRemoveActionDelegate.java)5
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/AsynchronousDebugLabelAdapter.java109
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DebugTargetTreeContentAdapter.java43
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DeferredExpression.java65
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DeferredExpressionManager.java82
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DeferredLaunch.java33
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DeferredLaunchManager.java32
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DeferredProcess.java38
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DeferredRegisterGroup.java80
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DeferredStackFrame.java96
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DeferredTarget.java43
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DeferredThread.java44
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DeferredVariable.java237
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/ExpressionManagerTreeContentAdapter.java42
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/ExpressionTreeContentAdapter.java45
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/LauchManagerTreeContentAdapter.java42
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/LaunchTreeContentAdapter.java42
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/ProcessTreeAdapter.java40
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/RegisterGroupTreeContentAdapter.java31
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/StackFrameSourceDisplayAdapter.java164
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/StackFrameTreeContentAdapter.java57
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/ThreadTreeContentAdapter.java42
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/VariableLabelAdapter.java47
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/VariableTreeContentAdapter.java209
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/PerspectiveManager.java57
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupManager.java86
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupService.java70
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AbstractModelProxy.java48
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousLabelAdapter.java155
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousRequestMonitor.java194
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousTreeContentAdapter.java149
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousTreeViewer.java892
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousViewer.java894
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/ChildrenRequestMonitor.java74
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/ContainerRequestMonitor.java62
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/DefaultElementComparer.java38
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/IAsynchronousLabelAdapter.java35
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/IAsynchronousRequestMonitor.java45
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/IAsynchronousTreeContentAdapter.java46
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/IChildrenRequestMonitor.java35
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/IContainerRequestMonitor.java30
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/ILabelRequestMonitor.java62
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/IModelChangedListener.java (renamed from org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DeferredExpressionLogicalStructure.java)24
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/IModelDelta.java49
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/IModelDeltaNode.java30
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/IModelProxy.java28
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/IModelProxyFactory.java (renamed from org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/IRemoteTreeViewerUpdateListener.java)13
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/IModelSelectionPolicy.java65
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/IPresentationContext.java34
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/IUpdatePolicy.java35
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/IUpdatePolicyFactory.java32
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/LabelRequestMonitor.java129
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/PresentationContext.java42
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/TreePath.java179
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/TreeSelection.java155
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/AbstractUpdatePolicy.java52
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DebugEventHandler.java154
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DebugTargetEventHandler.java70
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DebugTargetProxy.java94
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DefaultModelProxyFactory.java39
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DefaultSelectionPolicy.java114
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DefaultUpdatePolicy.java126
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DefaultUpdatePolicyFactory.java32
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DefaultVariableViewModelProxy.java54
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/EventHandlerModelProxy.java251
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/LaunchManagerProxy.java66
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/LaunchProxy.java80
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/ModelDelta.java23
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/ModelDeltaNode.java47
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/ProcessProxy.java62
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/ThreadEventHandler.java92
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/VariablesViewEventHandler.java58
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/AbstractDebugEventHandler.java61
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/AbstractDebugEventHandlerView.java10
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/AbstractViewerState.java112
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/RemoteTreeContentManager.java335
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/RemoteTreeViewer.java609
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleRemoveAllTerminatedAction.java2
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleTerminateActionDelegate.java2
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionPopupContentProvider.java44
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionView.java61
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionViewEventHandler.java39
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/RemoteExpressionContentManager.java84
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/RemoteExpressionsContentProvider.java34
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/DebugElementAdapterFactory.java151
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/DebugElementHelper.java2
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/DebugViewContentProvider.java100
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/LaunchView.java264
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/LaunchViewEventHandler.java250
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/LaunchViewer.java237
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/registers/DeferredRegisterViewStackFrame.java42
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/registers/RegistersView.java21
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/registers/RegistersViewerState.java121
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/registers/RemoteRegisterContentManager.java35
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/registers/RemoteRegistersViewContentProvider.java56
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/AvailableLogicalStructuresAction.java2
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/RemoteVariableContentManager.java114
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/RemoteVariablesContentProvider.java224
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/VariablesView.java270
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/VariablesViewEventHandler.java16
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/VariablesViewer.java186
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/ViewerState.java117
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/ui/IDebugUIConstants.java8
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/ui/InspectPopupDialog.java41
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/ui/contexts/IDebugContextListener.java31
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/ui/contexts/IDebugContextManager.java99
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/ui/contexts/IDebugContextProvider.java35
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/ui/contexts/ISourceDisplayAdapter.java31
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/ui/contexts/ISuspendTrigger.java26
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/ui/contexts/ISuspendTriggerListener.java (renamed from org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DeferredVariableLogicalStructure.java)24
149 files changed, 8611 insertions, 3991 deletions
diff --git a/org.eclipse.debug.ui/META-INF/MANIFEST.MF b/org.eclipse.debug.ui/META-INF/MANIFEST.MF
index 8ae417f8c..33489edc5 100644
--- a/org.eclipse.debug.ui/META-INF/MANIFEST.MF
+++ b/org.eclipse.debug.ui/META-INF/MANIFEST.MF
@@ -9,6 +9,8 @@ Bundle-Localization: plugin
Export-Package: org.eclipse.debug.internal.ui;x-internal:=true,
org.eclipse.debug.internal.ui.actions;x-internal:=true,
org.eclipse.debug.internal.ui.actions.breakpointGroups;x-internal:=true,
+ org.eclipse.debug.internal.ui.contexts;x-internal:=true,
+ org.eclipse.debug.internal.ui.contexts.actions;x-internal:=true,
org.eclipse.debug.internal.ui.elements.adapters;x-internal:=true,
org.eclipse.debug.internal.ui.importexport.breakpoints;x-internal:=true,
org.eclipse.debug.internal.ui.launchConfigurations;x-internal:=true,
@@ -17,6 +19,8 @@ Export-Package: org.eclipse.debug.internal.ui;x-internal:=true,
org.eclipse.debug.internal.ui.sourcelookup;x-internal:=true,
org.eclipse.debug.internal.ui.sourcelookup.browsers;x-internal:=true,
org.eclipse.debug.internal.ui.stringsubstitution;x-internal:=true,
+ org.eclipse.debug.internal.ui.viewers,
+ org.eclipse.debug.internal.ui.viewers.update;x-internal:=true,
org.eclipse.debug.internal.ui.views;x-internal:=true,
org.eclipse.debug.internal.ui.views.breakpoints;x-internal:=true,
org.eclipse.debug.internal.ui.views.console;x-internal:=true,
@@ -29,6 +33,7 @@ Export-Package: org.eclipse.debug.internal.ui;x-internal:=true,
org.eclipse.debug.ui,
org.eclipse.debug.ui.actions,
org.eclipse.debug.ui.console,
+ org.eclipse.debug.ui.contexts,
org.eclipse.debug.ui.memory,
org.eclipse.debug.ui.sourcelookup
Require-Bundle: org.eclipse.core.expressions,
diff --git a/org.eclipse.debug.ui/plugin.xml b/org.eclipse.debug.ui/plugin.xml
index 1cda9bdaa..23087b10f 100644
--- a/org.eclipse.debug.ui/plugin.xml
+++ b/org.eclipse.debug.ui/plugin.xml
@@ -187,7 +187,7 @@
<action
id="org.eclipse.debug.ui.actions.StepReturn"
hoverIcon="$nl$/icons/full/elcl16/stepreturn_co.gif"
- class="org.eclipse.debug.internal.ui.actions.StepReturnActionDelegate"
+ class="org.eclipse.debug.internal.ui.contexts.actions.StepReturnActionDelegate"
definitionId="org.eclipse.debug.ui.commands.StepReturn"
disabledIcon="$nl$/icons/full/dlcl16/stepreturn_co.gif"
icon="$nl$/icons/full/elcl16/stepreturn_co.gif"
@@ -198,7 +198,7 @@
<action
id="org.eclipse.debug.ui.actions.StepOver"
hoverIcon="$nl$/icons/full/elcl16/stepover_co.gif"
- class="org.eclipse.debug.internal.ui.actions.StepOverActionDelegate"
+ class="org.eclipse.debug.internal.ui.contexts.actions.StepOverActionDelegate"
definitionId="org.eclipse.debug.ui.commands.StepOver"
disabledIcon="$nl$/icons/full/dlcl16/stepover_co.gif"
icon="$nl$/icons/full/elcl16/stepover_co.gif"
@@ -209,7 +209,7 @@
<action
id="org.eclipse.debug.ui.actions.StepInto"
hoverIcon="$nl$/icons/full/elcl16/stepinto_co.gif"
- class="org.eclipse.debug.internal.ui.actions.StepIntoActionDelegate"
+ class="org.eclipse.debug.internal.ui.contexts.actions.StepIntoActionDelegate"
definitionId="org.eclipse.debug.ui.commands.StepInto"
disabledIcon="$nl$/icons/full/dlcl16/stepinto_co.gif"
icon="$nl$/icons/full/elcl16/stepinto_co.gif"
@@ -220,7 +220,7 @@
<action
id="org.eclipse.debug.ui.actions.Terminate"
hoverIcon="$nl$/icons/full/elcl16/terminate_co.gif"
- class="org.eclipse.debug.internal.ui.actions.TerminateActionDelegate"
+ class="org.eclipse.debug.internal.ui.contexts.actions.TerminateActionDelegate"
definitionId="org.eclipse.debug.ui.commands.Terminate"
disabledIcon="$nl$/icons/full/dlcl16/terminate_co.gif"
icon="$nl$/icons/full/elcl16/terminate_co.gif"
@@ -231,7 +231,7 @@
<action
id="org.eclipse.debug.ui.actions.Suspend"
hoverIcon="$nl$/icons/full/elcl16/suspend_co.gif"
- class="org.eclipse.debug.internal.ui.actions.SuspendActionDelegate"
+ class="org.eclipse.debug.internal.ui.contexts.actions.SuspendActionDelegate"
definitionId="org.eclipse.debug.ui.commands.Suspend"
disabledIcon="$nl$/icons/full/dlcl16/suspend_co.gif"
icon="$nl$/icons/full/elcl16/suspend_co.gif"
@@ -242,7 +242,7 @@
<action
id="org.eclipse.debug.ui.actions.Resume"
hoverIcon="$nl$/icons/full/elcl16/resume_co.gif"
- class="org.eclipse.debug.internal.ui.actions.ResumeActionDelegate"
+ class="org.eclipse.debug.internal.ui.contexts.actions.ResumeActionDelegate"
definitionId="org.eclipse.debug.ui.commands.Resume"
disabledIcon="$nl$/icons/full/dlcl16/resume_co.gif"
icon="$nl$/icons/full/elcl16/resume_co.gif"
@@ -392,7 +392,7 @@
<action
disabledIcon="$nl$/icons/full/dlcl16/rem_all_co.gif"
label="%RemoveAllBreakpointsAction.label"
- class="org.eclipse.debug.internal.ui.actions.RemoveAllBreakpointsAction"
+ class="org.eclipse.debug.internal.ui.contexts.actions.RemoveAllBreakpointsAction"
icon="$nl$/icons/full/elcl16/rem_all_co.gif"
definitionId="org.eclipse.debug.ui.commands.RemoveAllBreakpoints"
style="push"
@@ -437,7 +437,7 @@
class="org.eclipse.debug.internal.ui.actions.RetargetToggleLineBreakpointAction"
menubarPath="org.eclipse.ui.run/breakpointGroup"
id="org.eclipse.debug.ui.actions.ToggleBreakpoint">
- </action>
+ </action>
</actionSet>
</extension>
<extension
@@ -527,7 +527,7 @@
id="org.eclipse.debug.ui.debugview.toolbar.removeAllTerminated"
toolbarPath="threadGroup"
hoverIcon="$nl$/icons/full/elcl16/rem_all_co.gif"
- class="org.eclipse.debug.internal.ui.actions.RemoveAllTerminatedAction"
+ class="org.eclipse.debug.internal.ui.contexts.actions.RemoveAllTerminatedAction"
disabledIcon="$nl$/icons/full/dlcl16/rem_all_co.gif"
icon="$nl$/icons/full/elcl16/rem_all_co.gif"
helpContextId="remove_all_terminated_action_context"
@@ -538,7 +538,7 @@
id="org.eclipse.debug.ui.debugview.toolbar.disconnect"
toolbarPath="threadGroup"
hoverIcon="$nl$/icons/full/elcl16/disconnect_co.gif"
- class="org.eclipse.debug.internal.ui.actions.DisconnectActionDelegate"
+ class="org.eclipse.debug.internal.ui.contexts.actions.DisconnectActionDelegate"
disabledIcon="$nl$/icons/full/dlcl16/disconnect_co.gif"
icon="$nl$/icons/full/elcl16/disconnect_co.gif"
helpContextId="disconnect_action_context"
@@ -552,7 +552,7 @@
id="org.eclipse.debug.ui.debugview.toolbar.terminate"
toolbarPath="threadGroup"
hoverIcon="$nl$/icons/full/elcl16/terminate_co.gif"
- class="org.eclipse.debug.internal.ui.actions.TerminateActionDelegate"
+ class="org.eclipse.debug.internal.ui.contexts.actions.TerminateActionDelegate"
disabledIcon="$nl$/icons/full/dlcl16/terminate_co.gif"
icon="$nl$/icons/full/elcl16/terminate_co.gif"
helpContextId="terminate_action_context"
@@ -566,7 +566,7 @@
id="org.eclipse.debug.ui.debugview.toolbar.suspend"
toolbarPath="threadGroup"
hoverIcon="$nl$/icons/full/elcl16/suspend_co.gif"
- class="org.eclipse.debug.internal.ui.actions.SuspendActionDelegate"
+ class="org.eclipse.debug.internal.ui.contexts.actions.SuspendActionDelegate"
disabledIcon="$nl$/icons/full/dlcl16/suspend_co.gif"
enablesFor="1"
icon="$nl$/icons/full/elcl16/suspend_co.gif"
@@ -581,7 +581,7 @@
id="org.eclipse.debug.ui.debugview.toolbar.resume"
toolbarPath="threadGroup"
hoverIcon="$nl$/icons/full/elcl16/resume_co.gif"
- class="org.eclipse.debug.internal.ui.actions.ResumeActionDelegate"
+ class="org.eclipse.debug.internal.ui.contexts.actions.ResumeActionDelegate"
disabledIcon="$nl$/icons/full/dlcl16/resume_co.gif"
enablesFor="1"
icon="$nl$/icons/full/elcl16/resume_co.gif"
@@ -597,7 +597,7 @@
id="org.eclipse.debug.ui.debugview.toolbar.stepReturn"
toolbarPath="stepReturnGroup"
hoverIcon="$nl$/icons/full/elcl16/stepreturn_co.gif"
- class="org.eclipse.debug.internal.ui.actions.StepReturnActionDelegate"
+ class="org.eclipse.debug.internal.ui.contexts.actions.StepReturnActionDelegate"
disabledIcon="$nl$/icons/full/dlcl16/stepreturn_co.gif"
enablesFor="1"
icon="$nl$/icons/full/elcl16/stepreturn_co.gif"
@@ -612,7 +612,7 @@
id="org.eclipse.debug.ui.debugview.toolbar.stepOver"
toolbarPath="stepOverGroup"
hoverIcon="$nl$/icons/full/elcl16/stepover_co.gif"
- class="org.eclipse.debug.internal.ui.actions.StepOverActionDelegate"
+ class="org.eclipse.debug.internal.ui.contexts.actions.StepOverActionDelegate"
disabledIcon="$nl$/icons/full/dlcl16/stepover_co.gif"
enablesFor="1"
icon="$nl$/icons/full/elcl16/stepover_co.gif"
@@ -627,7 +627,7 @@
id="org.eclipse.debug.ui.debugview.toolbar.stepInto"
toolbarPath="stepIntoGroup"
hoverIcon="$nl$/icons/full/elcl16/stepinto_co.gif"
- class="org.eclipse.debug.internal.ui.actions.StepIntoActionDelegate"
+ class="org.eclipse.debug.internal.ui.contexts.actions.StepIntoActionDelegate"
disabledIcon="$nl$/icons/full/dlcl16/stepinto_co.gif"
enablesFor="1"
icon="$nl$/icons/full/elcl16/stepinto_co.gif"
@@ -641,7 +641,7 @@
<action
id="org.eclipse.debug.ui.debugview.toolbar.dropToFrame"
toolbarPath="emptyStepGroup"
- class="org.eclipse.debug.internal.ui.actions.DropToFrameActionDelegate"
+ class="org.eclipse.debug.internal.ui.contexts.actions.DropToFrameActionDelegate"
enablesFor="1"
icon="$nl$/icons/full/elcl16/drop_to_frame.gif"
label="%DropToFrameAction.label"
@@ -674,7 +674,7 @@
id="org.eclipse.debug.ui.breakpointsView.toolbar.removeAll"
toolbarPath="breakpointGroup"
hoverIcon="$nl$/icons/full/elcl16/rem_all_co.gif"
- class="org.eclipse.debug.internal.ui.actions.RemoveAllBreakpointsAction"
+ class="org.eclipse.debug.internal.ui.contexts.actions.RemoveAllBreakpointsAction"
disabledIcon="$nl$/icons/full/dlcl16/rem_all_co.gif"
icon="$nl$/icons/full/elcl16/rem_all_co.gif"
helpContextId="remove_all_breakpoints_action_context"
@@ -685,7 +685,7 @@
id="org.eclipse.debug.ui.breakpointsView.toolbar.remove"
toolbarPath="breakpointGroup"
hoverIcon="$nl$/icons/full/elcl16/rem_co.gif"
- class="org.eclipse.debug.internal.ui.actions.RemoveBreakpointAction"
+ class="org.eclipse.debug.internal.ui.contexts.actions.RemoveBreakpointAction"
disabledIcon="$nl$/icons/full/dlcl16/rem_co.gif"
icon="$nl$/icons/full/elcl16/rem_co.gif"
helpContextId="remove_breakpoint_action_context"
@@ -784,7 +784,7 @@
id="org.eclipse.debug.ui.expresssionsView.toolbar.removeAll"
toolbarPath="expressionGroup"
hoverIcon="$nl$/icons/full/elcl16/rem_all_co.gif"
- class="org.eclipse.debug.internal.ui.actions.RemoveAllExpressionsAction"
+ class="org.eclipse.debug.internal.ui.contexts.actions.RemoveAllExpressionsAction"
disabledIcon="$nl$/icons/full/dlcl16/rem_all_co.gif"
icon="$nl$/icons/full/elcl16/rem_all_co.gif"
helpContextId="remove_all_expressions_action_context"
@@ -795,7 +795,7 @@
id="org.eclipse.debug.ui.expresssionsView.toolbar.remove"
toolbarPath="expressionGroup"
hoverIcon="$nl$/icons/full/elcl16/rem_co.gif"
- class="org.eclipse.debug.internal.ui.actions.RemoveExpressionAction"
+ class="org.eclipse.debug.internal.ui.contexts.actions.RemoveExpressionAction"
disabledIcon="$nl$/icons/full/dlcl16/rem_co.gif"
icon="$nl$/icons/full/elcl16/rem_co.gif"
helpContextId="remove_expression_action_context"
@@ -1087,7 +1087,7 @@
label="%TerminateAllAction.label"
icon="$nl$/icons/full/elcl16/terminate_all_co.gif"
helpContextId="terminate_all_action_context"
- class="org.eclipse.debug.internal.ui.actions.TerminateAllAction"
+ class="org.eclipse.debug.internal.ui.contexts.actions.TerminateAllAction"
menubarPath="launchGroup"
id="org.eclipse.debug.ui.debugview.popupMenu.terminateAll">
</action>
@@ -1103,7 +1103,7 @@
label="%TerminateAndRemoveAction.label"
icon="$nl$/icons/full/elcl16/terminate_rem_co.gif"
helpContextId="terminate_and_remove_action_context"
- class="org.eclipse.debug.internal.ui.actions.TerminateAndRemoveActionDelegate"
+ class="org.eclipse.debug.internal.ui.contexts.actions.TerminateAndRemoveActionDelegate"
menubarPath="launchGroup"
id="org.eclipse.debug.ui.debugview.popupMenu.terminateAndRemove">
<selection
@@ -1115,7 +1115,7 @@
label="%RemoveAllTerminatedAction.label"
icon="$nl$/icons/full/elcl16/rem_all_co.gif"
helpContextId="remove_all_terminated_action_context"
- class="org.eclipse.debug.internal.ui.actions.RemoveAllTerminatedAction"
+ class="org.eclipse.debug.internal.ui.contexts.actions.RemoveAllTerminatedAction"
menubarPath="launchGroup"
id="org.eclipse.debug.ui.debugview.popupMenu.removeAllTerminated">
</action>
@@ -1123,7 +1123,7 @@
label="%DisconnectAction.label"
icon="$nl$/icons/full/elcl16/disconnect_co.gif"
helpContextId="disconnect_action_context"
- class="org.eclipse.debug.internal.ui.actions.DisconnectActionDelegate"
+ class="org.eclipse.debug.internal.ui.contexts.actions.DisconnectActionDelegate"
menubarPath="threadGroup"
id="org.eclipse.debug.ui.debugview.popupMenu.disconnect">
<selection
@@ -1132,7 +1132,7 @@
</action>
<action
label="%TerminateAndRelaunchAction.label"
- class="org.eclipse.debug.internal.ui.actions.TerminateAndRelaunchAction"
+ class="org.eclipse.debug.internal.ui.contexts.actions.TerminateAndRelaunchAction"
definitionId="org.eclipse.debug.ui.commands.TerminateAndRelaunch"
helpContextId="terminate_and_relaunch_action_context"
icon="$nl$/icons/full/etool16/term_restart.gif"
@@ -1144,7 +1144,7 @@
icon="$nl$/icons/full/elcl16/terminate_co.gif"
helpContextId="terminate_action_context"
definitionId="org.eclipse.debug.ui.commands.Terminate"
- class="org.eclipse.debug.internal.ui.actions.TerminateActionDelegate"
+ class="org.eclipse.debug.internal.ui.contexts.actions.TerminateActionDelegate"
menubarPath="threadGroup"
id="org.eclipse.debug.ui.debugview.popupMenu.terminate">
<selection
@@ -1156,7 +1156,7 @@
icon="$nl$/icons/full/elcl16/suspend_co.gif"
helpContextId="suspend_action_context"
definitionId="org.eclipse.debug.ui.commands.Suspend"
- class="org.eclipse.debug.internal.ui.actions.SuspendActionDelegate"
+ class="org.eclipse.debug.internal.ui.contexts.actions.SuspendActionDelegate"
menubarPath="threadGroup"
enablesFor="1"
id="org.eclipse.debug.ui.debugview.popupMenu.suspend">
@@ -1169,7 +1169,7 @@
icon="$nl$/icons/full/elcl16/resume_co.gif"
helpContextId="resume_action_context"
definitionId="org.eclipse.debug.ui.commands.Resume"
- class="org.eclipse.debug.internal.ui.actions.ResumeActionDelegate"
+ class="org.eclipse.debug.internal.ui.contexts.actions.ResumeActionDelegate"
menubarPath="threadGroup"
enablesFor="1"
id="org.eclipse.debug.ui.debugview.popupMenu.resume">
@@ -1182,7 +1182,7 @@
label="%DropToFrameAction.label"
icon="$nl$/icons/full/elcl16/drop_to_frame.gif"
helpContextId="drop_to_frame_action_context"
- class="org.eclipse.debug.internal.ui.actions.DropToFrameActionDelegate"
+ class="org.eclipse.debug.internal.ui.contexts.actions.DropToFrameActionDelegate"
menubarPath="stepReturnGroup"
enablesFor="1"
id="org.eclipse.debug.ui.debugview.popupMenu.dropToFrame">
@@ -1195,7 +1195,7 @@
icon="$nl$/icons/full/elcl16/stepreturn_co.gif"
helpContextId="step_return_action_context"
definitionId="org.eclipse.debug.ui.commands.StepReturn"
- class="org.eclipse.debug.internal.ui.actions.StepReturnActionDelegate"
+ class="org.eclipse.debug.internal.ui.contexts.actions.StepReturnActionDelegate"
menubarPath="stepReturnGroup"
enablesFor="1"
id="org.eclipse.debug.ui.debugview.popupMenu.stepReturn">
@@ -1208,7 +1208,7 @@
icon="$nl$/icons/full/elcl16/stepover_co.gif"
helpContextId="step_over_action_context"
definitionId="org.eclipse.debug.ui.commands.StepOver"
- class="org.eclipse.debug.internal.ui.actions.StepOverActionDelegate"
+ class="org.eclipse.debug.internal.ui.contexts.actions.StepOverActionDelegate"
menubarPath="stepOverGroup"
enablesFor="1"
id="org.eclipse.debug.ui.debugview.popupMenu.stepOver">
@@ -1221,7 +1221,7 @@
icon="$nl$/icons/full/elcl16/stepinto_co.gif"
helpContextId="step_into_action_context"
definitionId="org.eclipse.debug.ui.commands.StepInto"
- class="org.eclipse.debug.internal.ui.actions.StepIntoActionDelegate"
+ class="org.eclipse.debug.internal.ui.contexts.actions.StepIntoActionDelegate"
menubarPath="stepIntoGroup"
enablesFor="1"
id="org.eclipse.debug.ui.debugview.popupMenu.stepInto">
@@ -1271,7 +1271,7 @@
label="%SelectAll.label"
helpContextId="select_all_breakpoints_action_context"
definitionId="org.eclipse.ui.edit.selectAll"
- class="org.eclipse.debug.internal.ui.actions.SelectAllBreakpointsAction"
+ class="org.eclipse.debug.internal.ui.contexts.actions.SelectAllBreakpointsAction"
menubarPath="breakpointGroup"
id="org.eclipse.debug.ui.actions.SelectAllBreakpointsAction">
</action>
@@ -1279,7 +1279,7 @@
label="%RemoveAllAction.label"
icon="$nl$/icons/full/elcl16/rem_all_co.gif"
helpContextId="remove_all_breakpoints_action_context"
- class="org.eclipse.debug.internal.ui.actions.RemoveAllBreakpointsAction"
+ class="org.eclipse.debug.internal.ui.contexts.actions.RemoveAllBreakpointsAction"
menubarPath="breakpointGroup"
id="org.eclipse.debug.ui.actions.RemoveAllBreakpoints">
</action>
@@ -1287,7 +1287,7 @@
label="%RemoveAction.label"
icon="$nl$/icons/full/elcl16/rem_co.gif"
helpContextId="remove_breakpoint_action_context"
- class="org.eclipse.debug.internal.ui.actions.RemoveBreakpointAction"
+ class="org.eclipse.debug.internal.ui.contexts.actions.RemoveBreakpointAction"
menubarPath="breakpointGroup"
enablesFor="1+"
id="org.eclipse.debug.ui.breakpointsView.toolbar.remove">
@@ -1346,7 +1346,7 @@
label="%SelectAll.label"
helpContextId="select_all_variables_action_context"
definitionId="org.eclipse.ui.edit.selectAll"
- class="org.eclipse.debug.internal.ui.actions.SelectAllVariablesAction"
+ class="org.eclipse.debug.internal.ui.contexts.actions.SelectAllVariablesAction"
menubarPath="variableGroup"
id="org.eclipse.debug.ui.actions.SelectAllVariablesAction">
</action>
@@ -1360,7 +1360,7 @@
label="%RemoveAllAction.label"
icon="$nl$/icons/full/elcl16/rem_all_co.gif"
helpContextId="remove_all_expressions_action_context"
- class="org.eclipse.debug.internal.ui.actions.RemoveAllExpressionsAction"
+ class="org.eclipse.debug.internal.ui.contexts.actions.RemoveAllExpressionsAction"
menubarPath="expressionGroup"
id="org.eclipse.debug.ui.debugview.popupMenu.removeAllExpressionsAction">
</action>
@@ -1368,7 +1368,7 @@
label="%RemoveAction.label"
icon="$nl$/icons/full/elcl16/rem_co.gif"
helpContextId="remove_expression_action_context"
- class="org.eclipse.debug.internal.ui.actions.RemoveExpressionAction"
+ class="org.eclipse.debug.internal.ui.contexts.actions.RemoveExpressionAction"
menubarPath="expressionGroup"
id="org.eclipse.debug.ui.debugview.popupMenu.removeExpressionAction">
<selection
@@ -1394,7 +1394,7 @@
label="%SelectAll.label"
helpContextId="select_all_expressions_action_context"
definitionId="org.eclipse.ui.edit.selectAll"
- class="org.eclipse.debug.internal.ui.actions.SelectAllExpressionsAction"
+ class="org.eclipse.debug.internal.ui.contexts.actions.SelectAllExpressionsAction"
menubarPath="expressionGroup"
id="org.eclipse.debug.ui.actions.SelectAllExpressionsAction">
</action>
@@ -1416,7 +1416,7 @@
</selection>
</action>
<action
- class="org.eclipse.debug.internal.ui.actions.SelectAllVariablesAction"
+ class="org.eclipse.debug.internal.ui.contexts.actions.SelectAllVariablesAction"
label="%SelectAll.label"
menubarPath="variableGroup"
definitionId="org.eclipse.ui.edit.selectAll"
@@ -1752,7 +1752,7 @@ M4 = Platform-specific fourth key
description="%ActionDefinition.toggleMethodBreakpoint.description"
categoryId="org.eclipse.debug.ui.category.run"
id="org.eclipse.debug.ui.commands.ToggleMethodBreakpoint">
- </command>
+ </command>
<!-- console -->
<command
name="%ActionDefinition.eof.name"
@@ -2442,7 +2442,7 @@ M4 = Platform-specific fourth key
label="%RemoveAllTerminatedAction.label"
tooltip="%RemoveAllTerminatedAction.tooltip"
icon="$nl$/icons/full/elcl16/rem_all_co.gif"
- class="org.eclipse.debug.internal.ui.actions.RemoveAllTerminatedAction"
+ class="org.eclipse.debug.internal.ui.contexts.actions.RemoveAllTerminatedAction"
menubarPath="additions"
id="org.eclipse.debug.ui.consoleRemoveAllTerminatedAction"
helpContextId="console_remove_all_terminated_context"/>
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java
index b4a0ec96f..3d270cb71 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java
@@ -52,6 +52,7 @@ import org.eclipse.debug.core.ILaunchListener;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.core.IStatusHandler;
import org.eclipse.debug.core.Launch;
+import org.eclipse.debug.core.model.IDebugElement;
import org.eclipse.debug.core.model.IDebugTarget;
import org.eclipse.debug.core.model.IExpression;
import org.eclipse.debug.core.model.IProcess;
@@ -60,9 +61,11 @@ import org.eclipse.debug.core.model.IRegisterGroup;
import org.eclipse.debug.core.model.IStackFrame;
import org.eclipse.debug.core.model.IThread;
import org.eclipse.debug.core.model.IVariable;
+import org.eclipse.debug.internal.ui.contexts.SuspendTriggerAdapterFactory;
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationManager;
import org.eclipse.debug.internal.ui.launchConfigurations.PerspectiveManager;
import org.eclipse.debug.internal.ui.sourcelookup.SourceLookupFacility;
+import org.eclipse.debug.internal.ui.sourcelookup.SourceLookupManager;
import org.eclipse.debug.internal.ui.stringsubstitution.SelectedResourceManager;
import org.eclipse.debug.internal.ui.views.breakpoints.BreakpointOrganizerManager;
import org.eclipse.debug.internal.ui.views.breakpoints.OtherBreakpointCategory;
@@ -417,9 +420,12 @@ public class DebugUIPlugin extends AbstractUIPlugin implements ILaunchListener {
manager.registerAdapters(propertiesFactory, IExpression.class);
manager.registerAdapters(propertiesFactory, IExpressionManager.class);
manager.registerAdapters(propertiesFactory, OtherBreakpointCategory.class);
+ manager.registerAdapters(propertiesFactory, IDebugElement.class);
DebugUIAdapterFactory uiFactory = new DebugUIAdapterFactory();
manager.registerAdapters(uiFactory, ILaunchConfiguration.class);
manager.registerAdapters(uiFactory, ILaunchConfigurationType.class);
+ SuspendTriggerAdapterFactory factory = new SuspendTriggerAdapterFactory();
+ manager.registerAdapters(factory, ILaunch.class);
getStandardDisplay().asyncExec(
new Runnable() {
public void run() {
@@ -665,6 +671,7 @@ public class DebugUIPlugin extends AbstractUIPlugin implements ILaunchListener {
}
getLaunchConfigurationManager().startup();
+ SourceLookupManager.getDefault();
}
/**
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DelegatingModelPresentation.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DelegatingModelPresentation.java
index 1a968567e..23c462a3b 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DelegatingModelPresentation.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DelegatingModelPresentation.java
@@ -293,7 +293,7 @@ public class DelegatingModelPresentation implements IDebugModelPresentation, IDe
return show.booleanValue();
}
- protected HashMap getAttributes() {
+ public HashMap getAttributes() {
return fAttributes;
}
@@ -307,18 +307,10 @@ public class DelegatingModelPresentation implements IDebugModelPresentation, IDe
return (Map) getAttributes().clone();
}
- protected void setAttributes(HashMap attributes) {
- fAttributes = attributes;
- }
-
protected HashMap getLabelProviders() {
return fLabelProviders;
}
- protected void setLabelProviders(HashMap labelProviders) {
- fLabelProviders = labelProviders;
- }
-
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object)
*/
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/IInternalDebugUIConstants.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/IInternalDebugUIConstants.java
index 67db6b14c..afeade528 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/IInternalDebugUIConstants.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/IInternalDebugUIConstants.java
@@ -193,26 +193,34 @@ public interface IInternalDebugUIConstants {
*/
public static final String PREF_SWITCH_PERSPECTIVE_ON_SUSPEND= IDebugUIConstants.PLUGIN_ID + ".switch_perspective_on_suspend"; //$NON-NLS-1$
- /**
- * String preference controlling whether the debugger waits for a currently
- * pending (running or waiting) background build to complete before launching.
- * Valid values are either "always", "never", or "prompt".
- * If "always" or "never", launching will wait for builds to finish (or not) automatically.
- * If "prompt", the user will be prompted each time.
- *
- * @since 3.0
- */
- public static final String PREF_WAIT_FOR_BUILD= IDebugUIConstants.PLUGIN_ID + ".wait_for_build"; //$NON-NLS-1$
-
- /**
- * Font for Memory View
- *
- * @since 3.0
- */
- public final static String FONT_NAME = IDebugUIConstants.PLUGIN_ID + ".MemoryViewTableFont"; //$NON-NLS-1$
-
- public final static int ADD_UNIT_PER_LINE = 16; // number of addressable unit per line
- public final static int CHAR_PER_BYTE = 2; // number of characters to represent one byte
+ /**
+ * String preference controlling whether the debugger waits for a currently
+ * pending (running or waiting) background build to complete before launching.
+ * Valid values are either "always", "never", or "prompt".
+ * If "always" or "never", launching will wait for builds to finish (or not) automatically.
+ * If "prompt", the user will be prompted each time.
+ *
+ * @since 3.0
+ */
+ public static final String PREF_WAIT_FOR_BUILD= IDebugUIConstants.PLUGIN_ID + ".wait_for_build"; //$NON-NLS-1$
+
+ /**
+ * Maximum number of characters to display in the details area of the variables
+ * view, or 0 if unlimited.
+ *
+ * @since 3.1
+ */
+ public static final String PREF_MAX_DETAIL_LENGTH = IDebugUIConstants.PLUGIN_ID + ".max_detail_length"; //$NON-NLS-1$
+
+ /**
+ * Font for Memory View
+ *
+ * @since 3.0
+ */
+ public final static String FONT_NAME = IDebugUIConstants.PLUGIN_ID + ".MemoryViewTableFont"; //$NON-NLS-1$
+
+ public final static int ADD_UNIT_PER_LINE = 16; // number of addressable unit per line
+ public final static int CHAR_PER_BYTE = 2; // number of characters to represent one byte
/**
* Memory view identifier (value <code>"org.eclipse.debug.ui.MemoryView"</code>).
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/LazyModelPresentation.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/LazyModelPresentation.java
index 0a99ad7d1..140f0a556 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/LazyModelPresentation.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/LazyModelPresentation.java
@@ -337,6 +337,10 @@ public class LazyModelPresentation implements IDebugModelPresentation, IDebugEdi
public Map getAttributeMap() {
return (Map) fAttributes.clone();
}
+
+ public Map getAttributes() {
+ return fAttributes;
+ }
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object)
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/AbstractListenerActionDelegate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/AbstractListenerActionDelegate.java
deleted file mode 100644
index a34217039..000000000
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/AbstractListenerActionDelegate.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- * Pawel Piech - Bug 75183
- *******************************************************************************/
-package org.eclipse.debug.internal.ui.actions;
-
-
-import org.eclipse.debug.core.DebugEvent;
-import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.IDebugEventSetListener;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IActionDelegate2;
-import org.eclipse.ui.IViewPart;
-import org.eclipse.ui.IWorkbenchWindow;
-
-public abstract class AbstractListenerActionDelegate extends AbstractDebugActionDelegate implements IDebugEventSetListener, IActionDelegate2 {
-
- private boolean fDisposed = false;
-
- /**
- * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose()
- * @see org.eclipse.ui.IActionDelegate2#dispose()
- */
- public synchronized void dispose() {
- super.dispose();
- DebugPlugin.getDefault().removeDebugEventListener(this);
- fDisposed = true;
- }
-
- /**
- * @see IDebugEventSetListener#handleDebugEvents(DebugEvent[])
- */
- public void handleDebugEvents(final DebugEvent[] events) {
- if (getWindow() == null || getAction() == null) {
- return;
- }
- Shell shell= getWindow().getShell();
- if (shell == null || shell.isDisposed()) {
- return;
- }
- synchronized (this) {
- if (fDisposed) {
- return;
- }
- }
- for (int i = 0; i < events.length; i++) {
- if (events[i].getSource() != null) {
- doHandleDebugEvent(events[i]);
- }
- }
- }
-
- /**
- * Default implementation to update on specific debug events.
- * Subclasses should override to handle events differently.
- */
- protected void doHandleDebugEvent(DebugEvent event) {
- switch (event.getKind()) {
- case DebugEvent.TERMINATE :
- update(getAction(), getSelection());
- break;
- case DebugEvent.RESUME :
- if (!event.isEvaluation() || !((event.getDetail() & DebugEvent.EVALUATION_IMPLICIT) != 0)) {
- update(getAction(), getSelection());
- }
- break;
- case DebugEvent.SUSPEND :
- // Update on suspend events (even for evaluations), in case the user changed
- // the selection during an implicit evaluation.
- update(getAction(), getSelection());
- break;
- case DebugEvent.CHANGE :
- // Implementations can use this event for debugger state
- // changes other than just suspend/resume. This may or
- // may not affect the enable state of run/suspend/step
- // actions.
- update(getAction(), getSelection());
- break;
- }
- }
-
- /**
- * @see IWorkbenchWindowActionDelegate#init(IWorkbenchWindow)
- */
- public void init(IWorkbenchWindow window){
- super.init(window);
- DebugPlugin.getDefault().addDebugEventListener(this);
- }
-
- /**
- * @see IViewActionDelegate#init(IViewPart)
- */
- public void init(IViewPart view) {
- super.init(view);
- DebugPlugin.getDefault().addDebugEventListener(this);
- setWindow(view.getViewSite().getWorkbenchWindow());
- }
-
- /**
- * @see org.eclipse.ui.IActionDelegate2#init(org.eclipse.jface.action.IAction)
- */
- public void init(IAction action) {
- }
-
- /**
- * @see org.eclipse.ui.IActionDelegate2#runWithEvent(org.eclipse.jface.action.IAction, org.eclipse.swt.widgets.Event)
- */
- public void runWithEvent(IAction action, Event event) {
- run(action);
- }
-}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/CollapseAllAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/CollapseAllAction.java
index 873e68ff2..fa0987b2e 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/CollapseAllAction.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/CollapseAllAction.java
@@ -12,19 +12,19 @@ package org.eclipse.debug.internal.ui.actions;
import org.eclipse.debug.internal.ui.DebugPluginImages;
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
+import org.eclipse.debug.internal.ui.viewers.AsynchronousTreeViewer;
import org.eclipse.jface.action.Action;
-import org.eclipse.jface.viewers.AbstractTreeViewer;
/**
* CollapseAllAction
*/
public class CollapseAllAction extends Action {
- private AbstractTreeViewer fViewer;
+ private AsynchronousTreeViewer fViewer;
- public CollapseAllAction(AbstractTreeViewer viewer) {
- super(ActionMessages.CollapseAllAction_0, DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_COLLAPSE_ALL));
- setToolTipText(ActionMessages.CollapseAllAction_0);
+ public CollapseAllAction(AsynchronousTreeViewer viewer) {
+ super(ActionMessages.CollapseAllAction_0, DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_COLLAPSE_ALL));
+ setToolTipText(ActionMessages.CollapseAllAction_0);
setDisabledImageDescriptor(DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_DLCL_COLLAPSE_ALL));
setHoverImageDescriptor(DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_LCL_COLLAPSE_ALL));
fViewer = viewer;
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/CopyToClipboardActionDelegate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/CopyToClipboardActionDelegate.java
index 9d6037c11..88b97f922 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/CopyToClipboardActionDelegate.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/CopyToClipboardActionDelegate.java
@@ -23,19 +23,20 @@ import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ContentViewer;
import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.SWTError;
import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.swt.dnd.Clipboard;
import org.eclipse.swt.dnd.DND;
import org.eclipse.swt.dnd.TextTransfer;
import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;
public class CopyToClipboardActionDelegate extends AbstractDebugActionDelegate {
- private TreeViewer fViewer;
+ private ContentViewer fViewer;
/**
* @see AbstractDebugActionDelegate#initialize(IAction, ISelection)
@@ -45,7 +46,7 @@ public class CopyToClipboardActionDelegate extends AbstractDebugActionDelegate {
IDebugView adapter= (IDebugView)getView().getAdapter(IDebugView.class);
if (adapter != null) {
if (adapter.getViewer() instanceof ContentViewer) {
- setViewer((TreeViewer) adapter.getViewer());
+ setViewer((ContentViewer) adapter.getViewer());
}
adapter.setAction(getActionId(), action);
}
@@ -134,15 +135,20 @@ public class CopyToClipboardActionDelegate extends AbstractDebugActionDelegate {
* remove the child.
*/
protected Iterator pruneSelection() {
- TreeItem[] selection= getViewer().getTree().getSelection();
- List items= new ArrayList(selection.length);
- for (int i = 0; i < selection.length; i++) {
- TreeItem item= selection[i];
- if (isEnabledFor(item.getData())) {
- if(walkHierarchy(item, items)) {
- items.add(item);
+ Control control = getViewer().getControl();
+ List items = new ArrayList();
+ if (control instanceof Tree) {
+ Tree tree = (Tree) control;
+ TreeItem[] selection = tree.getSelection();
+
+ for (int i = 0; i < selection.length; i++) {
+ TreeItem item = selection[i];
+ if (isEnabledFor(item.getData())) {
+ if (walkHierarchy(item, items)) {
+ items.add(item);
+ }
}
- }
+ }
}
return items.iterator();
}
@@ -167,11 +173,11 @@ public class CopyToClipboardActionDelegate extends AbstractDebugActionDelegate {
return data instanceof IDebugTarget || data instanceof IThread;
}
- protected TreeViewer getViewer() {
+ protected ContentViewer getViewer() {
return fViewer;
}
- protected void setViewer(TreeViewer viewer) {
+ protected void setViewer(ContentViewer viewer) {
fViewer = viewer;
}
/**
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/DebugContextManager.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/DebugContextManager.java
new file mode 100644
index 000000000..f3ac0b4f9
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/DebugContextManager.java
@@ -0,0 +1,135 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.contexts;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.debug.ui.contexts.IDebugContextListener;
+import org.eclipse.debug.ui.contexts.IDebugContextManager;
+import org.eclipse.debug.ui.contexts.IDebugContextProvider;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+
+/**
+ * @since 3.2
+ */
+public class DebugContextManager implements IDebugContextManager {
+
+ private static DebugContextManager fgDefault;
+ private Map fServices = new HashMap();
+
+ private DebugContextManager() {
+ }
+
+ public static IDebugContextManager getDefault() {
+ if (fgDefault == null) {
+ fgDefault = new DebugContextManager();
+ }
+ return fgDefault;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.contexts.IDebugContextManager#addDebugContextProvider(org.eclipse.debug.ui.contexts.IDebugContextProvider)
+ */
+ public void addDebugContextProvider(IDebugContextProvider provider) {
+ IWorkbenchPart part = provider.getPart();
+ IWorkbenchWindow window = part.getSite().getWorkbenchWindow();
+ DebugWindowContextService service = createService(window);
+ service.addProvider(provider);
+ }
+
+ protected DebugWindowContextService createService(IWorkbenchWindow window) {
+ DebugWindowContextService service = (DebugWindowContextService) fServices.get(window);
+ if (service == null) {
+ service = new DebugWindowContextService(window);
+ fServices.put(window, service);
+ // TODO: register 'null' provider (global)
+ }
+ return service;
+ }
+
+ protected IDebugContextService getService(IWorkbenchWindow window) {
+ return (DebugWindowContextService) fServices.get(window);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.contexts.IDebugContextManager#removeDebugContextProvider(org.eclipse.debug.ui.contexts.IDebugContextProvider)
+ */
+ public void removeDebugContextProvider(IDebugContextProvider provider) {
+ IWorkbenchPart part = provider.getPart();
+ IWorkbenchWindow window = part.getSite().getWorkbenchWindow();
+ DebugWindowContextService service = (DebugWindowContextService) fServices.get(window);
+ if (service != null) {
+ service.removeProvider(provider);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.contexts.IDebugContextManager#addDebugContextListener(org.eclipse.debug.ui.contexts.IDebugContextListener, org.eclipse.ui.IWorkbenchWindow)
+ */
+ public void addDebugContextListener(IDebugContextListener listener, IWorkbenchWindow window) {
+ IDebugContextService service = createService(window);
+ service.addDebugContextListener(listener);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.contexts.IDebugContextManager#removeDebugContextListener(org.eclipse.debug.ui.contexts.IDebugContextListener, org.eclipse.ui.IWorkbenchWindow)
+ */
+ public void removeDebugContextListener(IDebugContextListener listener, IWorkbenchWindow window) {
+ IDebugContextService service = getService(window);
+ if (service != null) {
+ service.removeDebugContextListener(listener);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.contexts.IDebugContextManager#addDebugContextListener(org.eclipse.debug.ui.contexts.IDebugContextListener, org.eclipse.ui.IWorkbenchWindow, java.lang.String)
+ */
+ public void addDebugContextListener(IDebugContextListener listener, IWorkbenchWindow window, String partId) {
+ DebugWindowContextService service = createService(window);
+ service.addDebugContextListener(listener, partId);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.contexts.IDebugContextManager#removeDebugContextListener(org.eclipse.debug.ui.contexts.IDebugContextListener, org.eclipse.ui.IWorkbenchWindow, java.lang.String)
+ */
+ public void removeDebugContextListener(IDebugContextListener listener, IWorkbenchWindow window, String partId) {
+ IDebugContextService service = getService(window);
+ if (service != null) {
+ service.removeDebugContextListener(listener, partId);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.contexts.IDebugContextManager#getActiveContext(org.eclipse.ui.IWorkbenchWindow)
+ */
+ public ISelection getActiveContext(IWorkbenchWindow window) {
+ IDebugContextService service = getService(window);
+ if (service != null) {
+ return service.getActiveContext();
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.contexts.IDebugContextManager#getActiveContext(org.eclipse.ui.IWorkbenchWindow, java.lang.String)
+ */
+ public ISelection getActiveContext(IWorkbenchWindow window, String partId) {
+ IDebugContextService service = getService(window);
+ if (service != null) {
+ return service.getActiveContext(partId);
+ }
+ return null;
+ }
+
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/DebugWindowContextService.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/DebugWindowContextService.java
new file mode 100644
index 000000000..8397fb433
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/DebugWindowContextService.java
@@ -0,0 +1,261 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.contexts;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.ISafeRunnable;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.debug.internal.ui.DebugUIPlugin;
+import org.eclipse.debug.ui.contexts.IDebugContextListener;
+import org.eclipse.debug.ui.contexts.IDebugContextProvider;
+import org.eclipse.jface.util.ListenerList;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.IPartListener2;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchPartReference;
+import org.eclipse.ui.IWorkbenchWindow;
+
+/**
+ * Context service for a specific window.
+ *
+ * @since 3.2
+ */
+public class DebugWindowContextService implements IDebugContextService, IPartListener2, IDebugContextListener {
+
+ private Map fListenersByPartId = new HashMap();
+ private Map fProvidersByPartId = new HashMap();
+
+ private IWorkbenchWindow fWindow;
+ private List fProviders = new ArrayList();
+
+ public DebugWindowContextService(IWorkbenchWindow window) {
+ fWindow = window;
+ fWindow.getPartService().addPartListener(this);
+ }
+
+ public void dispose() {
+ fWindow.getPartService().removePartListener(this);
+ fWindow = null;
+ }
+
+ protected synchronized void addProvider(IDebugContextProvider provider) {
+ IWorkbenchPart part = provider.getPart();
+ String id = null;
+ if (part != null) {
+ id = part.getSite().getId();
+ }
+ fProvidersByPartId.put(part, id);
+ fProviders.add(provider);
+ IWorkbenchPart active = null;
+ IWorkbenchPage activePage = fWindow.getActivePage();
+ if (activePage != null) {
+ active = activePage.getActivePart();
+ }
+ if (fProviders.size() == 1 && (part == null || part.equals(active))) {
+ notifyActivated();
+ }
+ provider.addDebugContextListener(this);
+ }
+
+ protected synchronized void removeProvider(IDebugContextProvider provider) {
+ int index = fProviders.indexOf(provider);
+ if (index >= 0) {
+ IWorkbenchPart part = provider.getPart();
+ String id = null;
+ if (part != null) {
+ id = part.getSite().getId();
+ }
+ fProvidersByPartId.remove(id);
+ fProviders.remove(index);
+ if (index == 0) {
+ notifyActivated();
+ }
+ }
+ provider.removeDebugContextListener(this);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.contexts.IDebugContextService#addDebugContextListener(org.eclipse.debug.ui.contexts.IDebugContextListener)
+ */
+ public void addDebugContextListener(IDebugContextListener listener) {
+ addDebugContextListener(listener, null);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.contexts.IDebugContextService#removeDebugContextListener(org.eclipse.debug.ui.contexts.IDebugContextListener)
+ */
+ public void removeDebugContextListener(IDebugContextListener listener) {
+ removeDebugContextListener(listener, null);
+ }
+
+ protected void notifyActivated() {
+ if (fProviders.isEmpty()) {
+ notifyActivated(null, null);
+ } else {
+ IDebugContextProvider provider = (IDebugContextProvider) fProviders.get(0);
+ notifyActivated(provider.getActiveContext(), provider.getPart());
+ }
+ }
+
+ protected void notifyActivated(ISelection context, IWorkbenchPart part) {
+ notifyActivated(getListeners(null), context, part);
+ if (part != null) {
+ notifyActivated(getListeners(part), context, part);
+ }
+ }
+ protected void notifyActivated(ListenerList list, final ISelection context, final IWorkbenchPart part) {
+ if (list != null) {
+ Object[] listeners = list.getListeners();
+ for (int i = 0; i < listeners.length; i++) {
+ final IDebugContextListener listener = (IDebugContextListener) listeners[i];
+ Platform.run(new ISafeRunnable() {
+ public void run() throws Exception {
+ listener.contextActivated(context, part);
+ }
+ public void handleException(Throwable exception) {
+ DebugUIPlugin.log(exception);
+ }
+ });
+ }
+ }
+ }
+
+ protected ListenerList getListeners(IWorkbenchPart part) {
+ String id = null;
+ if (part != null) {
+ id = part.getSite().getId();
+ }
+ return (ListenerList) fListenersByPartId.get(id);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.contexts.IDebugContextService#addDebugContextListener(org.eclipse.debug.ui.contexts.IDebugContextListener, java.lang.String)
+ */
+ public synchronized void addDebugContextListener(IDebugContextListener listener, String partId) {
+ ListenerList list = (ListenerList) fListenersByPartId.get(partId);
+ if (list == null) {
+ list = new ListenerList();
+ fListenersByPartId.put(partId, list);
+ }
+ list.add(listener);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.contexts.IDebugContextService#removeDebugContextListener(org.eclipse.debug.ui.contexts.IDebugContextListener, java.lang.String)
+ */
+ public void removeDebugContextListener(IDebugContextListener listener, String partId) {
+ ListenerList list = (ListenerList) fListenersByPartId.get(partId);
+ if (list != null) {
+ list.remove(listener);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.contexts.IDebugContextService#getActiveContext(java.lang.String)
+ */
+ public ISelection getActiveContext(String partId) {
+ IDebugContextProvider provider = (IDebugContextProvider) fProvidersByPartId.get(partId);
+ if (provider != null) {
+ return provider.getActiveContext();
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.contexts.IDebugContextService#getActiveContext()
+ */
+ public ISelection getActiveContext() {
+ if (!fProviders.isEmpty()) {
+ ((IDebugContextProvider)fProviders.get(0)).getActiveContext();
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IPartListener2#partActivated(org.eclipse.ui.IWorkbenchPartReference)
+ */
+ public void partActivated(IWorkbenchPartReference partRef) {
+ Object provider = fProvidersByPartId.get(partRef.getId());
+ if (provider != null) {
+ int index = fProviders.indexOf(provider);
+ if (index > 0) {
+ fProviders.remove(index);
+ fProviders.add(0, provider);
+ notifyActivated();
+ }
+ }
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IPartListener2#partBroughtToTop(org.eclipse.ui.IWorkbenchPartReference)
+ */
+ public void partBroughtToTop(IWorkbenchPartReference partRef) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IPartListener2#partClosed(org.eclipse.ui.IWorkbenchPartReference)
+ */
+ public synchronized void partClosed(IWorkbenchPartReference partRef) {
+ IDebugContextProvider provider = (IDebugContextProvider) fProvidersByPartId.get(partRef.getId());
+ if (provider != null) {
+ removeProvider(provider);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IPartListener2#partDeactivated(org.eclipse.ui.IWorkbenchPartReference)
+ */
+ public void partDeactivated(IWorkbenchPartReference partRef) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IPartListener2#partOpened(org.eclipse.ui.IWorkbenchPartReference)
+ */
+ public void partOpened(IWorkbenchPartReference partRef) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IPartListener2#partHidden(org.eclipse.ui.IWorkbenchPartReference)
+ */
+ public void partHidden(IWorkbenchPartReference partRef) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IPartListener2#partVisible(org.eclipse.ui.IWorkbenchPartReference)
+ */
+ public void partVisible(IWorkbenchPartReference partRef) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IPartListener2#partInputChanged(org.eclipse.ui.IWorkbenchPartReference)
+ */
+ public void partInputChanged(IWorkbenchPartReference partRef) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.contexts.IDebugContextListener#contextActivated(java.lang.Object, org.eclipse.ui.IWorkbenchPart)
+ */
+ public synchronized void contextActivated(ISelection context, IWorkbenchPart part) {
+ if (!fProviders.isEmpty()) {
+ IDebugContextProvider provider = (IDebugContextProvider) fProviders.get(0);
+ if (provider.getPart() == part) {
+ notifyActivated();
+ }
+ }
+ }
+
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/IDebugContextService.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/IDebugContextService.java
new file mode 100644
index 000000000..146f262e3
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/IDebugContextService.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.contexts;
+
+import org.eclipse.debug.ui.contexts.IDebugContextListener;
+import org.eclipse.jface.viewers.ISelection;
+
+
+/**
+ * Debug context service for a window.
+ *
+ * @since 3.2
+ */
+public interface IDebugContextService {
+
+ /**
+ * Registers for context activation notification in this service.
+ *
+ * @param listener
+ */
+ public void addDebugContextListener(IDebugContextListener listener);
+ /**
+ * Deregisters for context activation notification in this service.
+ *
+ * @param listener
+ */
+ public void removeDebugContextListener(IDebugContextListener listener);
+
+ /**
+ * Registers for context activation notification in the specified part.
+ *
+ * @param listener
+ * @param partId
+ */
+ public void addDebugContextListener(IDebugContextListener listener, String partId);
+
+ /**
+ * Deregisters for context activation notification in the specified part.
+ *
+ * @param listener
+ * @param partId
+ */
+ public void removeDebugContextListener(IDebugContextListener listener, String partId);
+
+ /**
+ * Returns the active context in this service's window
+ * or <code>null</code>.
+ *
+ * @return
+ */
+ public ISelection getActiveContext();
+
+ /**
+ * Returns the active context in the specified part or <code>null</code>.
+ *
+ * @param partId
+ * @return
+ */
+ public ISelection getActiveContext(String partId);
+
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/LaunchSuspendTrigger.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/LaunchSuspendTrigger.java
new file mode 100644
index 000000000..5c9e57cff
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/LaunchSuspendTrigger.java
@@ -0,0 +1,108 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.contexts;
+
+import org.eclipse.core.runtime.ISafeRunnable;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.debug.core.DebugEvent;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.IDebugEventSetListener;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.model.IDebugElement;
+import org.eclipse.debug.core.model.IDebugTarget;
+import org.eclipse.debug.core.model.IThread;
+import org.eclipse.debug.internal.ui.DebugUIPlugin;
+import org.eclipse.debug.ui.contexts.ISuspendTrigger;
+import org.eclipse.debug.ui.contexts.ISuspendTriggerListener;
+import org.eclipse.jface.util.ListenerList;
+
+/**
+ * @since 3.2
+ */
+public class LaunchSuspendTrigger implements ISuspendTrigger, IDebugEventSetListener {
+
+ private ListenerList fListeners = new ListenerList();
+
+ public LaunchSuspendTrigger() {
+ DebugPlugin.getDefault().addDebugEventListener(this);
+ }
+
+ protected void dispose() {
+ fListeners.clear();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.contexts.ISuspendTrigger#addSuspendTriggerListener(org.eclipse.debug.ui.contexts.ISuspendTriggerListener)
+ */
+ public void addSuspendTriggerListener(ISuspendTriggerListener listener) {
+ fListeners.add(listener);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.contexts.ISuspendTrigger#removeSuspendTriggerListener(org.eclipse.debug.ui.contexts.ISuspendTriggerListener)
+ */
+ public void removeSuspendTriggerListener(ISuspendTriggerListener listener) {
+ fListeners.remove(listener);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.IDebugEventSetListener#handleDebugEvents(org.eclipse.debug.core.DebugEvent[])
+ */
+ public void handleDebugEvents(DebugEvent[] events) {
+ // open the debugger if this is a suspend event and the debug view is not yet open
+ // and the preferences are set to switch
+ for (int i = 0; i < events.length; i++) {
+ DebugEvent event = events[i];
+ if (event.getKind() == DebugEvent.SUSPEND && !event.isEvaluation() && event.getDetail() != DebugEvent.STEP_END) {
+ // Don't switch perspective for evaluations or stepping
+ notifySuspend(event);
+ }
+ }
+ }
+
+ /**
+ * @param event
+ */
+ private void notifySuspend(DebugEvent event) {
+ Object source = event.getSource();
+ if (source instanceof IDebugElement) {
+ final ILaunch launch = ((IDebugElement)source).getLaunch();
+ Object context = null;
+ if (source instanceof IThread) {
+ try {
+ context = ((IThread)source).getTopStackFrame();
+ } catch (DebugException e) {
+ }
+ } else if (source instanceof IDebugTarget) {
+ context = source;
+ }
+ final Object temp = context;
+ Object[] listeners = fListeners.getListeners();
+ for (int i = 0; i < listeners.length; i++) {
+ final ISuspendTriggerListener listener = (ISuspendTriggerListener) listeners[i];
+ Platform.run(new ISafeRunnable() {
+ public void run() throws Exception {
+ listener.suspended(launch, temp);
+ }
+
+ public void handleException(Throwable exception) {
+ DebugUIPlugin.log(exception);
+ }
+
+ });
+ }
+
+ }
+
+ }
+
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/SuspendTriggerAdapterFactory.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/SuspendTriggerAdapterFactory.java
new file mode 100644
index 000000000..056b7c418
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/SuspendTriggerAdapterFactory.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.contexts;
+
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.ui.contexts.ISuspendTrigger;
+
+/**
+ * @since 3.2
+ */
+public class SuspendTriggerAdapterFactory implements IAdapterFactory {
+
+ private static ISuspendTrigger fgTrigger = new LaunchSuspendTrigger();
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
+ */
+ public Object getAdapter(Object adaptableObject, Class adapterType) {
+ if (adapterType.equals(ISuspendTrigger.class)) {
+ if (adaptableObject instanceof ILaunch) {
+ return fgTrigger;
+ }
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList()
+ */
+ public Class[] getAdapterList() {
+ return new Class[]{ISuspendTrigger.class};
+ }
+
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/AbstractDebugContextActionDelegate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/AbstractDebugContextActionDelegate.java
new file mode 100644
index 000000000..5fe1dea6f
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/AbstractDebugContextActionDelegate.java
@@ -0,0 +1,462 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.debug.internal.ui.contexts.actions;
+
+import java.util.Iterator;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.internal.ui.DebugUIPlugin;
+import org.eclipse.debug.internal.ui.actions.ActionMessages;
+import org.eclipse.debug.internal.ui.contexts.DebugContextManager;
+import org.eclipse.debug.ui.IDebugUIConstants;
+import org.eclipse.debug.ui.contexts.IDebugContextListener;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.ui.IActionDelegate2;
+import org.eclipse.ui.IViewActionDelegate;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowActionDelegate;
+import org.eclipse.ui.progress.IWorkbenchSiteProgressService;
+
+public abstract class AbstractDebugContextActionDelegate implements IWorkbenchWindowActionDelegate, IViewActionDelegate, IActionDelegate2, IDebugContextListener {
+
+ /**
+ * The underlying action for this delegate
+ */
+ private IAction fAction;
+ /**
+ * This action's view part, or <code>null</code> if not installed in a
+ * view.
+ */
+ private IViewPart fViewPart;
+
+ /**
+ * Cache of the most recent seletion
+ */
+ private IStructuredSelection fSelection = StructuredSelection.EMPTY;
+
+ /**
+ * Whether this delegate has been initialized
+ */
+ private boolean fInitialized = false;
+
+ /**
+ * The window associated with this action delegate May be <code>null</code>
+ */
+ protected IWorkbenchWindow fWindow;
+
+ /**
+ * Background job for this action, or <code>null</code> if none.
+ */
+ private DebugRequestJob fBackgroundJob = null;
+
+ /**
+ * Background job to update enablement.
+ */
+ private UpdateEnablementJob fUpdateEnablementJob = new UpdateEnablementJob();
+
+ /**
+ * Used to schedule jobs, or <code>null</code> if none
+ */
+ private IWorkbenchSiteProgressService fProgressService = null;
+
+ class UpdateEnablementJob extends Job {
+
+ IAction targetAction = null;
+ ISelection targetSelection = null;
+
+ public UpdateEnablementJob() {
+ super(ActionMessages.AbstractDebugActionDelegate_1);
+ setPriority(Job.INTERACTIVE);
+ setSystem(true);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ protected IStatus run(IProgressMonitor monitor) {
+ IAction action = null;
+ ISelection selection = null;
+ synchronized (this) {
+ action = targetAction;
+ selection = targetSelection;
+ }
+ update(action, selection);
+ return Status.OK_STATUS;
+ }
+
+ public synchronized void setTargets(IAction action, ISelection selection) {
+ targetAction = action;
+ targetSelection = selection;
+ }
+ }
+
+ class DebugRequestJob extends Job {
+
+ private Object[] fElements = null;
+
+ /**
+ * Constructs a new job to perform a debug request (for example, step)
+ * in the background.
+ *
+ * @param name job name
+ */
+ public DebugRequestJob(String name) {
+ super(name);
+ setPriority(Job.INTERACTIVE);
+ setSystem(true);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ protected IStatus run(IProgressMonitor monitor) {
+ MultiStatus status = new MultiStatus(DebugUIPlugin.getUniqueIdentifier(), DebugException.REQUEST_FAILED, getStatusMessage(), null);
+ Object[] targets = null;
+ synchronized (this) {
+ targets = fElements;
+ fElements = null;
+ }
+ for (int i = 0; i < targets.length; i++) {
+ Object element = targets[i];
+ Object target = getTarget(element);
+ try {
+ // Action's enablement could have been changed since
+ // it was last enabled. Check that the action is still
+ // enabled before running the action.
+ if (target != null && isEnabledFor(target))
+ doAction(target);
+ } catch (DebugException e) {
+ status.merge(e.getStatus());
+ }
+ }
+ return status;
+ }
+
+ /**
+ * Sets the selection to operate on.
+ *
+ * @param elements
+ */
+ public synchronized void setTargets(Object[] elements) {
+ fElements = elements;
+ }
+
+ }
+
+ /**
+ * It's crucial that delegate actions have a zero-arg constructor so that
+ * they can be reflected into existence when referenced in an action set in
+ * the plugin's plugin.xml file.
+ */
+ public AbstractDebugContextActionDelegate() {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose()
+ */
+ public void dispose() {
+ IWorkbenchWindow window = getWindow();
+ if (getWindow() != null) {
+ IViewPart view = getView();
+ if (view != null) {
+ String partId = view.getSite().getId();
+ DebugContextManager.getDefault().removeDebugContextListener(this, window, partId);
+ } else {
+ DebugContextManager.getDefault().removeDebugContextListener(this, window);
+ }
+ }
+ fBackgroundJob = null;
+ fSelection = null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
+ */
+ public void init(IWorkbenchWindow window) {
+ setWindow(window);
+ DebugContextManager.getDefault().addDebugContextListener(this, window);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
+ */
+ public void run(IAction action) {
+ if (action.isEnabled()) {
+ IStructuredSelection selection = getContext();
+ // disable the action so it cannot be run again until an event or
+ // selection change updates the enablement
+ action.setEnabled(false);
+ runInBackground(action, selection);
+ }
+ }
+
+ /**
+ * Runs this action in a background job.
+ */
+ private void runInBackground(IAction action, IStructuredSelection selection) {
+ if (fBackgroundJob == null) {
+ fBackgroundJob = new DebugRequestJob(DebugUIPlugin.removeAccelerators(action.getText()));
+ }
+ fBackgroundJob.setTargets(selection.toArray());
+ schedule(fBackgroundJob);
+ }
+
+ /**
+ * AbstractDebugActionDelegates come in 2 flavors: IViewActionDelegate,
+ * IWorkbenchWindowActionDelegate delegates.
+ * </p>
+ * <ul>
+ * <li>IViewActionDelegate delegate: getView() != null</li>
+ * <li>IWorkbenchWindowActionDelegate: getView == null</li>
+ * </ul>
+ * <p>
+ * Only want to call update(action, selection) for IViewActionDelegates. An
+ * initialize call to update(action, selection) is made for all flavors to
+ * set the initial enabled state of the underlying action.
+ * IWorkbenchWindowActionDelegate's listen to selection changes in the debug
+ * view only.
+ * </p>
+ *
+ * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction,
+ * org.eclipse.jface.viewers.ISelection)
+ */
+ public void selectionChanged(IAction action, ISelection s) {
+ boolean wasInitialized = initialize(action, s);
+ if (!wasInitialized) {
+ if (getView() != null) {
+ fUpdateEnablementJob.setTargets(action, s);
+ schedule(fUpdateEnablementJob);
+
+ }
+ }
+ }
+
+ protected void update(IAction action, ISelection s) {
+ if (s instanceof IStructuredSelection) {
+ IStructuredSelection ss = (IStructuredSelection) s;
+ action.setEnabled(getEnableStateForContext(ss));
+ setContext(ss);
+ } else {
+ action.setEnabled(false);
+ setContext(StructuredSelection.EMPTY);
+ }
+ }
+
+ /**
+ * Performs the specific action on this element.
+ */
+ protected abstract void doAction(Object element) throws DebugException;
+
+ /**
+ * Returns the String to use as an error dialog message for a failed action.
+ * This message appears as the "Message:" in the error dialog for this
+ * action. Default is to return null.
+ */
+ protected String getErrorDialogMessage() {
+ return null;
+ }
+
+ /**
+ * Returns the String to use as a status message for a failed action. This
+ * message appears as the "Reason:" in the error dialog for this action.
+ * Default is to return the empty String.
+ */
+ protected String getStatusMessage() {
+ return ""; //$NON-NLS-1$
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart)
+ */
+ public void init(IViewPart view) {
+ fViewPart = view;
+ fProgressService = (IWorkbenchSiteProgressService) view.getAdapter(IWorkbenchSiteProgressService.class);
+ }
+
+ /**
+ * Returns this action's view part, or <code>null</code> if not installed
+ * in a view.
+ *
+ * @return view part or <code>null</code>
+ */
+ protected IViewPart getView() {
+ return fViewPart;
+ }
+
+ /**
+ * Initialize this delegate, updating this delegate's presentation. As well,
+ * all of the flavors of AbstractDebugActionDelegates need to have the
+ * initial enabled state set with a call to update(IAction, ISelection).
+ *
+ * @param action the presentation for this action
+ * @return whether the action was initialized
+ */
+ protected boolean initialize(IAction action, ISelection selection) {
+ if (!isInitialized()) {
+ setAction(action);
+ if (getView() == null) {
+ // update on the selection in the debug view
+ IWorkbenchWindow window = getWindow();
+ if (window != null && window.getShell() != null && !window.getShell().isDisposed()) {
+ IWorkbenchPage page = window.getActivePage();
+ if (page != null) {
+ selection = page.getSelection(IDebugUIConstants.ID_DEBUG_VIEW);
+ }
+ }
+ }
+ update(action, selection);
+ setInitialized(true);
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Returns the most recent selection
+ *
+ * @return structured selection
+ */
+ protected IStructuredSelection getContext() {
+ return fSelection;
+ }
+
+ /**
+ * Sets the most recent selection
+ *
+ * @parm selection structured selection
+ */
+ private void setContext(IStructuredSelection context) {
+ fSelection = context;
+ }
+
+ public void contextActivated(ISelection context, IWorkbenchPart part) {
+ fUpdateEnablementJob.setTargets(getAction(), context);
+ schedule(fUpdateEnablementJob);
+ }
+
+ protected void setAction(IAction action) {
+ fAction = action;
+ }
+
+ protected IAction getAction() {
+ return fAction;
+ }
+
+ protected void setView(IViewPart viewPart) {
+ fViewPart = viewPart;
+ }
+
+ protected boolean isInitialized() {
+ return fInitialized;
+ }
+
+ protected void setInitialized(boolean initialized) {
+ fInitialized = initialized;
+ }
+
+ protected IWorkbenchWindow getWindow() {
+ return fWindow;
+ }
+
+ protected void setWindow(IWorkbenchWindow window) {
+ fWindow = window;
+ }
+
+ /**
+ * Return whether the action should be enabled or not based on the given
+ * selection.
+ */
+ protected boolean getEnableStateForContext(IStructuredSelection selection) {
+ if (selection.size() == 0) {
+ return false;
+ }
+ Iterator itr = selection.iterator();
+ while (itr.hasNext()) {
+ Object element = itr.next();
+ Object target = getTarget(element);
+ if (target == null || !isEnabledFor(target)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Translates the selected object to the target to operate
+ * on as required. For example, an adpater on the selection.
+ *
+ * @param selectee
+ * @return target to operate/enable action on
+ */
+ protected Object getTarget(Object selectee) {
+ return selectee;
+ }
+
+ protected boolean isEnabledFor(Object element) {
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.IActionDelegate2#runWithEvent(org.eclipse.jface.action.IAction,
+ * org.eclipse.swt.widgets.Event)
+ */
+ public void runWithEvent(IAction action, Event event) {
+ run(action);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.IActionDelegate2#init(org.eclipse.jface.action.IAction)
+ */
+ public void init(IAction action) {
+ }
+
+ /**
+ * Schedules the given job with this action's progress service
+ *
+ * @param job
+ */
+ private void schedule(Job job) {
+ if (fProgressService == null) {
+ job.schedule();
+ } else {
+ fProgressService.schedule(job);
+ }
+ }
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/AbstractRemoveActionDelegate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/AbstractRemoveActionDelegate.java
index 473bdd44d..0bf3a1a4b 100644..100755
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/AbstractRemoveActionDelegate.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/AbstractRemoveActionDelegate.java
@@ -8,7 +8,7 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.debug.internal.ui.actions;
+package org.eclipse.debug.internal.ui.contexts.actions;
import org.eclipse.debug.ui.IDebugView;
@@ -16,7 +16,7 @@ import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IViewPart;
-public abstract class AbstractRemoveActionDelegate extends AbstractListenerActionDelegate {
+public abstract class AbstractRemoveActionDelegate extends AbstractDebugContextActionDelegate {
/**
* @see IViewActionDelegate#init(IViewPart)
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/AbstractRemoveAllActionDelegate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/AbstractRemoveAllActionDelegate.java
index 47d57a1c8..bc89eebb8 100644..100755
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/AbstractRemoveAllActionDelegate.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/AbstractRemoveAllActionDelegate.java
@@ -8,14 +8,14 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.debug.internal.ui.actions;
+package org.eclipse.debug.internal.ui.contexts.actions;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IViewPart;
-public abstract class AbstractRemoveAllActionDelegate extends AbstractListenerActionDelegate {
+public abstract class AbstractRemoveAllActionDelegate extends AbstractDebugContextActionDelegate {
/**
* @see AbstractDebugActionDelegate#doAction(Object)
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/DisconnectActionDelegate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/DisconnectActionDelegate.java
index bc2ee1866..d995da663 100644..100755
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/DisconnectActionDelegate.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/DisconnectActionDelegate.java
@@ -8,15 +8,16 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.debug.internal.ui.actions;
-
+package org.eclipse.debug.internal.ui.contexts.actions;
+import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.debug.core.DebugEvent;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IDebugTarget;
import org.eclipse.debug.core.model.IDisconnect;
+import org.eclipse.debug.internal.ui.actions.ActionMessages;
-public class DisconnectActionDelegate extends AbstractListenerActionDelegate {
+public class DisconnectActionDelegate extends AbstractDebugContextActionDelegate {
/**
* @see AbstractDebugActionDelegate#doAction(Object)
@@ -28,13 +29,6 @@ public class DisconnectActionDelegate extends AbstractListenerActionDelegate {
}
/**
- * @see AbstractDebugActionDelegate#isRunInBackground()
- */
- protected boolean isRunInBackground() {
- return true;
- }
-
- /**
* @see AbstractDebugActionDelegate#isEnabledFor(Object)
*/
protected boolean isEnabledFor(Object element) {
@@ -60,7 +54,20 @@ public class DisconnectActionDelegate extends AbstractListenerActionDelegate {
*/
protected void doHandleDebugEvent(DebugEvent event) {
if (event.getKind() == DebugEvent.TERMINATE && event.getSource() instanceof IDebugTarget) {
- update(getAction(), getSelection());
+ update(getAction(), getContext());
}
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.contexts.actions.AbstractDebugContextActionDelegate#getTarget(java.lang.Object)
+ */
+ protected Object getTarget(Object selectee) {
+ if (selectee instanceof IDisconnect) {
+ return selectee;
+ }
+ if (selectee instanceof IAdaptable) {
+ return ((IAdaptable)selectee).getAdapter(IDisconnect.class);
+ }
+ return null;
+ }
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/DropToFrameActionDelegate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/DropToFrameActionDelegate.java
index 5813bbfcd..70d628202 100644..100755
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/DropToFrameActionDelegate.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/DropToFrameActionDelegate.java
@@ -8,8 +8,9 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.debug.internal.ui.actions;
+package org.eclipse.debug.internal.ui.contexts.actions;
+import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
@@ -22,7 +23,7 @@ import org.eclipse.jface.viewers.ISelection;
/**
* Action delegate which performs a drop to frame.
*/
-public class DropToFrameActionDelegate extends AbstractListenerActionDelegate {
+public class DropToFrameActionDelegate extends AbstractDebugContextActionDelegate {
class UpdateJob extends Job {
IAction fAction;
@@ -67,13 +68,6 @@ public class DropToFrameActionDelegate extends AbstractListenerActionDelegate {
}
/**
- * @see AbstractDebugActionDelegate#isRunInBackground()
- */
- protected boolean isRunInBackground() {
- return true;
- }
-
- /**
* Enable the action for implementers of IDropToFrame which are able to perform
* the drop to frame operation.
*/
@@ -86,4 +80,17 @@ public class DropToFrameActionDelegate extends AbstractListenerActionDelegate {
fUpdateJob.setSelection(selection);
fUpdateJob.schedule();
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.contexts.actions.AbstractDebugContextActionDelegate#getTarget(java.lang.Object)
+ */
+ protected Object getTarget(Object selectee) {
+ if (selectee instanceof IDropToFrame) {
+ return selectee;
+ }
+ if (selectee instanceof IAdaptable) {
+ return ((IAdaptable)selectee).getAdapter(IDropToFrame.class);
+ }
+ return null;
+ }
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/FindVariableAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/FindVariableAction.java
index f951facf6..99ff587f3 100644..100755
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/FindVariableAction.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/FindVariableAction.java
@@ -8,12 +8,12 @@
* Contributors:
* IBM Corporation - initial implementation
*******************************************************************************/
-package org.eclipse.debug.internal.ui.actions;
+package org.eclipse.debug.internal.ui.contexts.actions;
-import org.eclipse.debug.core.DebugEvent;
import org.eclipse.debug.core.model.IStackFrame;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
+import org.eclipse.debug.internal.ui.actions.ActionMessages;
import org.eclipse.debug.internal.ui.views.variables.VariablesView;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
@@ -25,53 +25,49 @@ import org.eclipse.ui.texteditor.IUpdate;
import org.eclipse.ui.texteditor.IWorkbenchActionDefinitionIds;
/**
- * Action which prompts the user to help them find a variable in
- * the variables view.
+ * Action which prompts the user to help them find a variable in the variables
+ * view.
*/
public class FindVariableAction extends Action implements IUpdate {
-
- private class FindVariableDelegate extends AbstractListenerActionDelegate {
- protected void doAction(Object element) {
- VariablesView view= (VariablesView) getView();
- Shell shell = view.getSite().getShell();
- FindVariableDialog dialog= new FindVariableDialog(shell, view);
- dialog.open();
- }
+ private class FindVariableDelegate extends AbstractDebugContextActionDelegate {
- protected void update(IAction action, ISelection s) {
- if (action != null) {
- ((IUpdate) action).update();
- }
- }
+ protected void doAction(Object element) {
+ VariablesView view = (VariablesView) getView();
+ Shell shell = view.getSite().getShell();
+ FindVariableDialog dialog = new FindVariableDialog(shell, view);
+ dialog.open();
+ }
- protected void doHandleDebugEvent(DebugEvent event) {
- update(getAction(), null);
- }
+ protected void update(IAction action, ISelection s) {
+ if (action != null) {
+ ((IUpdate) action).update();
+ }
+ }
public void run(IAction action) {
doAction(null);
}
}
-
- private AbstractListenerActionDelegate fDelegate;
- public FindVariableAction(VariablesView view) {
- setText(ActionMessages.FindVariableAction_0);
+ private AbstractDebugContextActionDelegate fDelegate;
+
+ public FindVariableAction(VariablesView view) {
+ setText(ActionMessages.FindVariableAction_0);
setId(DebugUIPlugin.getUniqueIdentifier() + ".FindVariableAction"); //$NON-NLS-1$
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IDebugHelpContextIds.FIND_VARIABLE_ACTION);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IDebugHelpContextIds.FIND_VARIABLE_ACTION);
setActionDefinitionId(IWorkbenchActionDefinitionIds.FIND_REPLACE);
- fDelegate= new FindVariableDelegate();
- fDelegate.init(view);
- fDelegate.setAction(this);
- }
-
- public void run() {
- fDelegate.run(this);
- }
+ fDelegate = new FindVariableDelegate();
+ fDelegate.init(view);
+ fDelegate.setAction(this);
+ }
+
+ public void run() {
+ fDelegate.run(this);
+ }
public void update() {
- VariablesView view= (VariablesView) fDelegate.getView();
+ VariablesView view = (VariablesView) fDelegate.getView();
if (view != null) {
Viewer viewer = view.getViewer();
if (viewer != null) {
@@ -82,7 +78,7 @@ public class FindVariableAction extends Action implements IUpdate {
setEnabled(false);
}
- public void dispose() {
- fDelegate.dispose();
- }
+ public void dispose() {
+ fDelegate.dispose();
+ }
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/FindVariableDialog.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/FindVariableDialog.java
index d819ca1ec..3b8e86c53 100644..100755
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/FindVariableDialog.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/FindVariableDialog.java
@@ -8,7 +8,7 @@
* Contributors:
* IBM Corporation - initial implementation
*******************************************************************************/
-package org.eclipse.debug.internal.ui.actions;
+package org.eclipse.debug.internal.ui.contexts.actions;
import java.util.ArrayList;
import java.util.List;
@@ -17,11 +17,12 @@ import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IValue;
import org.eclipse.debug.core.model.IVariable;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
+import org.eclipse.debug.internal.ui.actions.ActionMessages;
+import org.eclipse.debug.internal.ui.viewers.AsynchronousTreeViewer;
import org.eclipse.debug.internal.ui.views.DebugViewDecoratingLabelProvider;
import org.eclipse.debug.internal.ui.views.DebugViewInterimLabelProvider;
import org.eclipse.debug.internal.ui.views.DebugViewLabelDecorator;
import org.eclipse.debug.internal.ui.views.variables.VariablesView;
-import org.eclipse.debug.internal.ui.views.variables.VariablesViewer;
import org.eclipse.debug.ui.IDebugModelPresentation;
import org.eclipse.debug.ui.IValueDetailListener;
import org.eclipse.jface.dialogs.Dialog;
@@ -65,7 +66,7 @@ public class FindVariableDialog extends Dialog {
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
public Object[] getElements(Object inputElement) {
- return getVariables(((VariablesViewer) fView.getViewer()).getTree().getItems());
+ return getVariables(((AsynchronousTreeViewer) fView.getViewer()).getTree().getItems());
}
private IVariable[] getVariables(TreeItem[] items) {
List variables= new ArrayList();
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RemoveAllBreakpointsAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/RemoveAllBreakpointsAction.java
index 29213a6c6..cc6d99128 100644..100755
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RemoveAllBreakpointsAction.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/RemoveAllBreakpointsAction.java
@@ -8,7 +8,7 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.debug.internal.ui.actions;
+package org.eclipse.debug.internal.ui.contexts.actions;
import org.eclipse.core.resources.IMarkerDelta;
@@ -22,6 +22,7 @@ import org.eclipse.debug.core.IBreakpointManager;
import org.eclipse.debug.core.IBreakpointsListener;
import org.eclipse.debug.core.model.IBreakpoint;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
+import org.eclipse.debug.internal.ui.actions.ActionMessages;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbenchWindow;
@@ -45,7 +46,7 @@ public class RemoveAllBreakpointsAction extends AbstractRemoveAllActionDelegate
if (window == null) {
return;
}
- boolean proceed = MessageDialog.openQuestion(window.getShell(), ActionMessages.RemoveAllBreakpointsAction_0, ActionMessages.RemoveAllBreakpointsAction_1); //
+ boolean proceed = MessageDialog.openQuestion(window.getShell(), ActionMessages.RemoveAllBreakpointsAction_0, ActionMessages.RemoveAllBreakpointsAction_1);
if (proceed) {
new Job(ActionMessages.RemoveAllBreakpointsAction_2) {
protected IStatus run(IProgressMonitor monitor) {
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RemoveAllExpressionsAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/RemoveAllExpressionsAction.java
index 127c8829d..77c98d050 100644..100755
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RemoveAllExpressionsAction.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/RemoveAllExpressionsAction.java
@@ -8,7 +8,7 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.debug.internal.ui.actions;
+package org.eclipse.debug.internal.ui.contexts.actions;
import org.eclipse.debug.core.DebugPlugin;
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RemoveAllTerminatedAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/RemoveAllTerminatedAction.java
index 17b80999a..918714d12 100644..100755
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RemoveAllTerminatedAction.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/RemoveAllTerminatedAction.java
@@ -8,19 +8,16 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.debug.internal.ui.actions;
+package org.eclipse.debug.internal.ui.contexts.actions;
import java.util.ArrayList;
import java.util.List;
-import org.eclipse.debug.core.DebugEvent;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchManager;
-import org.eclipse.debug.core.ILaunchesListener;
-import org.eclipse.debug.core.model.IDebugTarget;
-import org.eclipse.debug.core.model.IProcess;
+import org.eclipse.debug.core.ILaunchesListener2;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.ui.IViewPart;
@@ -28,19 +25,7 @@ import org.eclipse.ui.IViewPart;
* Removes all terminated/detached launches from the
* active debug view.
*/
-public class RemoveAllTerminatedAction extends AbstractRemoveAllActionDelegate implements ILaunchesListener {
-
- /**
- * @see ListenerActionDelegate#doHandleDebugEvent(DebugEvent)
- */
- protected void doHandleDebugEvent(DebugEvent event) {
- if (event.getKind() == DebugEvent.TERMINATE) {
- Object source = event.getSource();
- if (event.getKind() == DebugEvent.TERMINATE && (source instanceof IDebugTarget || source instanceof IProcess)) {
- update();
- }
- }
- }
+public class RemoveAllTerminatedAction extends AbstractRemoveAllActionDelegate implements ILaunchesListener2 {
/**
* Updates the enabled state of this action to enabled if at
@@ -84,7 +69,6 @@ public class RemoveAllTerminatedAction extends AbstractRemoveAllActionDelegate i
public void init(IViewPart view) {
super.init(view);
DebugPlugin.getDefault().getLaunchManager().addLaunchListener(this);
- DebugPlugin.getDefault().addDebugEventListener(this);
}
/**
@@ -99,26 +83,21 @@ public class RemoveAllTerminatedAction extends AbstractRemoveAllActionDelegate i
view.getSite().getSelectionProvider().removeSelectionChangedListener((ISelectionChangedListener) getAction());
}
}
-
- /**
- * @see ILaunchesListener#launchesAdded(ILaunch[])
- */
+
public void launchesAdded(ILaunch[] launches) {
}
- /**
- * @see ILaunchesListener#launchesChanged(ILaunch[])
- */
public void launchesChanged(ILaunch[] launches) {
}
- /**
- * @see ILaunchesListener#launchesRemoved(ILaunch[])
- */
public void launchesRemoved(ILaunch[] launches) {
if (getAction().isEnabled()) {
update();
}
}
+
+ public void launchesTerminated(ILaunch[] launches) {
+ update();
+ }
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RemoveBreakpointAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/RemoveBreakpointAction.java
index 3fb9528de..42b8b8a84 100644..100755
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RemoveBreakpointAction.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/RemoveBreakpointAction.java
@@ -8,7 +8,7 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.debug.internal.ui.actions;
+package org.eclipse.debug.internal.ui.contexts.actions;
import java.util.ArrayList;
@@ -25,6 +25,7 @@ import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.model.IBreakpoint;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
+import org.eclipse.debug.internal.ui.actions.ActionMessages;
import org.eclipse.debug.internal.ui.views.breakpoints.BreakpointContainer;
import org.eclipse.debug.internal.ui.views.breakpoints.BreakpointsView;
import org.eclipse.jface.action.IAction;
@@ -38,7 +39,7 @@ public class RemoveBreakpointAction extends AbstractRemoveActionDelegate {
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
*/
public void run(IAction action) {
- IStructuredSelection selection= getSelection();
+ IStructuredSelection selection= getContext();
if (selection.isEmpty()) {
return;
}
@@ -56,7 +57,7 @@ public class RemoveBreakpointAction extends AbstractRemoveActionDelegate {
} else if (next instanceof BreakpointContainer) {
if (!deleteContainers) {
// Prompt the user to delete containers only once.
- deleteContainers = MessageDialog.openConfirm(getView().getSite().getShell(), ActionMessages.RemoveBreakpointAction_0, ActionMessages.RemoveBreakpointAction_1); //
+ deleteContainers = MessageDialog.openConfirm(getView().getSite().getShell(), ActionMessages.RemoveBreakpointAction_0, ActionMessages.RemoveBreakpointAction_1);
if (!deleteContainers) {
// User cancelled. Do nothing
return;
@@ -100,7 +101,7 @@ public class RemoveBreakpointAction extends AbstractRemoveActionDelegate {
if (exception[0] != null) {
IWorkbenchWindow window= DebugUIPlugin.getActiveWorkbenchWindow();
if (window != null) {
- DebugUIPlugin.errorDialog(window.getShell(), ActionMessages.RemoveBreakpointAction_Removing_a_breakpoint_4,ActionMessages.RemoveBreakpointAction_Exceptions_occurred_attempting_to_remove_a_breakpoint__5 , exception[0]); //
+ DebugUIPlugin.errorDialog(window.getShell(), ActionMessages.RemoveBreakpointAction_Removing_a_breakpoint_4,ActionMessages.RemoveBreakpointAction_Exceptions_occurred_attempting_to_remove_a_breakpoint__5 , exception[0]);
} else {
DebugUIPlugin.log(exception[0]);
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RemoveExpressionAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/RemoveExpressionAction.java
index a699857c1..e143f3be4 100644..100755
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RemoveExpressionAction.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/RemoveExpressionAction.java
@@ -8,25 +8,37 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.debug.internal.ui.actions;
+package org.eclipse.debug.internal.ui.contexts.actions;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.IExpressionManager;
import org.eclipse.debug.core.model.IExpression;
+import org.eclipse.debug.internal.ui.viewers.AsynchronousTreeViewer;
+import org.eclipse.debug.internal.ui.viewers.TreePath;
+import org.eclipse.debug.internal.ui.viewers.TreeSelection;
import org.eclipse.debug.ui.IDebugView;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.ui.progress.WorkbenchJob;
public class RemoveExpressionAction extends AbstractRemoveActionDelegate {
protected void doAction(Object element) {
- IExpressionManager manager = DebugPlugin.getDefault().getExpressionManager();
- IExpression exp = getExpression(element);
- if (exp != null) {
- manager.removeExpression(exp);
- }
+ WorkbenchJob job = new WorkbenchJob("remove expression") { //$NON-NLS-1$
+ public IStatus runInUIThread(IProgressMonitor monitor) {
+ IExpressionManager manager = DebugPlugin.getDefault().getExpressionManager();
+ IExpression exp = getExpression();
+ if (exp != null) {
+ manager.removeExpression(exp);
+ }
+ return Status.OK_STATUS;
+ }
+ };
+ job.setSystem(true);
+ job.schedule();
}
/**
@@ -37,19 +49,24 @@ public class RemoveExpressionAction extends AbstractRemoveActionDelegate {
* the expression view.
* @return associated expression
*/
- protected IExpression getExpression(Object obj) {
+ protected IExpression getExpression() {
if (getView() == null) {
return null;
}
IDebugView adapter= (IDebugView)getView().getAdapter(IDebugView.class);
if (adapter != null) {
Viewer v= adapter.getViewer();
- if (v instanceof TreeViewer) {
- ITreeContentProvider cp = (ITreeContentProvider)((TreeViewer)v).getContentProvider();
- while (!(obj instanceof IExpression) && obj != null) {
- obj = cp.getParent(obj);
+ if (v instanceof AsynchronousTreeViewer) {
+ AsynchronousTreeViewer viewer = (AsynchronousTreeViewer) v;
+ TreeSelection selection = (TreeSelection) viewer.getSelection();
+ TreePath[] paths = selection.getPaths();
+ for (int i = paths.length-1; i >=0; i--) {
+ TreePath path = paths[i];
+ Object segment = path.getLastSegment();
+ if (segment instanceof IExpression) {
+ return (IExpression) segment;
+ }
}
- return (IExpression)obj;
}
}
return null;
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ResumeActionDelegate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/ResumeActionDelegate.java
index 3901fe488..14fd8358c 100644..100755
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ResumeActionDelegate.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/ResumeActionDelegate.java
@@ -8,18 +8,20 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.debug.internal.ui.actions;
+package org.eclipse.debug.internal.ui.contexts.actions;
import java.util.Iterator;
+import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IDebugElement;
import org.eclipse.debug.core.model.ISuspendResume;
import org.eclipse.debug.core.model.IThread;
+import org.eclipse.debug.internal.ui.actions.ActionMessages;
import org.eclipse.jface.viewers.IStructuredSelection;
-public class ResumeActionDelegate extends AbstractListenerActionDelegate {
+public class ResumeActionDelegate extends AbstractDebugContextActionDelegate {
/**
* @see AbstractDebugActionDelegate#doAction(Object)
@@ -52,12 +54,6 @@ public class ResumeActionDelegate extends AbstractListenerActionDelegate {
}
}
- /**
- * @see AbstractDebugActionDelegate#isRunInBackground()
- */
- protected boolean isRunInBackground() {
- return true;
- }
/**
* @see AbstractDebugActionDelegate#isEnabledFor(Object)
@@ -115,4 +111,16 @@ public class ResumeActionDelegate extends AbstractListenerActionDelegate {
return ActionMessages.ResumeActionDelegate_Resume_failed__1;
}
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.contexts.actions.AbstractDebugContextActionDelegate#getTarget(java.lang.Object)
+ */
+ protected Object getTarget(Object selectee) {
+ if (selectee instanceof ISuspendResume) {
+ return selectee;
+ }
+ if (selectee instanceof IAdaptable) {
+ return ((IAdaptable)selectee).getAdapter(ISuspendResume.class);
+ }
+ return null;
+ }
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/SelectAllAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/SelectAllAction.java
index 0b0155de8..32bf33753 100644..100755
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/SelectAllAction.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/SelectAllAction.java
@@ -8,29 +8,17 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.debug.internal.ui.actions;
-
+package org.eclipse.debug.internal.ui.contexts.actions;
import org.eclipse.debug.ui.IDebugView;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.ui.IViewPart;
-public abstract class SelectAllAction extends AbstractListenerActionDelegate {
+public abstract class SelectAllAction extends AbstractDebugContextActionDelegate {
- /**
- * @see IViewActionDelegate#init(IViewPart)
- */
- public void init(IViewPart view) {
- setView(view);
- setWindow(view.getViewSite().getWorkbenchWindow());
- }
- /**
- * @see AbstractDebugActionDelegate#initialize(IAction, ISelection)
- */
protected boolean initialize(IAction action, ISelection selection) {
if (!isInitialized()) {
IDebugView debugView =
@@ -52,9 +40,6 @@ public abstract class SelectAllAction extends AbstractListenerActionDelegate {
doAction(null);
}
- /**
- * @see AbstractDebugActionDelegate#doAction(Object)
- */
protected void doAction(Object element) {
if (!(getView() instanceof IDebugView)) {
return;
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/SelectAllBreakpointsAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/SelectAllBreakpointsAction.java
index fb1b285bd..9d9f258be 100644..100755
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/SelectAllBreakpointsAction.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/SelectAllBreakpointsAction.java
@@ -8,8 +8,7 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.debug.internal.ui.actions;
-
+package org.eclipse.debug.internal.ui.contexts.actions;
import org.eclipse.core.resources.IMarkerDelta;
import org.eclipse.debug.core.DebugPlugin;
@@ -23,8 +22,7 @@ import org.eclipse.ui.IViewPart;
public class SelectAllBreakpointsAction extends SelectAllAction implements IBreakpointsListener {
protected void update() {
- getAction().setEnabled(
- DebugPlugin.getDefault().getBreakpointManager().hasBreakpoints());
+ getAction().setEnabled(DebugPlugin.getDefault().getBreakpointManager().hasBreakpoints());
}
/**
@@ -36,7 +34,7 @@ public class SelectAllBreakpointsAction extends SelectAllAction implements IBrea
}
CheckboxTreeViewer viewer = ((BreakpointsView) getView()).getCheckboxViewer();
viewer.getTree().selectAll();
- //ensure that the selection change callback is fired
+ // ensure that the selection change callback is fired
viewer.setSelection(viewer.getSelection());
}
@@ -50,20 +48,22 @@ public class SelectAllBreakpointsAction extends SelectAllAction implements IBrea
}
/**
- * @see IBreakpointsListener#breakpointsChanged(IBreakpoint[], IMarkerDelta[])breakpointChanged(IBreakpoint, IMarkerDelta)
+ * @see IBreakpointsListener#breakpointsChanged(IBreakpoint[],
+ * IMarkerDelta[])breakpointChanged(IBreakpoint, IMarkerDelta)
*/
public void breakpointsChanged(IBreakpoint[] breakpoints, IMarkerDelta[] deltas) {
}
/**
- * @see IBreakpointsListener#breakpointsRemoved(IBreakpoint[], IMarkerDelta[])
+ * @see IBreakpointsListener#breakpointsRemoved(IBreakpoint[],
+ * IMarkerDelta[])
*/
public void breakpointsRemoved(IBreakpoint[] breakpoints, IMarkerDelta[] deltas) {
if (getAction() != null) {
update();
}
}
-
+
/**
* @see IViewActionDelegate#init(IViewPart)
*/
@@ -71,12 +71,12 @@ public class SelectAllBreakpointsAction extends SelectAllAction implements IBrea
super.init(view);
DebugPlugin.getDefault().getBreakpointManager().addBreakpointListener(this);
}
-
+
public void dispose() {
- DebugPlugin.getDefault().getBreakpointManager().removeBreakpointListener(this);
+ DebugPlugin.getDefault().getBreakpointManager().removeBreakpointListener(this);
super.dispose();
}
-
+
protected String getActionId() {
return IDebugView.SELECT_ALL_ACTION;
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/SelectAllExpressionsAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/SelectAllExpressionsAction.java
index 58e0bcd69..b77033043 100644..100755
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/SelectAllExpressionsAction.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/SelectAllExpressionsAction.java
@@ -8,8 +8,7 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.debug.internal.ui.actions;
-
+package org.eclipse.debug.internal.ui.contexts.actions;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.ui.IDebugView;
@@ -17,10 +16,9 @@ import org.eclipse.debug.ui.IDebugView;
public class SelectAllExpressionsAction extends SelectAllAction {
protected void update() {
- getAction().setEnabled(
- DebugPlugin.getDefault().getExpressionManager().hasExpressions());
+ getAction().setEnabled(DebugPlugin.getDefault().getExpressionManager().hasExpressions());
}
-
+
protected String getActionId() {
return IDebugView.SELECT_ALL_ACTION + ".Variables"; //$NON-NLS-1$
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/SelectAllVariablesAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/SelectAllVariablesAction.java
index 88af02d21..7e653c673 100644..100755
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/SelectAllVariablesAction.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/SelectAllVariablesAction.java
@@ -8,23 +8,37 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.debug.internal.ui.actions;
+package org.eclipse.debug.internal.ui.contexts.actions;
-
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.debug.ui.IDebugView;
-import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
-
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.ui.progress.WorkbenchJob;
+
public class SelectAllVariablesAction extends SelectAllAction {
protected void update() {
- if (!(getView() instanceof IDebugView)) {
- return;
- }
- Viewer viewer= ((IDebugView)getView()).getViewer();
- getAction().setEnabled(((TreeViewer)viewer).getTree().getItemCount() != 0);
+ WorkbenchJob job = new WorkbenchJob("update select all variables action") { //$NON-NLS-1$
+ public IStatus runInUIThread(IProgressMonitor monitor) {
+ if (!(getView() instanceof IDebugView)) {
+ return Status.OK_STATUS;
+ }
+ Viewer viewer = ((IDebugView) getView()).getViewer();
+ if (viewer != null) {
+ Tree tree = (Tree) viewer.getControl();
+ getAction().setEnabled(tree.getItemCount() != 0);
+ }
+ return Status.OK_STATUS;
+ }
+ };
+
+ job.setSystem(true);
+ job.schedule();
}
-
+
protected String getActionId() {
return IDebugView.SELECT_ALL_ACTION + ".Variables"; //$NON-NLS-1$
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/StepActionDelegate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/StepActionDelegate.java
index 1a5fcdf3f..a2ea2426f 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/StepActionDelegate.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/StepActionDelegate.java
@@ -8,14 +8,14 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.debug.internal.ui.actions;
-
+package org.eclipse.debug.internal.ui.contexts.actions;
+import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IStep;
-public abstract class StepActionDelegate extends AbstractListenerActionDelegate {
+public abstract class StepActionDelegate extends AbstractDebugContextActionDelegate {
/**
* @see AbstractDebugActionDelegate#doAction(Object)
@@ -55,4 +55,19 @@ public abstract class StepActionDelegate extends AbstractListenerActionDelegate
* @exception DebugException if the action fails
*/
protected abstract void stepAction(IStep element) throws DebugException;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.contexts.actions.AbstractDebugContextActionDelegate#getTarget(java.lang.Object)
+ */
+ protected Object getTarget(Object selectee) {
+ if (selectee instanceof IStep) {
+ return selectee;
+ }
+ if (selectee instanceof IAdaptable) {
+ return ((IAdaptable)selectee).getAdapter(IStep.class);
+ }
+ return null;
+ }
+
+
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/StepIntoActionDelegate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/StepIntoActionDelegate.java
index 5c981a48e..daee5b0b6 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/StepIntoActionDelegate.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/StepIntoActionDelegate.java
@@ -8,12 +8,11 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.debug.internal.ui.actions;
-
-
+package org.eclipse.debug.internal.ui.contexts.actions;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IStep;
+import org.eclipse.debug.internal.ui.actions.ActionMessages;
public class StepIntoActionDelegate extends StepActionDelegate {
@@ -35,7 +34,7 @@ public class StepIntoActionDelegate extends StepActionDelegate {
* @see AbstractDebugActionDelegate#getStatusMessage()
*/
protected String getStatusMessage() {
- return ActionMessages.StepIntoActionDelegate_Exceptions_occurred_attempting_to_step_into_the_frame_2;
+ return ActionMessages.StepIntoActionDelegate_Exceptions_occurred_attempting_to_step_into_the_frame_2;
}
/**
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/StepOverActionDelegate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/StepOverActionDelegate.java
index d785453dc..5b51652cc 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/StepOverActionDelegate.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/StepOverActionDelegate.java
@@ -8,11 +8,13 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.debug.internal.ui.actions;
+
+package org.eclipse.debug.internal.ui.contexts.actions;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IStep;
+import org.eclipse.debug.internal.ui.actions.ActionMessages;
public class StepOverActionDelegate extends StepActionDelegate {
@@ -51,3 +53,4 @@ public class StepOverActionDelegate extends StepActionDelegate {
return "org.eclipse.debug.internal.ui.actions.StepOverActionDelegate"; //$NON-NLS-1$
}
}
+
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/StepReturnActionDelegate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/StepReturnActionDelegate.java
index edbd7bfa7..f3bdbb77d 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/StepReturnActionDelegate.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/StepReturnActionDelegate.java
@@ -8,11 +8,11 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.debug.internal.ui.actions;
-
+package org.eclipse.debug.internal.ui.contexts.actions;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IStep;
+import org.eclipse.debug.internal.ui.actions.ActionMessages;
public class StepReturnActionDelegate extends StepActionDelegate {
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/SuspendActionDelegate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/SuspendActionDelegate.java
index e813a3e99..aa9f4fa6d 100644..100755
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/SuspendActionDelegate.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/SuspendActionDelegate.java
@@ -8,13 +8,15 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.debug.internal.ui.actions;
+package org.eclipse.debug.internal.ui.contexts.actions;
+import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.ISuspendResume;
+import org.eclipse.debug.internal.ui.actions.ActionMessages;
-public class SuspendActionDelegate extends AbstractListenerActionDelegate {
+public class SuspendActionDelegate extends AbstractDebugContextActionDelegate {
/**
* @see AbstractDebugActionDelegate#doAction(Object)
@@ -26,13 +28,6 @@ public class SuspendActionDelegate extends AbstractListenerActionDelegate {
}
/**
- * @see AbstractDebugActionDelegate#isRunInBackground()
- */
- protected boolean isRunInBackground() {
- return true;
- }
-
- /**
* @see AbstractDebugActionDelegate#isEnabledFor(Object)
*/
protected boolean isEnabledFor(Object element) {
@@ -53,4 +48,16 @@ public class SuspendActionDelegate extends AbstractListenerActionDelegate {
return ActionMessages.SuspendActionDelegate_Suspend_failed_1;
}
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.contexts.actions.AbstractDebugContextActionDelegate#getTarget(java.lang.Object)
+ */
+ protected Object getTarget(Object selectee) {
+ if (selectee instanceof ISuspendResume) {
+ return selectee;
+ }
+ if (selectee instanceof IAdaptable) {
+ return ((IAdaptable)selectee).getAdapter(ISuspendResume.class);
+ }
+ return null;
+ }
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/TerminateActionDelegate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/TerminateActionDelegate.java
index 06d9894ef..2bc940223 100644..100755
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/TerminateActionDelegate.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/TerminateActionDelegate.java
@@ -8,9 +8,10 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.debug.internal.ui.actions;
+package org.eclipse.debug.internal.ui.contexts.actions;
+import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.debug.core.DebugEvent;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.DebugPlugin;
@@ -19,11 +20,12 @@ import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.core.model.IDebugTarget;
import org.eclipse.debug.core.model.IProcess;
import org.eclipse.debug.core.model.ITerminate;
+import org.eclipse.debug.internal.ui.actions.ActionMessages;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
-public class TerminateActionDelegate extends AbstractListenerActionDelegate {
+public class TerminateActionDelegate extends AbstractDebugContextActionDelegate {
/**
* @see AbstractDebugActionDelegate#doAction(Object)
@@ -93,7 +95,7 @@ public class TerminateActionDelegate extends AbstractListenerActionDelegate {
*/
protected void doHandleDebugEvent(DebugEvent event) {
if (event.getKind() == DebugEvent.TERMINATE || event.getKind() == DebugEvent.CREATE) {
- update(getAction(), getSelection());
+ update(getAction(), getContext());
}
}
@@ -106,6 +108,20 @@ public class TerminateActionDelegate extends AbstractListenerActionDelegate {
super.update(action, s);
}
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.contexts.actions.AbstractDebugContextActionDelegate#getTarget(java.lang.Object)
+ */
+ protected Object getTarget(Object selectee) {
+ if (selectee instanceof ITerminate) {
+ return selectee;
+ }
+ if (selectee instanceof IAdaptable) {
+ return ((IAdaptable)selectee).getAdapter(ITerminate.class);
+ }
+ return null;
+ }
+
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/TerminateAllAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/TerminateAllAction.java
index f24fceb94..7f50937f7 100644..100755
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/TerminateAllAction.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/TerminateAllAction.java
@@ -8,7 +8,7 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.debug.internal.ui.actions;
+package org.eclipse.debug.internal.ui.contexts.actions;
import org.eclipse.debug.core.DebugEvent;
@@ -24,7 +24,7 @@ import org.eclipse.jface.viewers.StructuredSelection;
/**
* Terminates all launches.
*/
-public class TerminateAllAction extends AbstractListenerActionDelegate {
+public class TerminateAllAction extends AbstractDebugContextActionDelegate {
/* (non-Javadoc)
* @see org.eclipse.debug.internal.ui.actions.AbstractDebugActionDelegate#doAction(java.lang.Object)
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/TerminateAndRelaunchAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/TerminateAndRelaunchAction.java
index 0762f3b00..f17802b04 100644..100755
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/TerminateAndRelaunchAction.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/TerminateAndRelaunchAction.java
@@ -8,19 +8,20 @@
* Contributors:
* IBM Corporation - initial implementation
*******************************************************************************/
-package org.eclipse.debug.internal.ui.actions;
+package org.eclipse.debug.internal.ui.contexts.actions;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.model.ITerminate;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
+import org.eclipse.debug.internal.ui.actions.RelaunchActionDelegate;
/**
* Action which terminates a launch and then relaunches it.
* This is equivalent to the Terminate action followed by
* Relaunch, but is provided to the user as a convenience.
*/
-public class TerminateAndRelaunchAction extends AbstractListenerActionDelegate {
+public class TerminateAndRelaunchAction extends AbstractDebugContextActionDelegate {
protected void doAction(Object element) throws DebugException {
final ILaunch launch= RelaunchActionDelegate.getLaunch(element);
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/TerminateAndRemoveActionDelegate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/TerminateAndRemoveActionDelegate.java
index 65dcc6ecd..7d0aa6d62 100644..100755
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/TerminateAndRemoveActionDelegate.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/actions/TerminateAndRemoveActionDelegate.java
@@ -8,14 +8,15 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.debug.internal.ui.actions;
+package org.eclipse.debug.internal.ui.contexts.actions;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.ITerminate;
+import org.eclipse.debug.internal.ui.actions.ActionMessages;
import org.eclipse.debug.internal.ui.views.launch.LaunchView;
-public class TerminateAndRemoveActionDelegate extends AbstractDebugActionDelegate {
+public class TerminateAndRemoveActionDelegate extends AbstractDebugContextActionDelegate {
/**
* @see AbstractDebugActionDelegate#doAction(Object)
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/AsynchronousDebugLabelAdapter.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/AsynchronousDebugLabelAdapter.java
new file mode 100644
index 000000000..2867af51e
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/AsynchronousDebugLabelAdapter.java
@@ -0,0 +1,109 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.debug.internal.ui.elements.adapters;
+
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.model.IDebugElement;
+import org.eclipse.debug.internal.ui.DelegatingModelPresentation;
+import org.eclipse.debug.internal.ui.LazyModelPresentation;
+import org.eclipse.debug.internal.ui.viewers.AsynchronousLabelAdapter;
+import org.eclipse.debug.internal.ui.viewers.ILabelRequestMonitor;
+import org.eclipse.debug.internal.ui.viewers.IPresentationContext;
+import org.eclipse.debug.internal.ui.views.launch.DebugElementHelper;
+import org.eclipse.debug.ui.IDebugModelPresentation;
+import org.eclipse.debug.ui.IDebugView;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.ui.IWorkbenchPart;
+
+/**
+ * Asynchronous label adapter for debug elements.
+ *
+ * @since 3.2
+ */
+public class AsynchronousDebugLabelAdapter extends AsynchronousLabelAdapter {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.viewers.AsynchronousLabelAdapter#computeLabels(java.lang.Object, org.eclipse.debug.ui.viewers.IPresentationContext, org.eclipse.debug.ui.viewers.ILabelRequestMonitor)
+ */
+ protected void computeLabels(Object element, IPresentationContext context, ILabelRequestMonitor monitor) {
+ DelegatingModelPresentation presentation = DebugElementHelper.getPresentation();
+ // Honor view specific settings in a debug view by copying model presentation settings
+ // into the debug element helper's presentation before we get the label. This allows
+ // for qualified name and type name settings to remain in tact.
+ if (element instanceof IDebugElement && context.getPart() instanceof IDebugView) {
+ IWorkbenchPart part = context.getPart();
+ if (part instanceof IDebugView) {
+ IDebugModelPresentation pres = ((IDebugView)part).getPresentation(((IDebugElement)element).getModelIdentifier());
+ Map settings = null;
+ synchronized (presentation) {
+ if (pres instanceof DelegatingModelPresentation) {
+ settings = ((DelegatingModelPresentation)pres).getAttributes();
+ } else if (pres instanceof LazyModelPresentation) {
+ settings = ((LazyModelPresentation)pres).getAttributes();
+ }
+ if (settings != null) {
+ Iterator iterator = settings.entrySet().iterator();
+ while (iterator.hasNext()) {
+ Map.Entry entry = (Entry) iterator.next();
+ presentation.setAttribute((String) entry.getKey(), entry.getValue());
+ }
+ super.computeLabels(element, context, monitor);
+ return;
+ }
+ }
+ }
+ }
+ super.computeLabels(element, context, monitor);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.viewers.AsynchronousLabelAdapter#getLabels(java.lang.Object, org.eclipse.debug.ui.viewers.IPresentationContext)
+ */
+ protected String[] getLabels(Object element, IPresentationContext context) throws CoreException {
+ return new String[] {DebugElementHelper.getLabel(element)};
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.viewers.AsynchronousLabelAdapter#getImageDescriptors(java.lang.Object, org.eclipse.debug.ui.viewers.IPresentationContext)
+ */
+ protected ImageDescriptor[] getImageDescriptors(Object element, IPresentationContext context) throws CoreException {
+ return new ImageDescriptor[] {DebugElementHelper.getImageDescriptor(element)};
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.viewers.AsynchronousLabelAdapter#getFontDatas(java.lang.Object, org.eclipse.debug.ui.viewers.IPresentationContext)
+ */
+ protected FontData[] getFontDatas(Object element, IPresentationContext context) throws CoreException {
+ return new FontData[] {DebugElementHelper.getFont(element)};
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.viewers.AsynchronousLabelAdapter#getForegrounds(java.lang.Object, org.eclipse.debug.ui.viewers.IPresentationContext)
+ */
+ protected RGB[] getForegrounds(Object element, IPresentationContext context) throws CoreException {
+ return new RGB[] {DebugElementHelper.getForeground(element)};
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.viewers.AsynchronousLabelAdapter#getBackgrounds(java.lang.Object, org.eclipse.debug.ui.viewers.IPresentationContext)
+ */
+ protected RGB[] getBackgrounds(Object element, IPresentationContext context) throws CoreException {
+ return new RGB[] {DebugElementHelper.getBackground(element)};
+ }
+
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DebugTargetTreeContentAdapter.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DebugTargetTreeContentAdapter.java
new file mode 100644
index 000000000..eeeb01d3f
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DebugTargetTreeContentAdapter.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.debug.internal.ui.elements.adapters;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.model.IDebugTarget;
+import org.eclipse.debug.internal.ui.viewers.AsynchronousTreeContentAdapter;
+import org.eclipse.debug.internal.ui.viewers.IPresentationContext;
+import org.eclipse.debug.ui.IDebugUIConstants;
+
+public class DebugTargetTreeContentAdapter extends AsynchronousTreeContentAdapter {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.viewers.AsynchronousTreeContentAdapter#getChildren(java.lang.Object, org.eclipse.debug.ui.viewers.IPresentationContext)
+ */
+ protected Object[] getChildren(Object parent, IPresentationContext context) throws CoreException {
+ return ((IDebugTarget) parent).getThreads();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.viewers.AsynchronousTreeContentAdapter#hasChildren(java.lang.Object, org.eclipse.debug.ui.viewers.IPresentationContext)
+ */
+ protected boolean hasChildren(Object element, IPresentationContext context) throws CoreException {
+ return ((IDebugTarget)element).hasThreads();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.viewers.AsynchronousTreeContentAdapter#supportsPartId(java.lang.String)
+ */
+ protected boolean supportsPartId(String id) {
+ return IDebugUIConstants.ID_DEBUG_VIEW.equals(id);
+ }
+
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DeferredExpression.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DeferredExpression.java
deleted file mode 100644
index a0a6d3bab..000000000
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DeferredExpression.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.debug.internal.ui.elements.adapters;
-
-import org.eclipse.debug.core.DebugException;
-import org.eclipse.debug.core.model.IErrorReportingExpression;
-import org.eclipse.debug.core.model.IExpression;
-import org.eclipse.debug.core.model.IValue;
-
-public class DeferredExpression extends DeferredVariable {
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(java.lang.Object)
- */
- public Object[] getChildren(Object parent) {
- if (parent instanceof IErrorReportingExpression) {
- IErrorReportingExpression expression= (IErrorReportingExpression) parent;
- if (expression.hasErrors()) {
- return expression.getErrorMessages();
- }
- }
- if (parent instanceof IExpression) {
- IExpression expression = (IExpression)parent;
- IValue value = expression.getValue();
- try {
- return getValueChildren(expression, value);
- } catch (DebugException e) {
- }
- }
- return super.getChildren(parent);
- }
-
- protected boolean hasChildren(Object child) {
- if (child instanceof IErrorReportingExpression) {
- IErrorReportingExpression expression = (IErrorReportingExpression) child;
- if (expression.hasErrors()) {
- return true;
- }
- }
-
- if (child instanceof IExpression) {
- IExpression expression = (IExpression) child;
- IValue value = expression.getValue();
- if (value != null) {
- try {
- return value.hasVariables();
- } catch (DebugException e) {
- }
- }
- }
-
- return super.hasChildren(child);
- }
-
-
-
-}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DeferredExpressionManager.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DeferredExpressionManager.java
deleted file mode 100644
index 4b3d615f7..000000000
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DeferredExpressionManager.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.debug.internal.ui.elements.adapters;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.debug.core.DebugException;
-import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.IExpressionManager;
-import org.eclipse.debug.core.model.IExpression;
-import org.eclipse.debug.core.model.IValue;
-import org.eclipse.debug.internal.ui.views.variables.RemoteVariableContentManager;
-import org.eclipse.debug.ui.DeferredDebugElementWorkbenchAdapter;
-import org.eclipse.ui.progress.IElementCollector;
-
-public class DeferredExpressionManager extends DeferredDebugElementWorkbenchAdapter {
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(java.lang.Object)
- */
- public Object[] getChildren(Object parent) {
- return ((IExpressionManager)parent).getExpressions();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.model.IWorkbenchAdapter#getParent(java.lang.Object)
- */
- public Object getParent(Object element) {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.progress.IDeferredWorkbenchAdapter#fetchDeferredChildren(java.lang.Object, org.eclipse.ui.progress.IElementCollector, org.eclipse.core.runtime.IProgressMonitor)
- */
- public void fetchDeferredChildren(Object object, IElementCollector collector, IProgressMonitor monitor) {
- if (monitor.isCanceled()) {
- return;
- }
- Object[] children = getChildren(object);
- if (monitor.isCanceled()) {
- return;
- }
- if (children.length > 0) {
- if (collector instanceof RemoteVariableContentManager.VariableCollector) {
- RemoteVariableContentManager.VariableCollector remoteCollector = (RemoteVariableContentManager.VariableCollector) collector;
- for (int i = 0; i < children.length; i++) {
- if (monitor.isCanceled()) {
- return;
- }
- IExpression child = (IExpression) children[i];
- try {
- IValue value = child.getValue();
- if (value == null) {
- remoteCollector.setHasChildren(child, false);
- } else {
- remoteCollector.setHasChildren(child, value.hasVariables());
- }
- } catch (DebugException e) {
- }
- }
- }
- collector.add(children, monitor);
- }
- collector.done();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.progress.IDeferredWorkbenchAdapter#isContainer()
- */
- public boolean isContainer() {
- return DebugPlugin.getDefault().getExpressionManager().hasExpressions();
- }
-
-
-}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DeferredLaunch.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DeferredLaunch.java
deleted file mode 100644
index 0cd8a6bda..000000000
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DeferredLaunch.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.debug.internal.ui.elements.adapters;
-
-import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.ILaunch;
-import org.eclipse.debug.ui.DeferredDebugElementWorkbenchAdapter;
-
-public class DeferredLaunch extends DeferredDebugElementWorkbenchAdapter {
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(java.lang.Object)
- */
- public Object[] getChildren(Object parent) {
- return ((ILaunch)parent).getChildren();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.model.IWorkbenchAdapter#getParent(java.lang.Object)
- */
- public Object getParent(Object element) {
- return DebugPlugin.getDefault().getLaunchManager();
- }
-
-}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DeferredLaunchManager.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DeferredLaunchManager.java
deleted file mode 100644
index bd56dfae1..000000000
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DeferredLaunchManager.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.debug.internal.ui.elements.adapters;
-
-import org.eclipse.debug.core.ILaunchManager;
-import org.eclipse.debug.ui.DeferredDebugElementWorkbenchAdapter;
-
-public class DeferredLaunchManager extends DeferredDebugElementWorkbenchAdapter {
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(java.lang.Object)
- */
- public Object[] getChildren(Object parent) {
- return ((ILaunchManager) parent).getLaunches();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.model.IWorkbenchAdapter#getParent(java.lang.Object)
- */
- public Object getParent(Object element) {
- return null;
- }
-
-}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DeferredProcess.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DeferredProcess.java
deleted file mode 100644
index 341f5c438..000000000
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DeferredProcess.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.debug.internal.ui.elements.adapters;
-
-import org.eclipse.debug.core.model.IProcess;
-import org.eclipse.debug.ui.DeferredDebugElementWorkbenchAdapter;
-import org.eclipse.ui.progress.IDeferredWorkbenchAdapter;
-
-
-/**
- * Default deferred content provider for a process.
- */
-public class DeferredProcess extends DeferredDebugElementWorkbenchAdapter implements IDeferredWorkbenchAdapter {
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(java.lang.Object)
- */
- public Object[] getChildren(Object parent) {
- return EMPTY;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.model.IWorkbenchAdapter#getParent(java.lang.Object)
- */
- public Object getParent(Object element) {
- return ((IProcess)element).getLaunch();
- }
-
-
-}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DeferredRegisterGroup.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DeferredRegisterGroup.java
deleted file mode 100644
index 5c1fd35d6..000000000
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DeferredRegisterGroup.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.debug.internal.ui.elements.adapters;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.debug.core.DebugException;
-import org.eclipse.debug.core.model.IRegisterGroup;
-import org.eclipse.debug.core.model.IValue;
-import org.eclipse.debug.core.model.IVariable;
-import org.eclipse.debug.internal.ui.views.variables.RemoteVariableContentManager;
-import org.eclipse.debug.ui.DeferredDebugElementWorkbenchAdapter;
-import org.eclipse.ui.progress.IElementCollector;
-
-public class DeferredRegisterGroup extends DeferredDebugElementWorkbenchAdapter {
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(java.lang.Object)
- */
- public Object[] getChildren(Object parent) {
- try {
- return ((IRegisterGroup)parent).getRegisters();
- } catch (DebugException e) {
- }
- return EMPTY;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.model.IWorkbenchAdapter#getParent(java.lang.Object)
- */
- public Object getParent(Object element) {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.progress.IDeferredWorkbenchAdapter#fetchDeferredChildren(java.lang.Object, org.eclipse.ui.progress.IElementCollector, org.eclipse.core.runtime.IProgressMonitor)
- */
- public void fetchDeferredChildren(Object object, IElementCollector collector, IProgressMonitor monitor) {
- if (monitor.isCanceled()) {
- return;
- }
- Object[] children = getChildren(object);
- if (monitor.isCanceled()) {
- return;
- }
- if (children.length > 0) {
- if (collector instanceof RemoteVariableContentManager.VariableCollector) {
- RemoteVariableContentManager.VariableCollector remoteCollector = (RemoteVariableContentManager.VariableCollector) collector;
- for (int i = 0; i < children.length; i++) {
- if (monitor.isCanceled()) {
- return;
- }
- Object child = children[i];
- remoteCollector.setHasChildren(child, hasChildren(child));
- }
- }
- collector.add(children, monitor);
- }
- collector.done();
- }
-
- protected boolean hasChildren(Object child) {
- if (child instanceof IVariable) {
- IVariable var = (IVariable) child;
- try {
- IValue value = var.getValue();
- return value.hasVariables();
- } catch (DebugException e) {
- }
- }
- return false;
- }
-}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DeferredStackFrame.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DeferredStackFrame.java
deleted file mode 100644
index eec8af2f0..000000000
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DeferredStackFrame.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.debug.internal.ui.elements.adapters;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.debug.core.DebugException;
-import org.eclipse.debug.core.model.IStackFrame;
-import org.eclipse.debug.core.model.IValue;
-import org.eclipse.debug.core.model.IVariable;
-import org.eclipse.debug.internal.ui.views.variables.RemoteVariableContentManager;
-import org.eclipse.debug.ui.DeferredDebugElementWorkbenchAdapter;
-import org.eclipse.ui.progress.IElementCollector;
-
-
-/**
- * Default deferred workbench adapter for a stack frame
- */
-public class DeferredStackFrame extends DeferredDebugElementWorkbenchAdapter {
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(java.lang.Object)
- */
- public Object[] getChildren(Object parent) {
- if (parent instanceof IStackFrame) {
- IStackFrame frame = (IStackFrame) parent;
- try {
- return frame.getVariables();
- } catch (DebugException e) {
- return new Object[]{e};
- }
- }
- return EMPTY;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.model.IWorkbenchAdapter#getParent(java.lang.Object)
- */
- public Object getParent(Object element) {
- return ((IStackFrame)element).getThread();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.progress.IDeferredWorkbenchAdapter#fetchDeferredChildren(java.lang.Object, org.eclipse.ui.progress.IElementCollector, org.eclipse.core.runtime.IProgressMonitor)
- */
- public void fetchDeferredChildren(Object object, IElementCollector collector, IProgressMonitor monitor) {
- if (monitor.isCanceled()) {
- return;
- }
- Object[] children = getChildren(object);
- if (monitor.isCanceled()) {
- return;
- }
- if (children.length > 0) {
- if (collector instanceof RemoteVariableContentManager.VariableCollector) {
- RemoteVariableContentManager.VariableCollector remoteCollector = (RemoteVariableContentManager.VariableCollector) collector;
- for (int i = 0; i < children.length; i++) {
- if (monitor.isCanceled()) {
- return;
- }
- Object child = children[i];
- remoteCollector.setHasChildren(child, hasChildren(child));
- }
- }
- collector.add(children, monitor);
- }
- collector.done();
- }
-
- /**
- * Returns whether the given child has children.
- * Subclasses should override for different type of children.
- *
- * @param child child fetched from getChildren()
- * @return whether the given child has children
- */
- protected boolean hasChildren(Object child) {
- if (child instanceof IVariable) {
- IVariable variable = (IVariable) child;
- try {
- IValue value = variable.getValue();
- return value.hasVariables();
- } catch (DebugException e) {
- }
- }
- return false;
- }
-
-}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DeferredTarget.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DeferredTarget.java
deleted file mode 100644
index f28d0c8d7..000000000
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DeferredTarget.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.debug.internal.ui.elements.adapters;
-
-import org.eclipse.debug.core.DebugException;
-import org.eclipse.debug.core.model.IDebugTarget;
-import org.eclipse.debug.ui.DeferredDebugElementWorkbenchAdapter;
-import org.eclipse.ui.progress.IDeferredWorkbenchAdapter;
-
-
-/**
- * Default deferred content provider for a debug target
- */
-public class DeferredTarget extends DeferredDebugElementWorkbenchAdapter implements IDeferredWorkbenchAdapter {
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(java.lang.Object)
- */
- public Object[] getChildren(Object parent) {
- try {
- return ((IDebugTarget)parent).getThreads();
- } catch (DebugException e) {
- }
- return EMPTY;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.model.IWorkbenchAdapter#getParent(java.lang.Object)
- */
- public Object getParent(Object element) {
- return ((IDebugTarget)element).getLaunch();
- }
-
-
-}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DeferredThread.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DeferredThread.java
deleted file mode 100644
index 5a588fabc..000000000
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DeferredThread.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.debug.internal.ui.elements.adapters;
-
-import org.eclipse.debug.core.DebugException;
-import org.eclipse.debug.core.model.IThread;
-import org.eclipse.debug.ui.DeferredDebugElementWorkbenchAdapter;
-import org.eclipse.ui.progress.IDeferredWorkbenchAdapter;
-
-
-/**
- * Default deferred content provider for a debug target
- */
-public class DeferredThread extends DeferredDebugElementWorkbenchAdapter implements IDeferredWorkbenchAdapter {
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(java.lang.Object)
- */
- public Object[] getChildren(Object parent) {
- try {
- return ((IThread)parent).getStackFrames();
- } catch (DebugException e) {
- }
- return EMPTY;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.model.IWorkbenchAdapter#getParent(java.lang.Object)
- */
- public Object getParent(Object element) {
- return ((IThread)element).getDebugTarget();
- }
-
-
-
-}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DeferredVariable.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DeferredVariable.java
deleted file mode 100644
index d75f2bb08..000000000
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DeferredVariable.java
+++ /dev/null
@@ -1,237 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.debug.internal.ui.elements.adapters;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.debug.core.DebugException;
-import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.ILogicalStructureType;
-import org.eclipse.debug.core.model.IDebugElement;
-import org.eclipse.debug.core.model.IIndexedValue;
-import org.eclipse.debug.core.model.IValue;
-import org.eclipse.debug.core.model.IVariable;
-import org.eclipse.debug.internal.ui.views.variables.IndexedVariablePartition;
-import org.eclipse.debug.internal.ui.views.variables.RemoteVariableContentManager;
-import org.eclipse.debug.ui.DeferredDebugElementWorkbenchAdapter;
-import org.eclipse.ui.progress.IElementCollector;
-
-
-/**
- * Default deferred content provider for a variable
- */
-public class DeferredVariable extends DeferredDebugElementWorkbenchAdapter {
-
- private static final IVariable[] EMPTY_VARS = new IVariable[0];
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(java.lang.Object)
- */
- public Object[] getChildren(Object parent) {
- if (parent instanceof IVariable) {
- try {
- IVariable variable = (IVariable) parent;
- IValue value = variable.getValue();
- if (value != null) {
- return getValueChildren(variable, value);
- }
- } catch (DebugException e) {
- }
- }
- return EMPTY;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.progress.IDeferredWorkbenchAdapter#fetchDeferredChildren(java.lang.Object, org.eclipse.ui.progress.IElementCollector, org.eclipse.core.runtime.IProgressMonitor)
- */
- public void fetchDeferredChildren(Object object, IElementCollector collector, IProgressMonitor monitor) {
- if (monitor.isCanceled()) {
- return;
- }
- Object[] children = getChildren(object);
- if (monitor.isCanceled()) {
- return;
- }
- if (children.length > 0) {
- if (collector instanceof RemoteVariableContentManager.VariableCollector) {
- RemoteVariableContentManager.VariableCollector remoteCollector = (RemoteVariableContentManager.VariableCollector) collector;
- for (int i = 0; i < children.length; i++) {
- if (monitor.isCanceled()) {
- return;
- }
- Object child = children[i];
- remoteCollector.setHasChildren(child, hasChildren(child));
- }
- }
- collector.add(children, monitor);
- }
- collector.done();
- }
-
- protected boolean hasChildren(Object child) {
- if (child instanceof IVariable) {
- IVariable var = (IVariable) child;
- try {
- IValue value = var.getValue();
- return value.hasVariables();
- } catch (DebugException e) {
- }
- }
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.model.IWorkbenchAdapter#getParent(java.lang.Object)
- */
- public Object getParent(Object element) {
- return null;
- }
-
- /**
- * Returns children for the given value, creating array paritions if required
- *
- * @param parent expression or variable containing the given value
- * @param value the value to retrieve children for
- * @return children for the given value, creating array paritions if required
- * @throws DebugException
- */
- protected IVariable[] getValueChildren(IDebugElement parent, IValue value) throws DebugException {
- if (value == null) {
- return EMPTY_VARS;
- }
- IValue logicalValue = getLogicalValue(value);
- if (logicalValue instanceof IIndexedValue) {
- IIndexedValue indexedValue = (IIndexedValue)logicalValue;
- int partitionSize = computeParitionSize(indexedValue);
- if (partitionSize > 1) {
- int offset = indexedValue.getInitialOffset();
- int length = indexedValue.getSize();
- int numPartitions = length / partitionSize;
- int remainder = length % partitionSize;
- if (remainder > 0) {
- numPartitions++;
- }
- IVariable[] partitions = new IVariable[numPartitions];
- for (int i = 0; i < (numPartitions - 1); i++) {
- partitions[i] = new IndexedVariablePartition(parent, indexedValue, offset, partitionSize);
- offset = offset + partitionSize;
- }
- if (remainder == 0) {
- remainder = partitionSize;
- }
- partitions[numPartitions - 1] = new IndexedVariablePartition(parent, indexedValue, offset, remainder);
- return partitions;
- }
- }
- if (logicalValue == null) {
- // safeguard against an structure type returning null
- logicalValue = value;
- }
- return logicalValue.getVariables();
- }
-
- /**
- * Returns any logical value for the raw value.
- *
- * @param value
- * @return
- */
- protected IValue getLogicalValue(IValue value) {
- return getLogicalValue(value, new ArrayList());
- }
-
- /**
- * Returns any logical value for the raw value. This method will recurse
- * over the returned value until the same structure is encountered again
- * (to avoid infinite recursion).
- *
- * @param value
- * @param previousStructureIds the list of logical structures that have already
- * been applied to the returned value during the recursion of this method. Callers
- * should always pass in a new, empty list.
- * @return
- */
- private IValue getLogicalValue(IValue value, List previousStructureIds) {
- if (isShowLogicalStructure()) {
- ILogicalStructureType[] types = DebugPlugin.getLogicalStructureTypes(value);
- if (types.length > 0) {
- ILogicalStructureType type = DebugPlugin.getDefaultStructureType(types);
- if (type != null && !previousStructureIds.contains(type.getId())) {
- try {
- value= type.getLogicalStructure(value);
- previousStructureIds.add(type.getId());
- return getLogicalValue(value, previousStructureIds);
- } catch (CoreException e) {
- // unable to display logical structure
- }
- }
- }
- }
- return value;
- }
-
- /**
- * Return wether to show compute a logical structure or a raw structure.
- *
- * @return wether to show compute a logical structure or a raw structure
- */
- protected boolean isShowLogicalStructure() {
- return false;
- }
-
- /**
- * Returns the partition size to use for the given indexed value.
- * The partition size is computed by determining the number of levels
- * that an indexed collection must be nested in order to partition
- * the collection sub-collections of the preferred partition size.
- *
- * @param value indexed value
- * @return size of paritions the value should be subdivided into
- */
- protected int computeParitionSize(IIndexedValue value) {
- int partitionSize = 1;
- try {
- int length = value.getSize();
- int partitionDepth = 0;
- int preferredSize = getArrayPartitionSize();
- int remainder = length % preferredSize;
- length = length / preferredSize;
- while (length > 0) {
- if (remainder == 0 && length == 1) {
- break;
- }
- partitionDepth++;
- remainder = length % preferredSize;
- length = length / preferredSize;
- }
- for (int i = 0; i < partitionDepth; i++) {
- partitionSize = partitionSize * preferredSize;
- }
- } catch (DebugException e) {
- }
- return partitionSize;
- }
-
- /**
- * Returns the number of entries that should be displayed in each
- * partition of an indexed collection.
- *
- * @return the number of entries that should be displayed in each
- * partition of an indexed collection
- */
- protected int getArrayPartitionSize() {
- // TODO: should fix this with a user pref
- return 100;
- }
-}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/ExpressionManagerTreeContentAdapter.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/ExpressionManagerTreeContentAdapter.java
new file mode 100644
index 000000000..865cfa899
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/ExpressionManagerTreeContentAdapter.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.debug.internal.ui.elements.adapters;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.IExpressionManager;
+import org.eclipse.debug.internal.ui.viewers.AsynchronousTreeContentAdapter;
+import org.eclipse.debug.internal.ui.viewers.IPresentationContext;
+import org.eclipse.debug.ui.IDebugUIConstants;
+
+public class ExpressionManagerTreeContentAdapter extends AsynchronousTreeContentAdapter {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.elements.adapters.AsynchronousDebugTreeContentAdapter#getChildren(java.lang.Object, org.eclipse.debug.internal.ui.treeviewer.IPresentationContext)
+ */
+ protected Object[] getChildren(Object parent, IPresentationContext context) throws CoreException {
+ return ((IExpressionManager) parent).getExpressions();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.elements.adapters.AsynchronousDebugTreeContentAdapter#hasChildren(java.lang.Object, org.eclipse.debug.internal.ui.treeviewer.IPresentationContext)
+ */
+ protected boolean hasChildren(Object element, IPresentationContext context) throws CoreException {
+ return ((IExpressionManager)element).hasExpressions();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.viewers.AsynchronousTreeContentAdapter#supportsPartId(java.lang.String)
+ */
+ protected boolean supportsPartId(String id) {
+ return id.equals(IDebugUIConstants.ID_EXPRESSION_VIEW);
+ }
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/ExpressionTreeContentAdapter.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/ExpressionTreeContentAdapter.java
new file mode 100644
index 000000000..d35c00084
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/ExpressionTreeContentAdapter.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.elements.adapters;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.model.IExpression;
+import org.eclipse.debug.core.model.IValue;
+import org.eclipse.debug.internal.ui.viewers.IPresentationContext;
+
+/**
+ *
+ */
+public class ExpressionTreeContentAdapter extends VariableTreeContentAdapter {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.viewers.AsynchronousTreeContentAdapter#getChildren(java.lang.Object, org.eclipse.debug.ui.viewers.IPresentationContext)
+ */
+ protected Object[] getChildren(Object parent, IPresentationContext context) throws CoreException {
+ IExpression expression = (IExpression) parent;
+ IValue value = expression.getValue();
+ if (value != null) {
+ return getValueChildren(expression, value, context);
+ }
+ return EMPTY;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.viewers.AsynchronousTreeContentAdapter#hasChildren(java.lang.Object, org.eclipse.debug.ui.viewers.IPresentationContext)
+ */
+ protected boolean hasChildren(Object element, IPresentationContext context) throws CoreException {
+ IValue value = ((IExpression)element).getValue();
+ if (value == null) {
+ return false;
+ }
+ return value.hasVariables();
+ }
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/LauchManagerTreeContentAdapter.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/LauchManagerTreeContentAdapter.java
new file mode 100644
index 000000000..aa8a536a5
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/LauchManagerTreeContentAdapter.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.debug.internal.ui.elements.adapters;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.internal.ui.viewers.AsynchronousTreeContentAdapter;
+import org.eclipse.debug.internal.ui.viewers.IPresentationContext;
+import org.eclipse.debug.ui.IDebugUIConstants;
+
+public class LauchManagerTreeContentAdapter extends AsynchronousTreeContentAdapter {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.viewers.AsynchronousTreeContentAdapter#getChildren(java.lang.Object, org.eclipse.debug.ui.viewers.IPresentationContext)
+ */
+ protected Object[] getChildren(Object parent, IPresentationContext context) throws CoreException {
+ return ((ILaunchManager) parent).getLaunches();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.viewers.AsynchronousTreeContentAdapter#hasChildren(java.lang.Object, org.eclipse.debug.ui.viewers.IPresentationContext)
+ */
+ protected boolean hasChildren(Object element, IPresentationContext context) throws CoreException {
+ return ((ILaunchManager)element).getLaunches().length > 0;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.viewers.AsynchronousTreeContentAdapter#supportsPartId(java.lang.String)
+ */
+ protected boolean supportsPartId(String id) {
+ return IDebugUIConstants.ID_DEBUG_VIEW.equals(id);
+ }
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/LaunchTreeContentAdapter.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/LaunchTreeContentAdapter.java
new file mode 100644
index 000000000..7cebf9a8d
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/LaunchTreeContentAdapter.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.debug.internal.ui.elements.adapters;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.internal.ui.viewers.AsynchronousTreeContentAdapter;
+import org.eclipse.debug.internal.ui.viewers.IPresentationContext;
+import org.eclipse.debug.ui.IDebugUIConstants;
+
+public class LaunchTreeContentAdapter extends AsynchronousTreeContentAdapter {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.viewers.AsynchronousTreeContentAdapter#getChildren(java.lang.Object, org.eclipse.debug.ui.viewers.IPresentationContext)
+ */
+ protected Object[] getChildren(Object parent, IPresentationContext context) throws CoreException {
+ return ((ILaunch) parent).getChildren();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.viewers.AsynchronousTreeContentAdapter#hasChildren(java.lang.Object, org.eclipse.debug.ui.viewers.IPresentationContext)
+ */
+ protected boolean hasChildren(Object element, IPresentationContext context) throws CoreException {
+ return ((ILaunch)element).hasChildren();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.viewers.AsynchronousTreeContentAdapter#supportsPartId(java.lang.String)
+ */
+ protected boolean supportsPartId(String id) {
+ return IDebugUIConstants.ID_DEBUG_VIEW.equals(id);
+ }
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/ProcessTreeAdapter.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/ProcessTreeAdapter.java
new file mode 100644
index 000000000..2c4fc02c2
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/ProcessTreeAdapter.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.elements.adapters;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.internal.ui.viewers.AsynchronousTreeContentAdapter;
+import org.eclipse.debug.internal.ui.viewers.IPresentationContext;
+import org.eclipse.debug.ui.IDebugUIConstants;
+
+public class ProcessTreeAdapter extends AsynchronousTreeContentAdapter {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.viewers.AsynchronousTreeContentAdapter#getChildren(java.lang.Object, org.eclipse.debug.ui.viewers.IPresentationContext)
+ */
+ protected Object[] getChildren(Object parent, IPresentationContext context) throws CoreException {
+ return EMPTY;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.viewers.AsynchronousTreeContentAdapter#hasChildren(java.lang.Object, org.eclipse.debug.ui.viewers.IPresentationContext)
+ */
+ protected boolean hasChildren(Object element, IPresentationContext context) throws CoreException {
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.viewers.AsynchronousTreeContentAdapter#supportsPartId(java.lang.String)
+ */
+ protected boolean supportsPartId(String id) {
+ return IDebugUIConstants.ID_DEBUG_VIEW.equals(id);
+ }
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/RegisterGroupTreeContentAdapter.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/RegisterGroupTreeContentAdapter.java
new file mode 100644
index 000000000..477fbcf42
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/RegisterGroupTreeContentAdapter.java
@@ -0,0 +1,31 @@
+package org.eclipse.debug.internal.ui.elements.adapters;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.model.IRegisterGroup;
+import org.eclipse.debug.internal.ui.viewers.AsynchronousTreeContentAdapter;
+import org.eclipse.debug.internal.ui.viewers.IPresentationContext;
+import org.eclipse.debug.ui.IDebugUIConstants;
+
+public class RegisterGroupTreeContentAdapter extends AsynchronousTreeContentAdapter {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.viewers.AsynchronousTreeContentAdapter#getChildren(java.lang.Object, org.eclipse.debug.ui.viewers.IPresentationContext)
+ */
+ protected Object[] getChildren(Object parent, IPresentationContext context) throws CoreException {
+ return ((IRegisterGroup)parent).getRegisters();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.viewers.AsynchronousTreeContentAdapter#hasChildren(java.lang.Object, org.eclipse.debug.ui.viewers.IPresentationContext)
+ */
+ protected boolean hasChildren(Object element, IPresentationContext context) throws CoreException {
+ return ((IRegisterGroup)element).hasRegisters();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.viewers.AsynchronousTreeContentAdapter#supportsPartId(java.lang.String)
+ */
+ protected boolean supportsPartId(String id) {
+ return id.equals(IDebugUIConstants.ID_REGISTER_VIEW);
+ }
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/StackFrameSourceDisplayAdapter.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/StackFrameSourceDisplayAdapter.java
new file mode 100644
index 000000000..08024e5ab
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/StackFrameSourceDisplayAdapter.java
@@ -0,0 +1,164 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.elements.adapters;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.debug.core.DebugEvent;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.IDebugEventSetListener;
+import org.eclipse.debug.core.model.IDebugTarget;
+import org.eclipse.debug.core.model.ISourceLocator;
+import org.eclipse.debug.core.model.IStackFrame;
+import org.eclipse.debug.core.model.IThread;
+import org.eclipse.debug.internal.ui.InstructionPointerManager;
+import org.eclipse.debug.internal.ui.sourcelookup.SourceLookupResult;
+import org.eclipse.debug.internal.ui.views.launch.DecorationManager;
+import org.eclipse.debug.ui.DebugUITools;
+import org.eclipse.debug.ui.contexts.ISourceDisplayAdapter;
+import org.eclipse.debug.ui.sourcelookup.ISourceLookupResult;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.progress.UIJob;
+
+/**
+ * @since 3.2
+ */
+public class StackFrameSourceDisplayAdapter implements ISourceDisplayAdapter {
+
+ private IStackFrame fPrevFrame;
+ private SourceLookupResult fPrevResult;
+
+ /**
+ * Constructs singleton source display adapter for stack frames.
+ */
+ public StackFrameSourceDisplayAdapter() {
+ DebugPlugin.getDefault().addDebugEventListener(new IDebugEventSetListener() {
+ public void handleDebugEvents(DebugEvent[] events) {
+ for (int i = 0; i < events.length; i++) {
+ DebugEvent event = events[i];
+ switch (event.getKind()) {
+ case DebugEvent.TERMINATE:
+ case DebugEvent.RESUME:
+ if (!event.isEvaluation()) {
+ clearSourceSelection(event.getSource());
+ }
+ break;
+ }
+ }
+ }
+ });
+ }
+
+ /**
+ * A job to perform source lookup on the currently selected stack frame.
+ */
+ class SourceLookupJob extends Job {
+
+ private IStackFrame fTarget;
+ private ISourceLocator fLocator;
+ private IWorkbenchPage fPage;
+
+ /**
+ * Constructs a new source lookup job.
+ */
+ public SourceLookupJob(IStackFrame frame, ISourceLocator locator, IWorkbenchPage page) {
+ super("Debug Source Lookup");
+ setPriority(Job.INTERACTIVE);
+ setSystem(true);
+ fTarget = frame;
+ fLocator = locator;
+ fPage = page;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ protected IStatus run(IProgressMonitor monitor) {
+ if (!monitor.isCanceled()) {
+ ISourceLookupResult result = null;
+ result = DebugUITools.lookupSource(fTarget, fLocator);
+ synchronized (StackFrameSourceDisplayAdapter.this) {
+ fPrevResult = (SourceLookupResult)result;
+ fPrevFrame = fTarget;
+ }
+ if (!monitor.isCanceled()) {
+ SourceDisplayJob job = new SourceDisplayJob(result, fPage);
+ job.schedule();
+ }
+ }
+ return Status.OK_STATUS;
+ }
+
+ }
+
+ class SourceDisplayJob extends UIJob {
+
+ private ISourceLookupResult fResult;
+ private IWorkbenchPage fPage;
+
+ /**
+ * Constructs a new source display job
+ */
+ public SourceDisplayJob(ISourceLookupResult result, IWorkbenchPage page) {
+ super("Debug Source Display");
+ setSystem(true);
+ setPriority(Job.INTERACTIVE);
+ fResult = result;
+ fPage = page;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public IStatus runInUIThread(IProgressMonitor monitor) {
+ if (!monitor.isCanceled()) {
+ DebugUITools.displaySource(fResult, fPage);
+ }
+ return Status.OK_STATUS;
+ }
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.contexts.ISourceDisplayAdapter#displaySource(java.lang.Object, org.eclipse.ui.IWorkbenchPage)
+ */
+ public synchronized void displaySource(Object context, IWorkbenchPage page) {
+ IStackFrame frame = (IStackFrame)context;
+ if (frame.equals(fPrevFrame)) {
+ fPrevResult.updateArtifact(context);
+ (new SourceDisplayJob(fPrevResult, page)).schedule();
+ } else {
+ (new SourceLookupJob(frame, frame.getLaunch().getSourceLocator(), page)).schedule();
+ }
+
+ }
+
+ /**
+ * Deselects any source decorations associated with the given thread or
+ * debug target.
+ *
+ * @param source thread or debug target
+ */
+ private void clearSourceSelection(Object source) {
+ if (source instanceof IThread) {
+ IThread thread = (IThread)source;
+ DecorationManager.removeDecorations(thread);
+ InstructionPointerManager.getDefault().removeAnnotations(thread);
+ } else if (source instanceof IDebugTarget) {
+ IDebugTarget target = (IDebugTarget)source;
+ DecorationManager.removeDecorations(target);
+ InstructionPointerManager.getDefault().removeAnnotations(target);
+ }
+ }
+
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/StackFrameTreeContentAdapter.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/StackFrameTreeContentAdapter.java
new file mode 100644
index 000000000..79790ee35
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/StackFrameTreeContentAdapter.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.debug.internal.ui.elements.adapters;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.model.IStackFrame;
+import org.eclipse.debug.internal.ui.viewers.AsynchronousTreeContentAdapter;
+import org.eclipse.debug.internal.ui.viewers.IPresentationContext;
+import org.eclipse.debug.ui.IDebugUIConstants;
+
+public class StackFrameTreeContentAdapter extends AsynchronousTreeContentAdapter {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.viewers.AsynchronousTreeContentAdapter#getChildren(java.lang.Object, org.eclipse.debug.ui.viewers.IPresentationContext)
+ */
+ protected Object[] getChildren(Object parent, IPresentationContext context) throws CoreException {
+ String id = context.getPart().getSite().getId();
+ IStackFrame frame = (IStackFrame) parent;
+ if (id.equals(IDebugUIConstants.ID_VARIABLE_VIEW)) {
+ return frame.getVariables();
+ } else if (id.equals(IDebugUIConstants.ID_REGISTER_VIEW)) {
+ return frame.getRegisterGroups();
+ }
+ return EMPTY;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.viewers.AsynchronousTreeContentAdapter#hasChildren(java.lang.Object, org.eclipse.debug.ui.viewers.IPresentationContext)
+ */
+ protected boolean hasChildren(Object element, IPresentationContext context) throws CoreException {
+ String id = context.getPart().getSite().getId();
+ IStackFrame frame = (IStackFrame) element;
+ if (id.equals(IDebugUIConstants.ID_VARIABLE_VIEW)) {
+ return frame.hasVariables();
+ } else if (id.equals(IDebugUIConstants.ID_REGISTER_VIEW)) {
+ return frame.hasRegisterGroups();
+ }
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.viewers.AsynchronousTreeContentAdapter#supportsPartId(java.lang.String)
+ */
+ protected boolean supportsPartId(String id) {
+ return id.equals(IDebugUIConstants.ID_VARIABLE_VIEW) || id.equals(IDebugUIConstants.ID_REGISTER_VIEW);
+ }
+
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/ThreadTreeContentAdapter.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/ThreadTreeContentAdapter.java
new file mode 100644
index 000000000..4f25a4de7
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/ThreadTreeContentAdapter.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.debug.internal.ui.elements.adapters;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.model.IThread;
+import org.eclipse.debug.internal.ui.viewers.AsynchronousTreeContentAdapter;
+import org.eclipse.debug.internal.ui.viewers.IPresentationContext;
+import org.eclipse.debug.ui.IDebugUIConstants;
+
+public class ThreadTreeContentAdapter extends AsynchronousTreeContentAdapter {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.viewers.AsynchronousTreeContentAdapter#getChildren(java.lang.Object, org.eclipse.debug.ui.viewers.IPresentationContext)
+ */
+ protected Object[] getChildren(Object parent, IPresentationContext context) throws CoreException {
+ return ((IThread) parent).getStackFrames();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.viewers.AsynchronousTreeContentAdapter#hasChildren(java.lang.Object, org.eclipse.debug.ui.viewers.IPresentationContext)
+ */
+ protected boolean hasChildren(Object element, IPresentationContext context) throws CoreException {
+ return ((IThread)element).hasStackFrames();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.viewers.AsynchronousTreeContentAdapter#supportsPartId(java.lang.String)
+ */
+ protected boolean supportsPartId(String id) {
+ return IDebugUIConstants.ID_DEBUG_VIEW.equals(id);
+ }
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/VariableLabelAdapter.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/VariableLabelAdapter.java
new file mode 100644
index 000000000..917b94cde
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/VariableLabelAdapter.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.elements.adapters;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.model.IVariable;
+import org.eclipse.debug.internal.ui.DebugUIPlugin;
+import org.eclipse.debug.internal.ui.preferences.IDebugPreferenceConstants;
+import org.eclipse.debug.internal.ui.viewers.IPresentationContext;
+import org.eclipse.debug.internal.ui.views.launch.DebugElementHelper;
+import org.eclipse.swt.graphics.RGB;
+
+/**
+ * Label adapter for variables.
+ *
+ * @since 3.2
+ */
+public class VariableLabelAdapter extends AsynchronousDebugLabelAdapter {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.viewers.AsynchronousLabelAdapter#getForeground(java.lang.Object, org.eclipse.debug.ui.viewers.IPresentationContext)
+ */
+ protected RGB[] getForegrounds(Object element, IPresentationContext context) throws CoreException {
+ if (element instanceof IVariable) {
+ IVariable variable = (IVariable) element;
+ try {
+ if (variable.hasValueChanged()) {
+ return new RGB[] {DebugUIPlugin.getPreferenceColor(IDebugPreferenceConstants.CHANGED_VARIABLE_COLOR).getRGB()};
+ }
+ } catch (DebugException e) {
+ }
+ return new RGB[] {DebugElementHelper.getForeground(element)};
+ }
+ return super.getForegrounds(element, context);
+ }
+
+
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/VariableTreeContentAdapter.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/VariableTreeContentAdapter.java
new file mode 100644
index 000000000..1e37a1528
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/VariableTreeContentAdapter.java
@@ -0,0 +1,209 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.debug.internal.ui.elements.adapters;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILogicalStructureType;
+import org.eclipse.debug.core.model.IDebugElement;
+import org.eclipse.debug.core.model.IIndexedValue;
+import org.eclipse.debug.core.model.IValue;
+import org.eclipse.debug.core.model.IVariable;
+import org.eclipse.debug.internal.ui.viewers.AsynchronousTreeContentAdapter;
+import org.eclipse.debug.internal.ui.viewers.IPresentationContext;
+import org.eclipse.debug.internal.ui.views.variables.IndexedVariablePartition;
+import org.eclipse.debug.internal.ui.views.variables.VariablesView;
+import org.eclipse.debug.ui.IDebugUIConstants;
+import org.eclipse.ui.IWorkbenchPart;
+
+public class VariableTreeContentAdapter extends AsynchronousTreeContentAdapter {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.viewers.AsynchronousTreeContentAdapter#getChildren(java.lang.Object, org.eclipse.debug.ui.viewers.IPresentationContext)
+ */
+ protected Object[] getChildren(Object parent, IPresentationContext context) throws CoreException {
+ IVariable variable = (IVariable) parent;
+ IValue value = variable.getValue();
+ if (value != null) {
+ return getValueChildren(variable, value, context);
+ }
+ return EMPTY;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.viewers.AsynchronousTreeContentAdapter#hasChildren(java.lang.Object, org.eclipse.debug.ui.viewers.IPresentationContext)
+ */
+ protected boolean hasChildren(Object element, IPresentationContext context) throws CoreException {
+ IValue value = ((IVariable)element).getValue();
+ return value.hasVariables();
+ }
+
+ /**
+ * Returns children for the given value, creating array paritions if
+ * required
+ *
+ * @param parent expression or variable containing the given value
+ * @param value the value to retrieve children for
+ * @param context the context in which children have been requested
+ * @return children for the given value, creating array paritions if
+ * required
+ * @throws CoreException
+ */
+ protected Object[] getValueChildren(IDebugElement parent, IValue value, IPresentationContext context) throws CoreException {
+ if (value == null) {
+ return EMPTY;
+ }
+ IValue logicalValue = getLogicalValue(value, context);
+ if (logicalValue instanceof IIndexedValue) {
+ IIndexedValue indexedValue = (IIndexedValue) logicalValue;
+ int partitionSize = computeParitionSize(indexedValue);
+ if (partitionSize > 1) {
+ int offset = indexedValue.getInitialOffset();
+ int length = indexedValue.getSize();
+ int numPartitions = length / partitionSize;
+ int remainder = length % partitionSize;
+ if (remainder > 0) {
+ numPartitions++;
+ }
+ IVariable[] partitions = new IVariable[numPartitions];
+ for (int i = 0; i < (numPartitions - 1); i++) {
+ partitions[i] = new IndexedVariablePartition(parent, indexedValue, offset, partitionSize);
+ offset = offset + partitionSize;
+ }
+ if (remainder == 0) {
+ remainder = partitionSize;
+ }
+ partitions[numPartitions - 1] = new IndexedVariablePartition(parent, indexedValue, offset, remainder);
+ return partitions;
+ }
+ }
+ if (logicalValue == null) {
+ // safeguard against an structure type returning null
+ logicalValue = value;
+ }
+ return logicalValue.getVariables();
+ }
+
+ /**
+ * Returns the partition size to use for the given indexed value. The
+ * partition size is computed by determining the number of levels that an
+ * indexed collection must be nested in order to partition the collection
+ * sub-collections of the preferred partition size.
+ *
+ * @param value
+ * indexed value
+ * @return size of paritions the value should be subdivided into
+ */
+ protected int computeParitionSize(IIndexedValue value) {
+ int partitionSize = 1;
+ try {
+ int length = value.getSize();
+ int partitionDepth = 0;
+ int preferredSize = getArrayPartitionSize();
+ int remainder = length % preferredSize;
+ length = length / preferredSize;
+ while (length > 0) {
+ if (remainder == 0 && length == 1) {
+ break;
+ }
+ partitionDepth++;
+ remainder = length % preferredSize;
+ length = length / preferredSize;
+ }
+ for (int i = 0; i < partitionDepth; i++) {
+ partitionSize = partitionSize * preferredSize;
+ }
+ } catch (DebugException e) {
+ }
+ return partitionSize;
+ }
+
+ /**
+ * Returns any logical value for the raw value in the specified context
+ *
+ * @param value
+ * @param context
+ * @return
+ */
+ protected IValue getLogicalValue(IValue value, IPresentationContext context) {
+ return getLogicalValue(value, new ArrayList(), context);
+ }
+
+ /**
+ * Returns any logical value for the raw value. This method will recurse
+ * over the returned value until the same structure is encountered again (to
+ * avoid infinite recursion).
+ *
+ * @param value
+ * @param previousStructureIds
+ * the list of logical structures that have already been applied
+ * to the returned value during the recursion of this method.
+ * Callers should always pass in a new, empty list.
+ * @return
+ */
+ protected IValue getLogicalValue(IValue value, List previousStructureIds, IPresentationContext context) {
+ if (isShowLogicalStructure(context)) {
+ ILogicalStructureType[] types = DebugPlugin.getLogicalStructureTypes(value);
+ if (types.length > 0) {
+ ILogicalStructureType type = DebugPlugin.getDefaultStructureType(types);
+ if (type != null && !previousStructureIds.contains(type.getId())) {
+ try {
+ value = type.getLogicalStructure(value);
+ previousStructureIds.add(type.getId());
+ return getLogicalValue(value, previousStructureIds, context);
+ } catch (CoreException e) {
+ // unable to display logical structure
+ }
+ }
+ }
+ }
+ return value;
+ }
+
+ /**
+ * Return wether to show compute a logical structure or a raw structure
+ * in the specified context
+ *
+ * @return wether to show compute a logical structure or a raw structure
+ * in the specified context
+ */
+ protected boolean isShowLogicalStructure(IPresentationContext context) {
+ IWorkbenchPart part = context.getPart();
+ if (part instanceof VariablesView) {
+ return ((VariablesView) part).isShowLogicalStructure();
+ }
+ return false;
+ }
+
+ /**
+ * Returns the number of entries that should be displayed in each partition
+ * of an indexed collection.
+ *
+ * @return the number of entries that should be displayed in each partition
+ * of an indexed collection
+ */
+ protected int getArrayPartitionSize() {
+ // TODO: should fix this with a user pref
+ return 100;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.viewers.AsynchronousTreeContentAdapter#supportsPartId(java.lang.String)
+ */
+ protected boolean supportsPartId(String id) {
+ return id.equals(IDebugUIConstants.ID_VARIABLE_VIEW) || id.equals(IDebugUIConstants.ID_REGISTER_VIEW);
+ }
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/PerspectiveManager.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/PerspectiveManager.java
index 8fbeed8cb..be07fe5cd 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/PerspectiveManager.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/PerspectiveManager.java
@@ -19,26 +19,26 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException;
+
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.debug.core.DebugEvent;
import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.IDebugEventSetListener;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.debug.core.ILaunchListener;
import org.eclipse.debug.core.ILaunchManager;
-import org.eclipse.debug.core.model.IDebugElement;
-import org.eclipse.debug.core.model.IProcess;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.debug.ui.IDebugUIConstants;
+import org.eclipse.debug.ui.contexts.ISuspendTrigger;
+import org.eclipse.debug.ui.contexts.ISuspendTriggerListener;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialogWithToggle;
import org.eclipse.swt.widgets.Display;
@@ -67,7 +67,7 @@ import org.xml.sax.helpers.DefaultHandler;
* @see IDebugUIContants.ATTR_RUN_PERSPECTIVE
* @see IDebugUIContants.ATTR_DEBUG_PERSPECTIVE
*/
-public class PerspectiveManager implements ILaunchListener, IDebugEventSetListener {
+public class PerspectiveManager implements ILaunchListener, ISuspendTriggerListener {
/**
* Table of config types to tables of user specified perspective settings (mode ids
@@ -134,7 +134,6 @@ public class PerspectiveManager implements ILaunchListener, IDebugEventSetListen
public void startup() {
DebugPlugin plugin = DebugPlugin.getDefault();
plugin.getLaunchManager().addLaunchListener(this);
- plugin.addDebugEventListener(this);
}
/**
@@ -145,7 +144,6 @@ public class PerspectiveManager implements ILaunchListener, IDebugEventSetListen
public void shutdown() {
DebugPlugin plugin = DebugPlugin.getDefault();
plugin.getLaunchManager().removeLaunchListener(this);
- plugin.removeDebugEventListener(this);
}
/**
@@ -154,6 +152,10 @@ public class PerspectiveManager implements ILaunchListener, IDebugEventSetListen
* @see ILaunchListener#launchRemoved(ILaunch)
*/
public void launchRemoved(ILaunch launch) {
+ ISuspendTrigger trigger = (ISuspendTrigger) launch.getAdapter(ISuspendTrigger.class);
+ if (trigger != null) {
+ trigger.removeSuspendTriggerListener(this);
+ }
}
/**
@@ -172,6 +174,11 @@ public class PerspectiveManager implements ILaunchListener, IDebugEventSetListen
*/
public void launchAdded(ILaunch launch) {
+ ISuspendTrigger trigger = (ISuspendTrigger) launch.getAdapter(ISuspendTrigger.class);
+ if (trigger != null) {
+ trigger.addSuspendTriggerListener(this);
+ }
+
fPerspectiveSwitchLock.startSwitch();
String perspectiveId = null;
@@ -264,25 +271,6 @@ public class PerspectiveManager implements ILaunchListener, IDebugEventSetListen
}
/**
- * On a SUSPEND event, show the debug view. If no debug view is open,
- * switch to the perspective specified by the launcher.
- *
- * @see IDebugEventSetListener#handleDebugEvents(DebugEvent[])
- */
- public void handleDebugEvents(DebugEvent[] events) {
- // open the debugger if this is a suspend event and the debug view is not yet open
- // and the preferences are set to switch
- for (int i = 0; i < events.length; i++) {
- DebugEvent event = events[i];
- if (event.getKind() == DebugEvent.SUSPEND && !event.isEvaluation() &&
- event.getDetail() != DebugEvent.STEP_END) {
- // Don't switch perspective for evaluations or stepping
- handleBreakpointHit(event);
- }
- }
- }
-
- /**
* Makes the debug view visible.
*/
protected void showDebugView(final IWorkbenchWindow window) {
@@ -332,7 +320,7 @@ public class PerspectiveManager implements ILaunchListener, IDebugEventSetListen
*
* @param event the suspend event
*/
- private void handleBreakpointHit(DebugEvent event) {
+ private void handleBreakpointHit(ILaunch launch) {
// Must be called here to indicate that the perspective
// may be switching.
@@ -342,14 +330,6 @@ public class PerspectiveManager implements ILaunchListener, IDebugEventSetListen
// the perspective switch.
fPerspectiveSwitchLock.startSwitch();
- // apply event filters
- ILaunch launch= null;
- Object source = event.getSource();
- if (source instanceof IDebugElement) {
- launch = ((IDebugElement)source).getLaunch();
- } else if (source instanceof IProcess) {
- launch = ((IProcess)source).getLaunch();
- }
String perspectiveId = null;
try {
perspectiveId = getPerspectiveId(launch);
@@ -815,4 +795,11 @@ public class PerspectiveManager implements ILaunchListener, IDebugEventSetListen
public void schedulePostSwitch(Job job) {
fPerspectiveSwitchLock.schedulePostSwitch(job);
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.contexts.ISuspendTriggerListener#suspended(org.eclipse.debug.core.ILaunch, java.lang.Object)
+ */
+ public void suspended(ILaunch launch, Object context) {
+ handleBreakpointHit(launch);
+ }
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupManager.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupManager.java
new file mode 100644
index 000000000..952350436
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupManager.java
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.sourcelookup;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.ui.IWindowListener;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * Starts a source lookup service in each workbench window.
+ *
+ * @since 3.2
+ */
+public class SourceLookupManager implements IWindowListener {
+
+ private static SourceLookupManager fgDefault;
+
+ /**
+ * Services per window
+ */
+ private Map fServices = new HashMap();
+
+ private SourceLookupManager() {
+ IWorkbench workbench = PlatformUI.getWorkbench();
+ IWorkbenchWindow[] workbenchWindows = workbench.getWorkbenchWindows();
+ for (int i = 0; i < workbenchWindows.length; i++) {
+ IWorkbenchWindow window = workbenchWindows[i];
+ windowOpened(window);
+ }
+ workbench.addWindowListener(this);
+ }
+
+ /**
+ * Returns the default source lookup manager.
+ *
+ * @return
+ */
+ public static SourceLookupManager getDefault() {
+ if (fgDefault == null) {
+ fgDefault = new SourceLookupManager();
+ }
+ return fgDefault;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWindowListener#windowActivated(org.eclipse.ui.IWorkbenchWindow)
+ */
+ public void windowActivated(IWorkbenchWindow window) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWindowListener#windowDeactivated(org.eclipse.ui.IWorkbenchWindow)
+ */
+ public void windowDeactivated(IWorkbenchWindow window) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWindowListener#windowClosed(org.eclipse.ui.IWorkbenchWindow)
+ */
+ public void windowClosed(IWorkbenchWindow window) {
+ SourceLookupService service = (SourceLookupService) fServices.get(window);
+ if (service != null) {
+ service.dispose();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWindowListener#windowOpened(org.eclipse.ui.IWorkbenchWindow)
+ */
+ public void windowOpened(IWorkbenchWindow window) {
+ SourceLookupService service = new SourceLookupService(window);
+ fServices.put(window, service);
+ }
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupService.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupService.java
new file mode 100644
index 000000000..39cc2da9a
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupService.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.sourcelookup;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.debug.internal.ui.contexts.DebugContextManager;
+import org.eclipse.debug.ui.contexts.IDebugContextListener;
+import org.eclipse.debug.ui.contexts.ISourceDisplayAdapter;
+import org.eclipse.debug.ui.sourcelookup.ISourceLookupResult;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+
+/**
+ * Performs source lookup in a window.
+ *
+ * @since 3.2
+ */
+public class SourceLookupService implements IDebugContextListener {
+
+ private IWorkbenchWindow fWindow;
+
+ private Object fPrevTarget;
+ private ISourceLookupResult fPrevResult;
+
+ public SourceLookupService(IWorkbenchWindow window) {
+ fWindow = window;
+ DebugContextManager.getDefault().addDebugContextListener(this, window);
+ }
+
+ public void dispose() {
+ DebugContextManager.getDefault().removeDebugContextListener(this, fWindow);
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.contexts.IDebugContextListener#contextActivated(java.lang.Object, org.eclipse.ui.IWorkbenchPart)
+ */
+ public synchronized void contextActivated(ISelection selection, IWorkbenchPart part) {
+ if (selection instanceof IStructuredSelection) {
+ IStructuredSelection structuredSelection = (IStructuredSelection)selection;
+ if (structuredSelection.size() == 1) {
+ Object context = (structuredSelection).getFirstElement();
+ if (context instanceof IAdaptable) {
+ IAdaptable adaptable = (IAdaptable) context;
+ ISourceDisplayAdapter adapter = (ISourceDisplayAdapter) adaptable.getAdapter(ISourceDisplayAdapter.class);
+ if (adapter != null) {
+ IWorkbenchPage page = null;
+ if (part == null) {
+ page = fWindow.getActivePage();
+ } else {
+ page = part.getSite().getPage();
+ }
+ adapter.displaySource(context, page);
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AbstractModelProxy.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AbstractModelProxy.java
new file mode 100644
index 000000000..eec03e25e
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AbstractModelProxy.java
@@ -0,0 +1,48 @@
+package org.eclipse.debug.internal.ui.viewers;
+
+import org.eclipse.core.runtime.ISafeRunnable;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.debug.internal.core.ListenerList;
+import org.eclipse.debug.internal.ui.DebugUIPlugin;
+
+public abstract class AbstractModelProxy implements IModelProxy {
+
+ protected ListenerList fListeners = new ListenerList(1);
+
+ protected Object[] getListeners() {
+ synchronized (fListeners) {
+ return fListeners.getListeners();
+ }
+ }
+
+ public void addModelChangedListener(IModelChangedListener listener) {
+ synchronized (fListeners) {
+ fListeners.add(listener);
+ }
+ }
+
+ public void removeModelChangedListener(IModelChangedListener listener) {
+ synchronized (fListeners) {
+ fListeners.remove(listener);
+ }
+ }
+
+ public void fireModelChanged(final IModelDelta delta) {
+ Object[] listeners = getListeners();
+ for (int i = 0; i < listeners.length; i++) {
+ final IModelChangedListener listener = (IModelChangedListener) listeners[i];
+ ISafeRunnable safeRunnable = new ISafeRunnable() {
+ public void handleException(Throwable exception) {
+ DebugUIPlugin.log(exception);
+ }
+
+ public void run() throws Exception {
+ listener.modelChanged(delta);
+ }
+
+ };
+ Platform.run(safeRunnable);
+ }
+ }
+
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousLabelAdapter.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousLabelAdapter.java
new file mode 100644
index 000000000..0059c1926
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousLabelAdapter.java
@@ -0,0 +1,155 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.debug.internal.ui.viewers;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.ui.progress.UIJob;
+
+/**
+ * Abstract implementation of an asynchronous label adapter
+ * <p>
+ * Clients may subclass this class.
+ * </p>
+ * @since 3.2
+ */
+public abstract class AsynchronousLabelAdapter implements IAsynchronousLabelAdapter {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.viewers.IAsynchronousLabelAdapter#retrieveLabel(java.lang.Object, org.eclipse.debug.ui.viewers.IPresentationContext, org.eclipse.debug.ui.viewers.ILabelRequestMonitor)
+ */
+ public void retrieveLabel(final Object element, final IPresentationContext context, final ILabelRequestMonitor result) {
+ Job job = null;
+ if (requiresUIJob()) {
+ job = new UIJob("Retrieving labels") { //$NON-NLS-1$
+ public IStatus runInUIThread(IProgressMonitor monitor) {
+ computeLabels(element, context, result);
+ return Status.OK_STATUS;
+ }
+ };
+ } else {
+ job = new Job("Retrieving labels") { //$NON-NLS-1$
+ protected IStatus run(IProgressMonitor monitor) {
+ computeLabels(element, context, result);
+ return Status.OK_STATUS;
+ }
+ };
+ }
+ job.setSystem(true);
+ job.schedule();
+ }
+
+ /**
+ * Returns whether this label adapter requires to be run in the UI thread.
+ * By default, label jobs are not run in the UI thread. Subclasses should
+ * override if required.
+ *
+ * @return whether this label adapter requires to be run in the UI thread.
+ */
+ protected boolean requiresUIJob() {
+ return false;
+ }
+
+ /**
+ * Computes label attributes for the given element in the specified context.
+ *
+ * @param element element to compute label for
+ * @param context presentation context
+ * @param result monitor to report results to
+ */
+ protected void computeLabels(Object element, IPresentationContext context, ILabelRequestMonitor monitor) {
+ if (!monitor.isCanceled()) {
+ IStatus status = Status.OK_STATUS;
+ try {
+ monitor.setLabels(getLabels(element, context));
+ if (!monitor.isCanceled()) {
+ monitor.setImageDescriptors(getImageDescriptors(element, context));
+ }
+ if (!monitor.isCanceled()) {
+ monitor.setFontDatas(getFontDatas(element, context));
+ }
+ if (!monitor.isCanceled()) {
+ monitor.setBackgrounds(getBackgrounds(element, context));
+ }
+ if (!monitor.isCanceled()) {
+ monitor.setForegrounds(getForegrounds(element, context));
+ }
+ } catch (CoreException e) {
+ status = e.getStatus();
+ }
+ if (!monitor.isCanceled()) {
+ monitor.setStatus(status);
+ monitor.done();
+ }
+ }
+ }
+
+ /**
+ * Returns a label for the give element in the specified context.
+ *
+ * @param element element to compute label for
+ * @param context presentation context
+ * @return label
+ * @exception CoreException if an exception occurrs computing label
+ */
+ protected abstract String[] getLabels(Object element, IPresentationContext context) throws CoreException;
+
+ /**
+ * Returns an image descriptor for the given element in the specified context
+ * or <code>null</code>.
+ *
+ * @param element element to compute image descriptor for
+ * @param context presentation context
+ * @return image descriptor or <code>null</code>
+ * @throws CoreException if an exception occurrs computing image descriptor
+ */
+ protected abstract ImageDescriptor[] getImageDescriptors(Object element, IPresentationContext context) throws CoreException;
+
+ /**
+ * Returns font data for the given element in the specified context or <code>null</code>
+ * to use the default font.
+ *
+ * @param element element to compute font data for
+ * @param context presentation context
+ * @return font data or <code>null</code>
+ * @throws CoreException if an exception occurrs computing font data
+ */
+ protected abstract FontData[] getFontDatas(Object element, IPresentationContext context) throws CoreException;
+
+ /**
+ * Returns a foreground color for the given element in the specified context or <code>null</code>
+ * to use the default color.
+ *
+ * @param element element to compute color for
+ * @param context presentation context
+ * @return color or <code>null</code>
+ * @throws CoreException if an exception occurrs computing color
+ */
+ protected abstract RGB[] getForegrounds(Object element, IPresentationContext context) throws CoreException;
+
+ /**
+ * Returns a background color for the given element in the specified context or <code>null</code>
+ * to use the default color.
+ *
+ * @param element element to compute color for
+ * @param context presentation context
+ * @return color or <code>null</code>
+ * @throws CoreException if an exception occurrs computing color
+ */
+ protected abstract RGB[] getBackgrounds(Object element, IPresentationContext context) throws CoreException;
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousRequestMonitor.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousRequestMonitor.java
new file mode 100644
index 000000000..b80774c99
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousRequestMonitor.java
@@ -0,0 +1,194 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.viewers;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.swt.widgets.Widget;
+import org.eclipse.ui.progress.WorkbenchJob;
+
+/**
+ * Base implementation of an asynchronous request monitor.
+ * <p>
+ * Not intended to be subclassed or instantiated by clients. For internal use
+ * with the <code>AsynchronousTreeViewer</code> implementation.
+ * </p>
+ * @since 3.2
+ */
+abstract class AsynchronousRequestMonitor implements IAsynchronousRequestMonitor {
+
+ /**
+ * Widget the upadte is rooted at
+ */
+ private Widget fWidget;
+
+ /**
+ * Viewer the update is being performed for
+ */
+ private AsynchronousViewer fViewer;
+
+ /**
+ * Whether this request has been canelled
+ */
+ private boolean fCanceled = false;
+
+ /**
+ * Update request status or <code>null</code>
+ */
+ private IStatus fStatus = null;
+
+ /**
+ * Constructs an udpate rooted at the given item.
+ *
+ * @param item
+ */
+ AsynchronousRequestMonitor(Widget item, AsynchronousViewer viewer) {
+ fWidget = item;
+ fViewer = viewer;
+ }
+
+ /**
+ * Returns the viewer this update is being peformed for
+ *
+ * @return the viewer this update is being peformed for
+ */
+ protected AsynchronousViewer getViewer() {
+ return fViewer;
+ }
+
+ /**
+ * Returns the widget this update is rooted at
+ *
+ * @return the widget this update is rooted at
+ */
+ protected Widget getWidget() {
+ return fWidget;
+ }
+
+ /**
+ * Returns whether this update contains the given widget.
+ * That is, whether this update is for the same widget or a child of
+ * the given widget.
+ *
+ * @param widget widget to test containment on
+ * @return whether this update contains the given widget
+ */
+ protected boolean contains(Widget widget) {
+ if (widget == getWidget()) {
+ return true;
+ }
+ Widget parent = getViewer().getParent(widget);
+ while (parent != null) {
+ if (parent.equals(getWidget())) {
+ return true;
+ }
+ parent = getViewer().getParent(parent);
+ }
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.viewers.IAsynchronousRequestMonitor#setStatus(org.eclipse.core.runtime.IStatus)
+ */
+ public void setStatus(IStatus status) {
+ fStatus = status;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.runtime.IProgressMonitor#beginTask(java.lang.String, int)
+ */
+ public void beginTask(String name, int totalWork) {
+ // TODO Auto-generated method stub
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.runtime.IProgressMonitor#internalWorked(double)
+ */
+ public void internalWorked(double work) {
+ // TODO Auto-generated method stub
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.runtime.IProgressMonitor#isCanceled()
+ */
+ public boolean isCanceled() {
+ return fCanceled;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.runtime.IProgressMonitor#setCanceled(boolean)
+ */
+ public void setCanceled(boolean value) {
+ fCanceled = true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.runtime.IProgressMonitor#setTaskName(java.lang.String)
+ */
+ public void setTaskName(String name) {
+ // TODO Auto-generated method stub
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.runtime.IProgressMonitor#subTask(java.lang.String)
+ */
+ public void subTask(String name) {
+ // TODO Auto-generated method stub
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.runtime.IProgressMonitor#worked(int)
+ */
+ public void worked(int work) {
+ // TODO Auto-generated method stub
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.runtime.IProgressMonitor#done()
+ */
+ public final void done() {
+ if (!isCanceled()) {
+ WorkbenchJob job = new WorkbenchJob("AsynchronousRequestMonitor.done()") { //$NON-NLS-1$
+ public IStatus runInUIThread(IProgressMonitor monitor) {
+ // necessary to check if widget is disposed. The item may
+ // have been removed from the tree when another children update
+ // occured.
+ getViewer().updateComplete(AsynchronousRequestMonitor.this);
+ if (!isCanceled() && !getWidget().isDisposed()) {
+ if (fStatus != null && !fStatus.isOK()) {
+ getViewer().handlePresentationFailure(AsynchronousRequestMonitor.this, fStatus);
+ }
+ performUpdate();
+ }
+ return Status.OK_STATUS;
+ }
+ };
+ job.setSystem(true);
+ job.schedule();
+ }
+ }
+
+ /**
+ * Notification this update has been completed and should now be applied to
+ * this update's viewer. This method is called in the UI thread.
+ */
+ protected abstract void performUpdate();
+
+ /**
+ * Returns whether this update effectively contains the given update.
+ * That is, whether this update will also perform the given update.
+ *
+ * @param update update to compare to
+ * @return whether this update will also perform the given update
+ */
+ protected abstract boolean contains(AsynchronousRequestMonitor update);
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousTreeContentAdapter.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousTreeContentAdapter.java
new file mode 100644
index 000000000..add2918e8
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousTreeContentAdapter.java
@@ -0,0 +1,149 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.debug.internal.ui.viewers;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.debug.ui.IDebugUIConstants;
+import org.eclipse.ui.IWorkbenchPart;
+
+/**
+ * Abstract implementation of an asynchronous tree contenxt adapter.
+ * <p>
+ * Clients may subclass this class.
+ * </p>
+ * @since 3.2
+ */
+public abstract class AsynchronousTreeContentAdapter implements IAsynchronousTreeContentAdapter {
+
+ protected static final Object[] EMPTY = new Object[0];
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.viewers.IAsynchronousTreeContentAdapter#retrieveChildren(java.lang.Object, org.eclipse.debug.ui.viewers.IPresentationContext, org.eclipse.debug.ui.viewers.IChildrenRequestMonitor)
+ */
+ public void retrieveChildren(final Object parent, final IPresentationContext context, final IChildrenRequestMonitor result) {
+ Job job = new Job("Retrieving Children") { //$NON-NLS-1$
+ protected IStatus run(IProgressMonitor monitor) {
+ if (!monitor.isCanceled()) {
+ computeChildren(parent, context, result);
+ }
+ return Status.OK_STATUS;
+ }
+ };
+ job.setSystem(true);
+ job.schedule();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.viewers.IAsynchronousTreeContentAdapter#isContainer(java.lang.Object, org.eclipse.debug.ui.viewers.IPresentationContext, org.eclipse.debug.ui.viewers.IContainerRequestMonitor)
+ */
+ public void isContainer(final Object element, final IPresentationContext context, final IContainerRequestMonitor result) {
+ Job job = new Job("Computing hasChildren") { //$NON-NLS-1$
+ protected IStatus run(IProgressMonitor monitor) {
+ if (!monitor.isCanceled()) {
+ computeIsContainer(element, context, result);
+ }
+ return Status.OK_STATUS;
+ }
+ };
+ job.setSystem(true);
+ job.schedule();
+ }
+
+ /**
+ * Computes the children for the given parent in the specified context.
+ *
+ * @param parent parent to retrieve children for
+ * @param context presentation contenxt
+ * @param monitor result to report to
+ */
+ protected void computeChildren(Object parent, IPresentationContext context, IChildrenRequestMonitor monitor) {
+ if (!monitor.isCanceled()) {
+ IStatus status = Status.OK_STATUS;
+ try {
+ if (supportsContext(context)) {
+ monitor.addChildren(getChildren(parent, context));
+ }
+ } catch (CoreException e) {
+ status = e.getStatus();
+ }
+ monitor.setStatus(status);
+ monitor.done();
+ }
+ }
+
+ /**
+ * Computes whether the given element is a container.
+ *
+ * @param parent potential parent
+ * @param context presentation contenxt
+ * @param monitor result to report to
+ */
+ protected void computeIsContainer(Object parent, IPresentationContext context, IContainerRequestMonitor monitor) {
+ if (!monitor.isCanceled()) {
+ IStatus status = Status.OK_STATUS;
+ try {
+ monitor.setIsContainer(hasChildren(parent, context));
+ } catch (CoreException e) {
+ status = e.getStatus();
+ }
+ monitor.setStatus(status);
+ monitor.done();
+ }
+ }
+
+ /**
+ * Returns the children for the given parent in the specified context.
+ *
+ * @param parent element to retrieve children for
+ * @param context context children will be presented in
+ * @return children
+ * @throws CoreException if an exception occurrs retieving children
+ */
+ protected abstract Object[] getChildren(Object parent, IPresentationContext context) throws CoreException;
+
+ /**
+ * Returns whether the given element has children in the specified context.
+ *
+ * @param element element that may have children
+ * @param context context element will be presented in
+ * @return whether the given element has children in the specified context
+ * @throws CoreException if an exception occurrs determining whether the
+ * element has children
+ */
+ protected abstract boolean hasChildren(Object element, IPresentationContext context) throws CoreException;
+
+ /**
+ * Returns whether this adapter supports the given context.
+ *
+ * @param context
+ * @return whether this adapter supports the given context
+ */
+ protected boolean supportsContext(IPresentationContext context) {
+ IWorkbenchPart part = context.getPart();
+ if (part != null) {
+ return supportsPartId(part.getSite().getId());
+ }
+ return true;
+ }
+
+ /**
+ * Returns whether this adapter provides content in the specified part.
+ *
+ * @param id part id
+ * @return whether this adapter provides content in the specified part
+ */
+ protected abstract boolean supportsPartId(String id);
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousTreeViewer.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousTreeViewer.java
new file mode 100644
index 000000000..1866a5623
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousTreeViewer.java
@@ -0,0 +1,892 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.viewers;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.ViewerSorter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseListener;
+import org.eclipse.swt.events.TreeEvent;
+import org.eclipse.swt.events.TreeListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.swt.widgets.Widget;
+import org.eclipse.ui.progress.WorkbenchJob;
+
+/**
+ * A tree viewer that retrieves children and labels asynchronously via adapters
+ * and supports duplicate elements in the tree with different parents.
+ * Retrieving children and labels asynchrnously allows for arbitrary latency
+ * without blocking the UI thread.
+ * <p>
+ * TODO: tree editor not implemented TODO: table tree - what implications does
+ * it have on IPresentationAdapter?
+ *
+ * TODO: Deprecate the public/abstract deferred workbench adapter in favor of
+ * the presentation adapter.
+ * </p>
+ * <p>
+ * Clients may instantiate and subclass this class.
+ * </p>
+ *
+ * @since 3.2
+ */
+public class AsynchronousTreeViewer extends AsynchronousViewer {
+
+ /**
+ * A map of widget to parent widgets used to avoid requirement for parent
+ * access in UI thread. Currently used by update objects to detect/cancel
+ * updates on updates of children.
+ */
+ private Map fItemToParentItem = new HashMap();
+
+ /**
+ * The tree
+ */
+ private Tree fTree;
+
+ /**
+ * Array of tree paths to be expanded. As paths are expanded, those entries
+ * are set to <code>null</code>.
+ */
+ private TreePath[] fPendingExpansion;
+
+ /**
+ * Creates an asynchronous tree viewer on a newly-created tree control under
+ * the given parent. The tree control is created using the SWT style bits
+ * <code>MULTI, H_SCROLL, V_SCROLL,</code> and <code>BORDER</code>. The
+ * viewer has no input, no content provider, a default label provider, no
+ * sorter, and no filters.
+ *
+ * @param parent the parent control
+ */
+ public AsynchronousTreeViewer(Composite parent) {
+ this(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
+ }
+
+ /**
+ * Creates an asynchronous tree viewer on a newly-created tree control under
+ * the given parent. The tree control is created using the given SWT style
+ * bits. The viewer has no input.
+ *
+ * @param parent the parent control
+ * @param style the SWT style bits used to create the tree.
+ */
+ public AsynchronousTreeViewer(Composite parent, int style) {
+ this(new Tree(parent, style));
+ }
+
+ /**
+ * Creates an asynchronous tree viewer on the given tree control. The viewer
+ * has no input, no content provider, a default label provider, no sorter,
+ * and no filters.
+ *
+ * @param tree the tree control
+ */
+ public AsynchronousTreeViewer(Tree tree) {
+ super();
+ fTree = tree;
+ hookControl(fTree);
+ setUseHashlookup(false);
+ tree.addTreeListener(new TreeListener() {
+ public void treeExpanded(TreeEvent e) {
+ ((TreeItem) e.item).setExpanded(true);
+ internalRefresh(e.item.getData(), e.item);
+ }
+
+ public void treeCollapsed(TreeEvent e) {
+ }
+ });
+ tree.addMouseListener(new MouseListener() {
+
+ public void mouseUp(MouseEvent e) {
+ }
+
+ public void mouseDown(MouseEvent e) {
+ }
+
+ public void mouseDoubleClick(MouseEvent e) {
+ TreeItem item = ((Tree) e.widget).getItem(new Point(e.x, e.y));
+ if (item != null) {
+ if (item.getExpanded()) {
+ item.setExpanded(false);
+ } else {
+ item.setExpanded(true);
+ internalRefresh(item.getData(), item);
+ }
+ }
+ }
+ });
+ }
+
+ /**
+ * Returns the tree control for this viewer.
+ *
+ * @return the tree control for this viewer
+ */
+ public Tree getTree() {
+ return fTree;
+ }
+
+ /**
+ * Updates whether the given element has children.
+ *
+ * @param element element to update
+ * @param widget widget associated with the element in this viewer's tree
+ */
+ protected void updateHasChildren(Object element, Widget widget) {
+ IAsynchronousTreeContentAdapter adapter = getTreeContentAdapter(element);
+ if (adapter != null) {
+ IContainerRequestMonitor update = new ContainerRequestMonitor(widget, this);
+ schedule(update);
+ adapter.isContainer(element, getPresentationContext(), update);
+ }
+ }
+
+ /**
+ * Updates the children of the given element.
+ *
+ * @param parent element of which to update children
+ * @param widget widget associated with the element in this viewer's tree
+ */
+ protected void updateChildren(Object parent, Widget widget) {
+ IAsynchronousTreeContentAdapter adapter = getTreeContentAdapter(parent);
+ if (adapter != null) {
+ IChildrenRequestMonitor update = new ChildrenRequestMonitor(widget, this);
+ schedule(update);
+ adapter.retrieveChildren(parent, getPresentationContext(), update);
+ }
+ }
+
+ /**
+ * Returns the tree element adapter for the given element or
+ * <code>null</code> if none.
+ *
+ * @param element element to retrieve adapter for
+ * @return presentation adapter or <code>null</code>
+ */
+ protected IAsynchronousTreeContentAdapter getTreeContentAdapter(Object element) {
+ IAsynchronousTreeContentAdapter adapter = null;
+ if (element instanceof IAsynchronousTreeContentAdapter) {
+ adapter = (IAsynchronousTreeContentAdapter) element;
+ } else if (element instanceof IAdaptable) {
+ IAdaptable adaptable = (IAdaptable) element;
+ adapter = (IAsynchronousTreeContentAdapter) adaptable.getAdapter(IAsynchronousTreeContentAdapter.class);
+ }
+ return adapter;
+ }
+
+ /**
+ * Expands all elements in the given tree selection.
+ *
+ * @param selection
+ */
+ public synchronized void expand(ISelection selection) {
+ if (selection instanceof TreeSelection) {
+ fPendingExpansion = ((TreeSelection) selection).getPaths();
+ if (getControl().getDisplay().getThread() == Thread.currentThread()) {
+ attemptExpansion();
+ } else {
+ WorkbenchJob job = new WorkbenchJob("attemptExpansion") { //$NON-NLS-1$
+ public IStatus runInUIThread(IProgressMonitor monitor) {
+ attemptExpansion();
+ return Status.OK_STATUS;
+ }
+
+ };
+ job.setSystem(true);
+ job.schedule();
+ }
+ }
+ }
+
+ /**
+ * Attempts to expand all pending expansions.
+ */
+ synchronized void attemptExpansion() {
+ if (fPendingExpansion != null) {
+ for (int i = 0; i < fPendingExpansion.length; i++) {
+ TreePath path = fPendingExpansion[i];
+ if (path != null && attemptExpansion(path)) {
+ fPendingExpansion[i] = null;
+ }
+ }
+ }
+ }
+
+ /**
+ * Attempts to expand the given tree path and returns whether the expansion
+ * was completed.
+ *
+ * @param path path to exapand
+ * @return whether the expansion was completed
+ */
+ synchronized boolean attemptExpansion(TreePath path) {
+ int segmentCount = path.getSegmentCount();
+ for (int j = segmentCount - 1; j >= 0; j--) {
+ Object element = path.getSegment(j);
+ Widget[] treeItems = getWidgets(element);
+ if (treeItems != null) {
+ for (int k = 0; k < treeItems.length; k++) {
+ if (treeItems[k] instanceof TreeItem) {
+ TreeItem treeItem = (TreeItem) treeItems[k];
+ TreePath treePath = getTreePath(treeItem);
+ if (path.startsWith(treePath)) {
+ if (!treeItem.getExpanded() && treeItem.getItemCount() > 0) {
+ update(element);
+ updateChildren(element, treeItem);
+ expand(treeItem);
+ if (path.getSegmentCount() == treePath.getSegmentCount()) {
+ return true;
+ }
+ return false;
+ }
+ }
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.Viewer#getControl()
+ */
+ public Control getControl() {
+ return fTree;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.StructuredViewer#unmapAllElements()
+ */
+ protected synchronized void unmapAllElements() {
+ super.unmapAllElements();
+ fItemToParentItem.clear();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.Viewer#inputChanged(java.lang.Object,
+ * java.lang.Object)
+ */
+ protected void inputChanged(Object input, Object oldInput) {
+ super.inputChanged(input, oldInput);
+ map(input, fTree);
+ refresh();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.debug.ui.viewers.AsynchronousViewer#map(java.lang.Object,
+ * org.eclipse.swt.widgets.Widget)
+ */
+ protected void map(Object element, Widget item) {
+ super.map(element, item);
+ if (item instanceof TreeItem) {
+ TreeItem treeItem = (TreeItem) item;
+ TreeItem parentItem = treeItem.getParentItem();
+ if (parentItem != null) {
+ fItemToParentItem.put(treeItem, parentItem);
+ }
+ }
+ }
+
+ /**
+ * Returns all paths to the given element or <code>null</code> if none.
+ *
+ * @param element
+ * @return paths to the given element or <code>null</code>
+ */
+ public synchronized TreePath[] getTreePaths(Object element) {
+ Widget[] widgets = getWidgets(element);
+ if (widgets == null) {
+ return null;
+ }
+ TreePath[] paths = new TreePath[widgets.length];
+ for (int i = 0; i < widgets.length; i++) {
+ List path = new ArrayList();
+ path.add(element);
+ Widget widget = widgets[i];
+ TreeItem parent = null;
+ if (widget instanceof TreeItem) {
+ TreeItem treeItem = (TreeItem) widget;
+ parent = getParentItem(treeItem);
+ }
+ while (parent != null) {
+ Object data = getElement(parent);
+ if (data == null) {
+ // if the parent is unmapped while attempting selection
+ return null;
+ }
+ path.add(0, data);
+ parent = getParentItem(parent);
+ }
+ path.add(0, getInput());
+ paths[i] = new TreePath(path.toArray());
+ if (widget instanceof TreeItem) {
+ paths[i].setTreeItem((TreeItem) widget);
+ }
+ }
+ return paths;
+ }
+
+ /**
+ * Constructs and returns a tree path for the given item. Must be called
+ * from the UI thread.
+ *
+ * @param item item to constuct a path for
+ * @return tree path for the item
+ */
+ protected TreePath getTreePath(TreeItem item) {
+ TreeItem parent = item;
+ List path = new ArrayList();
+ while (parent != null) {
+ path.add(0, parent.getData());
+ parent = parent.getParentItem();
+ }
+ path.add(0, fTree.getData());
+ return new TreePath(path.toArray());
+ }
+
+ /**
+ * Called by <code>ContainerRequestMonitor</code> after it is determined
+ * if the widget contains children.
+ *
+ * @param widget
+ * @param containsChildren
+ */
+ synchronized void setIsContainer(Widget widget, boolean containsChildren) {
+ TreeItem[] prevChildren = null;
+ if (widget instanceof Tree) {
+ Tree tree = (Tree) widget;
+ prevChildren = tree.getItems();
+ } else {
+ prevChildren = ((TreeItem) widget).getItems();
+ }
+ if (containsChildren) {
+ if (prevChildren.length == 0) {
+ if (widget instanceof Tree) {
+ // update root elements in the tree
+ updateChildren(widget.getData(), widget);
+ } else {
+ // insert new dummy node to add +
+ newTreeItem(widget, 0);
+ if (((TreeItem) widget).getExpanded()) {
+ updateChildren(widget.getData(), widget);
+ }
+ }
+ } else {
+ if (widget instanceof Tree || ((TreeItem) widget).getExpanded()) {
+ // if expanded, update the children
+ updateChildren(widget.getData(), widget);
+ }
+ }
+ } else if (prevChildren.length > 0) {
+ // dispose previous children
+ for (int i = 0; i < prevChildren.length; i++) {
+ TreeItem prevChild = prevChildren[i];
+ unmap(prevChild.getData(), prevChild);
+ prevChild.dispose();
+ }
+ }
+ attemptExpansion();
+ }
+
+ /**
+ * Called by <code>ChildrenRequestMonitor</code> after children have been
+ * retrieved.
+ *
+ * @param widget
+ * @param newChildren
+ */
+ synchronized void setChildren(final Widget widget, final List newChildren) {
+ preservingSelection(new Runnable() {
+
+ public void run() {
+ // apply filters
+ Object[] children = filter(newChildren.toArray());
+
+ // sort filtered children
+ ViewerSorter viewerSorter = getSorter();
+ if (viewerSorter != null) {
+ viewerSorter.sort(AsynchronousTreeViewer.this, children);
+ }
+
+ // update tree
+ TreeItem[] prevItems = null;
+ if (widget instanceof Tree) {
+ Tree tree = (Tree) widget;
+ prevItems = tree.getItems();
+ } else {
+ prevItems = ((TreeItem) widget).getItems();
+ }
+
+ int index = 0;
+ for (; index < children.length; index++) {
+ Object kid = children[index];
+ TreeItem item = null;
+ if (index < prevItems.length) {
+ item = prevItems[index];
+ Object oldData = item.getData();
+ if (kid.equals(oldData)) {
+ if (kid != oldData) {
+ // if equal but not identical, remap the element
+ remap(kid, item);
+ }
+ } else {
+ unmap(oldData, item);
+ map(kid, item);
+ }
+ } else {
+ item = newTreeItem(widget, index);
+ map(kid, item);
+ }
+ internalRefresh(kid, item);
+ }
+ // remove left over old items
+ while (index < prevItems.length) {
+ TreeItem oldItem = prevItems[index];
+ unmap(oldItem.getData(), oldItem);
+ oldItem.dispose();
+ index++;
+ }
+ }
+
+ });
+
+ attemptExpansion();
+ attemptSelection(true);
+ }
+
+ /**
+ * Expands the given tree item and all of its parents. Does *not* update
+ * elements or retrieve children.
+ *
+ * @param child item to expand
+ */
+ private void expand(TreeItem child) {
+ if (!child.getExpanded()) {
+ child.setExpanded(true);
+
+ TreeItem parent = child.getParentItem();
+ if (parent != null) {
+ expand(parent);
+ }
+ }
+ }
+
+ /**
+ * Creates a new tree item as a child of the given widget at the specified
+ * index.
+ *
+ * @param parent parent widget - a Tree or TreeItem
+ * @param index index at which to create new child
+ * @return tree item
+ */
+ protected TreeItem newTreeItem(Widget parent, int index) {
+ if (parent instanceof Tree) {
+ return new TreeItem((Tree) parent, SWT.NONE, index);
+ }
+ return new TreeItem((TreeItem) parent, SWT.NONE, index);
+ }
+
+ /**
+ * Unmaps the given item, and unmaps and disposes of all children of that
+ * item. Does not dispose of the given item.
+ *
+ * @param kid
+ * @param oldItem
+ */
+ protected synchronized void unmap(Object kid, Widget widget) {
+ if (kid == null) {
+ // when unmapping a dummy item
+ return;
+ }
+
+ TreeItem[] selection = fTree.getSelection();
+ if (selection.length == 1 && isChild(widget, selection[0])) {
+ setSelection(null);
+ }
+
+ super.unmap(kid, widget);
+ fItemToParentItem.remove(widget);
+ if (widget instanceof TreeItem) {
+ TreeItem item = (TreeItem) widget;
+ TreeItem[] children = item.getItems();
+ for (int i = 0; i < children.length; i++) {
+ TreeItem child = children[i];
+ unmap(child.getData(), child);
+ child.dispose();
+ }
+ }
+ }
+
+ private boolean isChild(Widget parent, TreeItem child) {
+ if (child==null) {
+ return false;
+ } else if (parent == child) {
+ return true;
+ }
+ return isChild(parent, child.getParentItem());
+ }
+
+ /**
+ * Returns the parent item for an item or <code>null</code> if none.
+ *
+ * @param item item for which parent is requested
+ * @return parent item or <code>null</code>
+ */
+ protected synchronized TreeItem getParentItem(TreeItem item) {
+ return (TreeItem) fItemToParentItem.get(item);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.StructuredViewer#doFindInputItem(java.lang.Object)
+ */
+ protected Widget doFindInputItem(Object element) {
+ if (element.equals(getInput())) {
+ return fTree;
+ }
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.StructuredViewer#doFindItem(java.lang.Object)
+ */
+ protected Widget doFindItem(Object element) {
+ Widget[] widgets = getWidgets(element);
+ if (widgets != null && widgets.length > 0) {
+ return widgets[0];
+ }
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.ISelectionProvider#getSelection()
+ */
+ public ISelection getSelection() {
+ Control control = getControl();
+ if (control == null || control.isDisposed()) {
+ return StructuredSelection.EMPTY;
+ }
+ List list = getSelectionFromWidget();
+ return new TreeSelection((TreePath[]) list.toArray());
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.StructuredViewer#getSelectionFromWidget()
+ */
+ protected List getSelectionFromWidget() {
+ TreeItem[] selection = fTree.getSelection();
+ TreePath[] paths = new TreePath[selection.length];
+ for (int i = 0; i < selection.length; i++) {
+ paths[i] = getTreePath(selection[i]);
+ }
+ return Arrays.asList(paths);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.debug.ui.viewers.AsynchronousViewer#internalRefresh(java.lang.Object,
+ * org.eclipse.swt.widgets.Widget)
+ */
+ protected void internalRefresh(Object element, Widget item) {
+ super.internalRefresh(element, item);
+ updateHasChildren(element, item);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.StructuredViewer#reveal(java.lang.Object)
+ */
+ public void reveal(Object element) {
+ Widget[] widgets = getWidgets(element);
+ if (widgets != null && widgets.length > 0) {
+ // TODO: only reveals the first occurrence - should we reveal all?
+ TreeItem item = (TreeItem) widgets[0];
+ Tree tree = (Tree) getControl();
+ tree.showItem(item);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.debug.ui.viewers.AsynchronousViewer#doAttemptSelectionToWidget(org.eclipse.jface.viewers.ISelection,
+ * boolean)
+ */
+ protected synchronized ISelection doAttemptSelectionToWidget(ISelection selection, boolean reveal) {
+ List remaining = new ArrayList();
+ if (!selection.isEmpty()) {
+ List toSelect = new ArrayList();
+ List theElements = new ArrayList();
+ TreeSelection treeSelection = (TreeSelection) selection;
+ TreePath[] paths = treeSelection.getPaths();
+ for (int i = 0; i < paths.length; i++) {
+ TreePath path = paths[i];
+ if (path == null) {
+ continue;
+ }
+ TreePath[] treePaths = getTreePaths(path.getLastSegment());
+ boolean selected = false;
+ if (treePaths != null) {
+ for (int j = 0; j < treePaths.length; j++) {
+ TreePath existingPath = treePaths[j];
+ if (existingPath.equals(path)) {
+ TreeItem treeItem = existingPath.getTreeItem();
+ toSelect.add(treeItem);
+ theElements.add(path.getLastSegment());
+ selected = true;
+ break;
+ }
+ }
+ }
+ if (!selected) {
+ remaining.add(path);
+ }
+ }
+ if (!toSelect.isEmpty()) {
+ final TreeItem[] items = (TreeItem[]) toSelect.toArray(new TreeItem[toSelect.size()]);
+ // TODO: hack to ensure selection contains 'selected' element
+ // instead of 'equivalent' element. Handles synch problems
+ // between
+ // set selection & refresh
+ for (int i = 0; i < items.length; i++) {
+ TreeItem item = items[i];
+ Object element = theElements.get(i);
+ if (item.getData() != element) {
+ remap(element, item);
+ }
+ }
+ fTree.setSelection(items);
+ if (reveal) {
+ fTree.showItem(items[0]);
+ }
+ }
+ } else {
+ fTree.setSelection(new TreeItem[0]);
+ }
+ return new TreeSelection((TreePath[]) remaining.toArray(new TreePath[remaining.size()]));
+ }
+
+ /**
+ * Collapses all items in the tree.
+ */
+ public void collapseAll() {
+ TreeItem[] items = fTree.getItems();
+ for (int i = 0; i < items.length; i++) {
+ TreeItem item = items[i];
+ if (item.getExpanded())
+ collapse(item);
+ }
+ }
+
+ /**
+ * Collaspes the given item and all of its children items.
+ *
+ * @param item item to collapose recursively
+ */
+ protected void collapse(TreeItem item) {
+ TreeItem[] items = item.getItems();
+ for (int i = 0; i < items.length; i++) {
+ TreeItem child = items[i];
+ if (child.getExpanded()) {
+ collapse(child);
+ }
+ }
+ item.setExpanded(false);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.debug.ui.viewers.AsynchronousViewer#setColor(org.eclipse.swt.widgets.Widget,
+ * org.eclipse.swt.graphics.RGB, org.eclipse.swt.graphics.RGB)
+ */
+ void setColors(Widget widget, RGB[] foregrounds, RGB[] backgrounds) {
+ if (widget instanceof TreeItem) {
+ TreeItem item = (TreeItem) widget;
+ Color[] fgs = getColor(foregrounds);
+ Color[] bgs = getColor(backgrounds);
+ for (int i = 0; i < bgs.length; i++) {
+ item.setForeground(i, fgs[i]);
+ item.setBackground(i, bgs[i]);
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.debug.ui.viewers.AsynchronousViewer#setFont(org.eclipse.swt.widgets.Widget,
+ * org.eclipse.swt.graphics.FontData)
+ */
+ void setFonts(Widget widget, FontData[] fontData) {
+ if (widget instanceof TreeItem) {
+ TreeItem item = (TreeItem) widget;
+ Font[] fonts = getFonts(fontData);
+ for (int i = 0; i < fonts.length; i++) {
+ item.setFont(i, fonts[i]);
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.debug.ui.viewers.AsynchronousViewer#getParent(org.eclipse.swt.widgets.Widget)
+ */
+ protected Widget getParent(Widget widget) {
+ return (Widget) fItemToParentItem.get(widget);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.debug.ui.viewers.AsynchronousViewer#acceptsSelection(org.eclipse.jface.viewers.ISelection)
+ */
+ protected boolean acceptsSelection(ISelection selection) {
+ return selection instanceof TreeSelection;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.debug.ui.viewers.AsynchronousViewer#getEmptySelection()
+ */
+ protected ISelection getEmptySelection() {
+ return new TreeSelection(new TreePath[0]);
+ }
+
+ public void add(final TreePath treePath) {
+ WorkbenchJob job = new WorkbenchJob("AsynchronousTreeViewer.add()") { //$NON-NLS-1$
+ public IStatus runInUIThread(IProgressMonitor monitor) {
+ Widget widget = getTree();
+ for (int i = 0; i < treePath.getSegmentCount(); i++) {
+ Object segment = treePath.getSegment(i);
+ if (!segment.equals(getInput())) {
+ Widget child = findChild(widget, segment, true);
+ if (child == null) {
+ return Status.OK_STATUS;
+ }
+ widget = child;
+ }
+ }
+ return Status.OK_STATUS;
+ }
+ };
+
+ job.setSystem(true);
+ job.schedule();
+ }
+
+ private Widget findChild(Widget widget, Object segment, boolean create) {
+ TreeItem[] items = null;
+ if (widget instanceof Tree) {
+ items = ((Tree) widget).getItems();
+ } else if (widget instanceof TreeItem) {
+ items = ((TreeItem) widget).getItems();
+ }
+
+ if (items != null) {
+ for (int i = 0; i < items.length; i++) {
+ TreeItem item = items[i];
+ if (segment.equals(item.getData())) {
+ return item;
+ }
+ }
+ }
+
+ if (create) {
+ // child doesn't exist. create it.
+ List datas = new ArrayList();
+ for (int i = 0; i < items.length; i++) {
+ Object data = items[i].getData();
+ if (data != null)
+ datas.add(data);
+ }
+ datas.add(segment);
+ setChildren(widget, datas);
+
+ // search for the new child and return it...
+ Widget child = findChild(widget, segment, false);
+ return child;
+ }
+
+ return null;
+ }
+
+ public void remove(final TreePath treePath) {
+ WorkbenchJob job = new WorkbenchJob("AsynchronousTreeViewer.remove()") { //$NON-NLS-1$
+ public IStatus runInUIThread(IProgressMonitor monitor) {
+ Object lastSegment = treePath.getLastSegment();
+ TreePath[] treePaths = getTreePaths(lastSegment);
+ if (treePaths != null) {
+ for (int i = 0; i < treePaths.length; i++) {
+ TreePath path = treePaths[i];
+ if (path.equals(treePath)) {
+ TreeItem treeItem = path.getTreeItem();
+ unmap(lastSegment, treeItem);
+ treeItem.dispose();
+ }
+ }
+ }
+ return Status.OK_STATUS;
+ }
+ };
+
+ }
+
+ void setLabels(Widget widget, String[] text, ImageDescriptor[] image) {
+ if (widget instanceof TreeItem) {
+ TreeItem item = (TreeItem) widget;
+ item.setText(text);
+ item.setImage(getImages(image));
+ }
+ }
+
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousViewer.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousViewer.java
new file mode 100644
index 000000000..085581f3c
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousViewer.java
@@ -0,0 +1,894 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.viewers;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.internal.ui.elements.adapters.AsynchronousDebugLabelAdapter;
+import org.eclipse.debug.internal.ui.viewers.update.DefaultUpdatePolicy;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Item;
+import org.eclipse.swt.widgets.Widget;
+import org.eclipse.ui.progress.WorkbenchJob;
+
+/**
+ * A viewer that retrieves labels and content asynchronously via adapters and supports
+ * duplicate elements in the viewer. Retrieving conetnt and labels asynchrnously allows
+ * for arbitrary latency without blocking the UI thread.
+ * <p>
+ * This viewer uses adapters to retreive labels and content rather than
+ * a label provider and content provider. As such, the label provider for this viewer
+ * is <code>null</code> by default. The content provider returned by this viewer is
+ * non-<code>null</code> to conform to the viewer specification, but performs no
+ * useful function.
+ * </p>
+ * <p>
+ * The selection in this viewer is also set asynchronously. When the selection is set,
+ * the viewer attempts to perform the selection. If the elements in the specified selection
+ * are not yet in the viewer, the portion of the selection that could not be honored
+ * becomes a pending selection. As more elements are added to viewer, the pending selection
+ * is attempted to be set.
+ * </p>
+ * @since 3.2
+ */
+public abstract class AsynchronousViewer extends StructuredViewer {
+
+ /**
+ * A map of elements to associated tree items or tree
+ */
+ private Map fElementsToWidgets = new HashMap();
+
+ /**
+ * Map of widgets to their data elements used to avoid requirement to access
+ * data in UI thread.
+ */
+ private Map fWidgetsToElements = new HashMap();
+
+ /**
+ * List of updates currently being performed.
+ */
+ private List fPendingUpdates = new ArrayList();
+
+ /**
+ * Cache of images used for elements in this tree viewer. Label updates
+ * use the method <code>getImage(...)</code> to cache images for
+ * image descriptors. The images are disposed when this viewer is disposed.
+ */
+ private Map fImageCache = new HashMap();
+
+ /**
+ * Cache of the fonts used for elements in this tree viewer. Label updates
+ * use the method <code>getFont(...)</code> to cache fonts for
+ * FontData objects. The fonts are disposed with the viewer.
+ */
+ private Map fFontCache = new HashMap();
+
+ /**
+ * Cache of the colors used for elements in this tree viewer. Label updates
+ * use the method <code>getColor(...)</code> to cache colors for
+ * RGB values. The colors are disposed with the viewer.
+ */
+ private Map fColorCache = new HashMap();
+
+ /**
+ * The context in which this viewer is being used - i.e. what part it is contained
+ * in any any preference settings associated with it.
+ */
+ private IPresentationContext fContext;
+
+ private ISelection fPendingSelection;
+
+ private ISelection fCurrentSelection;
+
+ /**
+ * The update policy for this viewer.
+ */
+ private IUpdatePolicy fUpdatePolicy;
+
+ /**
+ * Cache of update policies keyed by element
+ */
+ private Map fModelProxies = new HashMap();
+
+ /**
+ * Creates a presentation adapter viewer
+ */
+ protected AsynchronousViewer() {
+ setContentProvider(new NullContentProvider());
+ createUpdatePolicy();
+ }
+
+ /**
+ * Clients must call this methods when this viewer is no longer needed
+ * so it can perform cleanup.
+ */
+ public synchronized void dispose() {
+ Iterator images = fImageCache.values().iterator();
+ while (images.hasNext()) {
+ Image image = (Image) images.next();
+ image.dispose();
+ }
+ fImageCache.clear();
+
+ Iterator fonts = fFontCache.values().iterator();
+ while (fonts.hasNext()) {
+ Font font = (Font) fonts.next();
+ font.dispose();
+ }
+ fFontCache.clear();
+
+ Iterator colors = fColorCache.values().iterator();
+ while (colors.hasNext()) {
+ Color color = (Color) colors.next();
+ color.dispose();
+ }
+ fColorCache.clear();
+
+ disposeAllModelProxies();
+ fUpdatePolicy.dispose();
+
+ unmapAllElements();
+ fPendingUpdates.clear();
+ }
+
+ /**
+ * Unintalls all update policies installed in this viewer
+ */
+ private void disposeAllModelProxies() {
+ Iterator updatePolicies = fModelProxies.values().iterator();
+ while (updatePolicies.hasNext()) {
+ IModelProxy proxy = (IModelProxy)updatePolicies.next();
+ proxy.dispose();
+ }
+ fModelProxies.clear();
+ }
+
+ /**
+ * Updates all occurrences of the given element in this viewer.
+ *
+ * @param element element to update
+ */
+ public void update(Object element) {
+ if (element == getInput()) {
+ return; // the input is not displayed
+ }
+ Widget[] items = getWidgets(element);
+ if (items != null) {
+ for (int i = 0; i < items.length; i++) {
+ updateLabel(element, items[i]);
+ }
+ }
+ }
+
+ /**
+ * Updates the label for a specific element and item.
+ *
+ * @param element element to update
+ * @param item its associated item
+ */
+ protected void updateLabel(Object element, Widget item) {
+ if (item instanceof Item) {
+ IAsynchronousLabelAdapter adapter = getLabelAdapter(element);
+ if (adapter != null) {
+ ILabelRequestMonitor labelUpdate = new LabelRequestMonitor(item, this);
+ schedule(labelUpdate);
+ adapter.retrieveLabel(element, getPresentationContext(), labelUpdate);
+ }
+ }
+ }
+
+ /**
+ * Returns the presentation context to be used in update requests.
+ * Clients may override this method if required to provide special
+ * implementations of contexts.
+ *
+ * @return presentation contenxt
+ */
+ public IPresentationContext getPresentationContext() {
+ return fContext;
+ }
+
+// /**
+// * Refreshes all occurrences of the given element in this tree, and visible
+// * children.
+// *
+// * @param element element to refresh
+// */
+// public void refresh(final Object element) {
+// // TODO: preserving selection currently has to be UI thread
+//// preservingSelection(new Runnable() {
+//// public void run() {
+// internalRefresh(element);
+//// }
+//// });
+// }
+
+ /**
+ * Returns the label adapter for the given element or <code>null</code> if none.
+ *
+ * @param element element to retrieve adapter for
+ * @return presentation adapter or <code>null</code>
+ */
+ protected IAsynchronousLabelAdapter getLabelAdapter(Object element) {
+ IAsynchronousLabelAdapter adapter = null;
+ if (element instanceof IAsynchronousLabelAdapter) {
+ adapter = (IAsynchronousLabelAdapter) element;
+ } else if (element instanceof IAdaptable) {
+ IAdaptable adaptable = (IAdaptable) element;
+ adapter = (IAsynchronousLabelAdapter) adaptable.getAdapter(IAsynchronousLabelAdapter.class);
+ }
+ // if no adapter, use default (i.e. model presentation)
+ if (adapter == null) {
+ return new AsynchronousDebugLabelAdapter();
+ }
+ return adapter;
+ }
+
+ /**
+ * Returns the update policy adapter for the given element or <code>null</code> if none.
+ *
+ * @param element element to retrieve adapter for
+ * @return update policy adapter or <code>null</code>
+ */
+// protected IUpdatePolicyFactory getUpdatePolicyAdapter(Object element) {
+// IUpdatePolicyFactory adapter = null;
+// if (element instanceof IUpdatePolicyFactory) {
+// adapter = (IUpdatePolicyFactory) element;
+// } else if (element instanceof IAdaptable) {
+// IAdaptable adaptable = (IAdaptable) element;
+// adapter = (IUpdatePolicyFactory) adaptable.getAdapter(IUpdatePolicyFactory.class);
+// }
+// return adapter;
+// }
+
+ /**
+ * Returns the model proxy factory for the given element of <code>null</code> if none.
+ *
+ * @param element element to retrieve adapters for
+ * @return model proxy factory adapter or <code>null</code>
+ */
+ protected IModelProxyFactory getModelProxyFactoryAdapter(Object element) {
+ IModelProxyFactory adapter = null;
+ if (element instanceof IModelProxyFactory) {
+ adapter = (IModelProxyFactory) element;
+ } else if (element instanceof IAdaptable) {
+ IAdaptable adaptable = (IAdaptable) element;
+ adapter = (IModelProxyFactory) adaptable.getAdapter(IModelProxyFactory.class);
+ }
+ return adapter;
+ }
+ /**
+ * Cancels any conflicting updates for children of the given item, and
+ * schedules the new update.
+ *
+ * @param update the update to schedule
+ */
+ protected void schedule(IAsynchronousRequestMonitor update) {
+ AsynchronousRequestMonitor absUpdate = (AsynchronousRequestMonitor) update;
+ synchronized (fPendingUpdates) {
+ Iterator updates = fPendingUpdates.listIterator();
+ while (updates.hasNext()) {
+ AsynchronousRequestMonitor pendingUpdate = (AsynchronousRequestMonitor) updates.next();
+ if (absUpdate.contains(pendingUpdate)) {
+ pendingUpdate.setCanceled(true);
+ updates.remove();
+ }
+ }
+ fPendingUpdates.add(update);
+ }
+ }
+
+ /**
+ * Returns the widgets associated with the given element or
+ * <code>null</code>.
+ *
+ * @param element element to retrieve widgets for
+ * @return widgets or <code>null</code> if none
+ */
+ protected synchronized Widget[] getWidgets(Object element) {
+ if (element == null) {
+ return null;
+ }
+ return (Widget[]) fElementsToWidgets.get(element);
+ }
+
+ /**
+ * Returns the element associated with the given widget or
+ * <code>null</code>.
+ *
+ * @param widget widget to retrieve element for
+ * @return element or <code>null</code> if none
+ */
+ protected synchronized Object getElement(Widget widget) {
+ return fWidgetsToElements.get(widget);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.StructuredViewer#unmapAllElements()
+ */
+ protected synchronized void unmapAllElements() {
+ Iterator iterator = fElementsToWidgets.keySet().iterator();
+ while (iterator.hasNext()) {
+ Object element = iterator.next();
+ Widget[] widgets = getWidgets(element);
+ if (widgets != null) {
+ for (int i = 0; i < widgets.length; i++) {
+ Widget widget = widgets[i];
+ if (widget instanceof Item) {
+ Item item = (Item) widget;
+ item.dispose();
+ }
+ }
+ }
+ }
+ fElementsToWidgets.clear();
+ fWidgetsToElements.clear();
+ disposeAllModelProxies();
+ }
+
+ /**
+ * Cancels all pending update requests.
+ */
+ protected synchronized void cancelPendingUpdates() {
+ Iterator updates = fPendingUpdates.iterator();
+ while (updates.hasNext()) {
+ IAsynchronousRequestMonitor update = (IAsynchronousRequestMonitor) updates.next();
+ update.setCanceled(true);
+ }
+ fPendingUpdates.clear();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.Viewer#inputChanged(java.lang.Object, java.lang.Object)
+ */
+ protected void inputChanged(Object input, Object oldInput) {
+ cancelPendingUpdates();
+ }
+
+ /**
+ * Maps the given element to the given item. Installs the elememt's
+ * update policy if not already installed.
+ *
+ * @param element model element
+ * @param item TreeItem or Tree
+ */
+ protected void map(Object element, Widget item) {
+ item.setData(element);
+ Widget[] widgets = getWidgets(element);
+ fWidgetsToElements.put(item, element);
+ if (widgets == null) {
+ fElementsToWidgets.put(element, new Widget[] { item });
+ } else {
+ Widget[] old = widgets;
+ Widget[] items = new Widget[old.length + 1];
+ System.arraycopy(old, 0, items, 0, old.length);
+ items[old.length] = item;
+ fElementsToWidgets.put(element, items);
+ }
+ installModelProxy(element);
+ }
+
+ /**
+ * Updates the cached information that maps the given element to the
+ * specified widget. This can be useful when an element is being remapped
+ * to an equal (but not identical) object.
+ *
+ * @param element
+ * @param item
+ */
+ protected void remap(Object element, Widget item) {
+ item.setData(element);
+ fWidgetsToElements.put(item, element);
+ Object widgets = fElementsToWidgets.remove(element);
+ fElementsToWidgets.put(element, widgets);
+ }
+
+ public void createUpdatePolicy() {
+ fUpdatePolicy = new DefaultUpdatePolicy();
+ fUpdatePolicy.init(this);
+ }
+
+ /**
+ * Installs the model proxy for the given element into this viewer
+ * if not already installed.
+ *
+ * @param element element to install an update policy for
+ */
+ public void installModelProxy(Object element) {
+ synchronized (fModelProxies) {
+ if (!fModelProxies.containsKey(element)) {
+ IModelProxyFactory modelProxyFactory = getModelProxyFactoryAdapter(element);
+ if (modelProxyFactory != null) {
+ IModelProxy proxy = modelProxyFactory.createModelProxy(element, getPresentationContext());
+ if (proxy != null) {
+ proxy.init(getPresentationContext());
+ fModelProxies.put(element, proxy);
+
+ if (fUpdatePolicy instanceof IModelChangedListener) {
+ proxy.addModelChangedListener((IModelChangedListener)fUpdatePolicy);
+ }
+ }
+ }
+ }
+ }
+ }
+
+
+ /**
+ * Uninstalls the model proxy installed for the given element, if any.
+ *
+ * @param element
+ */
+ protected void disposeModelProxy(Object element) {
+ synchronized (fModelProxies) {
+ IModelProxy proxy = (IModelProxy) fModelProxies.remove(element);
+ if (proxy != null) {
+ if (fUpdatePolicy instanceof IModelChangedListener) {
+ proxy.removeModelChangedListener((IModelChangedListener)fUpdatePolicy);
+ }
+
+ proxy.dispose();
+ }
+ }
+ }
+
+ /**
+ * Removes the update from the pending updates list.
+ *
+ * @param update
+ */
+ protected void updateComplete(IAsynchronousRequestMonitor update) {
+ synchronized (fPendingUpdates) {
+ fPendingUpdates.remove(update);
+ }
+ }
+
+ /**
+ * Unmaps the given item. Does not dispose of the given item,
+ * such that it can be reused.
+ *
+ * @param kid
+ * @param widget
+ */
+ protected synchronized void unmap(Object kid, Widget widget) {
+ if (kid == null) {
+ // when unmapping a dummy item
+ return;
+ }
+ Widget[] widgets = getWidgets(kid);
+ fWidgetsToElements.remove(widget);
+ if (widgets != null) {
+ for (int i = 0; i < widgets.length; i++) {
+ Widget item = widgets[i];
+ if (item == widget) {
+ if (widgets.length == 1) {
+ fElementsToWidgets.remove(kid);
+ // uninstall its update policy, if element no longer in viewer
+ disposeModelProxy(kid);
+ } else {
+ Widget[] newItems = new Widget[widgets.length - 1];
+ System.arraycopy(widgets, 0, newItems, 0, i);
+ if (i < newItems.length) {
+ System.arraycopy(widgets, i + 1, newItems, i, newItems.length - i);
+ }
+ fElementsToWidgets.put(kid, newItems);
+ }
+ }
+ }
+ }
+ }
+
+ Image[] getImages(ImageDescriptor[] descriptors) {
+ if (descriptors == null || descriptors.length == 0) {
+ return new Image[0];
+ }
+ Image[] images = new Image[descriptors.length];
+ for (int i = 0; i < images.length; i++) {
+ images[i] = getImage(descriptors[i]);
+ }
+ return images;
+ }
+
+ /**
+ * Returns an image for the given image descriptor or <code>null</code>. Adds the image
+ * to a cache of images if it does not already exist. The cache is cleared when this viewer
+ * is disposed.
+ *
+ * @param descriptor image descriptor or <code>null</code>
+ * @return image or <code>null</code>
+ */
+ Image getImage(ImageDescriptor descriptor) {
+ if (descriptor == null) {
+ return null;
+ }
+ Image image = (Image) fImageCache.get(descriptor);
+ if (image == null) {
+ image = new Image(getControl().getDisplay(), descriptor.getImageData());
+ fImageCache.put(descriptor, image);
+ }
+ return image;
+ }
+
+ Font[] getFonts(FontData[] fontDatas) {
+ if (fontDatas == null) {
+ return new Font[0];
+ }
+
+ Font[] fonts = new Font[fontDatas.length];
+ for (int i = 0; i < fonts.length; i++) {
+ fonts[i] = getFont(fontDatas[i]);
+ }
+ return fonts;
+ }
+
+ /**
+ * Returns a font for the given font data or <code>null</code>. Adds the font to this viewer's font
+ * cache which is disposed when this viewer is disposed.
+ *
+ * @param fontData font data or <code>null</code>
+ * @return font font or <code>null</code>
+ */
+ Font getFont(FontData fontData) {
+ if (fontData == null) {
+ return null;
+ }
+ Font font = (Font) fFontCache.get(fontData);
+ if (font == null) {
+ font = new Font(getControl().getDisplay(), fontData);
+ fFontCache.put(fontData, font);
+ }
+ return font;
+ }
+
+ Color[] getColor(RGB[] rgb) {
+ if (rgb == null) {
+ return new Color[0];
+ }
+ Color[] colors = new Color[rgb.length];
+ for (int i = 0; i < colors.length; i++) {
+ colors[i] = getColor(rgb[i]);
+ }
+ return colors;
+ }
+ /**
+ * Returns a color for the given RGB or <code>null</code>. Adds the color to this viewer's color
+ * cache which is disposed when this viewer is disposed.
+ *
+ * @param rgb RGB or <code>null</code>
+ * @return color or <code>null</code>
+ */
+ Color getColor(RGB rgb) {
+ if (rgb == null) {
+ return null;
+ }
+ Color color = (Color) fColorCache.get(rgb);
+ if (color == null) {
+ color = new Color(getControl().getDisplay(), rgb);
+ fColorCache.put(rgb, color);
+ }
+ return color;
+ }
+
+ /**
+ * Sets the context for this viewer.
+ *
+ * @param context
+ */
+ public void setContext(IPresentationContext context) {
+ fContext = context;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.StructuredViewer#doFindItem(java.lang.Object)
+ */
+ protected Widget doFindItem(Object element) {
+ Widget[] widgets = getWidgets(element);
+ if (widgets != null && widgets.length > 0) {
+ return widgets[0];
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.StructuredViewer#doUpdateItem(org.eclipse.swt.widgets.Widget, java.lang.Object, boolean)
+ */
+ protected void doUpdateItem(Widget item, Object element, boolean fullMap) {
+ updateLabel(element, item);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.StructuredViewer#internalRefresh(java.lang.Object)
+ */
+ protected void internalRefresh(Object element) {
+ Widget[] items = getWidgets(element);
+ if (items == null) {
+ return;
+ }
+ for (int i = 0; i < items.length; i++) {
+ internalRefresh(element, items[i]);
+ }
+ }
+
+ /**
+ * Refreshes a specific occurrence of an element.
+ *
+ * @param element element to update
+ * @param item item to update
+ */
+ protected void internalRefresh(Object element, Widget item) {
+ updateLabel(element, item);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.Viewer#setSelection(org.eclipse.jface.viewers.ISelection, boolean)
+ */
+ public synchronized void setSelection(ISelection selection, final boolean reveal) {
+ Control control = getControl();
+ if (control == null || control.isDisposed()) {
+ return;
+ }
+ if (!acceptsSelection(selection)) {
+ selection = getEmptySelection();
+ }
+ if (!overrideSelection(fCurrentSelection, selection)) {
+ return;
+ }
+ fPendingSelection = selection;
+ if (getControl().getDisplay().getThread() == Thread.currentThread()) {
+ attemptSelection(reveal);
+ } else {
+ WorkbenchJob job = new WorkbenchJob("attemptSelection") { //$NON-NLS-1$
+ public IStatus runInUIThread(IProgressMonitor monitor) {
+ attemptSelection(reveal);
+ return Status.OK_STATUS;
+ }
+
+ };
+ job.setSystem(true);
+ job.schedule();
+ }
+ }
+
+ /**
+ * Returns whether the candidate selection should override the current
+ * selection.
+ *
+ * @param current
+ * @param curr
+ * @return
+ */
+ protected boolean overrideSelection(ISelection current, ISelection candidate) {
+ IModelSelectionPolicy selectionPolicy = getSelectionPolicy(current);
+ if (selectionPolicy == null) {
+ return true;
+ }
+ if (selectionPolicy.contains(candidate, getPresentationContext())) {
+ return selectionPolicy.overrides(current, candidate, getPresentationContext());
+ }
+ return !selectionPolicy.isSticky(current, getPresentationContext());
+ }
+
+ /**
+ * Returns the selection policy associated with the given selection
+ * or <code>null</code> if none.
+ *
+ * @param selection or <code>null</code>
+ * @return selection policy or <code>null</code>
+ */
+ protected IModelSelectionPolicy getSelectionPolicy(ISelection selection) {
+ if (selection instanceof IStructuredSelection) {
+ IStructuredSelection ss = (IStructuredSelection) selection;
+ Object element = ss.getFirstElement();
+ if (element instanceof IAdaptable) {
+ IAdaptable adaptable = (IAdaptable) element;
+ return (IModelSelectionPolicy) adaptable.getAdapter(IModelSelectionPolicy.class);
+ }
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.StructuredViewer#setSelectionToWidget(org.eclipse.jface.viewers.ISelection, boolean)
+ */
+ final protected void setSelectionToWidget(ISelection selection, final boolean reveal) {
+ // NOT USED
+ throw new IllegalArgumentException("This method should not be called"); //$NON-NLS-1$
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.StructuredViewer#setSelectionToWidget(java.util.List, boolean)
+ */
+ final protected void setSelectionToWidget(List l, boolean reveal) {
+ // NOT USED
+ throw new IllegalArgumentException("This method should not be called"); //$NON-NLS-1$
+ }
+
+ /**
+ * Attempts to update any pending selection.
+ *
+ * @param reveal whether to reveal the selection
+ */
+ protected synchronized void attemptSelection(boolean reveal) {
+ if (fPendingSelection != null) {
+ fPendingSelection = doAttemptSelectionToWidget(fPendingSelection, reveal);
+ if (fPendingSelection.isEmpty()) {
+ fPendingSelection = null;
+ }
+ ISelection currentSelection = getSelection();
+ if (isSuppressEqualSelections() && currentSelection.equals(fCurrentSelection)) {
+ return;
+ }
+ fCurrentSelection = currentSelection;
+ updateSelection(fCurrentSelection);
+ }
+ }
+
+ /**
+ * Controls whether selection change notification is sent even when
+ * successive selections are equal.
+ *
+ * @return whether to suppress change notification for equal successive
+ * selections
+ */
+ protected boolean isSuppressEqualSelections() {
+ return true;
+ }
+
+ /**
+ * Attemtps to selection the specified selection and returns a selection
+ * representing the portion of the selection that could not be honored
+ * and still needs to be selected.
+ *
+ * @param selection selection to attempt
+ * @param reveal whether to reveal the selection
+ * @return remaining selection
+ */
+ protected abstract ISelection doAttemptSelectionToWidget(ISelection selection, boolean reveal);
+
+ /**
+ * Returns whether this viewer supports the given selection.
+ *
+ * @param selection a selection
+ * @return whether this viewer supports the given selection
+ */
+ protected abstract boolean acceptsSelection(ISelection selection);
+
+ /**
+ * Returns an empty selection supported by this viewer.
+ *
+ * @return an empty selection supported by this viewer
+ */
+ protected abstract ISelection getEmptySelection();
+
+ /**
+ * A content provider that does nothing.
+ */
+ private class NullContentProvider implements IStructuredContentProvider {
+ public void dispose() {
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+
+ public Object[] getElements(Object inputElement) {
+ return null;
+ }
+ }
+
+ /**
+ * Notification that a presentation update has failed.
+ * Subclasses may override as required. The default implementation
+ * does nothing.
+ *
+ * @param monitor monitor for the presentation request that failed
+ * @param status status of update
+ */
+ protected void handlePresentationFailure(IAsynchronousRequestMonitor monitor, IStatus status) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.StructuredViewer#preservingSelection(java.lang.Runnable)
+ */
+ protected synchronized void preservingSelection(Runnable updateCode) {
+ if (fPendingSelection == null) {
+ ISelection oldSelection = null;
+ try {
+ // preserve selection
+ oldSelection = fCurrentSelection;
+ // perform the update
+ updateCode.run();
+ } finally {
+ // restore selection
+ if (oldSelection == null) {
+ oldSelection = new TreeSelection(new TreePath[0]);
+ }
+ if (getControl().getDisplay().getThread() == Thread.currentThread()) {
+ restoreSelection(oldSelection);
+ } else {
+ final ISelection tempSelection = oldSelection;
+ WorkbenchJob job = new WorkbenchJob("attemptSelection") { //$NON-NLS-1$
+ public IStatus runInUIThread(IProgressMonitor monitor) {
+ restoreSelection(tempSelection);
+ return Status.OK_STATUS;
+ }
+
+ };
+ job.setSystem(true);
+ job.schedule();
+ }
+ }
+ } else {
+ updateCode.run();
+ }
+ }
+
+ protected synchronized void restoreSelection(ISelection oldSelection) {
+ doAttemptSelectionToWidget(oldSelection, false);
+ // send out notification if old and new differ
+ fCurrentSelection = getSelection();
+ if (!fCurrentSelection.equals(oldSelection))
+ handleInvalidSelection(oldSelection, fCurrentSelection);
+ }
+ /**
+ * Sets the color attributes of the given widget.
+ *
+ * @param widget the widget to update
+ * @param foreground foreground color of the widget or <code>null</code> if default
+ * @param background background color of the widget or <code>null</code> if default
+ */
+ abstract void setColors(Widget widget, RGB foreground[], RGB background[]);
+
+ /**
+ * Sets the label attributes of the given widget.
+ *
+ * @param widget the widget to update
+ * @param text label text
+ * @param image label image or <code>null</code>
+ */
+ abstract void setLabels(Widget widget, String[] text, ImageDescriptor[] image);
+
+ /**
+ * Sets the font attributes of the given widget.
+ *
+ * @param widget widget to update
+ * @param font font of the widget or <code>null</code> if default.
+ */
+ abstract void setFonts(Widget widget, FontData[] font);
+
+ /**
+ * Returns the parent widget of the give widget or <code>null</code>
+ * if none. This method can be called in a non-UI thread.
+ *
+ * @param widget widget
+ * @return parent widget or <code>null</code>
+ */
+ protected abstract Widget getParent(Widget widget);
+
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/ChildrenRequestMonitor.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/ChildrenRequestMonitor.java
new file mode 100644
index 000000000..adbb5634c
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/ChildrenRequestMonitor.java
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.viewers;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.swt.widgets.Widget;
+
+/**
+ * Implementation for <code>IChildrenRequestMonitor</code>. Collects
+ * children from an asynchronous tree content adapter.
+ * <p>
+ * Not intended to be subclassed or instantiated by clients. For use
+ * speficially with <code>AsynchronousTreeViewer</code>.
+ * </p>
+ * @since 3.2
+ */
+class ChildrenRequestMonitor extends AsynchronousRequestMonitor implements IChildrenRequestMonitor {
+
+ /**
+ * Collection of children retrieved
+ */
+ private List fChildren = new ArrayList();
+
+ /**
+ * Constucts a monitor to retrieve and update the children of the given
+ * widget.
+ *
+ * @param widget widget to retrieve children for
+ */
+ ChildrenRequestMonitor(Widget widget, AsynchronousTreeViewer viewer) {
+ super(widget, viewer);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.viewers.IChildrenRequestMonitor#addChild(java.lang.Object)
+ */
+ public void addChild(Object child) {
+ fChildren.add(child);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.viewers.IChildrenRequestMonitor#addChildren(java.lang.Object[])
+ */
+ public void addChildren(Object[] children) {
+ for (int i = 0; i < children.length; i++) {
+ fChildren.add(children[i]);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.viewers.AsynchronousRequestMonitor#contains(org.eclipse.debug.ui.viewers.AsynchronousRequestMonitor)
+ */
+ protected boolean contains(AsynchronousRequestMonitor update) {
+ return (update instanceof ChildrenRequestMonitor || update instanceof ContainerRequestMonitor) && contains(update.getWidget());
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.viewers.AsynchronousRequestMonitor#performUpdate()
+ */
+ protected void performUpdate() {
+ ((AsynchronousTreeViewer)getViewer()).setChildren(getWidget(), fChildren);
+ }
+
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/ContainerRequestMonitor.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/ContainerRequestMonitor.java
new file mode 100644
index 000000000..c7ba88ee0
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/ContainerRequestMonitor.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.viewers;
+
+import org.eclipse.swt.widgets.Widget;
+
+/**
+ * Implementation of an <code>IContainerRequestMonitor</code>. Collects whether
+ * an element contains children.
+ * <p>
+ * Not intended to be subclassed or instantiated by clients. For use
+ * speficially with <code>AsynchronousTreeViewer</code>.
+ * </p>
+ * @since 3.2
+ */
+class ContainerRequestMonitor extends AsynchronousRequestMonitor implements IContainerRequestMonitor {
+
+ /**
+ * Whether the item has children
+ */
+ private boolean fIsChildren = false;
+
+ /**
+ * Constructs an update request for the given item in the given viewer.
+ *
+ * @param item item to update
+ * @param viewer viewer the update was issued for
+ */
+ ContainerRequestMonitor(Widget item, AsynchronousTreeViewer viewer) {
+ super(item, viewer);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.viewers.AsynchronousRequestMonitor#performUpdate()
+ */
+ protected void performUpdate() {
+ ((AsynchronousTreeViewer)getViewer()).setIsContainer(getWidget(), fIsChildren);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.viewers.AsynchronousRequestMonitor#contains(org.eclipse.debug.ui.viewers.AsynchronousRequestMonitor)
+ */
+ protected boolean contains(AsynchronousRequestMonitor update) {
+ return (update instanceof ChildrenRequestMonitor || update instanceof ContainerRequestMonitor) && contains(update.getWidget());
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.viewers.IContainerRequestMonitor#setIsContainer(boolean)
+ */
+ public void setIsContainer(boolean container) {
+ fIsChildren = container;
+ }
+
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/DefaultElementComparer.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/DefaultElementComparer.java
new file mode 100644
index 000000000..46593e6be
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/DefaultElementComparer.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.viewers;
+
+import org.eclipse.jface.viewers.IElementComparer;
+
+/**
+ * Default comparator used to compare individual elements in a tree path.
+ *
+ * @since 3.2
+ * @see org.eclipse.debug.internal.ui.treeviewer.TreePath
+ */
+public class DefaultElementComparer implements IElementComparer {
+
+ public static final DefaultElementComparer INSTANCE= new DefaultElementComparer();
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IElementComparer#equals(java.lang.Object, java.lang.Object)
+ */
+ public boolean equals(Object a, Object b) {
+ return a.equals(b);
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IElementComparer#hashCode(java.lang.Object)
+ */
+ public int hashCode(Object element) {
+ return element.hashCode();
+ }
+}
+
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/IAsynchronousLabelAdapter.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/IAsynchronousLabelAdapter.java
new file mode 100644
index 000000000..e0bf9ac97
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/IAsynchronousLabelAdapter.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.viewers;
+
+/**
+ * Provides labels for elements. Note that implementations
+ * are must provide labels asynchronously.
+ * <p>
+ * Clients may implement this interface.
+ * </p>
+ * @since 3.2
+ */
+public interface IAsynchronousLabelAdapter {
+
+ /**
+ * Asynchronously retrieves the label of the given object reporting to
+ * the given monitor. If unable to retrieve label information, an exception should be
+ * reported to the monitor with an appropriate status.
+ *
+ * @param object the element for which a label is requested
+ * @param context the context in which the label has been requested
+ * @param monitor request monitor to report the result to
+ */
+ public void retrieveLabel(Object object, IPresentationContext context, ILabelRequestMonitor result);
+
+
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/IAsynchronousRequestMonitor.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/IAsynchronousRequestMonitor.java
new file mode 100644
index 000000000..8d2638e3c
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/IAsynchronousRequestMonitor.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.viewers;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+
+/**
+ * Common interface for requests made on elements in an asynchronous viewer. Results
+ * of a request are reported to a request monitor asynchronously (usually a
+ * specialization of this interface). An request may be cancelled by the client
+ * making the request, or by the adapter fulfilling the request.
+ * Adapters may report failure by setting an appropriate status on this monitor. When a request
+ * is complete, an adapter must call <code>done()</code> on the monitor, no matter
+ * if the update succeeded or failed. The <code>done()</code> method does not need to be
+ * called if a request is canceled.
+ * <p>
+ * Operations accepting a request monitor are expected to poll the
+ * monitor (using <code>isCanceled</code>) periodically and abort at their
+ * earliest convenience.
+ * </p>
+ * <p>
+ * This interface is not intended to be implemented by clients.
+ * </p>
+ * @since 3.2
+ */
+public interface IAsynchronousRequestMonitor extends IProgressMonitor {
+
+ /**
+ * Sets the status of this request, possibly <code>null</code>.
+ * When a request fails, the status indicates why the request failed.
+ * A <code>null</code> status is considered to be successful.
+ *
+ * @param status request status
+ */
+ public void setStatus(IStatus status);
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/IAsynchronousTreeContentAdapter.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/IAsynchronousTreeContentAdapter.java
new file mode 100644
index 000000000..65f4ef6f4
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/IAsynchronousTreeContentAdapter.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.viewers;
+
+/**
+ * Provides content for elements in a tree viewer. Note that implementations
+ * must provide content asynchronously.
+ * <p>
+ * Clients may implement this interface.
+ * </p>
+ * @since 3.2
+ */
+public interface IAsynchronousTreeContentAdapter {
+
+ /**
+ * Asynchronously retrieves the children of the given parent reporting to the
+ * given monitor. If unable to retrieve children, an exception should be reported
+ * to the monitor with an appropriate status.
+ *
+ * @param parent the element to retrieve children for
+ * @param context the context in which children have been requested
+ * @param monitor request monitor to report children to
+ */
+ public void retrieveChildren(Object parent, IPresentationContext context, IChildrenRequestMonitor result);
+
+ /**
+ * Asynchronously determines whether the given element contains children in the specified
+ * context reporting the result to the given monitor. If unable to determine
+ * whether the element has children, an exception should be reported to the monitor
+ * with an appropriate status.
+ *
+ * @param element the element on which children may exist
+ * @param context the context in which children may exist
+ * @param monitor request monitor to report the result to
+ */
+ public void isContainer(Object element, IPresentationContext context, IContainerRequestMonitor result);
+
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/IChildrenRequestMonitor.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/IChildrenRequestMonitor.java
new file mode 100644
index 000000000..2acb16b64
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/IChildrenRequestMonitor.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.viewers;
+
+/**
+ * A request monitor that collects children from an asynchronous tree content adapter.
+ * <p>
+ * This interface is not intended to be implemented by clients.
+ * </p>
+ * @since 3.2
+ */
+public interface IChildrenRequestMonitor extends IAsynchronousRequestMonitor {
+
+ /**
+ * Adds the given child to this request.
+ *
+ * @param child child to add
+ */
+ public void addChild(Object child);
+
+ /**
+ * Adds the given children to this request.
+ *
+ * @param children children to add
+ */
+ public void addChildren(Object[] children);
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/IContainerRequestMonitor.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/IContainerRequestMonitor.java
new file mode 100644
index 000000000..e1aff02c5
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/IContainerRequestMonitor.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.viewers;
+
+/**
+ * A request monitor that collects whether an element contains
+ * children.
+ * <p>
+ * This interface is not intended to be implemented by clients.
+ * </p>
+ * @since 3.2
+ */
+public interface IContainerRequestMonitor extends IAsynchronousRequestMonitor {
+
+ /**
+ * Sets whether an element contains children.
+ *
+ * @param container whether an element contains children
+ */
+ public void setIsContainer(boolean container);
+
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/ILabelRequestMonitor.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/ILabelRequestMonitor.java
new file mode 100644
index 000000000..b72976455
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/ILabelRequestMonitor.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.viewers;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.RGB;
+
+/**
+ * A request monitor that collects attributes of a element's
+ * label.
+ * <p>
+ * This interface is not intended to be implemented by clients.
+ * </p>
+ * @since 3.2
+ */
+public interface ILabelRequestMonitor extends IAsynchronousRequestMonitor {
+
+ /**
+ * Sets the text of the label. Cannot be <code>null</code>.
+ *
+ * @param text
+ */
+ public void setLabels(String[] text);
+
+ /**
+ * Sets the font of the label.
+ *
+ * @param fontData
+ */
+ public void setFontDatas(FontData[] fontData);
+
+ /**
+ * Sets the image of the label.
+ *
+ * @param image
+ */
+ public void setImageDescriptors(ImageDescriptor[] image);
+
+ /**
+ * Sets the foreground color of the label.
+ *
+ * @param foreground
+ */
+ public void setForegrounds(RGB[] foreground);
+
+ /**
+ * Sets the background color of the label.
+ *
+ * @param background
+ */
+ public void setBackgrounds(RGB[] background);
+
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DeferredExpressionLogicalStructure.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/IModelChangedListener.java
index d438af7dc..c8f4eefd7 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DeferredExpressionLogicalStructure.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/IModelChangedListener.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * Copyright (c) 2005 IBM Corporation 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
@@ -8,18 +8,20 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.debug.internal.ui.elements.adapters;
-
+package org.eclipse.debug.internal.ui.viewers;
/**
- * Workbench adapter for an expression when showing logical structures.
+ * A model changed listener is notified of changes in a model.
+ *
+ * @since 3.2
*/
-public class DeferredExpressionLogicalStructure extends DeferredExpression {
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.internal.ui.views.variables.DeferredVariable#isShowLogicalStructure()
+public interface IModelChangedListener {
+
+ /**
+ * Notification a model has changed as described by the given delta.
+ *
+ * @param delta model delta
*/
- protected boolean isShowLogicalStructure() {
- return true;
- }
+ public void modelChanged(IModelDelta delta);
+
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/IModelDelta.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/IModelDelta.java
new file mode 100644
index 000000000..4e7e5e985
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/IModelDelta.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.viewers;
+
+/**
+ * Describes a change within a model. A delta is a hierarchical description of a change
+ * within a model. It constists of a path of nodes. Each node references an element
+ * from a model, and desribes how that element changed.
+ * <p>
+ * An element can be added, removed, or changed. As well, its possible that an element
+ * did not change, but that one of its children changed. When an element changes, an
+ * additional information describes the change. For example, and element's content may have
+ * changed (its children), or its state may have changed.
+ * </p>
+ * <p>
+ * Optionally, an update action is provided with a node. A node may be expanded
+ * or selected.
+ * </p>
+ * @since 3.2
+ */
+public interface IModelDelta {
+
+ //change type
+ public static int NOCHANGE = 0;
+ public static int ADDED = 1;
+ public static int REMOVED = 1 << 1;
+ public static int CHANGED = 1 << 2;
+
+ //how it changed.
+ public static int CONTENT = 1 << 10;
+ public static int STATE = 1 << 11;
+
+ // action
+ public static int EXPAND = 1 << 12;
+ public static int SELECT = 1 << 13;
+
+ // TODO: should be part of the implementation rather than the interface (i.e.
+ // interface should bre read-only).
+ public IModelDeltaNode addNode(Object element, int flags);
+ public IModelDeltaNode[] getNodes();
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/IModelDeltaNode.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/IModelDeltaNode.java
new file mode 100644
index 000000000..a672eea4a
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/IModelDeltaNode.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.viewers;
+
+import org.eclipse.debug.internal.ui.viewers.update.ModelDeltaNode;
+
+/**
+ *
+ *
+ * @since 3.2
+ */
+public interface IModelDeltaNode {
+ public IModelDeltaNode getParent();
+ public Object getElement();
+ public int getFlags();
+ public ModelDeltaNode[] getNodes();
+
+ // TODO: should be part of the implementation rather than the interface (i.e.
+ // interface should bre read-only).
+ public IModelDeltaNode addNode(Object object, int flags);
+
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/IModelProxy.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/IModelProxy.java
new file mode 100644
index 000000000..b1a18dd33
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/IModelProxy.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.viewers;
+
+/**
+ *
+ *
+ * @since 3.2
+ */
+public interface IModelProxy {
+
+ public void init(IPresentationContext context);
+ public void dispose();
+ public void addModelChangedListener(IModelChangedListener listener);
+ public void removeModelChangedListener(IModelChangedListener listener);
+
+ // TODO: should be part of the implementation rather than the interface
+ public void fireModelChanged(IModelDelta delta);
+
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/IRemoteTreeViewerUpdateListener.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/IModelProxyFactory.java
index 34d56f8ff..9a1d64625 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/IRemoteTreeViewerUpdateListener.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/IModelProxyFactory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * Copyright (c) 2005 IBM Corporation 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
@@ -8,8 +8,13 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.debug.internal.ui.views;
+package org.eclipse.debug.internal.ui.viewers;
-public interface IRemoteTreeViewerUpdateListener {
- public void treeUpdated();
+/**
+ *
+ *
+ * @since 3.2
+ */
+public interface IModelProxyFactory {
+ public IModelProxy createModelProxy(Object element, IPresentationContext context);
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/IModelSelectionPolicy.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/IModelSelectionPolicy.java
new file mode 100644
index 000000000..40f1e758b
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/IModelSelectionPolicy.java
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.viewers;
+
+import org.eclipse.jface.viewers.ISelection;
+
+/**
+ * Resolves selection conflicts within a model. When
+ * a selection exists in a viewer, and a client asks
+ * to set another selection, the selection policy for
+ * that model is asked to determine whether the new
+ * selection should override the previous selection.
+ * When a selection is from a different model, the
+ * original selection is maintained if its model selection
+ * policy specifies the selection to be 'sticky'.
+ * <p>
+ * A selection policy is obtained as an adapter from
+ * an element in a viewer, and the adapter represents
+ * selections from an instance of a model.
+ * </p>
+ * @since 3.2
+ */
+public interface IModelSelectionPolicy {
+
+ /**
+ * Returns whether the given selection is contained in
+ * this model.
+ *
+ * @param selection
+ * @param context
+ * @return
+ */
+ public boolean contains(ISelection selection, IPresentationContext context);
+
+ /**
+ * Returns whether the candidate selection overrides the
+ * existing selection. The policy is only asked about selections
+ * that it contains.
+ *
+ * @param existing
+ * @param candidate
+ * @param context
+ * @return
+ */
+ public boolean overrides(ISelection existing, ISelection candidate, IPresentationContext context);
+
+ /**
+ * Returns whether the given selection should be maintained in the
+ * face of a selection attempt from a different model.
+ *
+ * @param selection
+ * @param context
+ * @return
+ */
+ public boolean isSticky(ISelection selection, IPresentationContext context);
+
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/IPresentationContext.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/IPresentationContext.java
new file mode 100644
index 000000000..89db4618e
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/IPresentationContext.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.viewers;
+
+import org.eclipse.ui.IWorkbenchPart;
+
+/**
+ * Context in which an asynchronous request has been made.
+ * <p>
+ * Clients are may implement and extend this interface to provide
+ * special contexts.
+ * </p>
+ * @since 3.2
+ */
+public interface IPresentationContext {
+
+ /**
+ * Returns the part for which a request is being made
+ * or <code>null</code> if none.
+ *
+ * @return the part for which a request is being made
+ * or <code>null</code>
+ */
+ public IWorkbenchPart getPart();
+
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/IUpdatePolicy.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/IUpdatePolicy.java
new file mode 100644
index 000000000..0930535db
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/IUpdatePolicy.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.viewers;
+
+
+
+/**
+ * An update policy updates elements from an instance of a model
+ * in a viewer.
+ *
+ * @since 3.2
+ */
+public interface IUpdatePolicy {
+
+ /**
+ * Installs this update policy on the given viewer.
+ *
+ * @param viewer viewer to update
+ */
+ public void init(AsynchronousViewer viewer);
+
+ /**
+ * Disposes this update policy.
+ */
+ public void dispose();
+
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/IUpdatePolicyFactory.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/IUpdatePolicyFactory.java
new file mode 100644
index 000000000..ba4fb8400
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/IUpdatePolicyFactory.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.viewers;
+
+
+/**
+ * Used to create update policies for elements. An update policy factory
+ * should be registered as adapters for root elements in a model.
+ *
+ * @since 3.2
+ */
+public interface IUpdatePolicyFactory {
+
+ /**
+ * Creates and returns an update policy to use for the given element in the
+ * specified context, or <code>null</code> if none.
+ *
+ * @param element the element to be updated
+ * @param context the context in which the element is being presented
+ * @return update policy or <code>null</code>
+ */
+ public IUpdatePolicy createUpdatePolicy(IPresentationContext context);
+
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/LabelRequestMonitor.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/LabelRequestMonitor.java
new file mode 100644
index 000000000..72cb34942
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/LabelRequestMonitor.java
@@ -0,0 +1,129 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.viewers;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Widget;
+
+/**
+ * Implementation of an <code>ILabelRequestMonitor</code>. Collects label
+ * attributes from an asynchronous label adapter.
+ * <p>
+ * Not intended to be subclassed or instantiated by clients. For use speficially
+ * with <code>AsynchronousViewer</code>.
+ * </p>
+ *
+ * @since 3.2
+ */
+class LabelRequestMonitor extends AsynchronousRequestMonitor implements ILabelRequestMonitor {
+
+ /**
+ * Retrieved label text. Only <code>null</code> if cancelled or failed.
+ */
+ private String[] fLabels;
+
+ /**
+ * Retrieved image descriptor or <code>null</code>
+ */
+ private ImageDescriptor[] fImageDescriptors;
+
+ /**
+ * Retrieved font data or <code>null</code>
+ */
+ private FontData[] fFontDatas;
+
+ /**
+ * Retieved colors or <code>null</code>
+ */
+ private RGB[] fForegrounds;
+ private RGB[] fBackgrounds;
+
+ /**
+ * Cosntructs a request to upate the label of the given widget in the give
+ * viewer.
+ *
+ * @param widget widget to update
+ * @param viewer viewer containing the widget
+ */
+ LabelRequestMonitor(Widget widget, AsynchronousViewer viewer) {
+ super(widget, viewer);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.debug.ui.viewers.AsynchronousRequestMonitor#performUpdate()
+ */
+ protected void performUpdate() {
+ AsynchronousViewer viewer = getViewer();
+ Widget widget = getWidget();
+ viewer.setLabels(widget, fLabels, fImageDescriptors);
+ viewer.setColors(widget, fForegrounds, fBackgrounds);
+ viewer.setFonts(widget, fFontDatas);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.debug.ui.viewers.AsynchronousRequestMonitor#contains(org.eclipse.debug.ui.viewers.AsynchronousRequestMonitor)
+ */
+ protected boolean contains(AsynchronousRequestMonitor update) {
+ return update instanceof LabelRequestMonitor && update.getWidget() == getWidget();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.debug.ui.viewers.ILabelRequestMonitor#setLabel(java.lang.String)
+ */
+ public void setLabels(String[] text) {
+ fLabels = text;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.debug.ui.viewers.ILabelRequestMonitor#setFontData(org.eclipse.swt.graphics.FontData)
+ */
+ public void setFontDatas(FontData[] fontData) {
+ fFontDatas = fontData;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.debug.ui.viewers.ILabelRequestMonitor#setImageDescriptor(org.eclipse.jface.resource.ImageDescriptor)
+ */
+ public void setImageDescriptors(ImageDescriptor[] image) {
+ fImageDescriptors = image;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.debug.ui.viewers.ILabelRequestMonitor#setForeground(org.eclipse.swt.graphics.RGB)
+ */
+ public void setForegrounds(RGB[] foreground) {
+ fForegrounds = foreground;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.debug.ui.viewers.ILabelRequestMonitor#setBackground(org.eclipse.swt.graphics.RGB)
+ */
+ public void setBackgrounds(RGB[] background) {
+ fBackgrounds = background;
+ }
+
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/PresentationContext.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/PresentationContext.java
new file mode 100644
index 000000000..0b07010ce
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/PresentationContext.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.viewers;
+
+import org.eclipse.ui.IWorkbenchPart;
+
+/**
+ * Presentation context.
+ * <p>
+ * Clients may instantiate and subclass this class.
+ * </p>
+ * @since 3.2
+ */
+public class PresentationContext implements IPresentationContext {
+
+ private IWorkbenchPart fPart;
+
+ /**
+ * Constructs a presentation context for the given part.
+ *
+ * @param part workbench part
+ */
+ public PresentationContext(IWorkbenchPart part) {
+ fPart = part;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.viewers.IPresentationContext#getPart()
+ */
+ public IWorkbenchPart getPart() {
+ return fPart;
+ }
+
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/TreePath.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/TreePath.java
new file mode 100644
index 000000000..d0145bee2
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/TreePath.java
@@ -0,0 +1,179 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.viewers;
+
+import org.eclipse.jface.util.Assert;
+import org.eclipse.jface.viewers.IElementComparer;
+import org.eclipse.swt.widgets.TreeItem;
+
+/**
+ * A tree path denotes a model element in a tree viewer. Tree path
+ * objects do have value semantics. A model element is represented by
+ * a path of elements in the tree from the root element to the leaf
+ * element.
+ * <p>
+ * Clients may instantiate this class. Not intended to be subclassed.
+ * </p>
+ * @since 3.2
+ */
+public final class TreePath {
+ private Object[] fSegments;
+ private int fHash;
+ private TreeItem fItem;
+
+ /**
+ * Constructs a path identifying a leaf node in a tree.
+ *
+ * @param segments path of elements to a leaf node in a tree, starting with the root element
+ */
+ public TreePath(Object[] segments) {
+ Assert.isNotNull(segments);
+ for (int i= 0; i < segments.length; i++) {
+ Assert.isNotNull(segments[i]);
+ }
+ fSegments= segments;
+ }
+
+ /**
+ * Returns the element at the specified index in this path.
+ *
+ * @param index index of element to return
+ * @return element at the specified index
+ */
+ public Object getSegment(int index) {
+ return fSegments[index];
+ }
+
+ /**
+ * Returns the number of elements in this path.
+ *
+ * @return the number of elements in this path
+ */
+ public int getSegmentCount() {
+ return fSegments.length;
+ }
+
+ /**
+ * Returns the first element in this path.
+ *
+ * @return the first element in this path
+ */
+ public Object getFirstSegment() {
+ if (fSegments.length == 0)
+ return null;
+ return fSegments[0];
+ }
+
+ /**
+ * Returns the last element in this path.
+ *
+ * @return the last element in this path
+ */
+ public Object getLastSegment() {
+ if (fSegments.length == 0)
+ return null;
+ return fSegments[fSegments.length - 1];
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ public boolean equals(Object other) {
+ if (!(other instanceof TreePath))
+ return false;
+ return equals((TreePath)other, null);
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ public int hashCode() {
+ if (fHash != 0)
+ return fHash;
+ for (int i= 0; i < fSegments.length; i++) {
+ fHash= fHash + fSegments[i].hashCode();
+ }
+ return fHash;
+ }
+
+ /**
+ * Returns whether this path is equivalent to the given path using the
+ * specified comparator to compare individual elements.
+ *
+ * @param otherPath tree path to compare to
+ * @param comparer compartor to use or <code>null</code> if default comparator
+ * should be used
+ * @return whether the paths are equal
+ */
+ public boolean equals(TreePath otherPath, IElementComparer comparer) {
+ if (comparer == null)
+ comparer= DefaultElementComparer.INSTANCE;
+ if (otherPath == null)
+ return false;
+ if (fSegments.length != otherPath.fSegments.length)
+ return false;
+ for (int i= 0; i < fSegments.length; i++) {
+ if (!comparer.equals(fSegments[i], otherPath.fSegments[i]))
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Used internally to set the tree item associated with the leaf element.
+ *
+ * @param item associated tree item for the leaf element
+ */
+ void setTreeItem(TreeItem item) {
+ fItem = item;
+ }
+
+ /**
+ * Used internally to return the tree item associated with the leaf element.
+ *
+ * @return tree item associated with leaf element or <code>null</code>
+ */
+ TreeItem getTreeItem() {
+ return fItem;
+ }
+
+ /**
+ * Returns whether this path starts with the same elements in the given path.
+ * This is indicates the given path is a prefix of this path, or is the same
+ * as this path.
+ *
+ * @param treePath path to compare to
+ * @return whether the given path is a prefix of this path, or the same as this
+ * path
+ */
+ public boolean startsWith(TreePath treePath) {
+ if (treePath == null) {
+ return false;
+ }
+
+ if (treePath.equals(this)) {
+ return true;
+ }
+
+ int segmentCount = treePath.getSegmentCount();
+ if (segmentCount >= fSegments.length) {
+ return false;
+ }
+ for (int i = 0; i < segmentCount; i++) {
+ Object segment = treePath.getSegment(i);
+ if (!segment.equals(fSegments[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+}
+
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/TreeSelection.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/TreeSelection.java
new file mode 100644
index 000000000..1cb75346c
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/TreeSelection.java
@@ -0,0 +1,155 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.viewers;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+
+/**
+ * A selection in a async tree viewer. Selections in an async tree viewer
+ * are identified by associated tree paths. As there can be duplicate elements
+ * in a tree viewer, paths are required to uniquely identify which leaf
+ * elements are selected.
+ * <p>
+ * Clients may instantiate this class. Not intended to be subclassed.
+ * </p>
+ * @since 3.2
+ */
+public class TreeSelection implements IStructuredSelection {
+
+ private TreePath[] fPaths = null;
+
+ /**
+ * Constructs a selection based on the elements identified by the
+ * given tree paths.
+ *
+ * @param paths tree paths where <code>null</code> indicates an
+ * empty selection
+ */
+ public TreeSelection(TreePath[] paths) {
+ fPaths = paths;
+ }
+
+ /**
+ * Constructs a selection based on the elements identified by the
+ * given tree path.
+ *
+ * @param treePath tree path where <code>null</code> indicates an
+ * empty selection.
+ */
+ public TreeSelection(TreePath treePath) {
+ this(treePath != null ? new TreePath[] {treePath} : null);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IStructuredSelection#getFirstElement()
+ */
+ public Object getFirstElement() {
+ if (fPaths != null && fPaths.length > 0) {
+ return fPaths[0].getLastSegment();
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IStructuredSelection#iterator()
+ */
+ public Iterator iterator() {
+ return toList().iterator();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IStructuredSelection#size()
+ */
+ public int size() {
+ if (fPaths != null) {
+ return fPaths.length;
+ }
+ return 0;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IStructuredSelection#toArray()
+ */
+ public Object[] toArray() {
+ int size = size();
+ Object[] selection = new Object[size];
+ for (int i = 0; i < size; i++) {
+ selection[i] = fPaths[i].getLastSegment();
+ }
+ return selection;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IStructuredSelection#toList()
+ */
+ public List toList() {
+ int size = size();
+ List selection = new ArrayList(size);
+ for (int i = 0; i < size; i++) {
+ selection.add(fPaths[i].getLastSegment());
+ }
+ return selection;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ISelection#isEmpty()
+ */
+ public boolean isEmpty() {
+ return size() == 0;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ public boolean equals(Object obj) {
+ if (obj instanceof TreeSelection) {
+ TreeSelection selection = (TreeSelection) obj;
+ int size = size();
+ if (selection.size() == size) {
+ if (size > 0) {
+ for (int i = 0; i < fPaths.length; i++) {
+ if (!fPaths[i].equals(selection.fPaths[i])) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ public int hashCode() {
+ int code = getClass().hashCode();
+ if (fPaths != null) {
+ for (int i = 0; i < fPaths.length; i++) {
+ code+=fPaths[i].hashCode();
+ }
+ }
+ return code;
+ }
+
+ /**
+ * Returns the paths in this selection
+ *
+ * @return the paths in this selection
+ */
+ public TreePath[] getPaths() {
+ return (TreePath[]) fPaths.clone();
+ }
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/AbstractUpdatePolicy.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/AbstractUpdatePolicy.java
new file mode 100644
index 000000000..8ead85266
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/AbstractUpdatePolicy.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.viewers.update;
+
+import org.eclipse.debug.internal.ui.viewers.AsynchronousViewer;
+import org.eclipse.debug.internal.ui.viewers.IUpdatePolicy;
+
+/**
+ * @since 3.2
+ *
+ */
+public abstract class AbstractUpdatePolicy implements IUpdatePolicy {
+
+ private AsynchronousViewer fViewer = null;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.viewers.IUpdatePolicy#init(org.eclipse.debug.ui.viewers.update.IPresentation)
+ */
+ public void init(AsynchronousViewer viewer) {
+ fViewer = viewer;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.viewers.IUpdatePolicy#dispose()
+ */
+ public synchronized void dispose() {
+ fViewer = null;
+ }
+
+ /**
+ * Returns the viewer this policy is installed on or <code>null</code>
+ * if disposed.
+ *
+ * @return presentation to update
+ */
+ public AsynchronousViewer getViewer() {
+ return fViewer;
+ }
+
+ protected synchronized boolean isDisposed() {
+ return fViewer == null;
+ }
+
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DebugEventHandler.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DebugEventHandler.java
new file mode 100644
index 000000000..95ee46604
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DebugEventHandler.java
@@ -0,0 +1,154 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.viewers.update;
+
+import org.eclipse.debug.core.DebugEvent;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.internal.ui.viewers.IModelDelta;
+import org.eclipse.debug.internal.ui.viewers.IModelProxy;
+
+/**
+ * Handles debug events for an event update policy in a viewer.
+ *
+ * @since 3.2
+ */
+public abstract class DebugEventHandler {
+
+ private IModelProxy fModelProxy;
+
+ /**
+ * Constructs an event handler for the given update policy.
+ *
+ * @param policy
+ */
+ public DebugEventHandler(IModelProxy proxy) {
+ fModelProxy = proxy;
+ }
+
+ /**
+ * Disposes this event handler
+ */
+ public void dispose() {
+ fModelProxy = null;
+ }
+
+ /**
+ * Returns the viewer this event handler is updating.
+ *
+ * @return
+ */
+ protected IModelProxy getModelProxy() {
+ return fModelProxy;
+ }
+
+ /**
+ * Returns whether this event handler handles the given event
+ *
+ * @param event event to handle
+ * @return whether this event handler handles the given event
+ */
+ protected abstract boolean handlesEvent(DebugEvent event);
+
+ /**
+ * Handles a create event.
+ *
+ * @param event
+ */
+ protected void handleCreate(DebugEvent event) {
+ refreshRoot(event);
+ }
+
+ /**
+ * Handles a terminate event.
+ *
+ * @param event
+ */
+ protected void handleTerminate(DebugEvent event) {
+ refreshRoot(event);
+ }
+
+ /**
+ * Handles a suspend event.
+ *
+ * @param event
+ */
+ protected void handleSuspend(DebugEvent event) {
+ refreshRoot(event);
+ }
+
+ /**
+ * Handles a resume event for which a suspend is expected shortly (<500ms).
+ *
+ * @param event
+ */
+ protected void handleResumeExpectingSuspend(DebugEvent event) {
+ refreshRoot(event);
+ }
+
+ /**
+ * Handles a resume event that is not expecting an immediate suspend event
+ *
+ * @param event
+ */
+ protected void handleResume(DebugEvent event) {
+ refreshRoot(event);
+ }
+
+ /**
+ * Handles a change event.
+ *
+ * @param event
+ */
+ protected void handleChange(DebugEvent event) {
+ refreshRoot(event);
+ }
+
+ /**
+ * Handles an unknown event.
+ *
+ * @param event
+ */
+ protected void handleOther(DebugEvent event) {
+ refreshRoot(event);
+ }
+
+ /**
+ * Notification that a pending suspend event was not received for the given
+ * resume event within the timeout period.
+ *
+ * @param resume resume event with missing suspend event
+ */
+ protected void handleSuspendTimeout(DebugEvent event) {
+ refreshRoot(event);
+ }
+
+ /**
+ * Handles the given suspend event which caused a timeout. It is
+ * parired with its original resume event.
+ *
+ * @param suspend suspend event
+ * @param resume resume event
+ */
+ protected void handleLateSuspend(DebugEvent suspend, DebugEvent resume) {
+ refreshRoot(suspend);
+ }
+
+ /**
+ * Fires a model delta to indicate that the launch manager should be refreshed.
+ * Subclasses should override individual handle events to provide deltas that
+ * better reflect the actual change in the model.
+ */
+ protected void refreshRoot(DebugEvent event) {
+ ModelDelta delta = new ModelDelta();
+ delta.addNode(DebugPlugin.getDefault().getLaunchManager(), IModelDelta.CHANGED | IModelDelta.CONTENT);
+ getModelProxy().fireModelChanged(delta);
+ }
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DebugTargetEventHandler.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DebugTargetEventHandler.java
new file mode 100644
index 000000000..fdac9e8b0
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DebugTargetEventHandler.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.viewers.update;
+
+import org.eclipse.debug.core.DebugEvent;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.model.IDebugTarget;
+import org.eclipse.debug.internal.ui.viewers.IModelDelta;
+import org.eclipse.debug.internal.ui.viewers.IModelDeltaNode;
+import org.eclipse.debug.internal.ui.viewers.IModelProxy;
+
+
+/**
+ * @since 3.2
+ */
+public class DebugTargetEventHandler extends DebugEventHandler {
+
+ /**
+ * Constructs an event handler for a debug target on the given viewer.
+ *
+ * @param viewer
+ */
+ public DebugTargetEventHandler(IModelProxy proxy) {
+ super(proxy);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.viewers.update.DebugEventHandler#handlesEvent(org.eclipse.debug.core.DebugEvent)
+ */
+ protected boolean handlesEvent(DebugEvent event) {
+ return event.getSource() instanceof IDebugTarget;
+ }
+
+ protected void handleChange(DebugEvent event) {
+ fireDelta((IDebugTarget) event.getSource(), IModelDelta.CHANGED | IModelDelta.STATE);
+ }
+
+ protected void handleCreate(DebugEvent event) {
+ fireDelta((IDebugTarget) event.getSource(), IModelDelta.ADDED | IModelDelta.CONTENT);
+ }
+
+ protected void handleResume(DebugEvent event) {
+ fireDelta((IDebugTarget) event.getSource(), IModelDelta.CHANGED | IModelDelta.STATE);
+ }
+
+ protected void handleSuspend(DebugEvent event) {
+ fireDelta((IDebugTarget) event.getSource(), IModelDelta.CHANGED | IModelDelta.CONTENT);
+ }
+
+ protected void handleTerminate(DebugEvent event) {
+ fireDelta((IDebugTarget) event.getSource(), IModelDelta.CHANGED | IModelDelta.STATE);
+ }
+
+ private void fireDelta(IDebugTarget target, int flags) {
+ ModelDelta delta = new ModelDelta();
+ IModelDeltaNode node = delta.addNode(DebugPlugin.getDefault().getLaunchManager(), IModelDelta.NOCHANGE);
+ node = node.addNode(target.getLaunch(), IModelDelta.NOCHANGE);
+ node.addNode(target, flags);
+ getModelProxy().fireModelChanged(delta);
+ }
+
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DebugTargetProxy.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DebugTargetProxy.java
new file mode 100644
index 000000000..fb79eafaf
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DebugTargetProxy.java
@@ -0,0 +1,94 @@
+package org.eclipse.debug.internal.ui.viewers.update;
+
+import org.eclipse.debug.core.DebugEvent;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.IDebugEventSetListener;
+import org.eclipse.debug.core.model.IDebugElement;
+import org.eclipse.debug.core.model.IDebugTarget;
+import org.eclipse.debug.core.model.IStackFrame;
+import org.eclipse.debug.core.model.IThread;
+import org.eclipse.debug.internal.ui.viewers.AbstractModelProxy;
+import org.eclipse.debug.internal.ui.viewers.IModelDelta;
+import org.eclipse.debug.internal.ui.viewers.IModelDeltaNode;
+import org.eclipse.debug.internal.ui.viewers.IPresentationContext;
+
+public class DebugTargetProxy extends AbstractModelProxy implements IDebugEventSetListener {
+
+ private IDebugTarget fDebugTarget;
+ private IPresentationContext fContext;
+
+ public DebugTargetProxy(IDebugTarget target) {
+ fDebugTarget = target;
+ }
+
+ public void init(IPresentationContext context) {
+ fContext = context;
+ DebugPlugin.getDefault().addDebugEventListener(this);
+ }
+
+ public void dispose() {
+ DebugPlugin.getDefault().removeDebugEventListener(this);
+ fContext = null;
+ }
+
+ public void handleDebugEvents(DebugEvent[] events) {
+ for (int i = 0; i < events.length; i++) {
+ DebugEvent event = events[i];
+ if (containsEvent(event)) {
+ switch (event.getKind()) {
+ case DebugEvent.CREATE:
+ dispatchCreate(event);
+ break;
+ case DebugEvent.TERMINATE:
+// dispatchTerminate(event);
+ break;
+ case DebugEvent.SUSPEND:
+// dispatchSuspend(event);
+ break;
+ case DebugEvent.RESUME:
+// dispatchResume(event);
+ break;
+ case DebugEvent.CHANGE:
+// dispatchChange(event);
+ break;
+ default:
+// dispatchOther(event);
+ break;
+ }
+ }
+ }
+ }
+
+ private void dispatchCreate(DebugEvent event) {
+ Object source = event.getSource();
+ ModelDelta delta = createDelta(source);
+ fireModelChanged(delta);
+ }
+
+ private ModelDelta createDelta(Object source) {
+ ModelDelta delta = new ModelDelta();
+ IModelDeltaNode node = delta.addNode(DebugPlugin.getDefault().getLaunchManager(), IModelDelta.NOCHANGE);
+ node = node.addNode(fDebugTarget.getLaunch(), IModelDelta.NOCHANGE);
+ node.addNode(fDebugTarget, IModelDelta.NOCHANGE);
+
+ if (source instanceof IThread) {
+ node.addNode(source, IModelDelta.ADDED | IModelDelta.CONTENT);
+ }
+
+ if (source instanceof IStackFrame) {
+ IStackFrame frame = (IStackFrame) source;
+ node.addNode(frame.getThread(), IModelDelta.NOCHANGE);
+ node.addNode(frame, IModelDelta.ADDED | IModelDelta.SELECT);
+ }
+ return delta;
+ }
+
+ protected boolean containsEvent(DebugEvent event) {
+ Object source = event.getSource();
+ if (source instanceof IDebugElement) {
+ return fDebugTarget.equals(((IDebugElement) source).getDebugTarget());
+ }
+ return false;
+ }
+
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DefaultModelProxyFactory.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DefaultModelProxyFactory.java
new file mode 100644
index 000000000..ffedccc52
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DefaultModelProxyFactory.java
@@ -0,0 +1,39 @@
+package org.eclipse.debug.internal.ui.viewers.update;
+
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.core.model.IDebugTarget;
+import org.eclipse.debug.core.model.IProcess;
+import org.eclipse.debug.core.model.IStackFrame;
+import org.eclipse.debug.internal.ui.viewers.IModelProxy;
+import org.eclipse.debug.internal.ui.viewers.IModelProxyFactory;
+import org.eclipse.debug.internal.ui.viewers.IPresentationContext;
+import org.eclipse.debug.ui.IDebugUIConstants;
+
+public class DefaultModelProxyFactory implements IModelProxyFactory {
+
+ public IModelProxy createModelProxy(Object element, IPresentationContext context) {
+ String id = context.getPart().getSite().getId();
+ if (IDebugUIConstants.ID_DEBUG_VIEW.equals(id)) {
+ if (element instanceof IDebugTarget) {
+ return new EventHandlerModelProxy();
+ }
+ if (element instanceof ILaunch) {
+ return new LaunchProxy((ILaunch)element);
+ }
+ if (element instanceof ILaunchManager) {
+ return new LaunchManagerProxy();
+ }
+ if (element instanceof IProcess) {
+ return new ProcessProxy((IProcess)element);
+ }
+ }
+ if (IDebugUIConstants.ID_VARIABLE_VIEW.equals(id)) {
+ if (element instanceof IStackFrame) {
+ return new DefaultVariableViewModelProxy((IStackFrame)element);
+ }
+ }
+ return null;
+ }
+
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DefaultSelectionPolicy.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DefaultSelectionPolicy.java
new file mode 100644
index 000000000..68db30414
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DefaultSelectionPolicy.java
@@ -0,0 +1,114 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.viewers.update;
+
+import org.eclipse.debug.core.model.IDebugElement;
+import org.eclipse.debug.core.model.IStackFrame;
+import org.eclipse.debug.internal.ui.viewers.IModelSelectionPolicy;
+import org.eclipse.debug.internal.ui.viewers.IPresentationContext;
+import org.eclipse.debug.ui.IDebugUIConstants;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IWorkbenchPart;
+
+/**
+ * @since 3.2
+ */
+public class DefaultSelectionPolicy implements IModelSelectionPolicy {
+
+ private IDebugElement fDebugElement;
+
+ /**
+ * Constructs a new selection policy for the given debug
+ * element.
+ *
+ * @param element
+ */
+ public DefaultSelectionPolicy(IDebugElement element) {
+ fDebugElement = element;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.viewers.IModelSelectionPolicy#contains(org.eclipse.jface.viewers.ISelection, org.eclipse.debug.ui.viewers.IPresentationContext)
+ */
+ public boolean contains(ISelection selection, IPresentationContext context) {
+ IWorkbenchPart part = context.getPart();
+ if (part != null) {
+ if (IDebugUIConstants.ID_DEBUG_VIEW.equals(part.getSite().getId())) {
+ if (selection instanceof IStructuredSelection) {
+ IStructuredSelection ss = (IStructuredSelection) selection;
+ Object element = ss.getFirstElement();
+ if (element instanceof IDebugElement) {
+ IDebugElement debugElement = (IDebugElement) element;
+ return fDebugElement.getDebugTarget().equals(debugElement.getDebugTarget());
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.viewers.IModelSelectionPolicy#overrides(org.eclipse.jface.viewers.ISelection, org.eclipse.jface.viewers.ISelection, org.eclipse.debug.ui.viewers.IPresentationContext)
+ */
+ public boolean overrides(ISelection existing, ISelection candidate, IPresentationContext context) {
+ IWorkbenchPart part = context.getPart();
+ if (part != null) {
+ if (IDebugUIConstants.ID_DEBUG_VIEW.equals(part.getSite().getId())) {
+ if (existing instanceof IStructuredSelection && candidate instanceof IStructuredSelection) {
+ IStructuredSelection ssExisting = (IStructuredSelection) existing;
+ IStructuredSelection ssCandidate = (IStructuredSelection) candidate;
+ return overrides(ssExisting.getFirstElement(), ssCandidate.getFirstElement());
+ }
+ }
+ }
+ return true;
+ }
+
+ protected boolean overrides(Object existing, Object candidate) {
+ if (existing == null) {
+ return true;
+ }
+ if (existing.equals(candidate)) {
+ return true;
+ }
+ if (existing instanceof IStackFrame && candidate instanceof IStackFrame) {
+ IStackFrame curr = (IStackFrame) existing;
+ IStackFrame next = (IStackFrame) candidate;
+ return curr.getThread().equals(next.getThread());
+ }
+ return !isSticky(existing);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.viewers.IModelSelectionPolicy#isSticky(org.eclipse.jface.viewers.ISelection, org.eclipse.debug.ui.viewers.IPresentationContext)
+ */
+ public boolean isSticky(ISelection selection, IPresentationContext context) {
+ IWorkbenchPart part = context.getPart();
+ if (part != null) {
+ if (IDebugUIConstants.ID_DEBUG_VIEW.equals(part.getSite().getId())) {
+ if (selection instanceof IStructuredSelection) {
+ return isSticky(((IStructuredSelection)selection).getFirstElement());
+ }
+ }
+ }
+ return false;
+ }
+
+ protected boolean isSticky(Object element) {
+ if (element instanceof IStackFrame) {
+ IStackFrame frame = (IStackFrame) element;
+ return frame.isSuspended();
+ }
+ return false;
+ }
+
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DefaultUpdatePolicy.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DefaultUpdatePolicy.java
new file mode 100644
index 000000000..f087d9d8d
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DefaultUpdatePolicy.java
@@ -0,0 +1,126 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.viewers.update;
+
+import java.util.ArrayList;
+
+import org.eclipse.debug.internal.ui.viewers.AsynchronousTreeViewer;
+import org.eclipse.debug.internal.ui.viewers.AsynchronousViewer;
+import org.eclipse.debug.internal.ui.viewers.IModelChangedListener;
+import org.eclipse.debug.internal.ui.viewers.IModelDelta;
+import org.eclipse.debug.internal.ui.viewers.IModelDeltaNode;
+import org.eclipse.debug.internal.ui.viewers.TreePath;
+import org.eclipse.debug.internal.ui.viewers.TreeSelection;
+
+/**
+ * Update policy for the launch manager.
+ *
+ * @since 3.2
+ */
+public class DefaultUpdatePolicy extends AbstractUpdatePolicy implements IModelChangedListener {
+
+ public DefaultUpdatePolicy() {
+ super();
+ }
+
+ public void init(AsynchronousViewer viewer) {
+ super.init(viewer);
+ }
+
+ public synchronized void dispose() {
+ super.dispose();
+ }
+
+ public void modelChanged(IModelDelta delta) {
+ IModelDeltaNode[] nodes = delta.getNodes();
+ updateNodes(nodes);
+ }
+
+ private void updateNodes(IModelDeltaNode[] nodes) {
+ for (int i = 0; i < nodes.length; i++) {
+ IModelDeltaNode node = nodes[i];
+ int flags = node.getFlags();
+
+ if ((flags & IModelDelta.CHANGED) != 0) {
+ handleChange(node);
+ } else if ((flags & IModelDelta.ADDED) != 0) {
+ handleAdd(node);
+ } else if ((flags & IModelDelta.REMOVED) != 0) {
+ handleRemove(node);
+ }
+
+ IModelDeltaNode[] childNodes = node.getNodes();
+ for (int j = 0; j < childNodes.length; j++) {
+ updateNodes(childNodes);
+ }
+ }
+ }
+
+ private void handleChange(IModelDeltaNode node) {
+ int flags = node.getFlags();
+ AsynchronousViewer viewer = getViewer();
+ if (viewer != null) {
+ if ((flags & IModelDelta.STATE) != 0) {
+ viewer.update(node.getElement());
+ }
+ if ((flags & IModelDelta.CONTENT) != 0) {
+ viewer.refresh(node.getElement());
+ }
+ if ((flags & IModelDelta.SELECT) != 0) {
+ viewer.update(node.getElement());
+ TreePath treePath = getTreePath(node);
+ ((AsynchronousTreeViewer) getViewer()).setSelection(new TreeSelection(treePath));
+ }
+ if ((flags & IModelDelta.EXPAND) != 0) {
+ viewer.update(node.getElement());
+ TreePath treePath = getTreePath(node);
+ ((AsynchronousTreeViewer) getViewer()).expand(new TreeSelection(treePath));
+ }
+ }
+ }
+
+ private void handleAdd(IModelDeltaNode node) {
+ int flags = node.getFlags();
+ final TreePath treePath = getTreePath(node);
+
+ ((AsynchronousTreeViewer) getViewer()).add(treePath);
+
+ if ((flags & IModelDelta.STATE) != 0) {
+ // do nothing??
+ }
+ if ((flags & IModelDelta.CONTENT) != 0) {
+ // do nothing??
+ }
+ if ((flags & IModelDelta.SELECT) != 0) {
+ ((AsynchronousTreeViewer) getViewer()).setSelection(new TreeSelection(treePath));
+ }
+ if ((flags & IModelDelta.EXPAND) != 0) {
+ ((AsynchronousTreeViewer) getViewer()).expand(new TreeSelection(treePath));
+ }
+ }
+
+ private void handleRemove(IModelDeltaNode node) {
+ TreePath treePath = getTreePath(node);
+ ((AsynchronousTreeViewer) getViewer()).remove(treePath);
+ }
+
+ private TreePath getTreePath(IModelDeltaNode node) {
+ ArrayList list = new ArrayList();
+ list.add(0, node.getElement());
+ while (node.getParent() != null) {
+ node = node.getParent();
+ list.add(0, node.getElement());
+ }
+
+ return new TreePath(list.toArray());
+ }
+
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DefaultUpdatePolicyFactory.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DefaultUpdatePolicyFactory.java
new file mode 100644
index 000000000..4f265b895
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DefaultUpdatePolicyFactory.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.viewers.update;
+
+import org.eclipse.debug.internal.ui.viewers.IPresentationContext;
+import org.eclipse.debug.internal.ui.viewers.IUpdatePolicy;
+import org.eclipse.debug.internal.ui.viewers.IUpdatePolicyFactory;
+
+/**
+ * @since 3.2
+ */
+public class DefaultUpdatePolicyFactory implements IUpdatePolicyFactory {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.debug.ui.viewers.IUpdatePolicyFactory#createUpdatePolicy(java.lang.Object,
+ * org.eclipse.debug.ui.viewers.IPresentationContext)
+ */
+ public IUpdatePolicy createUpdatePolicy(IPresentationContext context) {
+ return new DefaultUpdatePolicy();
+ }
+
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DefaultVariableViewModelProxy.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DefaultVariableViewModelProxy.java
new file mode 100644
index 000000000..17e211d8b
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DefaultVariableViewModelProxy.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.viewers.update;
+
+import org.eclipse.debug.core.DebugEvent;
+import org.eclipse.debug.core.model.IDebugElement;
+import org.eclipse.debug.core.model.IStackFrame;
+
+/**
+ * Default update for variables view.
+ *
+ * @since 3.2
+ */
+public class DefaultVariableViewModelProxy extends EventHandlerModelProxy {
+
+ /**
+ * Root model element for this update policy
+ */
+ private IStackFrame fFrame;
+
+ /**
+ * Constructs an update policy on the given target.
+ *
+ * @param target
+ */
+ public DefaultVariableViewModelProxy(IStackFrame frame) {
+ super();
+ fFrame = frame;
+ }
+
+ public void dispose() {
+ fFrame = null;
+ }
+
+ protected DebugEventHandler[] createEventHandlers() {
+ return new DebugEventHandler[] { new VariablesViewEventHandler(this, fFrame) };
+ }
+
+ protected boolean containsEvent(DebugEvent event) {
+ Object source = event.getSource();
+ if (source instanceof IDebugElement) {
+ return fFrame.getDebugTarget().equals(((IDebugElement) source).getDebugTarget());
+ }
+ return false;
+ }
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/EventHandlerModelProxy.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/EventHandlerModelProxy.java
new file mode 100644
index 000000000..d25899042
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/EventHandlerModelProxy.java
@@ -0,0 +1,251 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.viewers.update;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Timer;
+import java.util.TimerTask;
+
+import org.eclipse.debug.core.DebugEvent;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.IDebugEventSetListener;
+import org.eclipse.debug.internal.ui.viewers.AbstractModelProxy;
+import org.eclipse.debug.internal.ui.viewers.IPresentationContext;
+
+/**
+ * @since 3.2
+ */
+public class EventHandlerModelProxy extends AbstractModelProxy implements IDebugEventSetListener {
+
+ /**
+ * Map of elements to timer tasks
+ */
+ private Map fTimerTasks = new HashMap();
+
+ /**
+ * Timer for timer tasks
+ */
+ private Timer fTimer = new Timer(true);
+
+ /**
+ * Map of event source to resume events with a pending suspend that timed
+ * out.
+ */
+ private Map fPendingSuspends = new HashMap();
+
+ /**
+ * Event handlers for specific elements
+ */
+ private DebugEventHandler[] fHandlers = new DebugEventHandler[0];
+
+ private boolean fDisposed = false;
+
+ /**
+ * Task used to update an element that resumed for a step or evaluation that
+ * took too long to suspend.
+ */
+ private class PendingSuspendTask extends TimerTask {
+
+ private DebugEvent fEvent;
+ private DebugEventHandler fHandler;
+
+ /**
+ * Resume event for which there is a pending suspend.
+ *
+ * @param resume event
+ */
+ public PendingSuspendTask(DebugEventHandler handler, DebugEvent resume) {
+ fHandler = handler;
+ fEvent = resume;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.util.TimerTask#run()
+ */
+ public void run() {
+ synchronized (fPendingSuspends) {
+ fPendingSuspends.put(fEvent.getSource(), fEvent);
+ }
+ dispatchSuspendTimeout(fHandler, fEvent);
+ }
+
+ }
+
+ /**
+ * Adds the given handler to this event update policy.
+ *
+ * @param handler
+ */
+ protected DebugEventHandler[] createEventHandlers() {
+ return new DebugEventHandler[] { new DebugTargetEventHandler(this), new ThreadEventHandler(this) };
+ }
+
+ public synchronized void dispose() {
+ fDisposed = true;
+ fTimer.cancel();
+ fTimerTasks.clear();
+ DebugPlugin.getDefault().removeDebugEventListener(this);
+ for (int i = 0; i < fHandlers.length; i++) {
+ DebugEventHandler handler = fHandlers[i];
+ handler.dispose();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.debug.internal.ui.viewers.update.AbstractUpdatePolicy#init(org.eclipse.debug.ui.viewers.update.IPresentation)
+ */
+ public void init(IPresentationContext context) {
+ DebugPlugin.getDefault().addDebugEventListener(this);
+ fHandlers = createEventHandlers();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.debug.core.IDebugEventSetListener#handleDebugEvents(org.eclipse.debug.core.DebugEvent[])
+ */
+ public synchronized final void handleDebugEvents(DebugEvent[] events) {
+ if (isDisposed()) {
+ return;
+ }
+ for (int i = 0; i < events.length; i++) {
+ DebugEvent event = events[i];
+ for (int j = 0; j < fHandlers.length; j++) {
+ DebugEventHandler handler = fHandlers[j];
+ if (handler.handlesEvent(event)) {
+ switch (event.getKind()) {
+ case DebugEvent.CREATE:
+ dispatchCreate(handler, event);
+ break;
+ case DebugEvent.TERMINATE:
+ dispatchTerminate(handler, event);
+ break;
+ case DebugEvent.SUSPEND:
+ dispatchSuspend(handler, event);
+ break;
+ case DebugEvent.RESUME:
+ dispatchResume(handler, event);
+ break;
+ case DebugEvent.CHANGE:
+ dispatchChange(handler, event);
+ break;
+ default:
+ dispatchOther(handler, event);
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ private boolean isDisposed() {
+ return fDisposed;
+ }
+
+ /**
+ * Dispatches a create event.
+ *
+ * @param event
+ */
+ protected void dispatchCreate(DebugEventHandler handler, DebugEvent event) {
+ handler.handleCreate(event);
+ }
+
+ /**
+ * Dispatches a terminate event.
+ *
+ * @param event
+ */
+ protected void dispatchTerminate(DebugEventHandler handler, DebugEvent event) {
+ handler.handleTerminate(event);
+ }
+
+ /**
+ * Dispatches a suspend event. Subclasses may override.
+ *
+ * @param event
+ */
+ protected void dispatchSuspend(DebugEventHandler handler, DebugEvent event) {
+ // stop timer, if any
+ synchronized (fTimerTasks) {
+ TimerTask task = (TimerTask) fTimerTasks.remove(event.getSource());
+ if (task != null) {
+ task.cancel();
+ }
+ }
+ DebugEvent resume = null;
+ synchronized (fPendingSuspends) {
+ resume = (DebugEvent) fPendingSuspends.remove(event.getSource());
+ }
+ if (resume == null) {
+ handler.handleSuspend(event);
+ } else {
+ handler.handleLateSuspend(event, resume);
+ }
+ }
+
+ /**
+ * Dispatches a resume event. By default, if the resume is for an evaluation
+ * or a step, a timer is started to update the event source if the step or
+ * evaluation takes more than 500ms. Otherwise the source is refreshed.
+ * Subclasses may override.
+ *
+ * @param event
+ */
+ protected void dispatchResume(DebugEventHandler handler, DebugEvent event) {
+ if (event.isEvaluation() || event.isStepStart()) {
+ // start a timer to update if the corresponding suspend does not
+ // come quickly
+ PendingSuspendTask task = new PendingSuspendTask(handler, event);
+ synchronized (fTimerTasks) {
+ fTimerTasks.put(event.getSource(), task);
+ }
+ fTimer.schedule(task, 500);
+ handler.handleResumeExpectingSuspend(event);
+ } else {
+ handler.handleResume(event);
+ }
+ }
+
+ /**
+ * Dispatches a change event.
+ *
+ * @param event
+ */
+ protected void dispatchChange(DebugEventHandler handler, DebugEvent event) {
+ handler.handleChange(event);
+ }
+
+ /**
+ * Dispatches an unknown event.
+ *
+ * @param event
+ */
+ protected void dispatchOther(DebugEventHandler handler, DebugEvent event) {
+ handler.handleOther(event);
+ }
+
+ /**
+ * Notification that a pending suspend event was not received for the given
+ * resume event and handler within the timeout period.
+ *
+ * @param resume resume event with missing suspend event
+ */
+ protected void dispatchSuspendTimeout(DebugEventHandler handler, DebugEvent resume) {
+ handler.handleSuspendTimeout(resume);
+ }
+
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/LaunchManagerProxy.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/LaunchManagerProxy.java
new file mode 100644
index 000000000..91db2de16
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/LaunchManagerProxy.java
@@ -0,0 +1,66 @@
+package org.eclipse.debug.internal.ui.viewers.update;
+
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.core.ILaunchesListener2;
+import org.eclipse.debug.internal.ui.viewers.AbstractModelProxy;
+import org.eclipse.debug.internal.ui.viewers.IModelDelta;
+import org.eclipse.debug.internal.ui.viewers.IModelDeltaNode;
+import org.eclipse.debug.internal.ui.viewers.IPresentationContext;
+
+public class LaunchManagerProxy extends AbstractModelProxy implements ILaunchesListener2 {
+
+ private ILaunchManager fLaunchManager;
+
+ public void init(IPresentationContext context) {
+ fLaunchManager = DebugPlugin.getDefault().getLaunchManager();
+ fLaunchManager.addLaunchListener(this);
+ }
+
+ public void dispose() {
+ fLaunchManager.removeLaunchListener(this);
+ fLaunchManager = null;
+ }
+
+ public void launchesTerminated(ILaunch[] launches) {
+ ModelDelta delta = new ModelDelta();
+ IModelDeltaNode node = delta.addNode(fLaunchManager, IModelDelta.NOCHANGE);
+ for (int i = 0; i < launches.length; i++) {
+ ILaunch launch = launches[i];
+ node.addNode(launch, IModelDelta.CHANGED | IModelDelta.CONTENT);
+ }
+ fireModelChanged(delta);
+ }
+
+ public void launchesRemoved(ILaunch[] launches) {
+ ModelDelta delta = new ModelDelta();
+ IModelDeltaNode node = delta.addNode(fLaunchManager, IModelDelta.CHANGED | IModelDelta.CONTENT);
+ for (int i = 0; i < launches.length; i++) {
+ ILaunch launch = launches[i];
+ node.addNode(launch, IModelDelta.REMOVED);
+ }
+ fireModelChanged(delta);
+ }
+
+ public void launchesAdded(ILaunch[] launches) {
+ ModelDelta delta = new ModelDelta();
+ IModelDeltaNode node = delta.addNode(fLaunchManager, IModelDelta.NOCHANGE);
+ for (int i = 0; i < launches.length; i++) {
+ ILaunch launch = launches[i];
+ node.addNode(launch, IModelDelta.ADDED | IModelDelta.EXPAND);
+ }
+ fireModelChanged(delta);
+ }
+
+ public void launchesChanged(ILaunch[] launches) {
+ ModelDelta delta = new ModelDelta();
+ IModelDeltaNode node = delta.addNode(fLaunchManager, IModelDelta.NOCHANGE);
+ for (int i = 0; i < launches.length; i++) {
+ ILaunch launch = launches[i];
+ node.addNode(launch, IModelDelta.CHANGED | IModelDelta.STATE);
+ }
+ fireModelChanged(delta);
+ }
+
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/LaunchProxy.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/LaunchProxy.java
new file mode 100644
index 000000000..4300f1583
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/LaunchProxy.java
@@ -0,0 +1,80 @@
+package org.eclipse.debug.internal.ui.viewers.update;
+
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.core.ILaunchesListener2;
+import org.eclipse.debug.internal.ui.viewers.AbstractModelProxy;
+import org.eclipse.debug.internal.ui.viewers.IModelDelta;
+import org.eclipse.debug.internal.ui.viewers.IModelDeltaNode;
+import org.eclipse.debug.internal.ui.viewers.IPresentationContext;
+
+public class LaunchProxy extends AbstractModelProxy implements ILaunchesListener2 {
+
+ private ILaunchManager fLaunchManager = DebugPlugin.getDefault().getLaunchManager();
+ private ILaunch fLaunch;
+
+ LaunchProxy(ILaunch launch) {
+ fLaunch = launch;
+ }
+
+ public void init(IPresentationContext context) {
+ fLaunchManager.addLaunchListener(this);
+ }
+
+ public void dispose() {
+ fLaunchManager.removeLaunchListener(this);
+ }
+
+ public void launchesTerminated(ILaunch[] launches) {
+ for (int i = 0; i < launches.length; i++) {
+ if (launches[i] == fLaunch) {
+ ModelDelta delta = new ModelDelta();
+ IModelDeltaNode node = delta.addNode(fLaunchManager, IModelDelta.NOCHANGE);
+ node.addNode(fLaunch, IModelDelta.CHANGED | IModelDelta.CONTENT);
+ fireModelChanged(delta);
+ return;
+ }
+ }
+
+
+ }
+
+ public void launchesRemoved(ILaunch[] launches) {
+// for (int i = 0; i < launches.length; i++) {
+// if (launches[i] == fLaunch) {
+// ModelDelta delta = new ModelDelta();
+// IModelDeltaNode node = delta.addNode(fLaunchManager, IModelDelta.NOCHANGE);
+// node.addNode(fLaunch, IModelDelta.REMOVED);
+// fireModelChanged(delta);
+// return;
+// }
+// }
+ }
+
+ public void launchesAdded(ILaunch[] launches) {
+// for (int i = 0; i < launches.length; i++) {
+// if (launches[i] == fLaunch) {
+// ModelDelta delta = new ModelDelta();
+// IModelDeltaNode node = delta.addNode(fLaunchManager, IModelDelta.NOCHANGE);
+// node.addNode(fLaunch, IModelDelta.ADDED | IModelDelta.CONTENT | IModelDelta.EXPAND);
+// node.addNode(new Object(), IModelDelta.ADDED | IModelDelta.EXPAND);
+// fireModelChanged(delta);
+// return;
+// }
+// }
+ }
+
+ public void launchesChanged(ILaunch[] launches) {
+ for (int i = 0; i < launches.length; i++) {
+ if (launches[i] == fLaunch) {
+ ModelDelta delta = new ModelDelta();
+ IModelDeltaNode node = delta.addNode(fLaunchManager, IModelDelta.NOCHANGE);
+ node.addNode(fLaunch, IModelDelta.CHANGED | IModelDelta.CONTENT);
+ fireModelChanged(delta);
+ return;
+ }
+ }
+ }
+
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/ModelDelta.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/ModelDelta.java
new file mode 100644
index 000000000..b80c337af
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/ModelDelta.java
@@ -0,0 +1,23 @@
+package org.eclipse.debug.internal.ui.viewers.update;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.debug.internal.ui.viewers.IModelDelta;
+import org.eclipse.debug.internal.ui.viewers.IModelDeltaNode;
+
+public class ModelDelta implements IModelDelta {
+
+ private List fNodes = new ArrayList();
+
+ public IModelDeltaNode addNode(Object element, int flags) {
+ ModelDeltaNode node = new ModelDeltaNode(element, flags);
+ fNodes.add(node);
+ return node;
+ }
+
+ public IModelDeltaNode[] getNodes() {
+ return (ModelDeltaNode[]) fNodes.toArray(new ModelDeltaNode[0]);
+ }
+
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/ModelDeltaNode.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/ModelDeltaNode.java
new file mode 100644
index 000000000..d14618d94
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/ModelDeltaNode.java
@@ -0,0 +1,47 @@
+package org.eclipse.debug.internal.ui.viewers.update;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.debug.internal.ui.viewers.IModelDeltaNode;
+
+public class ModelDeltaNode implements IModelDeltaNode {
+
+ private IModelDeltaNode fParent;
+ private Object fElement;
+ private int fFlags;
+ private List fNodes = new ArrayList();
+
+ public ModelDeltaNode(Object element, int flags) {
+ fElement = element;
+ fFlags = flags;
+ }
+
+ public Object getElement() {
+ return fElement;
+ }
+
+ public int getFlags() {
+ return fFlags;
+ }
+
+ public IModelDeltaNode addNode(Object element, int flags) {
+ ModelDeltaNode node = new ModelDeltaNode(element, flags);
+ node.setParent(this);
+ fNodes.add(node);
+ return node;
+ }
+
+ void setParent(ModelDeltaNode node) {
+ fParent = node;
+ }
+
+ public IModelDeltaNode getParent() {
+ return fParent;
+ }
+
+ public ModelDeltaNode[] getNodes() {
+ return (ModelDeltaNode[]) fNodes.toArray(new ModelDeltaNode[0]);
+ }
+
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/ProcessProxy.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/ProcessProxy.java
new file mode 100644
index 000000000..9742b280d
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/ProcessProxy.java
@@ -0,0 +1,62 @@
+package org.eclipse.debug.internal.ui.viewers.update;
+
+import org.eclipse.debug.core.DebugEvent;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.IDebugEventSetListener;
+import org.eclipse.debug.core.model.IProcess;
+import org.eclipse.debug.internal.ui.viewers.AbstractModelProxy;
+import org.eclipse.debug.internal.ui.viewers.IModelDelta;
+import org.eclipse.debug.internal.ui.viewers.IModelDeltaNode;
+import org.eclipse.debug.internal.ui.viewers.IPresentationContext;
+
+public class ProcessProxy extends AbstractModelProxy implements IDebugEventSetListener {
+
+ private IProcess fProcess;
+
+ public ProcessProxy(IProcess process) {
+ fProcess = process;
+ }
+
+ public void init(IPresentationContext context) {
+ DebugPlugin.getDefault().addDebugEventListener(this);
+ }
+
+ public void dispose() {
+ DebugPlugin.getDefault().removeDebugEventListener(this);
+ }
+
+ protected synchronized boolean containsEvent(DebugEvent event) {
+ return fProcess.equals(event.getSource());
+ }
+
+ public void handleDebugEvents(DebugEvent[] events) {
+ for (int i = 0; i < events.length; i++) {
+ DebugEvent event = events[i];
+ switch (event.getKind()) {
+ case DebugEvent.CREATE:
+ handleCreate();
+ break;
+ default:
+ handleChange();
+ break;
+ }
+ }
+ }
+
+ private void handleChange() {
+ ModelDelta delta = new ModelDelta();
+ IModelDeltaNode node = delta.addNode(DebugPlugin.getDefault().getLaunchManager(), IModelDelta.NOCHANGE);
+ node = node.addNode(fProcess.getLaunch(), IModelDelta.NOCHANGE);
+ node.addNode(fProcess, IModelDelta.CHANGED | IModelDelta.STATE);
+ fireModelChanged(delta);
+ }
+
+ private void handleCreate() {
+ ModelDelta delta = new ModelDelta();
+ IModelDeltaNode node = delta.addNode(DebugPlugin.getDefault().getLaunchManager(), IModelDelta.NOCHANGE);
+ node = node.addNode(fProcess.getLaunch(), IModelDelta.NOCHANGE);
+ node.addNode(fProcess, IModelDelta.ADDED);
+ fireModelChanged(delta);
+ }
+
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/ThreadEventHandler.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/ThreadEventHandler.java
new file mode 100644
index 000000000..c8f5feeda
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/ThreadEventHandler.java
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.viewers.update;
+
+import org.eclipse.debug.core.DebugEvent;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.model.IThread;
+import org.eclipse.debug.internal.ui.viewers.IModelDelta;
+import org.eclipse.debug.internal.ui.viewers.IModelDeltaNode;
+import org.eclipse.debug.internal.ui.viewers.IModelProxy;
+
+/**
+ * @since 3.2
+ */
+public class ThreadEventHandler extends DebugEventHandler {
+ /**
+ * Constructs and event handler for a threads in the given viewer.
+ *
+ * @param viewer
+ */
+ public ThreadEventHandler(IModelProxy proxy) {
+ super(proxy);
+ }
+
+ public void dispose() {
+ super.dispose();
+ }
+
+ protected void handleSuspend(DebugEvent event) {
+ fireDelta((IThread) event.getSource(), IModelDelta.CHANGED | IModelDelta.CONTENT | IModelDelta.EXPAND);
+ }
+
+ protected void handleResumeExpectingSuspend(DebugEvent event) {
+ fireDelta((IThread) event.getSource(), IModelDelta.CHANGED | IModelDelta.STATE);
+ }
+
+ protected void handleResume(DebugEvent event) {
+ fireDelta((IThread) event.getSource(), IModelDelta.CHANGED | IModelDelta.STATE);
+ }
+
+ protected void handleCreate(DebugEvent event) {
+ fireDelta((IThread) event.getSource(), IModelDelta.ADDED | IModelDelta.STATE);
+ }
+
+ protected void handleTerminate(DebugEvent event) {
+ fireDelta((IThread) event.getSource(), IModelDelta.REMOVED);
+ }
+
+ protected void handleChange(DebugEvent event) {
+ fireDelta((IThread) event.getSource(), IModelDelta.CHANGED | IModelDelta.STATE);
+ }
+
+ protected void handleLateSuspend(DebugEvent suspend, DebugEvent resume) {
+ fireDelta((IThread) suspend.getSource(), IModelDelta.CHANGED | IModelDelta.CONTENT | IModelDelta.EXPAND);
+ }
+
+ protected void handleSuspendTimeout(DebugEvent event) {
+ fireDelta((IThread) event.getSource(), IModelDelta.CHANGED | IModelDelta.CONTENT);
+ }
+
+ private void fireDelta(IThread thread, int flags) {
+ ModelDelta delta = new ModelDelta();
+ IModelDeltaNode node = delta.addNode(DebugPlugin.getDefault().getLaunchManager(), IModelDelta.NOCHANGE);
+ node = node.addNode(thread.getLaunch(), IModelDelta.NOCHANGE);
+ node = node.addNode(thread.getDebugTarget(), IModelDelta.NOCHANGE);
+ node = node.addNode(thread, flags);
+ if ((flags & IModelDelta.EXPAND) != 0) {
+ Object topStackFrame = null;
+ try {
+ topStackFrame = thread.getTopStackFrame();
+ } catch (DebugException e) {
+ topStackFrame = new Object();
+ }
+ node.addNode(topStackFrame, IModelDelta.CHANGED | IModelDelta.SELECT);
+ }
+ getModelProxy().fireModelChanged(delta);
+ }
+
+ protected boolean handlesEvent(DebugEvent event) {
+ return event.getSource() instanceof IThread;
+ }
+
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/VariablesViewEventHandler.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/VariablesViewEventHandler.java
new file mode 100644
index 000000000..ce13ee6c6
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/VariablesViewEventHandler.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.viewers.update;
+
+import org.eclipse.debug.core.DebugEvent;
+import org.eclipse.debug.core.model.IStackFrame;
+import org.eclipse.debug.core.model.ISuspendResume;
+import org.eclipse.debug.internal.ui.viewers.IModelDelta;
+import org.eclipse.debug.internal.ui.viewers.IModelProxy;
+
+/**
+ *
+ * @since 3.2
+ */
+public class VariablesViewEventHandler extends DebugEventHandler {
+
+ private IStackFrame fFrame;
+
+ public VariablesViewEventHandler(IModelProxy proxy, IStackFrame frame) {
+ super(proxy);
+ fFrame = frame;
+ }
+
+ protected boolean handlesEvent(DebugEvent event) {
+ return true;
+ }
+
+ protected void refreshRoot(DebugEvent event) {
+ if (event.getDetail() != DebugEvent.EVALUATION_IMPLICIT) {
+ // Don't refresh everytime an implicit evaluation finishes
+ if (event.getSource() instanceof ISuspendResume) {
+ if (!((ISuspendResume)event.getSource()).isSuspended()) {
+ // no longer suspended
+ return;
+ }
+ }
+
+ ModelDelta delta = new ModelDelta();
+ delta.addNode(fFrame, IModelDelta.CHANGED | IModelDelta.CONTENT);
+ getModelProxy().fireModelChanged(delta);
+ //TODO: popuplate details pane (should it be built into the viewer?)
+ }
+ }
+
+ protected void handleResume(DebugEvent event) {
+ super.handleResume(event);
+ }
+
+
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/AbstractDebugEventHandler.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/AbstractDebugEventHandler.java
index deac03e1e..ceeb5838e 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/AbstractDebugEventHandler.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/AbstractDebugEventHandler.java
@@ -21,10 +21,12 @@ import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.debug.core.DebugEvent;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.IDebugEventSetListener;
+import org.eclipse.debug.internal.ui.viewers.AsynchronousTreeViewer;
import org.eclipse.debug.ui.AbstractDebugView;
import org.eclipse.jface.viewers.IBasicPropertyConstants;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.ui.progress.UIJob;
@@ -74,7 +76,7 @@ public abstract class AbstractDebugEventHandler implements IDebugEventSetListene
private static final int TIMEOUT = 200;
public EventProcessingJob() {
- super(DebugUIViewsMessages.AbstractDebugEventHandler_0);
+ super(DebugUIViewsMessages.AbstractDebugEventHandler_0);
setSystem(true);
setPriority(Job.INTERACTIVE);
}
@@ -200,13 +202,15 @@ public abstract class AbstractDebugEventHandler implements IDebugEventSetListene
*/
protected void insert(Object element) {
if (isAvailable()) {
- Object parent= ((ITreeContentProvider)getTreeViewer().getContentProvider()).getParent(element);
- // a parent can be null for a debug target or process that has not yet been associated
- // with a launch
- if (parent != null) {
- getView().showViewer();
- getTreeViewer().add(parent, element);
- }
+ Viewer viewer = getViewer();
+ if (viewer instanceof TreeViewer) {
+ TreeViewer tv = (TreeViewer) viewer;
+ Object parent = ((ITreeContentProvider)tv.getContentProvider()).getParent(element);
+ if (parent != null) {
+ getView().showViewer();
+ tv.add(parent, element);
+ }
+ }
}
}
@@ -216,7 +220,14 @@ public abstract class AbstractDebugEventHandler implements IDebugEventSetListene
protected void remove(Object element) {
if (isAvailable()) {
getView().showViewer();
- getTreeViewer().remove(element);
+ Viewer viewer = getViewer();
+ if (viewer instanceof TreeViewer) {
+ TreeViewer tv = (TreeViewer) viewer;
+ tv.remove(element);
+ } else if (viewer instanceof AsynchronousTreeViewer) {
+ AsynchronousTreeViewer atv = (AsynchronousTreeViewer) viewer;
+ atv.refresh();
+ }
}
}
@@ -226,7 +237,14 @@ public abstract class AbstractDebugEventHandler implements IDebugEventSetListene
protected void labelChanged(Object element) {
if (isAvailable()) {
getView().showViewer();
- getTreeViewer().update(element, new String[] {IBasicPropertyConstants.P_TEXT});
+ Viewer viewer = getViewer();
+ if (viewer instanceof TreeViewer) {
+ TreeViewer tv = (TreeViewer) viewer;
+ tv.update(element, new String[] {IBasicPropertyConstants.P_TEXT});
+ } else if (viewer instanceof AsynchronousTreeViewer) {
+ AsynchronousTreeViewer atv = (AsynchronousTreeViewer) viewer;
+ atv.update(element);
+ }
}
}
@@ -236,7 +254,14 @@ public abstract class AbstractDebugEventHandler implements IDebugEventSetListene
protected void refresh(Object element) {
if (isAvailable()) {
getView().showViewer();
- getTreeViewer().refresh(element);
+ Viewer viewer = getViewer();
+ if (viewer instanceof TreeViewer) {
+ TreeViewer treeViewer = (TreeViewer) viewer;
+ treeViewer.refresh(element);
+ } else if (viewer instanceof AsynchronousTreeViewer) {
+ AsynchronousTreeViewer asyncTreeViewer = (AsynchronousTreeViewer) viewer;
+ asyncTreeViewer.refresh(element);
+ }
}
}
@@ -246,7 +271,7 @@ public abstract class AbstractDebugEventHandler implements IDebugEventSetListene
public void refresh() {
if (isAvailable()) {
getView().showViewer();
- getTreeViewer().refresh();
+ getViewer().refresh();
}
}
@@ -299,17 +324,17 @@ public abstract class AbstractDebugEventHandler implements IDebugEventSetListene
protected Viewer getViewer() {
return getView().getViewer();
}
-
+
/**
- * Returns this event handler's viewer as a tree
+ * Returns this event handler's viewer as a structured
* viewer or <code>null</code> if none.
*
- * @return this event handler's viewer as a tree
+ * @return this event handler's viewer as a structured
* viewer or <code>null</code> if none
*/
- protected TreeViewer getTreeViewer() {
- if (getViewer() instanceof TreeViewer) {
- return (TreeViewer)getViewer();
+ protected StructuredViewer getStructuredViewer() {
+ if (getViewer() instanceof StructuredViewer) {
+ return (StructuredViewer)getViewer();
}
return null;
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/AbstractDebugEventHandlerView.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/AbstractDebugEventHandlerView.java
index 8cb5f3991..723ea3624 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/AbstractDebugEventHandlerView.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/AbstractDebugEventHandlerView.java
@@ -58,7 +58,10 @@ public abstract class AbstractDebugEventHandlerView extends AbstractDebugView {
*/
protected void becomesHidden() {
super.becomesHidden();
- getEventHandler().viewBecomesHidden();
+ AbstractDebugEventHandler eventHandler = getEventHandler();
+ if (eventHandler != null) {
+ getEventHandler().viewBecomesHidden();
+ }
}
/**
@@ -66,7 +69,10 @@ public abstract class AbstractDebugEventHandlerView extends AbstractDebugView {
*/
protected void becomesVisible() {
super.becomesVisible();
- getEventHandler().viewBecomesVisible();
+ AbstractDebugEventHandler eventHandler = getEventHandler();
+ if (eventHandler != null) {
+ eventHandler.viewBecomesVisible();
+ }
}
protected void clearStatusLine() {
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/AbstractViewerState.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/AbstractViewerState.java
index fab435003..6363d9aed 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/AbstractViewerState.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/AbstractViewerState.java
@@ -12,11 +12,12 @@ package org.eclipse.debug.internal.ui.views;
import java.util.ArrayList;
import java.util.List;
+
import org.eclipse.core.runtime.IPath;
import org.eclipse.debug.core.DebugException;
-import org.eclipse.debug.internal.ui.views.variables.VariablesViewer;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.debug.internal.ui.viewers.AsynchronousTreeViewer;
+import org.eclipse.debug.internal.ui.viewers.TreePath;
+import org.eclipse.debug.internal.ui.viewers.TreeSelection;
import org.eclipse.swt.widgets.TreeItem;
/**
@@ -26,19 +27,15 @@ import org.eclipse.swt.widgets.TreeItem;
public abstract class AbstractViewerState {
// paths to expanded elements
- protected List fSavedExpansion = null;
- protected IPath[] fSelection;
+ private List fSavedExpansion = null;
+ private IPath[] fSelection;
/**
* Constructs a memento for the given viewer.
*/
- public AbstractViewerState(TreeViewer viewer) {
+ public AbstractViewerState(AsynchronousTreeViewer viewer) {
saveState(viewer);
}
-
- public AbstractViewerState() {
-
- }
/**
* Saves the current state of the given viewer into
@@ -46,7 +43,7 @@ public abstract class AbstractViewerState {
*
* @param viewer viewer of which to save the state
*/
- public void saveState(TreeViewer viewer) {
+ public void saveState(AsynchronousTreeViewer viewer) {
List expanded = new ArrayList();
fSavedExpansion = null;
TreeItem[] items = viewer.getTree().getItems();
@@ -75,17 +72,30 @@ public abstract class AbstractViewerState {
}
}
- protected void collectExpandedItems(TreeItem item, List expanded) throws DebugException {
+ /**
+ * Collects paths to expanded children of the given element and returns
+ * whether any paths were expanded.
+ *
+ * @param item item to collect expanded paths for
+ * @param expanded list to add to
+ * @return whether any paths were found expanded
+ * @throws DebugException
+ */
+ protected boolean collectExpandedItems(TreeItem item, List expanded) throws DebugException {
if (item.getExpanded()) {
- IPath path = encodeElement(item);
- if (path != null) {
- expanded.add(path);
- TreeItem[] items = item.getItems();
- for (int i = 0; i < items.length; i++) {
- collectExpandedItems(items[i], expanded);
- }
+ boolean childExpanded = false;
+ TreeItem[] items = item.getItems();
+ for (int i = 0; i < items.length; i++) {
+ childExpanded = collectExpandedItems(items[i], expanded) || childExpanded;
}
+ if (!childExpanded) {
+ IPath path = encodeElement(item);
+ expanded.add(path);
+ }
+ } else {
+ return false;
}
+ return true;
}
/**
@@ -105,45 +115,41 @@ public abstract class AbstractViewerState {
*
* @param viewer viewer to which state is restored
*/
- public void restoreState(TreeViewer viewer) {
+ public void restoreState(AsynchronousTreeViewer viewer) {
boolean expansionComplete = true;
- if (fSavedExpansion != null && fSavedExpansion.size() > 0) {
- for (int i = 0; i < fSavedExpansion.size(); i++) {
- IPath path = (IPath) fSavedExpansion.get(i);
- if (path != null) {
- if (viewer instanceof VariablesViewer) {
- VariablesViewer variablesViewer = (VariablesViewer) viewer;
- boolean complete = variablesViewer.expandPath(path);
- if (!complete)
- expansionComplete = false;
- } else {
- Object obj;
- try {
- obj = decodePath(path, viewer);
- if (obj != null) {
- viewer.expandToLevel(obj, 1);
- } else {
- expansionComplete = false;
- }
- } catch (DebugException e) {
- }
- }
- }
- }
- if (expansionComplete) {
- fSavedExpansion = null;
- }
- }
+ if (fSavedExpansion != null && fSavedExpansion.size() > 0) {
+ for (int i = 0; i < fSavedExpansion.size(); i++) {
+ IPath path = (IPath) fSavedExpansion.get(i);
+ if (path != null) {
+ try {
+ TreePath treePath = decodePath(path, viewer);
+ if (treePath != null) {
+ viewer.expand(new TreeSelection(new TreePath[] { treePath }));
+
+ if (treePath.getSegmentCount()-1 != path.segmentCount()) {
+ expansionComplete = false;
+ }
+ } else {
+ expansionComplete =false;
+ }
+ } catch (DebugException e) {
+ }
+ }
+ }
+ if (expansionComplete) {
+ fSavedExpansion = null;
+ }
+ }
boolean selectionComplete = true;
if (fSelection != null && fSelection.length > 0) {
List selection = new ArrayList(fSelection.length);
for (int i = 0; i < fSelection.length; i++) {
IPath path = fSelection[i];
- Object obj;
+ TreePath obj;
try {
obj = decodePath(path, viewer);
- if (obj != null) {
+ if (obj != null && obj.getSegmentCount()-1 == path.segmentCount()) {
selection.add(obj);
} else {
selectionComplete = false;
@@ -152,7 +158,8 @@ public abstract class AbstractViewerState {
}
}
if (selection.size() > 0) {
- viewer.setSelection(new StructuredSelection(selection));
+ TreePath[] treePaths = (TreePath[]) selection.toArray(new TreePath[0]);
+ viewer.setSelection(new TreeSelection(treePaths));
}
if (selectionComplete) {
fSelection = null;
@@ -169,9 +176,6 @@ public abstract class AbstractViewerState {
* @return element represented by the path, or <code>null</code> if none
* @throws DebugException if unable to locate a variable
*/
- protected abstract Object decodePath(IPath path, TreeViewer viewer) throws DebugException;
+ protected abstract TreePath decodePath(IPath path, AsynchronousTreeViewer viewer) throws DebugException;
- public abstract AbstractViewerState copy();
-
-
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/RemoteTreeContentManager.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/RemoteTreeContentManager.java
deleted file mode 100644
index e6e99886e..000000000
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/RemoteTreeContentManager.java
+++ /dev/null
@@ -1,335 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.debug.internal.ui.views;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.debug.internal.ui.DebugUIPlugin;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.ui.IWorkbenchPartSite;
-import org.eclipse.ui.internal.progress.PendingUpdateAdapter;
-import org.eclipse.ui.model.IWorkbenchAdapter;
-import org.eclipse.ui.progress.DeferredTreeContentManager;
-import org.eclipse.ui.progress.IDeferredWorkbenchAdapter;
-import org.eclipse.ui.progress.IElementCollector;
-import org.eclipse.ui.progress.IWorkbenchSiteProgressService;
-import org.eclipse.ui.progress.WorkbenchJob;
-import org.osgi.framework.Bundle;
-/**
- * A remote content manager that merges content into a tree rather then replacing
- * its children with a "pending" node, and then the real children when they are available.
- * This avoids collapsing the viewer when a refresh is performed. This implementation is
- * currently tied to the <code>RemoteTreeViewer</code>.
- *
- * @since 3.1
- */
-public class RemoteTreeContentManager extends DeferredTreeContentManager {
-
- private RemoteTreeViewer fViewer;
- private IWorkbenchSiteProgressService progressService;
-
- /**
- * Job to fetch children
- */
- private Job fFetchJob = new FetchJob();
-
- /**
- * Queue of parents to fetch children for, and
- * associated element collectors and deferred adapters.
- */
- private List fElementQueue = new ArrayList();
- private List fCollectors = new ArrayList();
- private List fAdapaters = new ArrayList();
-
- /**
- * Fetching children is done in a single background job.
- * This makes fetching single threaded/serial per view.
- */
- class FetchJob extends Job {
-
- public FetchJob() {
- super(DebugUIViewsMessages.RemoteTreeContentManager_0);
- setSystem(true);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
- */
- protected IStatus run(IProgressMonitor monitor) {
- while (!fElementQueue.isEmpty() && !monitor.isCanceled()) {
- Object element = null;
- IElementCollector collector = null;
- IDeferredWorkbenchAdapter adapter = null;
- synchronized (fElementQueue) {
- // could have been cancelled after entering the while loop
- if (fElementQueue.isEmpty()) {
- return Status.CANCEL_STATUS;
- }
- element = fElementQueue.remove(0);
- collector = (IElementCollector) fCollectors.remove(0);
- adapter = (IDeferredWorkbenchAdapter) fAdapaters.remove(0);
- }
- adapter.fetchDeferredChildren(element, collector, monitor);
- }
- if (monitor.isCanceled()) {
- return Status.CANCEL_STATUS;
- }
- return Status.OK_STATUS;
- }
-
- }
-
- /**
- * Element collector
- */
- public class Collector implements IElementCollector {
- // number of children added to the tree
- int offset = 0;
- Object fParent;
-
- public Collector(Object parent) {
- fParent = parent;
- }
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.progress.IElementCollector#add(java.lang.Object, org.eclipse.core.runtime.IProgressMonitor)
- */
- public void add(Object element, IProgressMonitor monitor) {
- add(new Object[] { element }, monitor);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.progress.IElementCollector#add(java.lang.Object[], org.eclipse.core.runtime.IProgressMonitor)
- */
- public void add(Object[] elements, IProgressMonitor monitor) {
- Object[] filtered = fViewer.filter(elements);
- if (filtered.length > 0) {
- replaceChildren(fParent, filtered, offset, monitor);
- offset = offset + filtered.length;
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.progress.IElementCollector#done()
- */
- public void done() {
- prune(fParent, offset);
- }
- }
-
- /**
- * Contructs a new content manager.
- *
- * @param provider content provider
- * @param viewer viewer
- * @param site part site
- */
- public RemoteTreeContentManager(ITreeContentProvider provider, RemoteTreeViewer viewer, IWorkbenchPartSite site) {
- super(provider, viewer, site);
- fViewer = viewer;
- Object siteService = site.getAdapter(IWorkbenchSiteProgressService.class);
- if (siteService != null) {
- progressService = (IWorkbenchSiteProgressService) siteService;
- }
- }
-
- /**
- * Create the element collector for the receiver.
- *@param parent
- * The parent object being filled in,
- * @param placeholder
- * The adapter that will be used to indicate that results are
- * pending, possibly <code>null</code>
- * @return IElementCollector
- */
- protected IElementCollector createElementCollector(Object parent, PendingUpdateAdapter placeholder) {
- return new Collector(parent);
- }
-
- /**
- * Returns the child elements of the given element, or in the case of a
- * deferred element, returns a placeholder. If a deferred element is used, a
- * job is created to fetch the children in the background.
- *
- * @param parent
- * The parent object.
- * @return Object[] or <code>null</code> if parent is not an instance of
- * IDeferredWorkbenchAdapter.
- */
- public Object[] getChildren(final Object parent) {
- IDeferredWorkbenchAdapter element = getAdapter(parent);
- if (element == null)
- return null;
- Object[] currentChildren = fViewer.getCurrentChildren(parent);
- PendingUpdateAdapter placeholder = null;
- if (currentChildren == null || currentChildren.length == 0) {
- placeholder = new PendingUpdateAdapter();
- }
- startFetchingDeferredChildren(parent, element, placeholder);
- if (placeholder == null) {
- return currentChildren;
- }
- return new Object[] { placeholder };
- }
-
- /**
- * Create a UIJob to replace the children of the parent in the tree viewer.
- *
- * @param parent the parent for which children are to be replaced
- * @param children the replacement children
- * @param offset the offset at which to start replacing children
- * @param monitor progress monitor
- */
- protected void replaceChildren(final Object parent, final Object[] children, final int offset, IProgressMonitor monitor) {
- if (monitor.isCanceled()) {
- return;
- }
- WorkbenchJob updateJob = new WorkbenchJob(DebugUIViewsMessages.IncrementalDeferredTreeContentManager_0) {
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor)
- */
- public IStatus runInUIThread(IProgressMonitor updateMonitor) {
- //Cancel the job if the tree viewer got closed
- if (fViewer.getControl().isDisposed())
- return Status.CANCEL_STATUS;
- fViewer.replace(parent, children, offset);
- return Status.OK_STATUS;
- }
- };
- updateJob.setSystem(true);
- updateJob.setPriority(Job.INTERACTIVE);
- updateJob.schedule();
- }
-
- /**
- * Create a UIJob to prune the children of the parent in the tree viewer, starting
- * at the given offset.
- *
- * @param parent the parent for which children should be pruned
- * @param offset the offset at which children should be pruned. All children at and after
- * this index will be removed from the tree.
- * @param monitor
- */
- protected void prune(final Object parent, final int offset) {
- WorkbenchJob updateJob = new WorkbenchJob(DebugUIViewsMessages.IncrementalDeferredTreeContentManager_1) {
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor)
- */
- public IStatus runInUIThread(IProgressMonitor updateMonitor) {
- //Cancel the job if the tree viewer got closed
- if (fViewer.getControl().isDisposed())
- return Status.CANCEL_STATUS;
- fViewer.prune(parent, offset);
- return Status.OK_STATUS;
- }
- };
- updateJob.setSystem(true);
- updateJob.setPriority(Job.INTERACTIVE);
- updateJob.schedule();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.progress.DeferredTreeContentManager#runClearPlaceholderJob(org.eclipse.ui.internal.progress.PendingUpdateAdapter)
- */
- protected void runClearPlaceholderJob(PendingUpdateAdapter placeholder) {
- // the placeholder is not used when there were already children in the tree (null)
- if (placeholder != null) {
- super.runClearPlaceholderJob(placeholder);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.progress.DeferredTreeContentManager#getFetchJobName(java.lang.Object, org.eclipse.ui.progress.IDeferredWorkbenchAdapter)
- */
- protected String getFetchJobName(Object parent, IDeferredWorkbenchAdapter adapter) {
- return DebugUIViewsMessages.RemoteTreeContentManager_0;
- }
-
-
- /**
- * Returns the IDeferredWorkbenchAdapter for the element, or <code>null</code>.
- * If a client has contributed an IWorkbenchAdapter for the element, it
- * should be used in place of the debug platform's IDeferredWorkbenchAdapter,
- * in which case, <code>null</code> is returned.
- *
- * @param element
- * @return IDeferredWorkbenchAdapter or <code>null</code>
- */
- protected IDeferredWorkbenchAdapter getAdapter(Object element) {
- if (element instanceof IDeferredWorkbenchAdapter)
- return (IDeferredWorkbenchAdapter) element;
- if (!(element instanceof IAdaptable))
- return null;
- IAdaptable adaptable = (IAdaptable) element;
- IDeferredWorkbenchAdapter deferred = (IDeferredWorkbenchAdapter) adaptable.getAdapter(IDeferredWorkbenchAdapter.class);
- if (deferred == null)
- return null;
-
- DebugUIPlugin plugin = DebugUIPlugin.getDefault();
- Bundle bundle = plugin.getBundle(deferred.getClass());
- Bundle debugBundle = plugin.getBundle();
- if (!debugBundle.equals(bundle)) {
- // if client contributed, use it
- return deferred;
- }
- // if the client provided an IWorkbenchAdapter, use it
- IWorkbenchAdapter nonDeferred = (IWorkbenchAdapter) adaptable.getAdapter(IWorkbenchAdapter.class);
- if (nonDeferred != null) {
- bundle = plugin.getBundle(nonDeferred.getClass());
- if (!debugBundle.equals(bundle)) {
- // by returning null, we'll revert to using the the object's workbench adapter
- // by pretending it has no deffered adapter
- return null;
- }
- }
- return deferred;
- }
-
- protected void startFetchingDeferredChildren(final Object parent, final IDeferredWorkbenchAdapter adapter, PendingUpdateAdapter placeholder) {
- final IElementCollector collector = createElementCollector(parent, placeholder);
- synchronized (fElementQueue) {
- if (!fElementQueue.contains(parent)) {
- fElementQueue.add(parent);
- fCollectors.add(collector);
- fAdapaters.add(adapter);
- }
- }
- if (progressService == null)
- fFetchJob.schedule();
- else
- progressService.schedule(fFetchJob);
- }
-
- /**
- * Cancels any content this provider is currently fetching.
- */
- public void cancel() {
- synchronized (fElementQueue) {
- fFetchJob.cancel();
- fElementQueue.clear();
- fAdapaters.clear();
- fCollectors.clear();
- }
- }
-}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/RemoteTreeViewer.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/RemoteTreeViewer.java
deleted file mode 100644
index 70fb9cccd..000000000
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/RemoteTreeViewer.java
+++ /dev/null
@@ -1,609 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.debug.internal.ui.views;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.debug.core.ILaunch;
-import org.eclipse.jface.util.Assert;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.ViewerSorter;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Item;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeItem;
-import org.eclipse.swt.widgets.Widget;
-import org.eclipse.ui.model.IWorkbenchAdapter;
-import org.eclipse.ui.progress.UIJob;
-
-/**
- * A tree viewer that displays remote content. Content is retrieved in a background
- * job, and the viewer is updated incrementally on a refresh.
- *
- * @since 3.1
- */
-public class RemoteTreeViewer extends TreeViewer {
-
- private ExpansionJob fExpansionJob = null;
- private SelectionJob fSelectionJob = null;
-
-
- class ExpansionJob extends UIJob {
-
- private Object element;
- private List parents = new ArrayList(); // top down
-
- /**
- * Constucts a job to expand the given element.
- *
- * @param target the element to expand
- */
- public ExpansionJob() {
- super(DebugUIViewsMessages.LaunchViewer_1);
- setPriority(Job.INTERACTIVE);
- setSystem(true);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor)
- */
- public IStatus runInUIThread(IProgressMonitor monitor) {
- if (getControl().isDisposed() || element == null) {
- return Status.OK_STATUS;
- }
- synchronized (RemoteTreeViewer.this) {
- boolean allParentsExpanded = true;
- Iterator iterator = parents.iterator();
- while (iterator.hasNext() && !monitor.isCanceled()) {
- Object parent = iterator.next();
- Widget item = findItem(parent);
- if (item != null) {
- expandToLevel(parent, 1);
- } else {
- allParentsExpanded = false;
- break;
- }
- }
- if (allParentsExpanded) {
- Widget item = findItem(element);
- if (item != null) {
- if (isExpandable(element)) {
- expandToLevel(element, 1);
- }
- element = null;
- parents.clear();
- return Status.OK_STATUS;
- }
- }
- return Status.OK_STATUS;
- }
- }
-
- public void validate(Object object) {
- if (element != null) {
- if (element.equals(object) || parents.contains(object)) {
- cancel();
- element = null;
- }
- }
- }
-
- public void setDeferredExpansion(Object toExpand) {
- element = toExpand;
- parents.clear();
- addAllParents(parents, element);
- }
-
- }
-
- class SelectionJob extends UIJob {
-
- private IStructuredSelection selection;
- private Object first;
- private List parents = new ArrayList(); // top down
-
- /**
- * Constucts a job to select the given element.
- *
- * @param target the element to select
- */
- public SelectionJob() {
- super(DebugUIViewsMessages.LaunchViewer_0);
- setPriority(Job.INTERACTIVE);
- setSystem(true);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor)
- */
- public IStatus runInUIThread(IProgressMonitor monitor) {
- if (getControl().isDisposed() || selection == null) {
- return Status.OK_STATUS;
- }
- synchronized (RemoteTreeViewer.this) {
- boolean allParentsExpanded = true;
- Iterator iterator = parents.iterator();
- while (iterator.hasNext() && !monitor.isCanceled()) {
- Object parent = iterator.next();
- Widget item = findItem(parent);
- if (item != null) {
- expandToLevel(parent, 1);
- } else {
- allParentsExpanded = false;
- break;
- }
- }
- if (allParentsExpanded) {
- if (findItem(first) != null) {
- setSelection(selection, true);
- selection = null;
- first = null;
- parents.clear();
- return Status.OK_STATUS;
- }
- }
-
- return Status.OK_STATUS;
- }
- }
-
- public void setDeferredSelection(IStructuredSelection sel) {
- selection = sel;
- first = selection.getFirstElement();
- parents.clear();
- addAllParents(parents, first);
- }
-
- public void validate(Object object) {
- if (first != null) {
- if (first.equals(object) || parents.contains(object)) {
- cancel();
- selection = null;
- }
- }
- }
- }
-
-
- /**
- * Constructs a remote tree viewer parented by the given composite.
- *
- * @param parent parent composite
- */
- public RemoteTreeViewer(Composite parent) {
- super(parent);
- addDisposeListener();
- fExpansionJob = new ExpansionJob();
- fSelectionJob = new SelectionJob();
- }
-
- /**
- * Constructs a remote tree viewer parented by the given composite
- * with the given style.
- *
- * @param parent parent composite
- * @param style style bits
- */
- public RemoteTreeViewer(Composite parent, int style) {
- super(parent, style);
- addDisposeListener();
- fExpansionJob = new ExpansionJob();
- fSelectionJob = new SelectionJob();
- }
-
- /**
- * Constructs a remote tree viewer with the given tree.
- *
- * @param tree tree widget
- */
- public RemoteTreeViewer(Tree tree) {
- super(tree);
- addDisposeListener();
- fExpansionJob = new ExpansionJob();
- fSelectionJob = new SelectionJob();
- }
-
- private void addDisposeListener() {
- getControl().addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- cancelJobs();
- }
- });
- }
-
- protected void runDeferredUpdates() {
- if (fExpansionJob != null) {
- fExpansionJob.schedule();
- }
- if (fSelectionJob != null) {
- fSelectionJob.schedule();
- }
- }
-
- /**
- * The given element is being removed from the tree. Cancel
- * any deferred updates for the element.
- *
- * @param element
- */
- protected void validateDeferredUpdates(Object element) {
- if (element != null) {
- if (fExpansionJob != null) {
- fExpansionJob.validate(element);
- }
- if (fSelectionJob != null) {
- fSelectionJob.validate(element);
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.AbstractTreeViewer#add(java.lang.Object, java.lang.Object)
- */
- public synchronized void add(Object parentElement, Object childElement) {
- super.add(parentElement, childElement);
- runDeferredUpdates();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.AbstractTreeViewer#add(java.lang.Object, java.lang.Object[])
- */
- public synchronized void add(Object parentElement, Object[] childElements) {
- super.add(parentElement, childElements);
- runDeferredUpdates();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.AbstractTreeViewer#remove(java.lang.Object)
- */
- public synchronized void remove(Object element) {
- validateDeferredUpdates(element);
- super.remove(element);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.AbstractTreeViewer#remove(java.lang.Object[])
- */
- public synchronized void remove(Object[] elements) {
- for (int i = 0; i < elements.length; i++) {
- validateDeferredUpdates(elements[i]);
- }
- super.remove(elements);
- }
-
- /**
- * Cancels any deferred updates currently scheduled/running.
- */
- public void cancelJobs() {
- cancel(fSelectionJob);
- cancel(fExpansionJob);
- }
-
- public synchronized void deferExpansion(Object element) {
- TreeItem treeItem = (TreeItem) findItem(element);
- if (treeItem == null) {
- fExpansionJob.setDeferredExpansion(element);
- fExpansionJob.schedule();
- } else {
- if (!getExpanded(treeItem)) {
- fExpansionJob.setDeferredExpansion(element);
- fExpansionJob.schedule();
- }
- }
- }
-
- public synchronized void deferSelection(IStructuredSelection selection) {
- if (fSelectionJob == null) {
- fSelectionJob = new SelectionJob();
- }
-
- fSelectionJob.setDeferredSelection(selection);
- fSelectionJob.schedule();
- }
-
- public IStructuredSelection getDeferredSelection() {
- if (fSelectionJob != null) {
- return fSelectionJob.selection;
- }
- return null;
- }
-
- private void cancel(Job job) {
- if (job != null) {
- job.cancel();
- }
- }
-
- private void addAllParents(List list, Object element) {
- if (element instanceof IAdaptable) {
- IAdaptable adaptable = (IAdaptable) element;
- IWorkbenchAdapter adapter = (IWorkbenchAdapter) adaptable.getAdapter(IWorkbenchAdapter.class);
- if (adapter != null) {
- Object parent = adapter.getParent(element);
- if (parent != null) {
- list.add(0, parent);
- if (!(parent instanceof ILaunch))
- addAllParents(list, parent);
- }
- }
- }
- }
-
- public Object[] filter(Object[] elements) {
- return super.filter(elements);
- }
-
- public Object[] getCurrentChildren(Object parent) {
- Widget widget = findItem(parent);
- if (widget != null) {
- Item[] items = getChildren(widget);
- Object[] children = new Object[items.length];
- for (int i = 0; i < children.length; i++) {
- Object data = items[i].getData();
- if (data == null) {
- return null;
- }
- children[i] = data;
- }
- return children;
- }
- return null;
- }
-
- public synchronized void prune(final Object parent, final int offset) {
- Widget widget = findItem(parent);
- if (widget != null) {
- final Item[] currentChildren = getChildren(widget);
- if (offset < currentChildren.length) {
- preservingSelection(new Runnable() {
- public void run() {
- for (int i = offset; i < currentChildren.length; i++) {
- if (currentChildren[i].getData() != null) {
- disassociate(currentChildren[i]);
- }
- currentChildren[i].dispose();
- }
- }
- });
- }
- }
- }
-
- public synchronized void replace(final Object parent, final Object[] children, final int offset) {
- preservingSelection(new Runnable() {
- public void run() {
- Widget[] widgets = findItems(parent);
- for (int n = 0; n < widgets.length; n++) {
- Widget widget = widgets[n];
- if (widget == null) {
- add(parent, children);
- } else {
- Item[] currentChildren = getChildren(widget);
- int pos = offset;
- if (pos >= currentChildren.length) {
- // append
- add(parent, children);
- } else {
- // replace
- for (int i = 0; i < children.length; i++) {
- Object child = children[i];
- if (pos < currentChildren.length) {
- // replace
- Item item = currentChildren[pos];
- Object data = item.getData();
- if (!child.equals(data)) {
- // no need to cancel pending updates here, the child may have shifted up/down
- internalRefresh(item, child, true, true);
- } else {
- // If it's the same child, the label/content may still have changed
- doUpdateItem(item, child);
- updatePlus(item, child);
- }
- } else {
- // add
- int numLeft = children.length - i;
- if (numLeft >= 1) {
- Object[] others = new Object[numLeft];
- System.arraycopy(children, i, others, 0, numLeft);
- internalAdd(widget, parent, others);
- }
- break;
- }
- pos++;
- }
- }
- }
- }
-
- runDeferredUpdates();
- }
- });
- }
-
- protected void internalAdd(Widget widget, Object parentElement, Object[] childElements) {
-
- // optimization!
- // if the widget is not expanded we just invalidate the subtree
- if (widget instanceof Item) {
- Item ti = (Item) widget;
- if (!getExpanded(ti)) {
- boolean needDummy = isExpandable(parentElement);
- boolean haveDummy = false;
- // remove all children
- Item[] items = getItems(ti);
- for (int i = 0; i < items.length; i++) {
- if (items[i].getData() != null) {
- disassociate(items[i]);
- items[i].dispose();
- } else {
- if (needDummy && !haveDummy) {
- haveDummy = true;
- } else {
- items[i].dispose();
- }
- }
- }
- // append a dummy if necessary
- if (needDummy && !haveDummy)
- newItem(ti, SWT.NULL, -1);
- return;
- }
- }
-
- if (childElements.length > 0) {
- Object[] filtered = filter(childElements);
- if(getSorter() != null)
- getSorter().sort(this,filtered);
- createAddedElements(widget, filtered);
- }
- }
-
-
-
- // tree viewer hacks start here. These hacks allow us to display the same Object in a tree viewer more
- // than once. Workbench does on support this (July 6, 2005)
-
-
- private void createAddedElements(Widget widget, Object[] elements) {
-
- if(elements.length == 1){
- if (equals(elements[0], widget.getData()))
- return;
- }
-
- ViewerSorter sorter = getSorter ();
- Item[] items = getChildren(widget);
-
- //As the items are sorted already we optimize for a
- //start position
- int lastInsertion = 0;
-
- //Optimize for the empty case
- if(items.length == 0){
- for (int i = 0; i < elements.length; i++) {
- createTreeItem(widget, elements[i], -1);
- }
- return;
- }
-
- for (int i = 0; i < elements.length; i++) {
- boolean newItem = true;
- Object element = elements[i];
- int index;
- if(sorter == null){
- index = -1;
- }
- else{
- lastInsertion = insertionPosition(items,sorter,lastInsertion, element);
- //As we are only searching the original array we keep track of those positions only
- if(lastInsertion == items.length)
- index = -1;
- else{//See if we should just refresh
- while(lastInsertion < items.length && sorter.compare(this,element,items[lastInsertion].getData()) == 0){
- //As we cannot assume the sorter is consistent with equals() - therefore we can
- // just check against the item prior to this index (if any)
- if (items[lastInsertion].getData().equals(element)) {
- //refresh the element in case it has new children
- refresh(element);
- newItem = false;
- }
- lastInsertion ++;//We had an insertion so increment
- }
- //Did we get to the end?
- if(lastInsertion == items.length)
- index = -1;
- else
- index = lastInsertion + i; //Add the index as the array is growing
- }
- }
- if(newItem)
- createTreeItem(widget, element, index);
- }
- }
-
- //copied from super class
- private int insertionPosition(Item[] items, ViewerSorter sorter, int lastInsertion, Object element) {
- int size = items.length;
- if (sorter == null)
- return size;
- int min = lastInsertion, max = size - 1;
-
- while (min <= max) {
- int mid = (min + max) / 2;
- Object data = items[mid].getData();
- int compare = sorter.compare(this, data, element);
- if (compare == 0) {
- return mid;//Return if we already match
- }
- if (compare < 0)
- min = mid + 1;
- else
- max = mid - 1;
- }
- return min;
- }
-
- public void update(Object element, String[] properties) {
- Assert.isNotNull(element);
- Widget[] widgets = findItems(element);
- for (int i = 0; i < widgets.length; i++) {
- Widget widget = widgets[i];
- if (widget != null) {
- internalUpdate(widget, element, properties);
- }
- }
- }
-
- protected Widget[] findItems(Object target) {
- List widgets = new ArrayList();
- Object root = getRoot();
- if (root != null) {
- if (equals(root, target)) {
- Widget widget = findItem(root);
- widgets.add(widget);
- }
- }
- Item[] children = getChildren(getControl());
-
- if (children != null) {
- for (int i = 0; i < children.length; i++) {
- Item child = children[i];
- internalFindItems(target, child, widgets);
- }
- }
- return (Widget[]) widgets.toArray(new Widget[widgets.size()]);
- }
-
- private void internalFindItems(Object target, Item item, List widgets) {
- if (equals(target, item.getData())) {
- widgets.add(item);
- }
-
- Item[] children = getChildren(item);
- for (int i = 0; i < children.length; i++) {
- Item child = children[i];
- internalFindItems(target, child, widgets);
- }
- }
-}
-
-
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleRemoveAllTerminatedAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleRemoveAllTerminatedAction.java
index 0677d8c8a..889bd77d8 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleRemoveAllTerminatedAction.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleRemoveAllTerminatedAction.java
@@ -20,7 +20,7 @@ import org.eclipse.debug.core.model.IProcess;
import org.eclipse.debug.internal.ui.DebugPluginImages;
import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
-import org.eclipse.debug.internal.ui.actions.RemoveAllTerminatedAction;
+import org.eclipse.debug.internal.ui.contexts.actions.RemoveAllTerminatedAction;
import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.jface.action.Action;
import org.eclipse.ui.PlatformUI;
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleTerminateActionDelegate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleTerminateActionDelegate.java
index 5cf0c116a..58991384e 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleTerminateActionDelegate.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleTerminateActionDelegate.java
@@ -10,7 +10,7 @@
*******************************************************************************/
package org.eclipse.debug.internal.ui.views.console;
-import org.eclipse.debug.internal.ui.actions.TerminateActionDelegate;
+import org.eclipse.debug.internal.ui.contexts.actions.TerminateActionDelegate;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionPopupContentProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionPopupContentProvider.java
deleted file mode 100644
index 928450515..000000000
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionPopupContentProvider.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.debug.internal.ui.views.expression;
-
-import org.eclipse.debug.internal.ui.views.RemoteTreeViewer;
-import org.eclipse.debug.internal.ui.views.variables.VariablesView;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.ui.IWorkbenchPartSite;
-
-
-public class ExpressionPopupContentProvider extends RemoteExpressionsContentProvider {
-
- private Object input = null;
-
- public ExpressionPopupContentProvider(RemoteTreeViewer viewer, IWorkbenchPartSite site, VariablesView view) {
- super(viewer, site, view);
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
- */
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- super.inputChanged(viewer, oldInput, newInput);
- input = newInput;
- }
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
- */
- public Object[] getElements(Object parent) {
- if (parent == input) {
- return (Object[]) input;
- }
- return super.getElements(parent);
- }
-}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionView.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionView.java
index 65c7a65f0..982535089 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionView.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionView.java
@@ -14,16 +14,11 @@ package org.eclipse.debug.internal.ui.views.expression;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.model.IDebugElement;
-import org.eclipse.debug.core.model.IErrorReportingExpression;
import org.eclipse.debug.core.model.IExpression;
import org.eclipse.debug.core.model.IWatchExpression;
import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
import org.eclipse.debug.internal.ui.preferences.IDebugPreferenceConstants;
-import org.eclipse.debug.internal.ui.views.DebugViewInterimLabelProvider;
-import org.eclipse.debug.internal.ui.views.DebugViewLabelDecorator;
-import org.eclipse.debug.internal.ui.views.RemoteTreeViewer;
import org.eclipse.debug.internal.ui.views.variables.AvailableLogicalStructuresAction;
-import org.eclipse.debug.internal.ui.views.variables.RemoteVariablesContentProvider;
import org.eclipse.debug.internal.ui.views.variables.VariablesView;
import org.eclipse.debug.internal.ui.views.variables.VariablesViewEventHandler;
import org.eclipse.debug.internal.ui.views.variables.VariablesViewMessages;
@@ -32,17 +27,9 @@ import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.viewers.IBaseLabelProvider;
-import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.IWorkbenchPart;
@@ -53,52 +40,6 @@ import org.eclipse.ui.IWorkbenchPart;
*/
public class ExpressionView extends VariablesView {
- /**
- * A decorating label provider which provides color for expressions.
- */
- protected class ExpressionViewDecoratingLabelProvider extends VariablesView.VariablesViewDecoratingLabelProvider {
- /**
- * @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object)
- */
- public Color getForeground(Object element) {
- boolean expressionWithError= false;
- IErrorReportingExpression expression= null;
- if (element instanceof IErrorReportingExpression) {
- expression= (IErrorReportingExpression) element;
- } else if (element instanceof String) {
- Object parent= ((ITreeContentProvider)getVariablesViewer().getContentProvider()).getParent(element);
- if (parent instanceof IErrorReportingExpression) {
- expression= (IErrorReportingExpression) parent;
- }
- }
- if (expression != null && expression.hasErrors()) {
- expressionWithError= true;
- }
- if (expressionWithError) {
- return Display.getDefault().getSystemColor(SWT.COLOR_RED);
- }
- return super.getForeground(element);
- }
-
- public ExpressionViewDecoratingLabelProvider(StructuredViewer viewer, ILabelProvider provider, DebugViewLabelDecorator decorator) {
- super(viewer, provider, decorator);
- }
- }
- /**
- * @see org.eclipse.debug.internal.ui.views.variables.VariablesView#createLabelProvider()
- */
- protected IBaseLabelProvider createLabelProvider(StructuredViewer viewer) {
- return new ExpressionViewDecoratingLabelProvider(viewer, new DebugViewInterimLabelProvider(getModelPresentation()), new DebugViewLabelDecorator(getModelPresentation()));
- }
-
- /**
- * Creates this view's content provider.
- *
- * @return a content provider
- */
- protected RemoteVariablesContentProvider createContentProvider(Viewer viewer) {
- return new RemoteExpressionsContentProvider((RemoteTreeViewer)viewer, getSite(), this);
- }
/**
* Creates this view's event handler.
@@ -195,7 +136,7 @@ public class ExpressionView extends VariablesView {
*
* @see VariablesView#setViewerInput(IStructuredSelection)
*/
- protected void setViewerInput(IStructuredSelection ssel) {
+ protected void setViewerInput(Object obj) {
}
/* (non-Javadoc)
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionViewEventHandler.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionViewEventHandler.java
index f87c70047..d334cfebb 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionViewEventHandler.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionViewEventHandler.java
@@ -11,8 +11,6 @@
package org.eclipse.debug.internal.ui.views.expression;
-import java.util.List;
-
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.debug.core.DebugEvent;
import org.eclipse.debug.core.DebugPlugin;
@@ -25,7 +23,6 @@ import org.eclipse.debug.core.model.IWatchExpression;
import org.eclipse.debug.internal.ui.views.variables.VariablesViewEventHandler;
import org.eclipse.debug.ui.AbstractDebugView;
import org.eclipse.debug.ui.DebugUITools;
-import org.eclipse.jface.viewers.IContentProvider;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
@@ -87,10 +84,10 @@ public class ExpressionViewEventHandler extends VariablesViewEventHandler implem
Runnable r = new Runnable() {
public void run() {
if (isAvailable()) {
- getTreeViewer().refresh();
+ getStructuredViewer().refresh();
if (expressions.length > 0) {
ISelection selection = new StructuredSelection(expressions[0]);
- getTreeViewer().setSelection(selection, true);
+ getStructuredViewer().setSelection(selection, true);
}
}
}
@@ -102,31 +99,9 @@ public class ExpressionViewEventHandler extends VariablesViewEventHandler implem
* @see IExpressionsListener#expressionsRemoved(IExpression[])
*/
public void expressionsRemoved(final IExpression[] expressions) {
- Runnable r = new Runnable() {
- public void run() {
- if (isAvailable()) {
- getTreeViewer().getControl().setRedraw(false);
- for (int i = 0; i < expressions.length; i++) {
- IExpression expression = expressions[i];
- remove(expression);
- IContentProvider provider= getTreeViewer().getContentProvider();
- if (provider instanceof RemoteExpressionsContentProvider) {
- RemoteExpressionsContentProvider expressionProvider= (RemoteExpressionsContentProvider) provider;
- List decendants = expressionProvider.getCachedDecendants(expression);
- decendants.add(expression);
- // Remove the parent cache for the expression and its children
- expressionProvider.removeCache(decendants.toArray());
- IExpression[] allExpressions= DebugPlugin.getDefault().getExpressionManager().getExpressions();
- if (allExpressions.length > 0) {
- getTreeViewer().setSelection(new StructuredSelection(allExpressions[0]), true);
- }
- }
- }
- getTreeViewer().getControl().setRedraw(true);
- }
- }
- };
- getView().asyncExec(r);
+ if (isAvailable()) {
+ getStructuredViewer().refresh();
+ }
}
/**
@@ -136,7 +111,7 @@ public class ExpressionViewEventHandler extends VariablesViewEventHandler implem
Runnable r = new Runnable() {
public void run() {
if (isAvailable()) {
- getTreeViewer().getControl().setRedraw(false);
+ getStructuredViewer().getControl().setRedraw(false);
for (int i = 0; i < expressions.length; i++) {
IExpression expression = expressions[i];
refresh(expression);
@@ -146,7 +121,7 @@ public class ExpressionViewEventHandler extends VariablesViewEventHandler implem
getVariablesView().populateDetailPane();
}
}
- getTreeViewer().getControl().setRedraw(true);
+ getStructuredViewer().getControl().setRedraw(true);
}
}
};
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/RemoteExpressionContentManager.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/RemoteExpressionContentManager.java
deleted file mode 100644
index e5c60c54c..000000000
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/RemoteExpressionContentManager.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.debug.internal.ui.views.expression;
-
-import org.eclipse.debug.core.DebugException;
-import org.eclipse.debug.core.model.IErrorReportingExpression;
-import org.eclipse.debug.core.model.IExpression;
-import org.eclipse.debug.core.model.IValue;
-import org.eclipse.debug.core.model.IVariable;
-import org.eclipse.debug.internal.ui.elements.adapters.DeferredExpressionLogicalStructure;
-import org.eclipse.debug.internal.ui.views.RemoteTreeViewer;
-import org.eclipse.debug.internal.ui.views.variables.RemoteVariableContentManager;
-import org.eclipse.debug.internal.ui.views.variables.VariablesView;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.ui.IWorkbenchPartSite;
-import org.eclipse.ui.progress.IDeferredWorkbenchAdapter;
-
-/**
- * Remote content manager for variables. Creates an appropriate adapter for
- * logical structures.
- */
-public class RemoteExpressionContentManager extends RemoteVariableContentManager {
-
- private IDeferredWorkbenchAdapter fExpressionLogicalStructureAdapter = new DeferredExpressionLogicalStructure();
-
- /**
- * Constructs a remote content manager for a variables view.
- */
- public RemoteExpressionContentManager(ITreeContentProvider provider, RemoteTreeViewer viewer, IWorkbenchPartSite site, VariablesView view) {
- super(provider, viewer, site, view);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.progress.DeferredTreeContentManager#getAdapter(java.lang.Object)
- */
- protected IDeferredWorkbenchAdapter getAdapter(Object element) {
- if (element instanceof IExpression && fView !=null && fView.isShowLogicalStructure()) {
- return fExpressionLogicalStructureAdapter;
- }
- return super.getAdapter(element);
- }
-
- public boolean mayHaveChildren(Object element) {
- if (element instanceof IErrorReportingExpression) {
- IErrorReportingExpression iere = (IErrorReportingExpression) element;
- if (iere.hasErrors()) {
- //errors are displayed as children of the expression
- return true;
- }
- }
-
- if (element instanceof IExpression) {
- IExpression expression = (IExpression) element;
- IValue value = expression.getValue();
- if (value != null) {
- try {
- IVariable[] variables = value.getVariables();
- if (variables.length > 0) {
- //definitely children...
- return true;
- }
-
- //returning false because value!=null && variables.length=0 means no children
- return false;
- } catch (DebugException e) {
- }
- }
- }
-
- //expression has not been evaluated
- return super.mayHaveChildren(element);
- }
-
-
-
-}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/RemoteExpressionsContentProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/RemoteExpressionsContentProvider.java
deleted file mode 100644
index bae39c852..000000000
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/RemoteExpressionsContentProvider.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.debug.internal.ui.views.expression;
-
-import org.eclipse.debug.internal.ui.views.RemoteTreeContentManager;
-import org.eclipse.debug.internal.ui.views.RemoteTreeViewer;
-import org.eclipse.debug.internal.ui.views.variables.RemoteVariablesContentProvider;
-import org.eclipse.debug.internal.ui.views.variables.VariablesView;
-import org.eclipse.ui.IWorkbenchPartSite;
-
-public class RemoteExpressionsContentProvider extends RemoteVariablesContentProvider {
-
- /**
- * @param viewer
- * @param site
- * @param view
- */
- public RemoteExpressionsContentProvider(RemoteTreeViewer viewer, IWorkbenchPartSite site, VariablesView view) {
- super(viewer, site, view);
- }
-
- protected RemoteTreeContentManager createContentManager(RemoteTreeViewer viewer, IWorkbenchPartSite site, VariablesView view) {
- return new RemoteExpressionContentManager(this, viewer, site, view);
- }
-
-}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/DebugElementAdapterFactory.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/DebugElementAdapterFactory.java
index 5575513ce..38eae9048 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/DebugElementAdapterFactory.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/DebugElementAdapterFactory.java
@@ -14,6 +14,7 @@ import org.eclipse.core.runtime.IAdapterFactory;
import org.eclipse.debug.core.IExpressionManager;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.core.model.IDebugElement;
import org.eclipse.debug.core.model.IDebugTarget;
import org.eclipse.debug.core.model.IExpression;
import org.eclipse.debug.core.model.IProcess;
@@ -21,16 +22,28 @@ import org.eclipse.debug.core.model.IRegisterGroup;
import org.eclipse.debug.core.model.IStackFrame;
import org.eclipse.debug.core.model.IThread;
import org.eclipse.debug.core.model.IVariable;
-import org.eclipse.debug.internal.ui.elements.adapters.DeferredExpression;
-import org.eclipse.debug.internal.ui.elements.adapters.DeferredExpressionManager;
-import org.eclipse.debug.internal.ui.elements.adapters.DeferredLaunch;
-import org.eclipse.debug.internal.ui.elements.adapters.DeferredLaunchManager;
-import org.eclipse.debug.internal.ui.elements.adapters.DeferredProcess;
-import org.eclipse.debug.internal.ui.elements.adapters.DeferredRegisterGroup;
-import org.eclipse.debug.internal.ui.elements.adapters.DeferredStackFrame;
-import org.eclipse.debug.internal.ui.elements.adapters.DeferredTarget;
-import org.eclipse.debug.internal.ui.elements.adapters.DeferredThread;
-import org.eclipse.debug.internal.ui.elements.adapters.DeferredVariable;
+import org.eclipse.debug.internal.ui.elements.adapters.AsynchronousDebugLabelAdapter;
+import org.eclipse.debug.internal.ui.elements.adapters.DebugTargetTreeContentAdapter;
+import org.eclipse.debug.internal.ui.elements.adapters.ExpressionManagerTreeContentAdapter;
+import org.eclipse.debug.internal.ui.elements.adapters.ExpressionTreeContentAdapter;
+import org.eclipse.debug.internal.ui.elements.adapters.LauchManagerTreeContentAdapter;
+import org.eclipse.debug.internal.ui.elements.adapters.LaunchTreeContentAdapter;
+import org.eclipse.debug.internal.ui.elements.adapters.ProcessTreeAdapter;
+import org.eclipse.debug.internal.ui.elements.adapters.RegisterGroupTreeContentAdapter;
+import org.eclipse.debug.internal.ui.elements.adapters.StackFrameSourceDisplayAdapter;
+import org.eclipse.debug.internal.ui.elements.adapters.StackFrameTreeContentAdapter;
+import org.eclipse.debug.internal.ui.elements.adapters.ThreadTreeContentAdapter;
+import org.eclipse.debug.internal.ui.elements.adapters.VariableLabelAdapter;
+import org.eclipse.debug.internal.ui.elements.adapters.VariableTreeContentAdapter;
+import org.eclipse.debug.internal.ui.viewers.IAsynchronousLabelAdapter;
+import org.eclipse.debug.internal.ui.viewers.IAsynchronousTreeContentAdapter;
+import org.eclipse.debug.internal.ui.viewers.IModelProxyFactory;
+import org.eclipse.debug.internal.ui.viewers.IModelSelectionPolicy;
+import org.eclipse.debug.internal.ui.viewers.IUpdatePolicyFactory;
+import org.eclipse.debug.internal.ui.viewers.update.DefaultModelProxyFactory;
+import org.eclipse.debug.internal.ui.viewers.update.DefaultSelectionPolicy;
+import org.eclipse.debug.internal.ui.viewers.update.DefaultUpdatePolicyFactory;
+import org.eclipse.debug.ui.contexts.ISourceDisplayAdapter;
import org.eclipse.ui.model.IWorkbenchAdapter;
import org.eclipse.ui.model.IWorkbenchAdapter2;
import org.eclipse.ui.progress.IDeferredWorkbenchAdapter;
@@ -39,17 +52,24 @@ import org.eclipse.ui.progress.IDeferredWorkbenchAdapter;
* DebugElementAdapterFactory
*/
public class DebugElementAdapterFactory implements IAdapterFactory {
+
+ private static IUpdatePolicyFactory fgUpdatePolicyFactoryAdapter = new DefaultUpdatePolicyFactory();
+ private static IModelProxyFactory fgModelProxyFactoryAdapter = new DefaultModelProxyFactory();
+ private static ISourceDisplayAdapter fgStackFrameSourceDisplayAdapter = new StackFrameSourceDisplayAdapter();
- private static IDeferredWorkbenchAdapter fgLaunchManagerAdapter = new DeferredLaunchManager();
- private static IDeferredWorkbenchAdapter fgLaunchAdapter = new DeferredLaunch();
- private static IDeferredWorkbenchAdapter fgDebugTargetAdapter = new DeferredTarget();
- private static IDeferredWorkbenchAdapter fgProcessAdapter = new DeferredProcess();
- private static IDeferredWorkbenchAdapter fgThreadAdapter = new DeferredThread();
- private static IDeferredWorkbenchAdapter fgFrameAdapter = new DeferredStackFrame();
- private static IDeferredWorkbenchAdapter fgRegisterGroupAdapter = new DeferredRegisterGroup();
- private static IDeferredWorkbenchAdapter fgVariableAdapter = new DeferredVariable();
- private static IDeferredWorkbenchAdapter fgExpressionAdapter = new DeferredExpression();
- private static IDeferredWorkbenchAdapter fgExpressionManagerAdapter = new DeferredExpressionManager();
+ private static IAsynchronousLabelAdapter fgDebugLabelAdapter = new AsynchronousDebugLabelAdapter();
+ private static IAsynchronousLabelAdapter fgVariableLabelAdapter = new VariableLabelAdapter();
+
+ private static IAsynchronousTreeContentAdapter fgAsyncLaunchManager = new LauchManagerTreeContentAdapter();
+ private static IAsynchronousTreeContentAdapter fgAsyncLaunch = new LaunchTreeContentAdapter();
+ private static IAsynchronousTreeContentAdapter fgAsyncTarget = new DebugTargetTreeContentAdapter();
+ private static IAsynchronousTreeContentAdapter fgAsyncProcess = new ProcessTreeAdapter();
+ private static IAsynchronousTreeContentAdapter fgAsyncThread = new ThreadTreeContentAdapter();
+ private static IAsynchronousTreeContentAdapter fgAsyncFrame = new StackFrameTreeContentAdapter();
+ private static IAsynchronousTreeContentAdapter fgAsyncVariable = new VariableTreeContentAdapter();
+ private static IAsynchronousTreeContentAdapter fgAsyncRegisterGroup = new RegisterGroupTreeContentAdapter();
+ private static IAsynchronousTreeContentAdapter fgAsyncExpressionManager = new ExpressionManagerTreeContentAdapter();
+ private static IAsynchronousTreeContentAdapter fgAsyncExpression = new ExpressionTreeContentAdapter();
/* (non-Javadoc)
* @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
@@ -58,36 +78,70 @@ public class DebugElementAdapterFactory implements IAdapterFactory {
if (adapterType.isInstance(adaptableObject)) {
return adaptableObject;
}
- if (adapterType.equals(IWorkbenchAdapter.class) || adapterType.equals(IWorkbenchAdapter2.class) || adapterType.equals(IDeferredWorkbenchAdapter.class)) {
- if (adaptableObject instanceof ILaunchManager) {
- return fgLaunchManagerAdapter;
- }
- if (adaptableObject instanceof ILaunch) {
- return fgLaunchAdapter;
- }
- if (adaptableObject instanceof IDebugTarget) {
- return fgDebugTargetAdapter;
- }
- if (adaptableObject instanceof IProcess) {
- return fgProcessAdapter;
- }
- if (adaptableObject instanceof IThread) {
- return fgThreadAdapter;
- }
- if (adaptableObject instanceof IStackFrame) {
- return fgFrameAdapter;
- }
+
+ if (adapterType.equals(IAsynchronousTreeContentAdapter.class)) {
+ if (adaptableObject instanceof ILaunchManager) {
+ return fgAsyncLaunchManager;
+ }
+ if (adaptableObject instanceof ILaunch) {
+ return fgAsyncLaunch;
+ }
+ if (adaptableObject instanceof IDebugTarget) {
+ return fgAsyncTarget;
+ }
+ if (adaptableObject instanceof IProcess) {
+ return fgAsyncProcess;
+ }
+ if (adaptableObject instanceof IThread) {
+ return fgAsyncThread;
+ }
+ if (adaptableObject instanceof IStackFrame) {
+ return fgAsyncFrame;
+ }
+ if (adaptableObject instanceof IVariable) {
+ return fgAsyncVariable;
+ }
+ if (adaptableObject instanceof IRegisterGroup) {
+ return fgAsyncRegisterGroup;
+ }
+ if (adaptableObject instanceof IExpressionManager) {
+ return fgAsyncExpressionManager;
+ }
+ if (adaptableObject instanceof IExpression) {
+ return fgAsyncExpression;
+ }
+ }
+
+ if (adapterType.equals(IAsynchronousLabelAdapter.class)) {
if (adaptableObject instanceof IVariable) {
- return fgVariableAdapter;
- }
- if (adaptableObject instanceof IExpression) {
- return fgExpressionAdapter;
+ return fgVariableLabelAdapter;
}
- if (adaptableObject instanceof IRegisterGroup) {
- return fgRegisterGroupAdapter;
+ return fgDebugLabelAdapter;
+ }
+
+ if (adapterType.equals(IUpdatePolicyFactory.class)) {
+ if (adaptableObject instanceof ILaunch || adaptableObject instanceof IDebugTarget ||
+ adaptableObject instanceof IProcess || adaptableObject instanceof ILaunchManager ||
+ adaptableObject instanceof IStackFrame)
+ return fgUpdatePolicyFactoryAdapter;
+ }
+
+ if (adapterType.equals(IModelProxyFactory.class)) {
+ if (adaptableObject instanceof ILaunch || adaptableObject instanceof IDebugTarget ||
+ adaptableObject instanceof IProcess || adaptableObject instanceof ILaunchManager ||
+ adaptableObject instanceof IStackFrame)
+ return fgModelProxyFactoryAdapter;
+ }
+
+ if (adapterType.equals(ISourceDisplayAdapter.class)) {
+ if (adaptableObject instanceof IStackFrame) {
+ return fgStackFrameSourceDisplayAdapter;
}
- if (adaptableObject instanceof IExpressionManager) {
- return fgExpressionManagerAdapter;
+ }
+
+ if (adapterType.equals(IModelSelectionPolicy.class)) {
+ if (adaptableObject instanceof IDebugElement) {
+ return new DefaultSelectionPolicy((IDebugElement)adaptableObject);
}
}
return null;
@@ -97,7 +151,8 @@ public class DebugElementAdapterFactory implements IAdapterFactory {
* @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList()
*/
public Class[] getAdapterList() {
- return new Class[] {IWorkbenchAdapter.class, IWorkbenchAdapter2.class, IDeferredWorkbenchAdapter.class};
+ return new Class[] {IWorkbenchAdapter.class, IWorkbenchAdapter2.class, IDeferredWorkbenchAdapter.class, IAsynchronousLabelAdapter.class, IAsynchronousTreeContentAdapter.class,
+ IUpdatePolicyFactory.class, IModelProxyFactory.class, ISourceDisplayAdapter.class, IModelSelectionPolicy.class};
}
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/DebugElementHelper.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/DebugElementHelper.java
index 591ef9991..1e6bfa7e7 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/DebugElementHelper.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/DebugElementHelper.java
@@ -78,7 +78,7 @@ public class DebugElementHelper {
*
* @return a model presentation to use to retrieve lables & images
*/
- private static DelegatingModelPresentation getPresentation() {
+ public static DelegatingModelPresentation getPresentation() {
if (fgPresenetation == null) {
fgPresenetation = new DelegatingModelPresentation();
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/DebugViewContentProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/DebugViewContentProvider.java
deleted file mode 100644
index 1ab49eca3..000000000
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/DebugViewContentProvider.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.debug.internal.ui.views.launch;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.debug.core.DebugException;
-import org.eclipse.debug.core.ILaunch;
-import org.eclipse.debug.core.ILaunchManager;
-import org.eclipse.debug.core.model.IDebugTarget;
-import org.eclipse.debug.core.model.IProcess;
-import org.eclipse.debug.core.model.IStackFrame;
-import org.eclipse.debug.core.model.IThread;
-import org.eclipse.debug.internal.ui.views.RemoteTreeContentManager;
-import org.eclipse.ui.IWorkbenchPartSite;
-import org.eclipse.ui.model.BaseWorkbenchContentProvider;
-import org.eclipse.ui.progress.IDeferredWorkbenchAdapter;
-
-/**
- * Provides deferred content for the debug view.
- * @since 3.1
- */
-public class DebugViewContentProvider extends BaseWorkbenchContentProvider {
-
- private RemoteTreeContentManager fManager;
-
- public DebugViewContentProvider(LaunchViewer tree, IWorkbenchPartSite site) {
- fManager = new RemoteTreeContentManager(this, tree, site);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
- */
- public Object[] getChildren(Object parentElement) {
- if (parentElement instanceof IStackFrame) {
- return null;
- }
- Object[] children = fManager.getChildren(parentElement);
- if (children == null) {
- children = super.getChildren(parentElement);
- }
- return children;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
- */
- public boolean hasChildren(Object element) {
- if (element instanceof IStackFrame) {
- return false;
- }
- if (element instanceof IDebugTarget) {
- try {
- return ((IDebugTarget)element).hasThreads();
- } catch (DebugException e) {
- return false;
- }
- }
- if (element instanceof IThread) {
- try {
- return ((IThread)element).hasStackFrames();
- } catch (DebugException e) {
- return false;
- }
- }
- if (element instanceof IProcess) {
- return false;
- }
- if (element instanceof ILaunch) {
- return ((ILaunch)element).hasChildren();
- }
- if (element instanceof ILaunchManager) {
- return ((ILaunchManager) element).getLaunches().length > 0;
- }
- if (element instanceof IAdaptable) {
- IAdaptable adaptable = (IAdaptable) element;
- IDeferredWorkbenchAdapter adapter = (IDeferredWorkbenchAdapter) adaptable.getAdapter(IDeferredWorkbenchAdapter.class);
- if (adapter != null) {
- return adapter.isContainer();
- }
- }
- return super.hasChildren(element);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IContentProvider#dispose()
- */
- public void dispose() {
- fManager.cancel();
- super.dispose();
- }
-
-}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/LaunchView.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/LaunchView.java
index a3fafdb48..bf99085f7 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/LaunchView.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/LaunchView.java
@@ -24,8 +24,10 @@ import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.ISafeRunnable;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.debug.core.DebugException;
@@ -45,19 +47,22 @@ import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
import org.eclipse.debug.internal.ui.InstructionPointerManager;
import org.eclipse.debug.internal.ui.actions.AddToFavoritesAction;
import org.eclipse.debug.internal.ui.actions.EditLaunchConfigurationAction;
+import org.eclipse.debug.internal.ui.contexts.DebugContextManager;
import org.eclipse.debug.internal.ui.sourcelookup.EditSourceLookupPathAction;
import org.eclipse.debug.internal.ui.sourcelookup.LookupSourceAction;
import org.eclipse.debug.internal.ui.sourcelookup.SourceLookupResult;
+import org.eclipse.debug.internal.ui.viewers.AsynchronousTreeViewer;
+import org.eclipse.debug.internal.ui.viewers.PresentationContext;
+import org.eclipse.debug.internal.ui.viewers.TreePath;
+import org.eclipse.debug.internal.ui.viewers.TreeSelection;
import org.eclipse.debug.internal.ui.views.AbstractDebugEventHandlerView;
import org.eclipse.debug.internal.ui.views.DebugUIViewsMessages;
-import org.eclipse.debug.internal.ui.views.DebugViewDecoratingLabelProvider;
-import org.eclipse.debug.internal.ui.views.DebugViewInterimLabelProvider;
-import org.eclipse.debug.internal.ui.views.DebugViewLabelDecorator;
-import org.eclipse.debug.internal.ui.views.RemoteTreeViewer;
import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.debug.ui.IDebugEditorPresentation;
import org.eclipse.debug.ui.IDebugModelPresentation;
import org.eclipse.debug.ui.IDebugUIConstants;
+import org.eclipse.debug.ui.contexts.IDebugContextListener;
+import org.eclipse.debug.ui.contexts.IDebugContextProvider;
import org.eclipse.debug.ui.sourcelookup.ISourceLookupResult;
import org.eclipse.jface.action.GroupMarker;
import org.eclipse.jface.action.IMenuManager;
@@ -65,6 +70,7 @@ import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.ListenerList;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.ISelection;
@@ -73,15 +79,11 @@ import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.KeyAdapter;
import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.IPageLayout;
@@ -145,6 +147,71 @@ public class LaunchView extends AbstractDebugEventHandlerView implements ISelect
*/
private IWorkbenchSiteProgressService fProgressService = null;
+ class ContextProvider implements IDebugContextProvider {
+ /**
+ * Context listeners
+ */
+ private ListenerList fListeners = new ListenerList();
+
+ private ISelection fContext = null;
+
+ protected void dispose() {
+ fContext = null;
+ fListeners.clear();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.contexts.IDebugContextProvider#getPart()
+ */
+ public IWorkbenchPart getPart() {
+ return LaunchView.this;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.contexts.IDebugContextProvider#addDebugContextListener(org.eclipse.debug.ui.contexts.IDebugContextListener)
+ */
+ public void addDebugContextListener(IDebugContextListener listener) {
+ fListeners.add(listener);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.contexts.IDebugContextProvider#removeDebugContextListener(org.eclipse.debug.ui.contexts.IDebugContextListener)
+ */
+ public void removeDebugContextListener(IDebugContextListener listener) {
+ fListeners.remove(listener);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.contexts.IDebugContextProvider#getActiveContext()
+ */
+ public synchronized ISelection getActiveContext() {
+ return fContext;
+ }
+
+ protected synchronized void activate(ISelection selection) {
+ fContext = selection;
+ Object[] listeners = fListeners.getListeners();
+ for (int i = 0; i < listeners.length; i++) {
+ final IDebugContextListener listener = (IDebugContextListener) listeners[i];
+ Platform.run(new ISafeRunnable() {
+ public void run() throws Exception {
+ listener.contextActivated(fContext, ContextProvider.this.getPart());
+ }
+ public void handleException(Throwable exception) {
+ DebugUIPlugin.log(exception);
+ }
+ });
+
+ }
+ }
+
+ }
+
+ /**
+ * Context provider
+ */
+ private ContextProvider fProvider = new ContextProvider();
+
/**
* Context manager which automatically opens and closes views
* based on debug contexts.
@@ -214,43 +281,6 @@ public class LaunchView extends AbstractDebugEventHandlerView implements ISelect
}
- /**
- * Label provider for the launch view which renders pending launches
- * with italic font.
- */
- private class LaunchViewLabelProvider extends DebugViewDecoratingLabelProvider {
-
- // The cached italic font used for pending launches
- private Font fItalicFont= null;
-
- public LaunchViewLabelProvider(StructuredViewer viewer, IDebugModelPresentation presentation) {
- super(viewer, new DebugViewInterimLabelProvider(presentation), new DebugViewLabelDecorator(presentation));
- }
-
- public Font getFont(Object element) {
- if (element instanceof DebugUIPlugin.PendingLaunch) {
- if (fItalicFont == null) {
- Control control = getViewer().getControl();
- Font originalFont = control.getFont();
- FontData fontData[] = originalFont.getFontData();
- // Add the italic attribute
- for (int i = 0; i < fontData.length; i++) {
- fontData[i].setStyle(fontData[i].getStyle() | SWT.ITALIC);
- }
- fItalicFont= new Font(control.getDisplay(), fontData);
- }
- return fItalicFont;
- }
- return super.getFont(element);
- }
-
- public void dispose() {
- if (fItalicFont != null) {
- fItalicFont.dispose();
- }
- super.dispose();
- }
- }
/**
* Job used for source display.
@@ -299,24 +329,28 @@ public class LaunchView extends AbstractDebugEventHandlerView implements ISelect
* @see org.eclipse.debug.ui.AbstractDebugView#createViewer(org.eclipse.swt.widgets.Composite)
*/
protected Viewer createViewer(Composite parent) {
- LaunchViewer lv = new LaunchViewer(parent);
- lv.addPostSelectionChangedListener(this);
- lv.getControl().addKeyListener(new KeyAdapter() {
- public void keyPressed(KeyEvent event) {
- if (event.character == SWT.DEL && event.stateMask == 0) {
- handleDeleteKeyPressed();
- }
- }
- });
- lv.setContentProvider(new DebugViewContentProvider(lv, getSite()));
- final DelegatingModelPresentation presentation = new DelegatingModelPresentation();
- lv.setLabelProvider(new LaunchViewLabelProvider(lv, presentation));
- fEditorPresentation = presentation;
- // add my viewer as a selection provider, so selective re-launch works
- getSite().setSelectionProvider(lv);
- lv.setInput(DebugPlugin.getDefault().getLaunchManager());
- setEventHandler(new LaunchViewEventHandler(this));
- return lv;
+ AsynchronousTreeViewer viewer = new LaunchViewer(parent);
+ viewer.setContext(new PresentationContext(this));
+ viewer.setInput(DebugPlugin.getDefault().getLaunchManager());
+
+ viewer.addSelectionChangedListener(this);
+ // TODO: why post and selection change listener?
+ // viewer.addPostSelectionChangedListener(this);
+ viewer.getControl().addKeyListener(new KeyAdapter() {
+ public void keyPressed(KeyEvent event) {
+ if (event.character == SWT.DEL && event.stateMask == 0) {
+ handleDeleteKeyPressed();
+ }
+ }
+ });
+ final DelegatingModelPresentation presentation = new DelegatingModelPresentation();
+ fEditorPresentation = presentation;
+ // add my viewer as a selection provider, so selective re-launch works
+ getSite().setSelectionProvider(viewer);
+ viewer.setInput(DebugPlugin.getDefault().getLaunchManager());
+ //setEventHandler(new LaunchViewEventHandler(this));
+ DebugContextManager.getDefault().addDebugContextProvider(fProvider);
+ return viewer;
}
private void handleDeleteKeyPressed() {
@@ -337,7 +371,7 @@ public class LaunchView extends AbstractDebugEventHandlerView implements ISelect
}
if (itemsToTerminate) {
// Prompt the user to proceed with termination
- if (!MessageDialog.openQuestion(getSite().getShell(), DebugUIViewsMessages.LaunchView_Terminate_and_Remove_1, DebugUIViewsMessages.LaunchView_Terminate_and_remove_selected__2)) { //
+ if (!MessageDialog.openQuestion(getSite().getShell(), DebugUIViewsMessages.LaunchView_Terminate_and_Remove_1, DebugUIViewsMessages.LaunchView_Terminate_and_remove_selected__2)) {
return;
}
}
@@ -353,7 +387,7 @@ public class LaunchView extends AbstractDebugEventHandlerView implements ISelect
if (!status.isOK()) {
IWorkbenchWindow window= DebugUIPlugin.getActiveWorkbenchWindow();
if (window != null) {
- DebugUIPlugin.errorDialog(window.getShell(), DebugUIViewsMessages.LaunchView_Terminate_and_Remove_4, DebugUIViewsMessages.LaunchView_Terminate_and_remove_failed_5, status); //
+ DebugUIPlugin.errorDialog(window.getShell(), DebugUIViewsMessages.LaunchView_Terminate_and_Remove_4, DebugUIViewsMessages.LaunchView_Terminate_and_remove_failed_5, status);
} else {
DebugUIPlugin.log(status);
}
@@ -406,27 +440,26 @@ public class LaunchView extends AbstractDebugEventHandlerView implements ISelect
if (!isAvailable()) {
return;
}
- TreeViewer tv = (TreeViewer)getViewer();
- tv.expandToLevel(2);
- final Object[] elements = tv.getExpandedElements();
+
// traverse debug model in non UI thread
Job initJob = new Job(DebugUIViewsMessages.LaunchView_2) {
/* (non-Javadoc)
* @see org.eclipse.core.internal.jobs.InternalJob#run(org.eclipse.core.runtime.IProgressMonitor)
*/
protected IStatus run(IProgressMonitor monitor) {
- for (int i = 0; i < elements.length; i++) {
- if (elements[i] instanceof ILaunch) {
- final IStackFrame frame = findFrame((ILaunch)elements[i]);
- if (frame != null) {
- Runnable runnable = new Runnable() {
- public void run() {
- autoExpand(frame, true);
- }
- };
- asyncExec(runnable);
- }
- }
+ ILaunchManager launchManager = (ILaunchManager) getViewer().getInput();
+ ILaunch[] launches = launchManager.getLaunches();
+ for (int i = 0; i < launches.length; i++) {
+ ILaunch launch = launches[i];
+ final IStackFrame frame = findFrame(launch);
+ if (frame != null) {
+ Runnable runnable = new Runnable() {
+ public void run() {
+ autoExpand(frame, true);
+ }
+ };
+ asyncExec(runnable);
+ }
}
return Status.OK_STATUS;
}
@@ -507,10 +540,14 @@ public class LaunchView extends AbstractDebugEventHandlerView implements ISelect
* @see org.eclipse.ui.IWorkbenchPart#dispose()
*/
public void dispose() {
- RemoteTreeViewer viewer = (RemoteTreeViewer) getViewer();
+ fProvider.dispose();
+ Viewer viewer = getViewer();
if (viewer != null) {
viewer.removeSelectionChangedListener(this);
- viewer.cancelJobs();
+ if (viewer instanceof AsynchronousTreeViewer) {
+ AsynchronousTreeViewer asyncTreeViewer = (AsynchronousTreeViewer) viewer;
+ asyncTreeViewer.dispose();
+ }
}
if (fContextListener != null) {
fContextListener.dispose();
@@ -551,12 +588,21 @@ public class LaunchView extends AbstractDebugEventHandlerView implements ISelect
* @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
*/
public void selectionChanged(SelectionChangedEvent event) {
- clearStatusLine();
- updateObjects();
- showEditorForCurrentSelection();
+ fProvider.activate(event.getSelection());
+
+// clearStatusLine();
+// updateObjects();
+// Object element = ((IStructuredSelection) getViewer().getSelection()).getFirstElement();
+// if (element != null && !element.equals(fStackFrame)) {
+// showEditorForCurrentSelection();
+// }
+
+// TODO: replace view conetxt stuff based on debug context
if (isActive()) {
- fContextListener.updateForSelection(((IStructuredSelection) getViewer().getSelection()).getFirstElement());
+ Object element = ((IStructuredSelection)event.getSelection()).getFirstElement();
+ fContextListener.updateForSelection(element);
}
+
}
/**
@@ -603,9 +649,8 @@ public class LaunchView extends AbstractDebugEventHandlerView implements ISelect
if (o == null || o instanceof IStackFrame) {
return;
}
- TreeViewer tViewer= (TreeViewer)getViewer();
- boolean expanded= tViewer.getExpandedState(o);
- tViewer.setExpandedState(o, !expanded);
+ StructuredViewer viewer = (StructuredViewer) getViewer();
+ viewer.refresh(o);
}
/* (non-Javadoc)
@@ -834,29 +879,27 @@ public class LaunchView extends AbstractDebugEventHandlerView implements ISelect
* @param selectNeeded whether the element should be selected
*/
public void autoExpand(Object element, boolean selectNeeded) {
- LaunchViewer launchViewer = (LaunchViewer)getViewer();
- launchViewer.deferExpansion(element);
- if (selectNeeded) {
- IStructuredSelection selection = (IStructuredSelection) getViewer().getSelection();
- // if a frame is selected in a different thread, do not update selection
- Iterator iterator = selection.iterator();
- while (iterator.hasNext()) {
- Object object = iterator.next();
- if (object instanceof IStackFrame) {
- if (element instanceof IStackFrame) {
- IThread currThread = ((IStackFrame)object).getThread();
- if (!currThread.equals(((IStackFrame)element).getThread())) {
- // a frame in a different thread is selected, don't change
- return;
- }
- } else {
- // a frame is selected and the new selection is not a frame
- // do not change the selection
- return;
- }
+ AsynchronousTreeViewer viewer = (AsynchronousTreeViewer) getViewer();
+ TreePath[] treePaths = viewer.getTreePaths(element);
+ if (element instanceof IStackFrame) {
+ IStackFrame frame = (IStackFrame) element;
+ if (treePaths != null) {
+ viewer.expand(new TreeSelection(treePaths));
+ if (selectNeeded) {
+ viewer.setSelection(new TreeSelection(treePaths));
+ }
+ } else {
+ ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
+ ILaunch launch = frame.getLaunch();
+ IDebugTarget debugTarget = frame.getDebugTarget();
+ IThread thread = frame.getThread();
+
+ TreePath treePath = new TreePath(new Object[] {launchManager, launch, debugTarget, thread, frame});
+ viewer.expand(new TreeSelection(new TreePath[] {treePath}));
+ if (selectNeeded) {
+ viewer.setSelection(new TreeSelection(new TreePath[] {treePath}));
}
}
- launchViewer.deferSelection(new StructuredSelection(element));
}
}
@@ -1102,4 +1145,5 @@ public class LaunchView extends AbstractDebugEventHandlerView implements ISelect
*/
public void partInputChanged(IWorkbenchPartReference partRef) {
}
+
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/LaunchViewEventHandler.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/LaunchViewEventHandler.java
index 5fa1102a3..6a4230b05 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/LaunchViewEventHandler.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/LaunchViewEventHandler.java
@@ -16,12 +16,13 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Set;
-import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.DebugEvent;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
-import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.core.ILaunchesListener2;
import org.eclipse.debug.core.model.IDebugElement;
@@ -30,10 +31,12 @@ import org.eclipse.debug.core.model.IProcess;
import org.eclipse.debug.core.model.IStackFrame;
import org.eclipse.debug.core.model.IThread;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
+import org.eclipse.debug.internal.ui.viewers.AsynchronousTreeViewer;
+import org.eclipse.debug.internal.ui.viewers.TreePath;
+import org.eclipse.debug.internal.ui.viewers.TreeSelection;
import org.eclipse.debug.internal.ui.views.AbstractDebugEventHandler;
import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.ui.progress.WorkbenchJob;
/**
* Handles debug events, updating the launch view and viewer.
@@ -86,16 +89,6 @@ public class LaunchViewEventHandler extends AbstractDebugEventHandler implements
}
/**
- * Returns the parent for the given element.
- *
- * @param element
- * @return parent
- */
- private Object getParent(Object element) {
- return ((ITreeContentProvider)getTreeViewer().getContentProvider()).getParent(element);
- }
-
- /**
* @see AbstractDebugEventHandler#doHandleDebugEvents(DebugEvent[])
*/
protected void doHandleDebugEvents(DebugEvent[] events, Object data) {
@@ -107,27 +100,41 @@ public class LaunchViewEventHandler extends AbstractDebugEventHandler implements
switch (event.getKind()) {
case DebugEvent.CREATE :
if (source instanceof IThread) {
- insert(source);
+ IThread thread = (IThread) source;
+ IDebugTarget target = thread.getDebugTarget();
+ refresh(target);
} else {
- Object parent = getParent(source);
- if (parent != null) {
- refresh(parent);
- }
+ getViewer().refresh();
if (source instanceof IDebugTarget | source instanceof IProcess) {
getLaunchView().autoExpand(source, true);
}
}
break;
- case DebugEvent.TERMINATE :
+ case DebugEvent.TERMINATE:
clearSourceSelection(source);
- if (source instanceof IThread) {
- fThreadTimer.getTimedOutThreads().remove(source);
- remove(source);
- } else {
- Object parent = getParent(source);
- if (parent != null) {
- refresh(parent);
+ if (source instanceof IDebugElement) {
+ IDebugElement element = (IDebugElement) source;
+ if (source instanceof IThread) {
+ fThreadTimer.getTimedOutThreads().remove(source);
+ remove(source);
+ } else {
+ IDebugTarget debugTarget = element.getDebugTarget();
+ if (debugTarget != null) {
+ refresh(debugTarget);
+ }
+ }
+
+ ILaunch launch = element.getLaunch();
+ if (launch.isTerminated()) {
+ update(launch);
}
+ resetSelection(source, data);
+ } else if (source instanceof IProcess) {
+ IProcess process = (IProcess) source;
+ refresh(process);
+ update(process.getLaunch());
+ } else {
+ refresh(source);
}
break;
case DebugEvent.RESUME :
@@ -141,10 +148,8 @@ public class LaunchViewEventHandler extends AbstractDebugEventHandler implements
break;
case DebugEvent.CHANGE :
Object element = null;
- IStructuredSelection selection = getLaunchViewer().getDeferredSelection();
- if (selection == null) {
- selection = (IStructuredSelection) getLaunchViewer().getSelection();
- }
+ AsynchronousTreeViewer viewer = (AsynchronousTreeViewer) getViewer();
+ IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
element = selection.getFirstElement();
IStackFrame lastFrame = null;
@@ -173,6 +178,12 @@ public class LaunchViewEventHandler extends AbstractDebugEventHandler implements
}
}
+ private void update(Object element) {
+ AsynchronousTreeViewer viewer = (AsynchronousTreeViewer) getLaunchView().getViewer();
+ viewer.update(element);
+ }
+
+
/**
* Handles the given resume event with the given source.
*/
@@ -189,25 +200,36 @@ public class LaunchViewEventHandler extends AbstractDebugEventHandler implements
}
return;
}
+ fLastStackFrame = null;
refresh(source);
+ resetSelection(source, data);
+ }
+
+ private void resetSelection(Object source, Object data) {
if (source instanceof IThread) {
- if (data instanceof IStackFrame) {
- selectAndReveal(data);
- return;
+ AsynchronousTreeViewer viewer = (AsynchronousTreeViewer) getViewer();
+ TreePath[] treePaths = null;
+ if (data instanceof IStackFrame) {
+ treePaths = viewer.getTreePaths(data);
+ } else {
+ treePaths = viewer.getTreePaths(source);
+ }
+
+ if (treePaths != null && treePaths.length > 0) {
+ viewer.setSelection(new TreeSelection(new TreePath[] { treePaths[0] }));
}
- selectAndReveal(source);
}
}
-
+
+
/**
- * Updates the stack frame icons for a running thread.
- * This is useful for the case where a thread is resumed
- * temporarily but the view should keep the stack frame
- * visible (for example, step start or evaluation start).
+ * Updates the stack frame icons for a running thread. This is useful for
+ * the case where a thread is resumed temporarily but the view should keep
+ * the stack frame visible (for example, step start or evaluation start).
*/
protected void updateRunningThread(IThread thread) {
- labelChanged(thread);
- getLaunchViewer().updateStackFrameImages(thread);
+ labelChanged(thread);
+// getLaunchViewer().updateStackFrameImages(thread);
clearSourceSelection(thread);
}
@@ -249,33 +271,26 @@ public class LaunchViewEventHandler extends AbstractDebugEventHandler implements
frame = (IStackFrame) data;
}
- // if the top frame is the same, only update labels and images, and re-select
- // the frame to display source
- if (frame != null && frame.equals(fLastStackFrame)) {
- if (wasTimedOut) {
- getLaunchViewer().updateStackFrameImages(thread);
- }
- getLaunchViewer().update(new Object[] {thread, frame}, null);
- if (!evaluationEvent) {
- getLaunchViewer().deferExpansion(thread);
- getLaunchViewer().deferSelection(new StructuredSelection(frame));
- } else if (wasTimedOut) {
- getLaunchView().showEditorForCurrentSelection();
+ LaunchView launchView = getLaunchView();
+ if (frame != null) {
+ if (frame.equals(fLastStackFrame) && !wasTimedOut) {
+ // if the top frame is the same, only update the frame, and re-select
+ // the frame to display source
+ refresh(frame);
+ } else {
+ refresh(thread);
}
- return;
- }
-
- if (frame == null) {
+ fLastStackFrame = frame;
+ // Auto-expand the thread. Only select the thread if this wasn't
+ // the end of an evaluation
+
+ launchView.autoExpand(frame, !evaluationEvent);
+ launchView.openEditorForStackFrame(frame);
+ } else {
// suspend event, but no frames in the thead
- fLastStackFrame = null;
+ fLastStackFrame = null;
refresh(thread);
- getLaunchView().autoExpand(thread, !evaluationEvent);
- } else {
- fLastStackFrame = frame;
- // Auto-expand the thread. Only select the thread if this wasn't the end
- // of an evaluation
- refresh(thread);
- getLaunchView().autoExpand(frame, !evaluationEvent);
+ launchView.autoExpand(thread, !evaluationEvent);
}
}
@@ -310,15 +325,6 @@ public class LaunchViewEventHandler extends AbstractDebugEventHandler implements
}
/**
- * Returns this event handler's launch viewer
- *
- * @return launch viewer
- */
- protected LaunchViewer getLaunchViewer() {
- return (LaunchViewer)getViewer();
- }
-
- /**
* Returns this event handler's launch view
*
* @return launch view
@@ -471,13 +477,16 @@ public class LaunchViewEventHandler extends AbstractDebugEventHandler implements
// Refresh the UI to show that the thread
// is performing a long evaluation
final IThread thread= (IThread)entry.getKey();
- fStopTimes.remove(thread);
- getView().asyncExec(new Runnable() {
- public void run() {
+ fStopTimes.remove(thread);
+ WorkbenchJob job = new WorkbenchJob("updateRunningThread") { //$NON-NLS-1$
+ public IStatus runInUIThread(IProgressMonitor monitor) {
fTimedOutThreads.add(thread);
updateRunningThread(thread);
+ return Status.OK_STATUS;
}
- });
+ };
+ job.setSystem(true);
+ job.schedule();
} else {
timeToWait= Math.min(timeToWait, stopTime - currentTime);
}
@@ -518,8 +527,8 @@ public class LaunchViewEventHandler extends AbstractDebugEventHandler implements
* @see org.eclipse.debug.core.ILaunchesListener#launchesChanged(org.eclipse.debug.core.ILaunch)
*/
public void launchesChanged(final ILaunch[] launches) {
- Runnable r= new Runnable() {
- public void run() {
+ WorkbenchJob job = new WorkbenchJob("LaunchViewEventHandler.launchesChanged") { //$NON-NLS-1$
+ public IStatus runInUIThread(IProgressMonitor monitor) {
if (isAvailable()) {
if (launches.length == 1) {
refresh(launches[0]);
@@ -532,72 +541,56 @@ public class LaunchViewEventHandler extends AbstractDebugEventHandler implements
}
}
}
+ return Status.OK_STATUS;
}
};
-
- getView().asyncExec(r);
+ job.setSystem(true);
+ job.schedule();
}
/**
* @see org.eclipse.debug.core.ILaunchesListener#launchesRemoved(org.eclipse.debug.core.ILaunch)
*/
public void launchesRemoved(final ILaunch[] launches) {
- Runnable r= new Runnable() {
- public void run() {
+ WorkbenchJob job = new WorkbenchJob("LaunchViewEventHandler.launchesRemoved") { //$NON-NLS-1$
+ public IStatus runInUIThread(IProgressMonitor monitor) {
if (isAvailable()) {
if (launches.length == 1) {
- remove(launches[0]);
+ LaunchViewEventHandler.this.remove(launches[0]);
} else {
refresh();
}
getLaunchView().cleanupLaunches(launches);
- // auto select the next suspended thread if no current selection
- if (getLaunchViewer().getSelection().isEmpty()) {
- // only change selection if the thing removed is of the same type as the things still there
- Set types = new HashSet();
- for (int i = 0; i < launches.length; i++) {
- ILaunch launch = launches[i];
- ILaunchConfiguration configuration = launch.getLaunchConfiguration();
- if (configuration != null) {
- try {
- types.add(configuration.getType());
- } catch (CoreException e) {
- }
- }
- }
- ILaunchManager lm= DebugPlugin.getDefault().getLaunchManager();
- IDebugTarget[] targets= lm.getDebugTargets();
- if (targets.length > 0) {
- IDebugTarget target= targets[targets.length - 1];
- ILaunchConfiguration configuration = target.getLaunch().getLaunchConfiguration();
- if (configuration != null) {
- try {
- if (types.contains(configuration.getType())) {
- IThread[] threads= target.getThreads();
- for (int i=0; i < threads.length; i++) {
- if (threads[i].isSuspended()) {
- IStackFrame topStackFrame = threads[i].getTopStackFrame();
- if (topStackFrame != null) {
- getLaunchView().autoExpand(topStackFrame, true);
- }
- return;
- }
- }
+ ILaunchManager lm= DebugPlugin.getDefault().getLaunchManager();
+ IDebugTarget[] targets= lm.getDebugTargets();
+ if (targets.length > 0) {
+ IDebugTarget target= targets[targets.length - 1];
+ try {
+ IThread[] threads= target.getThreads();
+ for (int i=0; i < threads.length; i++) {
+ if (threads[i].isSuspended()) {
+ IStackFrame topStackFrame = threads[i].getTopStackFrame();
+ if (topStackFrame != null) {
+ getLaunchView().autoExpand(topStackFrame, true);
}
- } catch (CoreException e) {
- DebugUIPlugin.log(e);
+ return Status.OK_STATUS;
}
- getLaunchView().autoExpand(target.getLaunch(), true);
- }
+ }
+ } catch (DebugException de) {
+ DebugUIPlugin.log(de);
}
+
+ getLaunchView().autoExpand(target.getLaunch(), true);
}
}
+ return Status.OK_STATUS;
}
};
-
- getView().asyncExec(r);
+
+ job.setSystem(true);
+ job.schedule();
}
@@ -614,12 +607,15 @@ public class LaunchViewEventHandler extends AbstractDebugEventHandler implements
}
}
}
- Runnable r= new Runnable() {
- public void run() {
+ WorkbenchJob job = new WorkbenchJob("LaunchViewEventHandler.launchesTerminated") { //$NON-NLS-1$
+ public IStatus runInUIThread(IProgressMonitor monitor) {
getLaunchView().cleanupLaunches(launches);
+ return Status.OK_STATUS;
}
+
};
- getView().asyncExec(r);
+ job.setSystem(true);
+ job.schedule();
}
/* (non-Javadoc)
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/LaunchViewer.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/LaunchViewer.java
index 4ea2fcdc4..cf1c52e9b 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/LaunchViewer.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/LaunchViewer.java
@@ -1,83 +1,190 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
package org.eclipse.debug.internal.ui.views.launch;
+import java.util.ArrayList;
+import java.util.List;
-import org.eclipse.debug.core.model.IThread;
-import org.eclipse.debug.internal.ui.views.RemoteTreeViewer;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.debug.core.model.IStackFrame;
+import org.eclipse.debug.internal.ui.DebugUIPlugin;
+import org.eclipse.debug.internal.ui.viewers.AsynchronousTreeContentAdapter;
+import org.eclipse.debug.internal.ui.viewers.AsynchronousTreeViewer;
+import org.eclipse.debug.internal.ui.viewers.IAsynchronousTreeContentAdapter;
+import org.eclipse.debug.internal.ui.viewers.IPresentationContext;
+import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Item;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeItem;
-import org.eclipse.swt.widgets.Widget;
-
-/**
- * The launch viewer displays a tree of launches.
- */
-public class LaunchViewer extends RemoteTreeViewer {
- /**
- * Overridden to fix bug 39709 - duplicate items in launch viewer. The
- * workaround is required since debug creation events (which result in
- * additions to the tree) are processed asynchrnously with the expanding
- * of a launch/debug target in the tree.
- *
- * @see org.eclipse.jface.viewers.AbstractTreeViewer#add(java.lang.Object, java.lang.Object)
- */
- public synchronized void add(Object parentElement, Object childElement) {
- if (findItem(childElement) == null) {
- super.add(parentElement, childElement);
- }
+import org.eclipse.ui.model.IWorkbenchAdapter;
+import org.eclipse.ui.progress.IDeferredWorkbenchAdapter;
+import org.eclipse.ui.progress.IElementCollector;
+import org.osgi.framework.Bundle;
+
+public class LaunchViewer extends AsynchronousTreeViewer {
+
+ public LaunchViewer(Composite parent) {
+ super(parent);
}
- public LaunchViewer(Composite parent) {
- super(new Tree(parent, SWT.MULTI));
- setUseHashlookup(true);
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.treeviewer.AsynchronousTreeViewer#getTreeContentAdapter(java.lang.Object)
+ */
+ protected IAsynchronousTreeContentAdapter getTreeContentAdapter(Object element) {
+ AsynchronousTreeContentAdapter legacyAdapter = getLegacyAdapter(element);
+ if (legacyAdapter != null) {
+ return legacyAdapter;
+ }
+
+ IAsynchronousTreeContentAdapter presentationAdapter = super.getTreeContentAdapter(element);
+ if (presentationAdapter != null) {
+ return presentationAdapter;
+ }
+
+ return new BogusTreeAdapter();
}
-
+
/**
- * Update the images for all stack frame children of the given thread.
+ * Returns a wrapper to the legacy workbench adapter if supported by the given object.
*
- * @param parentThread the thread whose frames should be updated
- */
- protected void updateStackFrameImages(IThread parentThread) {
- Widget parentItem= findItem(parentThread);
- if (parentItem != null) {
- Item[] items= getItems((Item)parentItem);
- for (int i = 0; i < items.length; i++) {
- updateTreeItemImage((TreeItem)items[i]);
+ * @param element
+ * @return
+ */
+ private AsynchronousTreeContentAdapter getLegacyAdapter(Object element) {
+ if (element instanceof IDeferredWorkbenchAdapter) {
+ return new WrappedDeferredWorkbenchTreeAdapter((IDeferredWorkbenchAdapter) element, element);
+ }
+
+ if (!(element instanceof IAdaptable)) {
+ return null;
+ }
+
+ IAdaptable adaptable = (IAdaptable) element;
+ IDeferredWorkbenchAdapter deferred = (IDeferredWorkbenchAdapter) adaptable.getAdapter(IDeferredWorkbenchAdapter.class);
+ if (deferred != null) {
+ DebugUIPlugin plugin = DebugUIPlugin.getDefault();
+ Bundle bundle = plugin.getBundle(deferred.getClass());
+ Bundle debugBundle = plugin.getBundle();
+ if (!debugBundle.equals(bundle)) {
+ // if client contributed, use it
+ return new WrappedDeferredWorkbenchTreeAdapter(deferred, element);
}
}
+ // if the client provided an IWorkbenchAdapter, use it
+ IWorkbenchAdapter nonDeferred = (IWorkbenchAdapter) adaptable.getAdapter(IWorkbenchAdapter.class);
+ if (nonDeferred != null) {
+ DebugUIPlugin plugin = DebugUIPlugin.getDefault();
+ Bundle bundle = plugin.getBundle(nonDeferred.getClass());
+ Bundle debugBundle = plugin.getBundle();
+ bundle = plugin.getBundle(nonDeferred.getClass());
+ if (!debugBundle.equals(bundle)) {
+ return new WrappedWorkbenchTreeAdapter(nonDeferred);
+ }
+ }
+ return null;
}
-
- /**
- * Updates the image of the given tree item.
- *
- * @param treeItem the item
- */
- protected void updateTreeItemImage(TreeItem treeItem) {
- ILabelProvider provider = (ILabelProvider) getLabelProvider();
- Image image = provider.getImage(treeItem.getData());
- if (image != null) {
- treeItem.setImage(image);
- }
+
+ private class ElementCollector implements IElementCollector {
+ List children = new ArrayList();
+
+ public void add(Object element, IProgressMonitor monitor) {
+ children.add(element);
+ }
+
+ public void add(Object[] elements, IProgressMonitor monitor) {
+ for (int i = 0; i < elements.length; i++) {
+ children.add(elements[i]);
+ }
+ }
+
+ public void done() {
+ }
+
+ public Object[] getChildren() {
+ return children.toArray();
+ }
+
+ }
+
+ private class WrappedDeferredWorkbenchTreeAdapter extends AsynchronousTreeContentAdapter {
+ private IDeferredWorkbenchAdapter fAdapter;
+
+ private Object fElement;
+
+ public WrappedDeferredWorkbenchTreeAdapter(IDeferredWorkbenchAdapter adapter, Object element) {
+ fAdapter = adapter;
+ fElement = element;
+ }
+
+ protected Object[] getChildren(Object parent, IPresentationContext context) throws CoreException {
+ ElementCollector elementCollector = new ElementCollector();
+ fAdapter.fetchDeferredChildren(fElement, elementCollector, new NullProgressMonitor());
+ return elementCollector.getChildren();
+ }
+
+ protected boolean hasChildren(Object element, IPresentationContext context) throws CoreException {
+ if (element instanceof IStackFrame) {
+ return false;
+ }
+ return fAdapter.isContainer();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.viewers.AsynchronousTreeContentAdapter#supportsPartId(java.lang.String)
+ */
+ protected boolean supportsPartId(String id) {
+ return IDebugUIConstants.ID_DEBUG_VIEW.equals(id);
+ }
+ }
+
+ private class WrappedWorkbenchTreeAdapter extends AsynchronousTreeContentAdapter {
+ private IWorkbenchAdapter fAdapter;
+
+ public WrappedWorkbenchTreeAdapter(IWorkbenchAdapter adapter) {
+ fAdapter = adapter;
+ }
+
+ protected Object[] getChildren(Object parent, IPresentationContext context) throws CoreException {
+ return fAdapter.getChildren(parent);
+ }
+
+ protected boolean hasChildren(Object element, IPresentationContext context) throws CoreException {
+ if (element instanceof IStackFrame) {
+ return false;
+ }
+ return fAdapter.getChildren(element).length > 0;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.viewers.AsynchronousTreeContentAdapter#supportsPartId(java.lang.String)
+ */
+ protected boolean supportsPartId(String id) {
+ return IDebugUIConstants.ID_DEBUG_VIEW.equals(id);
+ }
+
}
+ private class BogusTreeAdapter extends AsynchronousTreeContentAdapter {
+ protected Object[] getChildren(Object parent, IPresentationContext context) throws CoreException {
+ return new Object[0];
+ }
+ protected boolean hasChildren(Object element, IPresentationContext context) throws CoreException {
+ return false;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.viewers.AsynchronousTreeContentAdapter#supportsPartId(java.lang.String)
+ */
+ protected boolean supportsPartId(String id) {
+ return false;
+ }
+ }
+
/* (non-Javadoc)
- * @see org.eclipse.jface.viewers.StructuredViewer#refresh(java.lang.Object)
+ * @see org.eclipse.debug.ui.viewers.AsynchronousViewer#isSuppressEqualSelections()
*/
- public void refresh(Object element) {
- super.refresh(element);
+ protected boolean isSuppressEqualSelections() {
+ // fire activation changes all the time
+ return false;
}
-
+
+
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/registers/DeferredRegisterViewStackFrame.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/registers/DeferredRegisterViewStackFrame.java
deleted file mode 100644
index 2ca1bca42..000000000
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/registers/DeferredRegisterViewStackFrame.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.debug.internal.ui.views.registers;
-
-import org.eclipse.debug.core.DebugException;
-import org.eclipse.debug.core.model.IRegisterGroup;
-import org.eclipse.debug.core.model.IStackFrame;
-import org.eclipse.debug.internal.ui.elements.adapters.DeferredStackFrame;
-
-public class DeferredRegisterViewStackFrame extends DeferredStackFrame {
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(java.lang.Object)
- */
- public Object[] getChildren(Object parent) {
- try {
- return ((IStackFrame)parent).getRegisterGroups();
- } catch (DebugException e) {
- }
- return EMPTY;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.internal.ui.elements.adapters.DeferredStackFrame#hasChildren(java.lang.Object)
- */
- protected boolean hasChildren(Object child) {
- IRegisterGroup group = (IRegisterGroup) child;
- try {
- return group.hasRegisters();
- } catch (DebugException e) {
- }
- return false;
- }
-}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/registers/RegistersView.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/registers/RegistersView.java
index e11673e54..ad3cc2e4b 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/registers/RegistersView.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/registers/RegistersView.java
@@ -12,15 +12,11 @@ package org.eclipse.debug.internal.ui.views.registers;
import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
import org.eclipse.debug.internal.ui.preferences.IDebugPreferenceConstants;
-import org.eclipse.debug.internal.ui.views.AbstractViewerState;
-import org.eclipse.debug.internal.ui.views.RemoteTreeViewer;
-import org.eclipse.debug.internal.ui.views.variables.RemoteVariablesContentProvider;
import org.eclipse.debug.internal.ui.views.variables.VariablesView;
import org.eclipse.debug.internal.ui.views.variables.VariablesViewEventHandler;
import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.viewers.Viewer;
/**
* Displays registers and their values with a detail area.
@@ -28,16 +24,6 @@ import org.eclipse.jface.viewers.Viewer;
public class RegistersView extends VariablesView {
/**
- * @see org.eclipse.debug.internal.ui.views.variables.VariablesView#createContentProvider()
- */
- protected RemoteVariablesContentProvider createContentProvider(Viewer viewer) {
- RemoteRegistersViewContentProvider cp = new RemoteRegistersViewContentProvider((RemoteTreeViewer) viewer, getSite(), this);
-// TODO
-// cp.setExceptionHandler(this);
- return cp;
- }
-
- /**
* @see org.eclipse.debug.ui.AbstractDebugView#getHelpContextId()
*/
protected String getHelpContextId() {
@@ -67,12 +53,7 @@ public class RegistersView extends VariablesView {
return RegistersViewMessages.RegistersView_0;
}
- /**
- * @see org.eclipse.debug.internal.ui.views.variables.VariablesView#getViewerState()
- */
- protected AbstractViewerState getViewerState() {
- return new RegistersViewerState(getVariablesViewer());
- }
+
/* (non-Javadoc)
* @see org.eclipse.debug.internal.ui.views.variables.VariablesView#createEventHandler()
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/registers/RegistersViewerState.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/registers/RegistersViewerState.java
deleted file mode 100644
index df647236c..000000000
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/registers/RegistersViewerState.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2004, 2005 QNX Software 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:
- * QNX Software Systems - Initial API and implementation
-***********************************************************************/
-package org.eclipse.debug.internal.ui.views.registers;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.debug.core.DebugException;
-import org.eclipse.debug.core.model.IRegisterGroup;
-import org.eclipse.debug.core.model.IVariable;
-import org.eclipse.debug.internal.ui.views.AbstractViewerState;
-import org.eclipse.debug.internal.ui.views.RemoteTreeViewer;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.swt.widgets.TreeItem;
-
-/**
- * Memento of the expanded and selected items in a registers viewer.
- *
- */
-public class RegistersViewerState extends AbstractViewerState {
-
- public RegistersViewerState( TreeViewer viewer ) {
- super( viewer );
- }
-
- public RegistersViewerState() {
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.debug.internal.ui.views.AbstractViewerState#encodeElement(org.eclipse.swt.widgets.TreeItem)
- */
- public IPath encodeElement( TreeItem item ) throws DebugException {
- Object obj = item.getData();
- String name = ( obj instanceof IRegisterGroup ) ?
- ((IRegisterGroup)obj).getName() : ((IVariable)obj).getName();
- IPath path = new Path( name );
- TreeItem parent = item.getParentItem();
- while( parent != null ) {
- obj = parent.getData();
- name = ( obj instanceof IRegisterGroup ) ?
- ((IRegisterGroup)obj).getName() : ((IVariable)obj).getName();
- path = new Path( name ).append( path );
- parent = parent.getParentItem();
- }
- return path;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.debug.internal.ui.views.AbstractViewerState#decodePath(org.eclipse.core.runtime.IPath, org.eclipse.jface.viewers.TreeViewer)
- */
- public Object decodePath( IPath path, TreeViewer viewer ) throws DebugException {
- ITreeContentProvider contentProvider = (ITreeContentProvider)viewer.getContentProvider();
- String[] names = path.segments();
- Object parent = viewer.getInput();
- Object element = null;
- for( int i = 0; i < names.length; i++ ) {
- element = null;
- Object[] children = null;
- if (viewer instanceof RemoteTreeViewer) {
- children = ((RemoteTreeViewer) viewer).getCurrentChildren(parent);
- } else {
- children = contentProvider.getChildren(parent);
- }
-
- if (children == null)
- return null;
-
- String name = names[i];
- for( int j = 0; j < children.length; j++ ) {
- if ( children[j] instanceof IRegisterGroup ) {
- if ( name.equals( ((IRegisterGroup)children[j]).getName() ) ) {
- element = children[j];
- break;
- }
- }
- else if ( children[j] instanceof IVariable ) {
- if ( name.equals( ((IVariable)children[j]).getName() ) ) {
- element = children[j];
- break;
- }
- }
- }
- if ( element == null ) {
- return null;
- }
- parent = element;
- }
- return element;
- }
-
- public AbstractViewerState copy() {
- RegistersViewerState copy = new RegistersViewerState();
- if (fSavedExpansion != null) {
- copy.fSavedExpansion = new ArrayList();
- for (Iterator iter = fSavedExpansion.iterator(); iter.hasNext();) {
- copy.fSavedExpansion.add(iter.next());
- }
- }
-
- if (fSelection != null) {
- copy.fSelection = new IPath[fSelection.length];
- for (int i = 0; i < fSelection.length; i++) {
- IPath sel = fSelection[i];
- copy.fSelection[i] = sel;
- }
- }
- return copy;
- }
-}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/registers/RemoteRegisterContentManager.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/registers/RemoteRegisterContentManager.java
deleted file mode 100644
index 83b3e51f5..000000000
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/registers/RemoteRegisterContentManager.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.debug.internal.ui.views.registers;
-
-import org.eclipse.debug.core.model.IStackFrame;
-import org.eclipse.debug.internal.ui.views.RemoteTreeViewer;
-import org.eclipse.debug.internal.ui.views.variables.RemoteVariableContentManager;
-import org.eclipse.debug.internal.ui.views.variables.VariablesView;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.ui.IWorkbenchPartSite;
-import org.eclipse.ui.progress.IDeferredWorkbenchAdapter;
-
-public class RemoteRegisterContentManager extends RemoteVariableContentManager {
- public RemoteRegisterContentManager(ITreeContentProvider provider, RemoteTreeViewer viewer, IWorkbenchPartSite site, VariablesView view) {
- super(provider, viewer, site, view);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.internal.ui.views.variables.RemoteVariableContentManager#getAdapter(java.lang.Object)
- */
- protected IDeferredWorkbenchAdapter getAdapter(Object element) {
- if (element instanceof IStackFrame) {
- return new DeferredRegisterViewStackFrame();
- }
- return super.getAdapter(element);
- }
-}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/registers/RemoteRegistersViewContentProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/registers/RemoteRegistersViewContentProvider.java
deleted file mode 100644
index ece2bd513..000000000
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/registers/RemoteRegistersViewContentProvider.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2004, 2005 QNX Software 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:
- * QNX Software Systems - Initial API and implementation
-***********************************************************************/
-package org.eclipse.debug.internal.ui.views.registers;
-
-import org.eclipse.debug.core.DebugException;
-import org.eclipse.debug.core.model.IRegisterGroup;
-import org.eclipse.debug.core.model.IStackFrame;
-import org.eclipse.debug.internal.ui.DebugUIPlugin;
-import org.eclipse.debug.internal.ui.views.RemoteTreeContentManager;
-import org.eclipse.debug.internal.ui.views.RemoteTreeViewer;
-import org.eclipse.debug.internal.ui.views.variables.RemoteVariablesContentProvider;
-import org.eclipse.debug.internal.ui.views.variables.VariablesView;
-import org.eclipse.ui.IWorkbenchPartSite;
-
-/**
- * Provides contents for the registers view
- */
-public class RemoteRegistersViewContentProvider extends RemoteVariablesContentProvider {
-
- public RemoteRegistersViewContentProvider(RemoteTreeViewer viewer, IWorkbenchPartSite site, VariablesView view) {
- super(viewer, site, view);
- }
-
- /**
- * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
- */
- public boolean hasChildren(Object element) {
- try {
- if (element instanceof IStackFrame) {
- return ((IStackFrame)element).hasRegisterGroups();
- }
- if (element instanceof IRegisterGroup) {
- return ((IRegisterGroup)element).hasRegisters();
- }
- } catch (DebugException de) {
- DebugUIPlugin.log(de);
- return false;
- }
- return super.hasChildren(element);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.internal.ui.views.variables.RemoteVariablesContentProvider#createContentManager(org.eclipse.debug.internal.ui.views.RemoteTreeViewer, org.eclipse.ui.IWorkbenchPartSite, org.eclipse.debug.internal.ui.views.variables.VariablesView)
- */
- protected RemoteTreeContentManager createContentManager(RemoteTreeViewer viewer, IWorkbenchPartSite site, VariablesView view) {
- return new RemoteRegisterContentManager(this, viewer, site, view);
- }
-}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/AvailableLogicalStructuresAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/AvailableLogicalStructuresAction.java
index 704b9b795..62644e211 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/AvailableLogicalStructuresAction.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/AvailableLogicalStructuresAction.java
@@ -123,7 +123,7 @@ public class AvailableLogicalStructuresAction extends Action implements IMenuCre
setValue(null);
setTypes(null);
if (getView().isShowLogicalStructure()) {
- ISelection s = getView().getVariablesViewer().getSelection();
+ ISelection s = getView().getViewer().getSelection();
if (s instanceof IStructuredSelection) {
IStructuredSelection selection = (IStructuredSelection) s;
if (selection.size() == 1) {
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/RemoteVariableContentManager.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/RemoteVariableContentManager.java
deleted file mode 100644
index 358cddd8c..000000000
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/RemoteVariableContentManager.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.debug.internal.ui.views.variables;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.eclipse.debug.core.model.IVariable;
-import org.eclipse.debug.internal.ui.elements.adapters.DeferredVariableLogicalStructure;
-import org.eclipse.debug.internal.ui.views.RemoteTreeContentManager;
-import org.eclipse.debug.internal.ui.views.RemoteTreeViewer;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.ui.IWorkbenchPartSite;
-import org.eclipse.ui.internal.progress.PendingUpdateAdapter;
-import org.eclipse.ui.progress.IDeferredWorkbenchAdapter;
-import org.eclipse.ui.progress.IElementCollector;
-
-/**
- * Remote content manager for variables. Creates an appropriate adapter for
- * logical structures.
- */
-public class RemoteVariableContentManager extends RemoteTreeContentManager {
-
- protected VariablesView fView;
- private IDeferredWorkbenchAdapter fVariableLogicalStructureAdapter = new DeferredVariableLogicalStructure();
-
- private Set fHasChildren = new HashSet();
- private Set fNoChildren = new HashSet();
-
- /**
- * Special collector to also collect accurate "has children" information.
- */
- public class VariableCollector extends RemoteTreeContentManager.Collector {
-
- public VariableCollector(Object parent) {
- super(parent);
- }
-
- /**
- * Notification the given element has children
- *
- * @param element
- */
- public void setHasChildren(Object element, boolean children) {
- synchronized (fHasChildren) {
- if (children) {
- fHasChildren.add(element);
- fNoChildren.remove(element);
- } else {
- fNoChildren.add(element);
- fHasChildren.remove(element);
- }
- }
- }
-
- }
-
- /**
- * Constructs a remote content manager for a variables view.
- */
- public RemoteVariableContentManager(ITreeContentProvider provider, RemoteTreeViewer viewer, IWorkbenchPartSite site, VariablesView view) {
- super(provider, viewer, site);
- fView = view;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.progress.DeferredTreeContentManager#getAdapter(java.lang.Object)
- */
- protected IDeferredWorkbenchAdapter getAdapter(Object element) {
- if (element instanceof IVariable && fView !=null && fView.isShowLogicalStructure()) {
- return fVariableLogicalStructureAdapter;
- }
- return super.getAdapter(element);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.progress.DeferredTreeContentManager#createElementCollector(java.lang.Object, org.eclipse.ui.internal.progress.PendingUpdateAdapter)
- */
- protected IElementCollector createElementCollector(Object parent, PendingUpdateAdapter placeholder) {
- return new VariableCollector(parent);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.progress.DeferredTreeContentManager#mayHaveChildren(java.lang.Object)
- */
- public boolean mayHaveChildren(Object element) {
- synchronized (fHasChildren) {
- if (fHasChildren.contains(element)) {
- return true;
- } else if (fNoChildren.contains(element)) {
- return false;
- }
- }
- return super.mayHaveChildren(element);
- }
-
- /**
- * Called to clear the "has children" state cache when the view input changes.
- */
- public void clearHasChildrenCache() {
- synchronized (fHasChildren) {
- fHasChildren.clear();
- fNoChildren.clear();
- }
- }
-}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/RemoteVariablesContentProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/RemoteVariablesContentProvider.java
deleted file mode 100644
index 03fa80ca5..000000000
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/RemoteVariablesContentProvider.java
+++ /dev/null
@@ -1,224 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.debug.internal.ui.views.variables;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.debug.internal.ui.views.IDebugExceptionHandler;
-import org.eclipse.debug.internal.ui.views.RemoteTreeContentManager;
-import org.eclipse.debug.internal.ui.views.RemoteTreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.ui.IWorkbenchPartSite;
-import org.eclipse.ui.model.BaseWorkbenchContentProvider;
-
-/**
- * Provide the contents for a variables viewer.
- */
-public class RemoteVariablesContentProvider extends BaseWorkbenchContentProvider {
-
- /**
- * A table that maps children to their parent element
- * such that this content provider can walk back up the
- * parent chain (since values do not know their
- * parent).
- * Map of <code>IVariable</code> (child) -> <code>IVariable</code> (parent).
- */
- private HashMap fParentCache;
-
- /**
- * Handler for exceptions as content is retrieved
- */
- private IDebugExceptionHandler fExceptionHandler = null;
-
- /**
- * Flag indicating whether contributed content providers should be used or not.
- */
- private boolean fUseObjectBrowsers;
-
- /**
- * Remote content manager to retrieve content in the background.
- */
- private RemoteVariableContentManager fManager;
-
- /**
- * Constructs a new provider
- */
- public RemoteVariablesContentProvider(RemoteTreeViewer viewer, IWorkbenchPartSite site, VariablesView view) {
- fManager = (RemoteVariableContentManager)createContentManager(viewer, site, view);
- fParentCache = new HashMap(10);
- }
-
- protected RemoteTreeContentManager createContentManager(RemoteTreeViewer viewer, IWorkbenchPartSite site, VariablesView view) {
- return new RemoteVariableContentManager(this, viewer, site, view);
- }
-
- /**
- * @see ITreeContentProvider#getChildren(Object)
- */
- public Object[] getChildren(Object parent) {
- Object[] children = fManager.getChildren(parent);
- if (children == null) {
- children = super.getChildren(parent);
- }
- if (children != null) {
- cache(parent, children);
- return children;
- }
- return new Object[0];
- }
-
- /**
- * Caches the given elememts as children of the given
- * parent.
- *
- * @param parent parent element
- * @param children children elements
- */
- protected void cache(Object parent, Object[] children) {
- for (int i = 0; i < children.length; i++) {
- Object child = children[i];
- // avoid cycles in the cache, which can happen for
- // recursive data structures
- if (!fParentCache.containsKey(child)) {
- fParentCache.put(child, parent);
- }
- }
- }
-
- /**
- * @see ITreeContentProvider#getParent(Object)
- */
- public Object getParent(Object item) {
- return fParentCache.get(item);
- }
-
- /**
- * Unregisters this content provider from the debug plugin so that
- * this object can be garbage-collected.
- */
- public void dispose() {
- fManager.clearHasChildrenCache();
- fManager.cancel();
- fParentCache= null;
- setExceptionHandler(null);
- }
-
- protected void clearCache() {
- if (fParentCache != null) {
- fParentCache.clear();
- }
- }
-
- /**
- * Remove the cached parent for the given children
- *
- * @param children for which to remove cached parents
- */
- public void removeCache(Object[] children) {
- if (fParentCache == null) {
- return;
- }
- for (int i = 0; i < children.length; i++) {
- fParentCache.remove(children[i]);
- }
- }
-
- /**
- * @see ITreeContentProvider#hasChildren(Object)
- */
- public boolean hasChildren(Object element) {
- return fManager.mayHaveChildren(element);
- }
-
- /**
- * @see IContentProvider#inputChanged(Viewer, Object, Object)
- */
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- clearCache();
- fManager.cancel();
- fManager.clearHasChildrenCache();
- }
-
- /**
- * Return all cached decendants of the given parent.
- *
- * @param parent the element whose decendants are to be calculated
- * @return list of decendants that have been cached for
- * the given parent
- */
- public List getCachedDecendants(Object parent) {
- Iterator children = fParentCache.keySet().iterator();
- List cachedChildren = new ArrayList(10);
- while (children.hasNext()) {
- Object child = children.next();
- if (isCachedDecendant(child, parent)) {
- cachedChildren.add(child);
- }
- }
- return cachedChildren;
- }
-
- /**
- * Returns whether the given child is a cached descendant
- * of the given parent.
- *
- * @return whether the given child is a cached descendant
- * of the given parent
- */
- protected boolean isCachedDecendant(Object child, Object parent) {
- Object p = getParent(child);
- while (p != null) {
- if (p.equals(parent)) {
- return true;
- }
- p = getParent(p);
- }
- return false;
- }
-
- /**
- * Sets an exception handler for this content provider.
- *
- * @param handler debug exception handler or <code>null</code>
- */
- protected void setExceptionHandler(IDebugExceptionHandler handler) {
- fExceptionHandler = handler;
- }
-
- /**
- * Returns the exception handler for this content provider.
- *
- * @return debug exception handler or <code>null</code>
- */
- protected IDebugExceptionHandler getExceptionHandler() {
- return fExceptionHandler;
- }
-
- /**
- * Show logical structure of values
- */
- public void setShowLogicalStructure(boolean flag) {
- fUseObjectBrowsers = flag;
- }
-
- public boolean isShowLogicalStructure() {
- return fUseObjectBrowsers;
- }
-
- public RemoteVariableContentManager getContentManager() {
- return fManager;
- }
-
-}
-
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/VariablesView.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/VariablesView.java
index 7d77097e6..7f7f8c022 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/VariablesView.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/VariablesView.java
@@ -25,6 +25,7 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.model.IDebugElement;
import org.eclipse.debug.core.model.IDebugTarget;
import org.eclipse.debug.core.model.IExpression;
import org.eclipse.debug.core.model.IStackFrame;
@@ -41,21 +42,20 @@ import org.eclipse.debug.internal.ui.VariablesViewModelPresentation;
import org.eclipse.debug.internal.ui.actions.AssignValueAction;
import org.eclipse.debug.internal.ui.actions.ChangeVariableValueAction;
import org.eclipse.debug.internal.ui.actions.CollapseAllAction;
-import org.eclipse.debug.internal.ui.actions.FindVariableAction;
import org.eclipse.debug.internal.ui.actions.ShowTypesAction;
import org.eclipse.debug.internal.ui.actions.ToggleDetailPaneAction;
+import org.eclipse.debug.internal.ui.contexts.DebugContextManager;
+import org.eclipse.debug.internal.ui.contexts.actions.FindVariableAction;
import org.eclipse.debug.internal.ui.preferences.IDebugPreferenceConstants;
+import org.eclipse.debug.internal.ui.viewers.AsynchronousTreeViewer;
+import org.eclipse.debug.internal.ui.viewers.PresentationContext;
import org.eclipse.debug.internal.ui.views.AbstractDebugEventHandlerView;
import org.eclipse.debug.internal.ui.views.AbstractViewerState;
-import org.eclipse.debug.internal.ui.views.DebugViewDecoratingLabelProvider;
-import org.eclipse.debug.internal.ui.views.DebugViewInterimLabelProvider;
-import org.eclipse.debug.internal.ui.views.DebugViewLabelDecorator;
import org.eclipse.debug.internal.ui.views.IDebugExceptionHandler;
-import org.eclipse.debug.internal.ui.views.IRemoteTreeViewerUpdateListener;
-import org.eclipse.debug.internal.ui.views.RemoteTreeViewer;
import org.eclipse.debug.ui.IDebugModelPresentation;
import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.debug.ui.IValueDetailListener;
+import org.eclipse.debug.ui.contexts.IDebugContextListener;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IMenuListener;
@@ -82,16 +82,12 @@ import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.ListenerList;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IBaseLabelProvider;
-import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
@@ -102,22 +98,19 @@ import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.KeyListener;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IMemento;
-import org.eclipse.ui.INullSelectionListener;
-import org.eclipse.ui.ISelectionListener;
-import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IViewSite;
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.console.actions.TextViewerAction;
+import org.eclipse.ui.progress.WorkbenchJob;
import org.eclipse.ui.texteditor.FindReplaceAction;
import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
import org.eclipse.ui.texteditor.IUpdate;
@@ -126,37 +119,11 @@ import org.eclipse.ui.texteditor.IWorkbenchActionDefinitionIds;
/**
* This view shows variables and their values for a particular stack frame
*/
-public class VariablesView extends AbstractDebugEventHandlerView implements ISelectionListener,
+public class VariablesView extends AbstractDebugEventHandlerView implements IDebugContextListener,
IPropertyChangeListener,
IValueDetailListener,
- IDebugExceptionHandler,
- INullSelectionListener {
+ IDebugExceptionHandler {
- /**
- * A decorating label provider which adds coloring to variables to
- * reflect their changed state
- */
- protected class VariablesViewDecoratingLabelProvider extends DebugViewDecoratingLabelProvider {
-
- public VariablesViewDecoratingLabelProvider(StructuredViewer viewer, ILabelProvider provider, DebugViewLabelDecorator decorator) {
- super(viewer, provider, decorator);
- }
-
- public Color getForeground(Object element) {
- if (element instanceof IVariable) {
- IVariable variable = (IVariable) element;
- try {
- if (variable.hasValueChanged()) {
- return DebugUIPlugin.getPreferenceColor(IDebugPreferenceConstants.CHANGED_VARIABLE_COLOR);
- }
- } catch (DebugException e) {
- DebugUIPlugin.log(e);
- }
- }
- return super.getForeground(element);
- }
-
- }
/**
* Internal interface for a cursor listener. I.e. aggregation
@@ -347,7 +314,6 @@ public class VariablesView extends AbstractDebugEventHandlerView implements ISel
/** Whether logical structuers are showing */
private boolean fShowLogical;
- private IRemoteTreeViewerUpdateListener fUpdateListener;
/**
* Remove myself as a selection listener
@@ -357,13 +323,17 @@ public class VariablesView extends AbstractDebugEventHandlerView implements ISel
*/
public void dispose() {
getViewSite().getActionBars().getStatusLineManager().remove(fStatusLineItem);
- getSite().getPage().removeSelectionListener(IDebugUIConstants.ID_DEBUG_VIEW, this);
+ DebugContextManager.getDefault().removeDebugContextListener(this, getSite().getWorkbenchWindow());
+ //getSite().getPage().removeSelectionListener(IDebugUIConstants.ID_DEBUG_VIEW, this);
DebugUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this);
JFaceResources.getFontRegistry().removeListener(this);
Viewer viewer = getViewer();
if (viewer != null) {
getDetailDocument().removeDocumentListener(getDetailDocumentListener());
- ((VariablesViewer)viewer).removeUpdateListener(fUpdateListener);
+ if (viewer instanceof AsynchronousTreeViewer) {
+ AsynchronousTreeViewer asyncTreeViewer = (AsynchronousTreeViewer) viewer;
+ asyncTreeViewer.dispose();
+ }
}
IAction action= getAction("FindVariable"); //$NON-NLS-1$
if (action != null && action instanceof FindVariableAction) {
@@ -372,49 +342,42 @@ public class VariablesView extends AbstractDebugEventHandlerView implements ISel
super.dispose();
}
- protected void setViewerInput(IStructuredSelection ssel) {
- IStackFrame frame= null;
- if (ssel.size() == 1) {
- Object input= ssel.getFirstElement();
- if (input instanceof IStackFrame) {
- frame= (IStackFrame)input;
- }
- }
+ protected void setViewerInput(Object context) {
- getDetailViewer().setEditable(frame != null);
+ getDetailViewer().setEditable(context != null);
Object current= getViewer().getInput();
- if (current == null && frame == null) {
+ if (current == null && context == null) {
return;
}
- if (current != null && current.equals(frame)) {
+ if (current != null && current.equals(context)) {
return;
}
-
+
if (current != null) {
// save state
fLastState = getViewerState();
fSelectionStates.put(current, fLastState);
}
- if (frame != null) {
- setDebugModel(frame.getModelIdentifier());
+ if (context instanceof IDebugElement) {
+ setDebugModel(((IDebugElement)context).getModelIdentifier());
}
showViewer();
- getViewer().setInput(frame);
+ getViewer().setInput(context);
+ restoreState();
}
protected void restoreState() {
- VariablesViewer viewer = getVariablesViewer();
- IStackFrame frame = (IStackFrame) viewer.getInput();
- if (frame != null) {
- AbstractViewerState state = (AbstractViewerState)fSelectionStates.get(frame);
- if (state == null && fLastState != null) {
+ VariablesViewer viewer = (VariablesViewer) getViewer();
+ Object context= viewer.getInput();
+ if (context != null) {
+ AbstractViewerState state = (AbstractViewerState)fSelectionStates.get(context);
+ if (state == null) {
// attempt to restore selection/expansion based on last frame
- state = fLastState.copy();
- fLastState = state;
+ state = fLastState;
}
if (state != null) {
state.restoreState(viewer);
@@ -422,16 +385,12 @@ public class VariablesView extends AbstractDebugEventHandlerView implements ISel
}
}
- /**
- * Returns the variables viewer for this view
- */
- protected VariablesViewer getVariablesViewer() {
- return (VariablesViewer)getViewer();
- }
/**
* Clears expanded state for stack frames which are
* a child of the given thread or debug target.
+ *
+ * TODO: this was called by event handler which no longer exists
*/
protected void clearExpandedVariables(Object parent) {
List list = null;
@@ -504,7 +463,7 @@ public class VariablesView extends AbstractDebugEventHandlerView implements ISel
try {
svc = mp.newDetailsViewerConfiguration();
} catch (CoreException e) {
- DebugUIPlugin.errorDialog(getSite().getShell(), VariablesViewMessages.VariablesView_Error_1, VariablesViewMessages.VariablesView_Unable_to_configure_variable_details_area__2, e); //
+ DebugUIPlugin.errorDialog(getSite().getShell(), VariablesViewMessages.VariablesView_Error_1, VariablesViewMessages.VariablesView_Unable_to_configure_variable_details_area__2, e);
}
}
ISourceViewer detailViewer = getDetailViewer();
@@ -531,7 +490,7 @@ public class VariablesView extends AbstractDebugEventHandlerView implements ISel
getEventHandler().refresh();
} else if (propertyName.equals(IInternalDebugUIConstants.DETAIL_PANE_FONT)) {
getDetailViewer().getTextWidget().setFont(JFaceResources.getFont(IInternalDebugUIConstants.DETAIL_PANE_FONT));
- } else if (propertyName.equals(IDebugUIConstants.PREF_MAX_DETAIL_LENGTH)) {
+ } else if (propertyName.equals(IInternalDebugUIConstants.PREF_MAX_DETAIL_LENGTH)) {
populateDetailPane();
}
}
@@ -540,7 +499,9 @@ public class VariablesView extends AbstractDebugEventHandlerView implements ISel
* @see org.eclipse.debug.ui.AbstractDebugView#createViewer(Composite)
*/
public Viewer createViewer(Composite parent) {
- TreeViewer variablesViewer = createTreeViewer(parent);
+ VariablesViewer variablesViewer = (VariablesViewer) createTreeViewer(parent);
+ variablesViewer.setContext(new PresentationContext(this));
+
createDetailsViewer();
getSashForm().setMaximizedControl(variablesViewer.getControl());
@@ -552,12 +513,6 @@ public class VariablesView extends AbstractDebugEventHandlerView implements ISel
}
setDetailPaneOrientation(orientation);
- fUpdateListener = new IRemoteTreeViewerUpdateListener() {
- public void treeUpdated() {
- restoreState();
- }
- };
- ((VariablesViewer)variablesViewer).addUpdateListener(fUpdateListener);
return variablesViewer;
}
@@ -608,19 +563,16 @@ public class VariablesView extends AbstractDebugEventHandlerView implements ISel
/**
* Create and return the main tree viewer that displays variable.
*/
- protected TreeViewer createTreeViewer(Composite parent) {
+ protected Viewer createTreeViewer(Composite parent) {
fModelPresentation = new VariablesViewModelPresentation();
DebugUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this);
JFaceResources.getFontRegistry().addListener(this);
// create the sash form that will contain the tree viewer & text viewer
setSashForm(new SashForm(parent, SWT.NONE));
-
+
// add tree viewer
- final TreeViewer variablesViewer = new VariablesViewer(getSashForm(), SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL, this);
- RemoteVariablesContentProvider provider = createContentProvider(variablesViewer);
- variablesViewer.setContentProvider(provider);
- variablesViewer.setLabelProvider(createLabelProvider(variablesViewer));
- variablesViewer.setUseHashlookup(true);
+ final VariablesViewer variablesViewer = new VariablesViewer(getSashForm(), SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL, this);
+ variablesViewer.setUseHashlookup(false);
variablesViewer.getControl().addFocusListener(new FocusAdapter() {
/* (non-Javadoc)
* @see org.eclipse.swt.events.FocusListener#focusGained(FocusEvent)
@@ -630,32 +582,26 @@ public class VariablesView extends AbstractDebugEventHandlerView implements ISel
setAction(SELECT_ALL_ACTION, getAction(VARIABLES_SELECT_ALL_ACTION));
setAction(COPY_ACTION, getAction(VARIABLES_COPY_ACTION));
getViewSite().getActionBars().updateActionBars();
- setFocusViewer(getVariablesViewer());
+ setFocusViewer(getViewer());
}
});
variablesViewer.addPostSelectionChangedListener(getTreeSelectionChangedListener());
getVariablesViewSelectionProvider().setUnderlyingSelectionProvider(variablesViewer);
getSite().setSelectionProvider(getVariablesViewSelectionProvider());
- // listen to selection in debug view
- getSite().getPage().addSelectionListener(IDebugUIConstants.ID_DEBUG_VIEW, this);
+ // listen to debug context
+ DebugContextManager.getDefault().addDebugContextListener(this, getSite().getWorkbenchWindow());
+ // getSite().getPage().addSelectionListener(IDebugUIConstants.ID_DEBUG_VIEW, this);
VariablesViewEventHandler handler = createEventHandler();
- handler.setContentManager(provider.getContentManager());
- setEventHandler(handler);
+ // TODO: replaced with update policy
+ if (handler != null) {
+ setEventHandler(handler);
+ }
return variablesViewer;
}
/**
- * Creates and returns a label provider for this view.
- *
- * @return a label provider for this view.
- */
- protected IBaseLabelProvider createLabelProvider(StructuredViewer viewer) {
- return new VariablesViewDecoratingLabelProvider(viewer, new DebugViewInterimLabelProvider(getModelPresentation()), new DebugViewLabelDecorator(getModelPresentation()));
- }
-
- /**
* Create the widgetry for the details viewer.
*/
protected void createDetailsViewer() {
@@ -681,18 +627,7 @@ public class VariablesView extends AbstractDebugEventHandlerView implements ISel
setAction(COPY_ACTION, getAction(DETAIL_COPY_ACTION));
getViewSite().getActionBars().updateActionBars();
setFocusViewer((Viewer)getDetailViewer());
- IAction assist = getAction("ContentAssist"); //$NON-NLS-1$
- getSite().getKeyBindingService().registerAction(assist);
}
-
- /* (non-Javadoc)
- * @see org.eclipse.swt.events.FocusAdapter#focusLost(org.eclipse.swt.events.FocusEvent)
- */
- public void focusLost(FocusEvent e) {
- IAction assist = getAction("ContentAssist"); //$NON-NLS-1$
- getSite().getKeyBindingService().unregisterAction(assist);
- }
-
});
// add a context menu to the detail area
@@ -702,14 +637,6 @@ public class VariablesView extends AbstractDebugEventHandlerView implements ISel
detailsViewer.getTextWidget().addKeyListener(getCursorListener());
}
- /**
- * Creates this view's content provider.
- *
- * @return a content provider
- */
- protected RemoteVariablesContentProvider createContentProvider(Viewer viewer) {
- return new RemoteVariablesContentProvider((RemoteTreeViewer) viewer, getSite(), this);
- }
/**
* Creates this view's event handler.
@@ -717,7 +644,8 @@ public class VariablesView extends AbstractDebugEventHandlerView implements ISel
* @return an event handler
*/
protected VariablesViewEventHandler createEventHandler() {
- return new VariablesViewEventHandler(this);
+ // TODO: replaced by update policy
+ return null;
}
/* (non-Javadoc)
@@ -769,7 +697,7 @@ public class VariablesView extends AbstractDebugEventHandlerView implements ISel
* Make sure the currently selected item in the tree is visible.
*/
protected void revealTreeSelection() {
- VariablesViewer viewer = getVariablesViewer();
+ StructuredViewer viewer = (StructuredViewer) getViewer();
if (viewer != null) {
ISelection selection = viewer.getSelection();
if (selection instanceof IStructuredSelection) {
@@ -840,7 +768,7 @@ public class VariablesView extends AbstractDebugEventHandlerView implements ISel
action = new ToggleLogicalStructureAction(this);
setAction("ToggleContentProviders", action); //$NON-NLS-1$
- action = new CollapseAllAction(getVariablesViewer());
+ action = new CollapseAllAction((AsynchronousTreeViewer)getViewer());
setAction("CollapseAll", action); //$NON-NLS-1$
action = new ChangeVariableValueAction(this);
@@ -854,6 +782,7 @@ public class VariablesView extends AbstractDebugEventHandlerView implements ISel
textAction.setHoverImageDescriptor(DebugPluginImages.getImageDescriptor(IDebugUIConstants.IMG_LCL_CONTENT_ASSIST));
textAction.setDisabledImageDescriptor(DebugPluginImages.getImageDescriptor(IDebugUIConstants.IMG_DLCL_CONTENT_ASSIST));
setAction("ContentAssist", textAction); //$NON-NLS-1$
+ getSite().getKeyBindingService().registerAction(textAction);
textAction= new TextViewerAction(getDetailViewer(), ITextOperationTarget.SELECT_ALL);
textAction.configureAction(VariablesViewMessages.VariablesView_Select__All_5, "", ""); //$NON-NLS-1$ //$NON-NLS-2$
@@ -861,7 +790,7 @@ public class VariablesView extends AbstractDebugEventHandlerView implements ISel
setAction(DETAIL_SELECT_ALL_ACTION, textAction);
textAction= new TextViewerAction(getDetailViewer(), ITextOperationTarget.COPY);
- textAction.configureAction(VariablesViewMessages.VariablesView__Copy_8, "", ""); //$NON-NLS-1$ //$NON-NLS-2$
+ textAction.configureAction(VariablesViewMessages.VariablesView__Copy_8, "", ""); //$NON-NLS-1$ //$NON-NLS-2$
textAction.setActionDefinitionId(IWorkbenchActionDefinitionIds.COPY);
setAction(DETAIL_COPY_ACTION, textAction);
@@ -993,7 +922,7 @@ public class VariablesView extends AbstractDebugEventHandlerView implements ISel
if (fTreeSelectionChangedListener == null) {
fTreeSelectionChangedListener = new ISelectionChangedListener() {
public void selectionChanged(final SelectionChangedEvent event) {
- if (event.getSelectionProvider().equals(getVariablesViewer())) {
+ if (event.getSelectionProvider().equals(getViewer())) {
clearStatusLine();
getVariablesViewSelectionProvider().fireSelectionChanged(event);
// if the detail pane is not visible, don't waste time retrieving details
@@ -1053,12 +982,15 @@ public class VariablesView extends AbstractDebugEventHandlerView implements ISel
* detail pane.
*/
protected void populateDetailPaneFromSelection(final IStructuredSelection selection) {
- Runnable runnable = new Runnable() {
- public void run() {
+ WorkbenchJob wJob = new WorkbenchJob("Populate Details Pane") { //$NON-NLS-1$
+ public IStatus runInUIThread(IProgressMonitor monitor) {
getDetailDocument().set(""); //$NON-NLS-1$
- }
+ return Status.OK_STATUS;
+ }
};
- DebugUIPlugin.getStandardDisplay().asyncExec(runnable);
+ wJob.setSystem(true);
+ wJob.schedule();
+
try {
if (!selection.isEmpty()) {
IValue val = null;
@@ -1082,8 +1014,9 @@ public class VariablesView extends AbstractDebugEventHandlerView implements ISel
}
final IValue finalVal = val;
- runnable = new Runnable() {
- public void run() {
+
+ wJob = new WorkbenchJob("Populate Details Pane"){ //$NON-NLS-1$
+ public IStatus runInUIThread(IProgressMonitor monitor) {
getDetailDocument().set(""); //$NON-NLS-1$
setDebugModel(finalVal.getModelIdentifier());
fValueSelection = selection;
@@ -1091,16 +1024,22 @@ public class VariablesView extends AbstractDebugEventHandlerView implements ISel
fSelectionIterator.next();
fLastValueDetail= finalVal;
getModelPresentation().computeDetail(finalVal, VariablesView.this);
- }
- };
- DebugUIPlugin.getStandardDisplay().asyncExec(runnable);
+ return Status.OK_STATUS;
+ }
+ };
+ wJob.setSystem(true);
+ wJob.schedule();
}
} catch (DebugException de) {
- DebugUIPlugin.getStandardDisplay().asyncExec(new Runnable() {
- public void run() {
- getDetailDocument().set(VariablesViewMessages.VariablesView__error_occurred_retrieving_value__18);
- }
- });
+ wJob = new WorkbenchJob("Populate Details Pane") { //$NON-NLS-1$
+ public IStatus runInUIThread(IProgressMonitor monitor) {
+ getDetailDocument().set(VariablesViewMessages.VariablesView__error_occurred_retrieving_value__18);
+ return Status.OK_STATUS;
+ }
+
+ };
+ wJob.setSystem(true);
+ wJob.schedule();
}
}
@@ -1121,7 +1060,7 @@ public class VariablesView extends AbstractDebugEventHandlerView implements ISel
insert = "\n" + result; //$NON-NLS-1$
}
try {
- int max = DebugUIPlugin.getDefault().getPreferenceStore().getInt(IDebugUIConstants.PREF_MAX_DETAIL_LENGTH);
+ int max = DebugUIPlugin.getDefault().getPreferenceStore().getInt(IInternalDebugUIConstants.PREF_MAX_DETAIL_LENGTH);
if (max > 0 && insert.length() > max) {
insert = insert.substring(0, max) + "..."; //$NON-NLS-1$
}
@@ -1145,7 +1084,7 @@ public class VariablesView extends AbstractDebugEventHandlerView implements ISel
getModelPresentation().computeDetail(val, VariablesView.this);
} catch (DebugException e) {
DebugUIPlugin.log(e);
- getDetailDocument().set(VariablesViewMessages.VariablesView__error_occurred_retrieving_value__18); //
+ getDetailDocument().set(VariablesViewMessages.VariablesView__error_occurred_retrieving_value__18);
}
} else {
fValueSelection = null;
@@ -1333,23 +1272,19 @@ public class VariablesView extends AbstractDebugEventHandlerView implements ISel
protected VariablesViewSelectionProvider getVariablesViewSelectionProvider() {
return fSelectionProvider;
}
- /**
- * The <code>VariablesView</code> listens for selection changes in the <code>LaunchView</code>
- *
- * @see ISelectionListener#selectionChanged(IWorkbenchPart, ISelection)
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.contexts.IDebugContextListener#contextActivated(java.lang.Object, org.eclipse.ui.IWorkbenchPart)
*/
- public void selectionChanged(IWorkbenchPart part, ISelection selection) {
+ public void contextActivated(ISelection selection, IWorkbenchPart part) {
if (!isAvailable() || !isVisible()) {
return;
}
- if (selection == null) {
- setViewerInput(new StructuredSelection());
- } else if (selection instanceof IStructuredSelection) {
- setViewerInput((IStructuredSelection) selection);
- } else {
- getDetailViewer().setEditable(false);
+ if (selection instanceof IStructuredSelection) {
+ setViewerInput(((IStructuredSelection)selection).getFirstElement());
}
+
updateAction("ContentAssist"); //$NON-NLS-1$
updateAction("FindVariable"); //$NON-NLS-1$
}
@@ -1364,19 +1299,6 @@ public class VariablesView extends AbstractDebugEventHandlerView implements ISel
IAction action = getAction(DOUBLE_CLICK_ACTION);
if (action != null && action.isEnabled()) {
action.run();
- } else {
- ISelection selection= event.getSelection();
- if (!(selection instanceof IStructuredSelection)) {
- return;
- }
- IStructuredSelection ss= (IStructuredSelection)selection;
- Object o= ss.getFirstElement();
-
- if (o != null) {
- TreeViewer tViewer= (TreeViewer)getViewer();
- boolean expanded= tViewer.getExpandedState(o);
- tViewer.setExpandedState(o, !expanded);
- }
}
}
/**
@@ -1470,7 +1392,7 @@ public class VariablesView extends AbstractDebugEventHandlerView implements ISel
* @see org.eclipse.debug.ui.AbstractDebugView#becomesHidden()
*/
protected void becomesHidden() {
- setViewerInput(new StructuredSelection());
+ setViewerInput(null);
super.becomesHidden();
}
@@ -1479,11 +1401,8 @@ public class VariablesView extends AbstractDebugEventHandlerView implements ISel
*/
protected void becomesVisible() {
super.becomesVisible();
- IViewPart part = getSite().getPage().findView(IDebugUIConstants.ID_DEBUG_VIEW);
- if (part != null) {
- ISelection selection = getSite().getPage().getSelection(IDebugUIConstants.ID_DEBUG_VIEW);
- selectionChanged(part, selection);
- }
+ ISelection selection = DebugContextManager.getDefault().getActiveContext(getSite().getWorkbenchWindow());
+ contextActivated(selection, null);
}
/**
@@ -1495,6 +1414,10 @@ public class VariablesView extends AbstractDebugEventHandlerView implements ISel
return new ViewerState(getVariablesViewer());
}
+ private VariablesViewer getVariablesViewer() {
+ return (VariablesViewer) getViewer();
+ }
+
/**
* Returns this view's "cursor" listener to be installed on the view's
* associated details viewer. This listener is listening to key and mouse button events.
@@ -1563,4 +1486,5 @@ public class VariablesView extends AbstractDebugEventHandlerView implements ISel
return ""; //$NON-NLS-1$
}
}
+
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/VariablesViewEventHandler.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/VariablesViewEventHandler.java
index 03547626c..716e47fb3 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/VariablesViewEventHandler.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/VariablesViewEventHandler.java
@@ -21,7 +21,6 @@ import org.eclipse.debug.core.model.ISuspendResume;
import org.eclipse.debug.core.model.IThread;
import org.eclipse.debug.core.model.IVariable;
import org.eclipse.debug.internal.ui.views.AbstractDebugEventHandler;
-import org.eclipse.debug.internal.ui.views.RemoteTreeContentManager;
import org.eclipse.debug.ui.AbstractDebugView;
/**
@@ -29,8 +28,6 @@ import org.eclipse.debug.ui.AbstractDebugView;
*/
public class VariablesViewEventHandler extends AbstractDebugEventHandler {
- private RemoteTreeContentManager fContentManager = null;
-
/**
* Constructs a new event handler on the given view
*
@@ -82,15 +79,6 @@ public class VariablesViewEventHandler extends AbstractDebugEventHandler {
// clear variable expansion state
getVariablesView().clearExpandedVariables(event.getSource());
}
- if (!event.isEvaluation()) {
- Object input = getVariablesView().getVariablesViewer().getInput();
- if (input instanceof IStackFrame) {
- IStackFrame frame = (IStackFrame)input;
- if (event.getSource().equals(frame.getThread())) {
- fContentManager.cancel();
- }
- }
- }
}
/**
@@ -188,10 +176,6 @@ public class VariablesViewEventHandler extends AbstractDebugEventHandler {
return (DebugEvent[]) all.toArray(new DebugEvent[all.size()]);
}
- public void setContentManager(RemoteTreeContentManager manager) {
- fContentManager = manager;
- }
-
protected boolean isFiltered(DebugEvent event) {
if (event.getKind() == DebugEvent.CHANGE) {
Object source = event.getSource();
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/VariablesViewer.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/VariablesViewer.java
index 2ba972ccf..54a4bc63e 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/VariablesViewer.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/VariablesViewer.java
@@ -1,186 +1,44 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
package org.eclipse.debug.internal.ui.views.variables;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
-import org.eclipse.debug.core.DebugException;
-import org.eclipse.debug.core.model.IRegisterGroup;
<