Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Barnes2005-11-21 11:10:22 -0500
committerKevin Barnes2005-11-21 11:10:22 -0500
commit1fa778c0a5c53b2869df5d597d31a4ddecc84531 (patch)
treef08a04d045beff96b33b8e5cbd62a2b2157333aa /org.eclipse.debug.ui
parent6f61758dcf785a86427fe62929a0833c5178436e (diff)
downloadeclipse.platform.debug-1fa778c0a5c53b2869df5d597d31a4ddecc84531.tar.gz
eclipse.platform.debug-1fa778c0a5c53b2869df5d597d31a4ddecc84531.tar.xz
eclipse.platform.debug-1fa778c0a5c53b2869df5d597d31a4ddecc84531.zip
merging async_viewer_branch_2
Diffstat (limited to 'org.eclipse.debug.ui')
-rw-r--r--org.eclipse.debug.ui/.settings/org.eclipse.jdt.core.prefs138
-rw-r--r--org.eclipse.debug.ui/META-INF/MANIFEST.MF5
-rw-r--r--org.eclipse.debug.ui/icons/full/dlcl16/export_brkpts.gifbin217 -> 217 bytes
-rw-r--r--org.eclipse.debug.ui/icons/full/dlcl16/import_brkpts.gifbin217 -> 217 bytes
-rw-r--r--org.eclipse.debug.ui/icons/full/elcl16/export_brkpts.gifbin217 -> 217 bytes
-rw-r--r--org.eclipse.debug.ui/icons/full/elcl16/import_brkpts.gifbin217 -> 217 bytes
-rw-r--r--org.eclipse.debug.ui/icons/full/wizban/export_brkpts_wizban.gifbin3306 -> 3330 bytes
-rw-r--r--org.eclipse.debug.ui/icons/full/wizban/import_brkpts_wizban.gifbin3330 -> 3306 bytes
-rw-r--r--org.eclipse.debug.ui/plugin.xml146
-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/AbstractRemoveActionDelegate.java42
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/AbstractRemoveAllActionDelegate.java63
-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/actions/RemoveAllExpressionsAction.java33
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RemoveExpressionAction.java58
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/SelectAllAction.java76
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/AbstractDebugContextActionDelegate.java387
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/DisconnectActionDelegate.java (renamed from org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/DisconnectActionDelegate.java)32
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/DropToFrameActionDelegate.java (renamed from org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/DropToFrameActionDelegate.java)25
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/FindVariableAction.java (renamed from org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/FindVariableAction.java)70
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/FindVariableDialog.java (renamed from org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/FindVariableDialog.java)7
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/ResumeActionDelegate.java (renamed from org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ResumeActionDelegate.java)24
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/StepActionDelegate.java (renamed from org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/StepActionDelegate.java)28
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/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/actions/context/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/actions/context/StepReturnActionDelegate.java (renamed from org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/StepReturnActionDelegate.java)4
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/SuspendActionDelegate.java (renamed from org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/SuspendActionDelegate.java)25
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/TerminateActionDelegate.java (renamed from org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/TerminateActionDelegate.java)36
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/TerminateAllAction.java (renamed from org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/TerminateAllAction.java)26
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/TerminateAndRelaunchAction.java (renamed from org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/TerminateAndRelaunchAction.java)16
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/TerminateAndRemoveActionDelegate.java (renamed from org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/TerminateAndRemoveActionDelegate.java)12
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/selection/AbstractRemoveActionDelegate.java (renamed from org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/SelectAllExpressionsAction.java)23
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/selection/AbstractRemoveAllActionDelegate.java107
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/selection/AbstractSelectionActionDelegate.java194
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/selection/RemoveAllBreakpointsAction.java (renamed from org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RemoveAllBreakpointsAction.java)91
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/selection/RemoveAllExpressionsAction.java73
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/selection/RemoveAllTerminatedAction.java (renamed from org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RemoveAllTerminatedAction.java)94
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/selection/RemoveBreakpointAction.java (renamed from org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RemoveBreakpointAction.java)14
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/selection/RemoveExpressionAction.java62
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/selection/SelectAllAction.java58
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/selection/SelectAllBreakpointsAction.java (renamed from org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/SelectAllBreakpointsAction.java)55
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/selection/SelectAllExpressionsAction.java54
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/selection/SelectAllVariablesAction.java (renamed from org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/SelectAllVariablesAction.java)28
-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.java277
-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/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.java67
-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/importexport/breakpoints/EmbeddedBreakpointsViewer.java62
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/PerspectiveManager.java76
-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.java73
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AbstractAddRemoveRequestMonitor.java51
-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/AddRequestMonitor.java40
-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.java148
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousTreeViewer.java957
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousViewer.java940
-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/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/RemoveRequestMonitor.java39
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/TreePath.java182
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/TreeSelection.java159
-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.java30
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DefaultExpressionModelProxy.java59
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DefaultModelProxyFactory.java61
-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.java114
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DefaultVariableViewModelProxy.java61
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DefaultWatchExpressionModelProxy.java80
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/EventHandlerModelProxy.java253
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/ExpressionEventHandler.java58
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/ExpressionManagerModelProxy.java71
-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.java59
-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.java44
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/ThreadEventHandler.java192
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/VariablesViewEventHandler.java53
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/AbstractDebugEventHandler.java352
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/AbstractDebugEventHandlerView.java78
-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/DebugUIViewsMessages.java2
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/DebugUIViewsMessages.properties1
-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/breakpoints/BreakpointsViewer.java39
-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.java138
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionViewEventHandler.java180
-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.java142
-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.java456
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/LaunchViewEventHandler.java665
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/LaunchViewUpdatePolicy.java47
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/LaunchViewer.java249
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/FormatTableRenderingDialog.java2
-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.java28
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/registers/RegistersViewEventHandler.java45
-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.java442
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/VariablesViewEventHandler.java219
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/VariablesViewer.java196
-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/DebugPopup.java44
-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.java55
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/ui/contexts/IDebugContextListener.java41
-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
175 files changed, 9863 insertions, 6229 deletions
diff --git a/org.eclipse.debug.ui/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.debug.ui/.settings/org.eclipse.jdt.core.prefs
index fb028583d..11f20e210 100644
--- a/org.eclipse.debug.ui/.settings/org.eclipse.jdt.core.prefs
+++ b/org.eclipse.debug.ui/.settings/org.eclipse.jdt.core.prefs
@@ -1,69 +1,69 @@
-#Mon Nov 01 21:09:49 GMT-08:00 2004
-org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
-org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning
-org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
-org.eclipse.jdt.core.compiler.problem.unsafeTypeOperation=warning
-org.eclipse.jdt.core.compiler.problem.forbiddenReference=ignore
-org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
-org.eclipse.jdt.core.compiler.problem.unusedImport=warning
-org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
-org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
-org.eclipse.jdt.core.builder.invalidClasspath=abort
-org.eclipse.jdt.core.builder.resourceCopyExclusionFilter=*.launch
-org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
-org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.problem.deprecation=warning
-org.eclipse.jdt.core.compiler.source=1.3
-org.eclipse.jdt.core.compiler.problem.finalParameterBound=ignore
-org.eclipse.jdt.core.compiler.problem.unusedParameter=warning
-org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
-org.eclipse.jdt.core.compiler.compliance=1.4
-org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
-org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
-org.eclipse.jdt.core.builder.cleanOutputFolder=clean
-org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
-org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
-org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
-org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=enabled
-org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
-org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
-org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
-org.eclipse.jdt.core.classpath.exclusionPatterns=enabled
-org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
-org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public
-org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
-org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning
-org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=private
-org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
-org.eclipse.jdt.core.incompatibleJDKLevel=ignore
-eclipse.preferences.version=1
-org.eclipse.jdt.core.circularClasspath=error
-org.eclipse.jdt.core.compiler.maxProblemPerUnit=100
-org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=enabled
-org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
-org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=private
-org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
-org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled
-org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.doc.comment.support=disabled
-org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
-org.eclipse.jdt.core.incompleteClasspath=error
-org.eclipse.jdt.core.compiler.problem.invalidJavadoc=ignore
-org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=enabled
-org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
-org.eclipse.jdt.core.builder.duplicateResourceTask=warning
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
+#Wed Nov 16 16:42:14 CST 2005
+eclipse.preferences.version=1
+org.eclipse.jdt.core.builder.cleanOutputFolder=clean
+org.eclipse.jdt.core.builder.duplicateResourceTask=warning
+org.eclipse.jdt.core.builder.invalidClasspath=abort
+org.eclipse.jdt.core.builder.resourceCopyExclusionFilter=*.launch
+org.eclipse.jdt.core.circularClasspath=error
+org.eclipse.jdt.core.classpath.exclusionPatterns=enabled
+org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.4
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.doc.comment.support=disabled
+org.eclipse.jdt.core.compiler.maxProblemPerUnit=100
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
+org.eclipse.jdt.core.compiler.problem.deprecation=warning
+org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
+org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
+org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
+org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
+org.eclipse.jdt.core.compiler.problem.finalParameterBound=ignore
+org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=ignore
+org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
+org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning
+org.eclipse.jdt.core.compiler.problem.invalidJavadoc=ignore
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=enabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=private
+org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning
+org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
+org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore
+org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=enabled
+org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public
+org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=enabled
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=private
+org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
+org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
+org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
+org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning
+org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
+org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
+org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
+org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
+org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
+org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
+org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
+org.eclipse.jdt.core.compiler.problem.unsafeTypeOperation=warning
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.unusedImport=warning
+org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedParameter=warning
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
+org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
+org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
+org.eclipse.jdt.core.compiler.source=1.3
+org.eclipse.jdt.core.incompatibleJDKLevel=ignore
+org.eclipse.jdt.core.incompleteClasspath=error
diff --git a/org.eclipse.debug.ui/META-INF/MANIFEST.MF b/org.eclipse.debug.ui/META-INF/MANIFEST.MF
index 8ae417f8c..939b766fa 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.actions.context;x-internal:=true,
+ org.eclipse.debug.internal.ui.contexts;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/icons/full/dlcl16/export_brkpts.gif b/org.eclipse.debug.ui/icons/full/dlcl16/export_brkpts.gif
index e416bf0f0..57e9ffd2d 100644
--- a/org.eclipse.debug.ui/icons/full/dlcl16/export_brkpts.gif
+++ b/org.eclipse.debug.ui/icons/full/dlcl16/export_brkpts.gif
Binary files differ
diff --git a/org.eclipse.debug.ui/icons/full/dlcl16/import_brkpts.gif b/org.eclipse.debug.ui/icons/full/dlcl16/import_brkpts.gif
index 57e9ffd2d..e416bf0f0 100644
--- a/org.eclipse.debug.ui/icons/full/dlcl16/import_brkpts.gif
+++ b/org.eclipse.debug.ui/icons/full/dlcl16/import_brkpts.gif
Binary files differ
diff --git a/org.eclipse.debug.ui/icons/full/elcl16/export_brkpts.gif b/org.eclipse.debug.ui/icons/full/elcl16/export_brkpts.gif
index ffcd7b85c..c1083f887 100644
--- a/org.eclipse.debug.ui/icons/full/elcl16/export_brkpts.gif
+++ b/org.eclipse.debug.ui/icons/full/elcl16/export_brkpts.gif
Binary files differ
diff --git a/org.eclipse.debug.ui/icons/full/elcl16/import_brkpts.gif b/org.eclipse.debug.ui/icons/full/elcl16/import_brkpts.gif
index c1083f887..ffcd7b85c 100644
--- a/org.eclipse.debug.ui/icons/full/elcl16/import_brkpts.gif
+++ b/org.eclipse.debug.ui/icons/full/elcl16/import_brkpts.gif
Binary files differ
diff --git a/org.eclipse.debug.ui/icons/full/wizban/export_brkpts_wizban.gif b/org.eclipse.debug.ui/icons/full/wizban/export_brkpts_wizban.gif
index 081e3c079..90cb1e98a 100644
--- a/org.eclipse.debug.ui/icons/full/wizban/export_brkpts_wizban.gif
+++ b/org.eclipse.debug.ui/icons/full/wizban/export_brkpts_wizban.gif
Binary files differ
diff --git a/org.eclipse.debug.ui/icons/full/wizban/import_brkpts_wizban.gif b/org.eclipse.debug.ui/icons/full/wizban/import_brkpts_wizban.gif
index 90cb1e98a..081e3c079 100644
--- a/org.eclipse.debug.ui/icons/full/wizban/import_brkpts_wizban.gif
+++ b/org.eclipse.debug.ui/icons/full/wizban/import_brkpts_wizban.gif
Binary files differ
diff --git a/org.eclipse.debug.ui/plugin.xml b/org.eclipse.debug.ui/plugin.xml
index 1cda9bdaa..500a8a5e1 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.actions.context.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.actions.context.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.actions.context.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.actions.context.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.actions.context.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.actions.context.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.actions.selection.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.actions.selection.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,118 +538,88 @@
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.actions.context.DisconnectActionDelegate"
disabledIcon="$nl$/icons/full/dlcl16/disconnect_co.gif"
icon="$nl$/icons/full/elcl16/disconnect_co.gif"
helpContextId="disconnect_action_context"
label="%DisconnectAction.label"
tooltip="%DisconnectAction.tooltip">
- <selection
- class="org.eclipse.debug.core.model.IDisconnect">
- </selection>
</action>
<action
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.actions.context.TerminateActionDelegate"
disabledIcon="$nl$/icons/full/dlcl16/terminate_co.gif"
icon="$nl$/icons/full/elcl16/terminate_co.gif"
helpContextId="terminate_action_context"
label="%TerminateAction.label"
tooltip="%TerminateAction.tooltip">
- <selection
- class="org.eclipse.debug.core.model.ITerminate">
- </selection>
</action>
<action
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.actions.context.SuspendActionDelegate"
disabledIcon="$nl$/icons/full/dlcl16/suspend_co.gif"
- enablesFor="1"
icon="$nl$/icons/full/elcl16/suspend_co.gif"
label="%SuspendAction.label"
helpContextId="suspend_action_context"
tooltip="%SuspendAction.tooltip">
- <selection
- class="org.eclipse.debug.core.model.ISuspendResume">
- </selection>
</action>
<action
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.actions.context.ResumeActionDelegate"
disabledIcon="$nl$/icons/full/dlcl16/resume_co.gif"
- enablesFor="1"
icon="$nl$/icons/full/elcl16/resume_co.gif"
label="%ResumeAction.label"
helpContextId="resume_action_context"
tooltip="%ResumeAction.tooltip">
- <selection
- class="org.eclipse.debug.core.model.ISuspendResume">
- </selection>
</action>
<!-- Step Group -->
<action
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.actions.context.StepReturnActionDelegate"
disabledIcon="$nl$/icons/full/dlcl16/stepreturn_co.gif"
- enablesFor="1"
icon="$nl$/icons/full/elcl16/stepreturn_co.gif"
label="%StepReturnAction.label"
helpContextId="step_return_action_context"
tooltip="%StepReturnAction.tooltip">
- <selection
- class="org.eclipse.debug.core.model.IStep">
- </selection>
</action>
<action
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.actions.context.StepOverActionDelegate"
disabledIcon="$nl$/icons/full/dlcl16/stepover_co.gif"
- enablesFor="1"
icon="$nl$/icons/full/elcl16/stepover_co.gif"
label="%StepOverAction.label"
helpContextId="step_over_action_context"
tooltip="%StepOverAction.tooltip">
- <selection
- class="org.eclipse.debug.core.model.IStep">
- </selection>
</action>
<action
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.actions.context.StepIntoActionDelegate"
disabledIcon="$nl$/icons/full/dlcl16/stepinto_co.gif"
- enablesFor="1"
icon="$nl$/icons/full/elcl16/stepinto_co.gif"
label="%StepIntoAction.label"
helpContextId="step_into_action_context"
tooltip="%StepIntoAction.tooltip">
- <selection
- class="org.eclipse.debug.core.model.IStep">
- </selection>
</action>
<action
id="org.eclipse.debug.ui.debugview.toolbar.dropToFrame"
toolbarPath="emptyStepGroup"
- class="org.eclipse.debug.internal.ui.actions.DropToFrameActionDelegate"
- enablesFor="1"
+ class="org.eclipse.debug.internal.ui.actions.context.DropToFrameActionDelegate"
icon="$nl$/icons/full/elcl16/drop_to_frame.gif"
label="%DropToFrameAction.label"
helpContextId="drop_to_frame_action_context"
tooltip="%DropToFrameAction.tooltip">
- <selection
- class="org.eclipse.debug.core.model.IDropToFrame">
- </selection>
</action>
<!-- Render Group -->
<action
@@ -674,7 +644,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.actions.selection.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 +655,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.actions.selection.RemoveBreakpointAction"
disabledIcon="$nl$/icons/full/dlcl16/rem_co.gif"
icon="$nl$/icons/full/elcl16/rem_co.gif"
helpContextId="remove_breakpoint_action_context"
@@ -784,7 +754,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.actions.selection.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 +765,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.actions.selection.RemoveExpressionAction"
disabledIcon="$nl$/icons/full/dlcl16/rem_co.gif"
icon="$nl$/icons/full/elcl16/rem_co.gif"
helpContextId="remove_expression_action_context"
@@ -1087,7 +1057,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.actions.context.TerminateAllAction"
menubarPath="launchGroup"
id="org.eclipse.debug.ui.debugview.popupMenu.terminateAll">
</action>
@@ -1103,7 +1073,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.actions.context.TerminateAndRemoveActionDelegate"
menubarPath="launchGroup"
id="org.eclipse.debug.ui.debugview.popupMenu.terminateAndRemove">
<selection
@@ -1115,7 +1085,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.actions.selection.RemoveAllTerminatedAction"
menubarPath="launchGroup"
id="org.eclipse.debug.ui.debugview.popupMenu.removeAllTerminated">
</action>
@@ -1123,16 +1093,13 @@
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.actions.context.DisconnectActionDelegate"
menubarPath="threadGroup"
id="org.eclipse.debug.ui.debugview.popupMenu.disconnect">
- <selection
- class="org.eclipse.debug.core.model.IDisconnect">
- </selection>
</action>
<action
label="%TerminateAndRelaunchAction.label"
- class="org.eclipse.debug.internal.ui.actions.TerminateAndRelaunchAction"
+ class="org.eclipse.debug.internal.ui.actions.context.TerminateAndRelaunchAction"
definitionId="org.eclipse.debug.ui.commands.TerminateAndRelaunch"
helpContextId="terminate_and_relaunch_action_context"
icon="$nl$/icons/full/etool16/term_restart.gif"
@@ -1144,90 +1111,63 @@
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.actions.context.TerminateActionDelegate"
menubarPath="threadGroup"
id="org.eclipse.debug.ui.debugview.popupMenu.terminate">
- <selection
- class="org.eclipse.debug.core.model.ITerminate">
- </selection>
</action>
<action
label="%SuspendAction.label"
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.actions.context.SuspendActionDelegate"
menubarPath="threadGroup"
- enablesFor="1"
id="org.eclipse.debug.ui.debugview.popupMenu.suspend">
- <selection
- class="org.eclipse.debug.core.model.ISuspendResume">
- </selection>
</action>
<action
label="%ResumeAction.label"
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.actions.context.ResumeActionDelegate"
menubarPath="threadGroup"
- enablesFor="1"
id="org.eclipse.debug.ui.debugview.popupMenu.resume">
- <selection
- class="org.eclipse.debug.core.model.ISuspendResume">
- </selection>
</action>
<!-- Step Group -->
<action
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.actions.context.DropToFrameActionDelegate"
menubarPath="stepReturnGroup"
- enablesFor="1"
id="org.eclipse.debug.ui.debugview.popupMenu.dropToFrame">
- <selection
- class="org.eclipse.debug.core.model.IDropToFrame">
- </selection>
</action>
<action
label="%StepReturnAction.label"
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.actions.context.StepReturnActionDelegate"
menubarPath="stepReturnGroup"
- enablesFor="1"
id="org.eclipse.debug.ui.debugview.popupMenu.stepReturn">
- <selection
- class="org.eclipse.debug.core.model.IStep">
- </selection>
</action>
<action
label="%StepOverAction.label"
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.actions.context.StepOverActionDelegate"
menubarPath="stepOverGroup"
- enablesFor="1"
id="org.eclipse.debug.ui.debugview.popupMenu.stepOver">
- <selection
- class="org.eclipse.debug.core.model.IStep">
- </selection>
</action>
<action
label="%StepIntoAction.label"
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.actions.context.StepIntoActionDelegate"
menubarPath="stepIntoGroup"
- enablesFor="1"
id="org.eclipse.debug.ui.debugview.popupMenu.stepInto">
- <selection
- class="org.eclipse.debug.core.model.IStep">
- </selection>
</action>
<!-- Render Group -->
<action
@@ -1271,7 +1211,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.actions.selection.SelectAllBreakpointsAction"
menubarPath="breakpointGroup"
id="org.eclipse.debug.ui.actions.SelectAllBreakpointsAction">
</action>
@@ -1279,7 +1219,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.actions.selection.RemoveAllBreakpointsAction"
menubarPath="breakpointGroup"
id="org.eclipse.debug.ui.actions.RemoveAllBreakpoints">
</action>
@@ -1287,7 +1227,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.actions.selection.RemoveBreakpointAction"
menubarPath="breakpointGroup"
enablesFor="1+"
id="org.eclipse.debug.ui.breakpointsView.toolbar.remove">
@@ -1346,7 +1286,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.actions.selection.SelectAllVariablesAction"
menubarPath="variableGroup"
id="org.eclipse.debug.ui.actions.SelectAllVariablesAction">
</action>
@@ -1360,7 +1300,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.actions.selection.RemoveAllExpressionsAction"
menubarPath="expressionGroup"
id="org.eclipse.debug.ui.debugview.popupMenu.removeAllExpressionsAction">
</action>
@@ -1368,7 +1308,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.actions.selection.RemoveExpressionAction"
menubarPath="expressionGroup"
id="org.eclipse.debug.ui.debugview.popupMenu.removeExpressionAction">
<selection
@@ -1394,7 +1334,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.actions.selection.SelectAllExpressionsAction"
menubarPath="expressionGroup"
id="org.eclipse.debug.ui.actions.SelectAllExpressionsAction">
</action>
@@ -1416,7 +1356,7 @@
</selection>
</action>
<action
- class="org.eclipse.debug.internal.ui.actions.SelectAllVariablesAction"
+ class="org.eclipse.debug.internal.ui.actions.selection.SelectAllVariablesAction"
label="%SelectAll.label"
menubarPath="variableGroup"
definitionId="org.eclipse.ui.edit.selectAll"
@@ -1752,7 +1692,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 +2382,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.actions.selection.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/AbstractRemoveActionDelegate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/AbstractRemoveActionDelegate.java
deleted file mode 100644
index 473bdd44d..000000000
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/AbstractRemoveActionDelegate.java
+++ /dev/null
@@ -1,42 +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.actions;
-
-
-import org.eclipse.debug.ui.IDebugView;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.ui.IViewPart;
-
-public abstract class AbstractRemoveActionDelegate extends AbstractListenerActionDelegate {
-
- /**
- * @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= (IDebugView)getView().getAdapter(IDebugView.class);
- if (debugView != null) {
- debugView.setAction(IDebugView.REMOVE_ACTION, action);
- }
- return super.initialize(action, selection);
- }
- return false;
- }
-}
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/actions/AbstractRemoveAllActionDelegate.java
deleted file mode 100644
index 47d57a1c8..000000000
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/AbstractRemoveAllActionDelegate.java
+++ /dev/null
@@ -1,63 +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.actions;
-
-
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.ui.IViewPart;
-
-public abstract class AbstractRemoveAllActionDelegate extends AbstractListenerActionDelegate {
-
- /**
- * @see AbstractDebugActionDelegate#doAction(Object)
- */
- protected void doAction(Object element) {
- doAction();
- update();
- }
-
- /**
- * @see IActionDelegate#run(IAction)
- */
- public void run(IAction action){
- doAction(null);
- }
-
- protected abstract void doAction();
-
- protected void update(IAction action, ISelection s) {
- update();
- }
-
- protected abstract void update();
-
- /**
- * Remove all actions do care nothing about the current selection
- * @see IActionDelegate#selectionChanged(IAction, ISelection)
- */
- public void selectionChanged(IAction action, ISelection s) {
- if (!isInitialized()) {
- action.setEnabled(false);
- setAction(action);
- setInitialized(true);
- }
- update();
- }
-
- /**
- * @see IViewActionDelegate#init(IViewPart)
- */
- public void init(IViewPart view) {
- setView(view);
- setWindow(view.getViewSite().getWorkbenchWindow());
- }
-}
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/actions/RemoveAllExpressionsAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RemoveAllExpressionsAction.java
deleted file mode 100644
index 127c8829d..000000000
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RemoveAllExpressionsAction.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.actions;
-
-
-import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.IExpressionManager;
-import org.eclipse.debug.core.model.IExpression;
-
-/**
- * Removes all expressions from the expressions view.
- */
-public class RemoveAllExpressionsAction extends AbstractRemoveAllActionDelegate {
-
- protected void doAction() {
- IExpressionManager manager = DebugPlugin.getDefault().getExpressionManager();
- IExpression[] expressions= manager.getExpressions();
- manager.removeExpressions(expressions);
- }
-
- protected void update() {
- getAction().setEnabled(
- DebugPlugin.getDefault().getExpressionManager().hasExpressions());
- }
-}
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/actions/RemoveExpressionAction.java
deleted file mode 100644
index a699857c1..000000000
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RemoveExpressionAction.java
+++ /dev/null
@@ -1,58 +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.actions;
-
-
-import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.IExpressionManager;
-import org.eclipse.debug.core.model.IExpression;
-import org.eclipse.debug.ui.IDebugView;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-
-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);
- }
- }
-
- /**
- * Returns the expression associated with the given
- * element.
- *
- * @param element an expression of child of an expression in
- * the expression view.
- * @return associated expression
- */
- protected IExpression getExpression(Object obj) {
- 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);
- }
- return (IExpression)obj;
- }
- }
- 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/actions/SelectAllAction.java
deleted file mode 100644
index 0b0155de8..000000000
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/SelectAllAction.java
+++ /dev/null
@@ -1,76 +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.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 {
-
- /**
- * @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 =
- (IDebugView) getView().getAdapter(IDebugView.class);
- if (debugView != null) {
- debugView.setAction(getActionId(), action);
- }
- return super.initialize(action, selection);
- }
- return false;
- }
-
- protected abstract String getActionId();
-
- /**
- * @see IActionDelegate#run(IAction)
- */
- public void run(IAction action){
- doAction(null);
- }
-
- /**
- * @see AbstractDebugActionDelegate#doAction(Object)
- */
- protected void doAction(Object element) {
- if (!(getView() instanceof IDebugView)) {
- return;
- }
- Viewer viewer = ((IDebugView) getView()).getViewer();
- if (!(viewer instanceof TreeViewer)) {
- return;
- }
- ((TreeViewer) viewer).getTree().selectAll();
- //ensure that the selection change callback is fired
- viewer.setSelection(viewer.getSelection());
- }
-
- protected abstract void update();
-
- protected void update(IAction action, ISelection selection) {
- update();
- }
-}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/AbstractDebugContextActionDelegate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/AbstractDebugContextActionDelegate.java
new file mode 100644
index 000000000..9281ed046
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/AbstractDebugContextActionDelegate.java
@@ -0,0 +1,387 @@
+/*******************************************************************************
+ * 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.actions.context;
+
+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.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;
+
+ /**
+ * The window associated with this action delegate May be <code>null</code>
+ */
+ protected IWorkbenchWindow fWindow;
+
+ /**
+ * Used to schedule jobs, or <code>null</code> if none
+ */
+ private IWorkbenchSiteProgressService fProgressService = null;
+
+ private UpdateEnablementJob fUpdateJob = null;
+
+ class UpdateEnablementJob extends Job {
+
+ 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) {
+ ISelection context = null;
+ synchronized (this) {
+ context = targetSelection;
+ targetSelection = null;
+ }
+ update(getAction(), context);
+ return Status.OK_STATUS;
+ }
+
+ protected synchronized void setContext(ISelection context) {
+ targetSelection = context;
+ }
+ }
+
+ private DebugRequestJob fRequestJob = null;
+
+ class DebugRequestJob extends Job {
+
+ private Object[] fElements = null;
+
+ /**
+ * Constructs a new job to perform a debug request (for example, step)
+ * in the background.
+ */
+ public DebugRequestJob() {
+ super(DebugUIPlugin.removeAccelerators(getAction().getText()));
+ 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;
+ }
+
+ protected synchronized void setElements(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);
+ }
+ }
+ 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 synchronized void run(IAction action) {
+ IStructuredSelection selection = getContext();
+ if (selection != null && action.isEnabled()) {
+ // disable the action so it cannot be run again until an event or
+ // selection change updates the enablement
+ action.setEnabled(false);
+ if (fRequestJob == null) {
+ fRequestJob = new DebugRequestJob();
+ }
+ fRequestJob.setElements(selection.toArray());
+ schedule(fRequestJob);
+ }
+ }
+
+ public void selectionChanged(IAction action, ISelection s) {
+ // do nothing
+ }
+
+ protected synchronized 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) {
+ setView(view);
+ setWindow(view.getSite().getWorkbenchWindow());
+ fProgressService = (IWorkbenchSiteProgressService) view.getSite().getAdapter(IWorkbenchSiteProgressService.class);
+ DebugContextManager.getDefault().addDebugContextListener(this, getWindow(), IDebugUIConstants.ID_DEBUG_VIEW);
+ }
+
+ /**
+ * 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;
+ }
+
+ /**
+ * 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;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.contexts.IDebugContextListener#contextActivated(org.eclipse.jface.viewers.ISelection, org.eclipse.ui.IWorkbenchPart)
+ */
+ public synchronized void contextActivated(ISelection context, IWorkbenchPart part) {
+ setContext(null);
+ if (fUpdateJob == null) {
+ fUpdateJob = new UpdateEnablementJob();
+ }
+ fUpdateJob.setContext(context);
+ schedule(fUpdateJob);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.contexts.IDebugContextListener#contextChanged(org.eclipse.jface.viewers.ISelection, org.eclipse.ui.IWorkbenchPart)
+ */
+ public void contextChanged(ISelection context, IWorkbenchPart part) {
+ contextActivated(context, part);
+ }
+
+ protected void setAction(IAction action) {
+ fAction = action;
+ }
+
+ protected IAction getAction() {
+ return fAction;
+ }
+
+ protected void setView(IViewPart viewPart) {
+ fViewPart = viewPart;
+ }
+
+ 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) {
+ setAction(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/DisconnectActionDelegate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/DisconnectActionDelegate.java
index bc2ee1866..791ce892e 100644
--- 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/actions/context/DisconnectActionDelegate.java
@@ -8,15 +8,14 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.debug.internal.ui.actions;
+package org.eclipse.debug.internal.ui.actions.context;
-
-import org.eclipse.debug.core.DebugEvent;
+import org.eclipse.core.runtime.IAdaptable;
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 +27,6 @@ public class DisconnectActionDelegate extends AbstractListenerActionDelegate {
}
/**
- * @see AbstractDebugActionDelegate#isRunInBackground()
- */
- protected boolean isRunInBackground() {
- return true;
- }
-
- /**
* @see AbstractDebugActionDelegate#isEnabledFor(Object)
*/
protected boolean isEnabledFor(Object element) {
@@ -55,12 +47,16 @@ public class DisconnectActionDelegate extends AbstractListenerActionDelegate {
return ActionMessages.DisconnectActionDelegate_Disconnect_failed_1;
}
- /**
- * @see ListenerActionDelegate#doHandleDebugEvent(DebugEvent)
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.actions.context.AbstractDebugContextActionDelegate#getTarget(java.lang.Object)
*/
- protected void doHandleDebugEvent(DebugEvent event) {
- if (event.getKind() == DebugEvent.TERMINATE && event.getSource() instanceof IDebugTarget) {
- update(getAction(), getSelection());
+ 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/actions/context/DropToFrameActionDelegate.java
index 5813bbfcd..390bac468 100644
--- 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/actions/context/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.actions.context;
+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.actions.context.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/actions/context/FindVariableAction.java
index f951facf6..0b4645d03 100644
--- 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/actions/context/FindVariableAction.java
@@ -8,12 +8,12 @@
* Contributors:
* IBM Corporation - initial implementation
*******************************************************************************/
-package org.eclipse.debug.internal.ui.actions;
+package org.eclipse.debug.internal.ui.actions.context;
-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/actions/context/FindVariableDialog.java
index d819ca1ec..92d7a39d7 100644
--- 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/actions/context/FindVariableDialog.java
@@ -8,7 +8,7 @@
* Contributors:
* IBM Corporation - initial implementation
*******************************************************************************/
-package org.eclipse.debug.internal.ui.actions;
+package org.eclipse.debug.internal.ui.actions.context;
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/ResumeActionDelegate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/ResumeActionDelegate.java
index 3901fe488..fc386486e 100644
--- 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/actions/context/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.actions.context;
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.actions.context.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/StepActionDelegate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/StepActionDelegate.java
index 1a5fcdf3f..e916b2d43 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/actions/context/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.actions.context;
+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)
@@ -25,13 +25,6 @@ public abstract class StepActionDelegate extends AbstractListenerActionDelegate
stepAction((IStep)object);
}
}
-
- /**
- * @see AbstractDebugActionDelegate#isRunInBackground()
- */
- protected boolean isRunInBackground() {
- return true;
- }
/**
* @see AbstractDebugActionDelegate#isEnabledFor(Object)
@@ -55,4 +48,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.actions.context.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/actions/context/StepIntoActionDelegate.java
index 5c981a48e..8ec624585 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/actions/context/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.actions.context;
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/actions/context/StepOverActionDelegate.java
index d785453dc..52d4fb970 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/actions/context/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.actions.context;
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/actions/context/StepReturnActionDelegate.java
index edbd7bfa7..03215ed2b 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/actions/context/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.actions.context;
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/actions/context/SuspendActionDelegate.java
index e813a3e99..1b28eafa4 100644
--- 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/actions/context/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.actions.context;
+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.actions.context.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/actions/context/TerminateActionDelegate.java
index 06d9894ef..312570dba 100644
--- 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/actions/context/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.actions.context;
+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)
@@ -61,13 +63,6 @@ public class TerminateActionDelegate extends AbstractListenerActionDelegate {
}
/**
- * @see AbstractDebugActionDelegate#isRunInBackground()
- */
- protected boolean isRunInBackground() {
- return true;
- }
-
- /**
* @see AbstractDebugActionDelegate#isEnabledFor(Object)
*/
protected boolean isEnabledFor(Object element) {
@@ -87,15 +82,6 @@ public class TerminateActionDelegate extends AbstractListenerActionDelegate {
protected String getErrorDialogMessage() {
return ActionMessages.TerminateActionDelegate_Terminate_failed__1;
}
-
- /**
- * @see ListenerActionDelegate#doHandleDebugEvent(DebugEvent)
- */
- protected void doHandleDebugEvent(DebugEvent event) {
- if (event.getKind() == DebugEvent.TERMINATE || event.getKind() == DebugEvent.CREATE) {
- update(getAction(), getSelection());
- }
- }
/* (non-Javadoc)
* @see org.eclipse.debug.internal.ui.actions.AbstractDebugActionDelegate#update(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
@@ -106,6 +92,20 @@ public class TerminateActionDelegate extends AbstractListenerActionDelegate {
super.update(action, s);
}
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.actions.context.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/actions/context/TerminateAllAction.java
index f24fceb94..055ce2601 100644
--- 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/actions/context/TerminateAllAction.java
@@ -8,10 +8,9 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.debug.internal.ui.actions;
+package org.eclipse.debug.internal.ui.actions.context;
-import org.eclipse.debug.core.DebugEvent;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
@@ -24,7 +23,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)
@@ -38,13 +37,6 @@ public class TerminateAllAction extends AbstractListenerActionDelegate {
}
}
- /* (non-Javadoc)
- * @see org.eclipse.debug.internal.ui.actions.AbstractDebugActionDelegate#isRunInBackground()
- */
- protected boolean isRunInBackground() {
- return true;
- }
-
/**
* Update the action enablement based on the launches present in
* the launch manager. selection is unused and can be <code>null</code>.
@@ -71,20 +63,6 @@ public class TerminateAllAction extends AbstractListenerActionDelegate {
}
/* (non-Javadoc)
- * @see org.eclipse.debug.internal.ui.actions.AbstractListenerActionDelegate#doHandleDebugEvent(org.eclipse.debug.core.DebugEvent)
- */
- protected void doHandleDebugEvent(DebugEvent event) {
- switch (event.getKind()) {
- case DebugEvent.TERMINATE :
- update(getAction(), null);
- break;
- case DebugEvent.CREATE :
- update(getAction(), null);
- break;
- }
- }
-
- /* (non-Javadoc)
* @see org.eclipse.debug.internal.ui.actions.AbstractDebugActionDelegate#getSelection()
*/
protected IStructuredSelection getSelection() {
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/actions/context/TerminateAndRelaunchAction.java
index 0762f3b00..4cfce978f 100644
--- 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/actions/context/TerminateAndRelaunchAction.java
@@ -8,19 +8,21 @@
* Contributors:
* IBM Corporation - initial implementation
*******************************************************************************/
-package org.eclipse.debug.internal.ui.actions;
+package org.eclipse.debug.internal.ui.actions.context;
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;
+import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationManager;
/**
* 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);
@@ -37,19 +39,13 @@ public class TerminateAndRelaunchAction extends AbstractListenerActionDelegate {
}
});
}
-
- /**
- * @see AbstractDebugActionDelegate#isRunInBackground()
- */
- protected boolean isRunInBackground() {
- return true;
- }
/**
* @see AbstractDebugActionDelegate#isEnabledFor(Object)
*/
protected boolean isEnabledFor(Object element) {
+ ILaunch launch = RelaunchActionDelegate.getLaunch(element);
return element instanceof ITerminate && ((ITerminate)element).canTerminate() &&
- RelaunchActionDelegate.getLaunch(element) != null;
+ launch != null && LaunchConfigurationManager.isVisible(launch.getLaunchConfiguration());
}
}
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/actions/context/TerminateAndRemoveActionDelegate.java
index 65dcc6ecd..a96070dce 100644
--- 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/actions/context/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.actions.context;
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)
@@ -25,13 +26,6 @@ public class TerminateAndRemoveActionDelegate extends AbstractDebugActionDelegat
}
/**
- * @see AbstractDebugActionDelegate#isRunInBackground()
- */
- protected boolean isRunInBackground() {
- return true;
- }
-
- /**
* @see AbstractDebugActionDelegate#isEnabledFor(Object)
*/
protected boolean isEnabledFor(Object element) {
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/actions/selection/AbstractRemoveActionDelegate.java
index 58e0bcd69..49f70a1d7 100644
--- 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/actions/selection/AbstractRemoveActionDelegate.java
@@ -8,20 +8,23 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.debug.internal.ui.actions;
+package org.eclipse.debug.internal.ui.actions.selection;
-import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.ui.IDebugView;
+import org.eclipse.ui.IViewPart;
-public class SelectAllExpressionsAction extends SelectAllAction {
-
- protected void update() {
- getAction().setEnabled(
- DebugPlugin.getDefault().getExpressionManager().hasExpressions());
- }
+public abstract class AbstractRemoveActionDelegate extends AbstractSelectionActionDelegate {
- protected String getActionId() {
- return IDebugView.SELECT_ALL_ACTION + ".Variables"; //$NON-NLS-1$
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.actions.selection.AbstractSelectionActionDelegate#init(org.eclipse.ui.IViewPart)
+ */
+ public void init(IViewPart view) {
+ super.init(view);
+ IDebugView debugView= (IDebugView)getView().getAdapter(IDebugView.class);
+ if (debugView != null) {
+ debugView.setAction(IDebugView.REMOVE_ACTION, getAction());
+ }
}
+
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/selection/AbstractRemoveAllActionDelegate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/selection/AbstractRemoveAllActionDelegate.java
new file mode 100644
index 000000000..eb953ac9d
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/selection/AbstractRemoveAllActionDelegate.java
@@ -0,0 +1,107 @@
+/*******************************************************************************
+ * 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.actions.selection;
+
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+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.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowActionDelegate;
+
+public abstract class AbstractRemoveAllActionDelegate implements IViewActionDelegate, IActionDelegate2, IWorkbenchWindowActionDelegate {
+
+ private IAction fAction;
+
+ /**
+ * Needed for reflective creation
+ */
+ public AbstractRemoveAllActionDelegate() {}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IActionDelegate2#dispose()
+ */
+ public void dispose() {
+ fAction = null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IActionDelegate2#init(org.eclipse.jface.action.IAction)
+ */
+ public void init(IAction action) {
+ fAction = action;
+ }
+
+ /**
+ * Returns this delegate's action.
+ *
+ * @return
+ */
+ protected IAction getAction() {
+ return fAction;
+ }
+
+ /* (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.IViewActionDelegate#init(org.eclipse.ui.IViewPart)
+ */
+ public void init(IViewPart view) {
+ initialize();
+ update();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
+ */
+ public void init(IWorkbenchWindow window) {
+ initialize();
+ update();
+ }
+
+ /**
+ * Initializes any listeners, etc.
+ */
+ protected abstract void initialize();
+
+ /**
+ * Update enablement.
+ */
+ protected void update() {
+ IAction action = getAction();
+ if (action != null) {
+ action.setEnabled(isEnabled());
+ }
+ }
+
+ /**
+ * Returns whether this action is enabled
+ *
+ * @return
+ */
+ protected abstract boolean isEnabled();
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
+ */
+ public void selectionChanged(IAction action, ISelection s) {
+ // do nothing
+ }
+
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/selection/AbstractSelectionActionDelegate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/selection/AbstractSelectionActionDelegate.java
new file mode 100644
index 000000000..497e1e179
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/selection/AbstractSelectionActionDelegate.java
@@ -0,0 +1,194 @@
+/*******************************************************************************
+ * 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.actions.selection;
+
+import java.util.Iterator;
+
+import org.eclipse.core.runtime.jobs.Job;
+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.progress.IWorkbenchSiteProgressService;
+
+public abstract class AbstractSelectionActionDelegate implements IViewActionDelegate, IActionDelegate2 {
+
+ /**
+ * 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;
+
+ /**
+ * Used to schedule jobs, or <code>null</code> if none
+ */
+ private IWorkbenchSiteProgressService fProgressService = null;
+
+ /**
+ * 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 AbstractSelectionActionDelegate() {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose()
+ */
+ public void dispose() {
+ fSelection = null;
+ }
+
+ public void selectionChanged(IAction action, ISelection s) {
+ if (s instanceof IStructuredSelection) {
+ IStructuredSelection ss = (IStructuredSelection) s;
+ action.setEnabled(getEnableStateForSelection(ss));
+ setSelection(ss);
+ } else {
+ action.setEnabled(false);
+ setSelection(StructuredSelection.EMPTY);
+ }
+ }
+
+ /**
+ * 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) {
+ setView(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;
+ }
+
+ /**
+ * Returns the most recent selection
+ *
+ * @return structured selection
+ */
+ protected IStructuredSelection getSelection() {
+ return fSelection;
+ }
+
+ /**
+ * Sets the most recent selection
+ *
+ * @parm selection structured selection
+ */
+ private void setSelection(IStructuredSelection context) {
+ fSelection = context;
+ }
+
+ protected void setAction(IAction action) {
+ fAction = action;
+ }
+
+ protected IAction getAction() {
+ return fAction;
+ }
+
+ protected void setView(IViewPart viewPart) {
+ fViewPart = viewPart;
+ }
+
+ /**
+ * Return whether the action should be enabled or not based on the given
+ * selection.
+ */
+ protected boolean getEnableStateForSelection(IStructuredSelection selection) {
+ if (selection.size() == 0) {
+ return false;
+ }
+ Iterator itr = selection.iterator();
+ while (itr.hasNext()) {
+ Object element = itr.next();
+ if (!isEnabledFor(element)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ 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) {
+ setAction(action);
+ }
+
+ /**
+ * Schedules the given job with this action's progress service
+ *
+ * @param job
+ */
+ protected 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/RemoveAllBreakpointsAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/selection/RemoveAllBreakpointsAction.java
index 29213a6c6..d7a08b858 100644
--- 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/actions/selection/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.actions.selection;
import org.eclipse.core.resources.IMarkerDelta;
@@ -22,8 +22,9 @@ 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.action.IAction;
import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbenchWindow;
/**
@@ -33,49 +34,17 @@ import org.eclipse.ui.IWorkbenchWindow;
public class RemoveAllBreakpointsAction extends AbstractRemoveAllActionDelegate implements IBreakpointsListener {
/* (non-Javadoc)
- * @see org.eclipse.debug.internal.ui.actions.AbstractRemoveAllActionDelegate#doAction()
+ * @see org.eclipse.debug.internal.ui.actions.selection.AbstractRemoveAllActionDelegate#isEnabled()
*/
- protected void doAction() {
- final IBreakpointManager breakpointManager= DebugPlugin.getDefault().getBreakpointManager();
- final IBreakpoint[] breakpoints= breakpointManager.getBreakpoints();
- if (breakpoints.length < 1) {
- return;
- }
- IWorkbenchWindow window= DebugUIPlugin.getActiveWorkbenchWindow();
- if (window == null) {
- return;
- }
- boolean proceed = MessageDialog.openQuestion(window.getShell(), ActionMessages.RemoveAllBreakpointsAction_0, ActionMessages.RemoveAllBreakpointsAction_1); //
- if (proceed) {
- new Job(ActionMessages.RemoveAllBreakpointsAction_2) {
- protected IStatus run(IProgressMonitor monitor) {
- try {
- breakpointManager.removeBreakpoints(breakpoints, true);
- } catch (CoreException e) {
- DebugUIPlugin.log(e);
- return Status.CANCEL_STATUS;
- }
- return Status.OK_STATUS;
- }
- }.schedule();
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.internal.ui.actions.AbstractRemoveAllActionDelegate#update()
- */
- protected void update() {
- getAction().setEnabled(
- DebugPlugin.getDefault().getBreakpointManager().hasBreakpoints());
+ protected boolean isEnabled() {
+ return DebugPlugin.getDefault().getBreakpointManager().hasBreakpoints();
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.IBreakpointsListener#breakpointsAdded(org.eclipse.debug.core.model.IBreakpoint[])
*/
public void breakpointsAdded(IBreakpoint[] breakpoints) {
- if (getAction() != null && !getAction().isEnabled()){
- update();
- }
+ update();
}
/* (non-Javadoc)
@@ -94,10 +63,9 @@ public class RemoveAllBreakpointsAction extends AbstractRemoveAllActionDelegate
}
/* (non-Javadoc)
- * @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart)
+ * @see org.eclipse.debug.internal.ui.actions.selection.AbstractRemoveAllActionDelegate#initialize()
*/
- public void init(IViewPart view) {
- super.init(view);
+ protected void initialize() {
DebugPlugin.getDefault().getBreakpointManager().addBreakpointListener(this);
}
@@ -105,16 +73,37 @@ public class RemoveAllBreakpointsAction extends AbstractRemoveAllActionDelegate
* @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose()
*/
public void dispose() {
- DebugPlugin.getDefault().getBreakpointManager().removeBreakpointListener(this);
+ DebugPlugin.getDefault().getBreakpointManager().removeBreakpointListener(this);
super.dispose();
}
-
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
- */
- public void init(IWorkbenchWindow window) {
- super.init(window);
- DebugPlugin.getDefault().getBreakpointManager().addBreakpointListener(this);
- }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
+ */
+ public void run(IAction action) {
+ final IBreakpointManager breakpointManager= DebugPlugin.getDefault().getBreakpointManager();
+ final IBreakpoint[] breakpoints= breakpointManager.getBreakpoints();
+ if (breakpoints.length < 1) {
+ return;
+ }
+ IWorkbenchWindow window= DebugUIPlugin.getActiveWorkbenchWindow();
+ if (window == null) {
+ return;
+ }
+ boolean proceed = MessageDialog.openQuestion(window.getShell(), ActionMessages.RemoveAllBreakpointsAction_0, ActionMessages.RemoveAllBreakpointsAction_1);
+ if (proceed) {
+ new Job(ActionMessages.RemoveAllBreakpointsAction_2) {
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ breakpointManager.removeBreakpoints(breakpoints, true);
+ } catch (CoreException e) {
+ DebugUIPlugin.log(e);
+ return Status.CANCEL_STATUS;
+ }
+ return Status.OK_STATUS;
+ }
+ }.schedule();
+ }
+ }
+
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/selection/RemoveAllExpressionsAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/selection/RemoveAllExpressionsAction.java
new file mode 100644
index 000000000..916041e14
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/selection/RemoveAllExpressionsAction.java
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * 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.actions.selection;
+
+
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.IExpressionManager;
+import org.eclipse.debug.core.IExpressionsListener;
+import org.eclipse.debug.core.model.IExpression;
+import org.eclipse.jface.action.IAction;
+
+/**
+ * Removes all expressions from the expressions view.
+ */
+public class RemoveAllExpressionsAction extends AbstractRemoveAllActionDelegate implements IExpressionsListener {
+
+ public void run(IAction action) {
+ IExpressionManager manager = DebugPlugin.getDefault().getExpressionManager();
+ IExpression[] expressions= manager.getExpressions();
+ manager.removeExpressions(expressions);
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.actions.selection.AbstractRemoveAllActionDelegate#isEnabled()
+ */
+ protected boolean isEnabled() {
+ return DebugPlugin.getDefault().getExpressionManager().hasExpressions();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.actions.selection.AbstractRemoveAllActionDelegate#initialize()
+ */
+ protected void initialize() {
+ DebugPlugin.getDefault().getExpressionManager().addExpressionListener(this);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.actions.selection.AbstractRemoveAllActionDelegate#dispose()
+ */
+ public void dispose() {
+ DebugPlugin.getDefault().getExpressionManager().removeExpressionListener(this);
+ super.dispose();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.IExpressionsListener#expressionsAdded(org.eclipse.debug.core.model.IExpression[])
+ */
+ public void expressionsAdded(IExpression[] expressions) {
+ update();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.IExpressionsListener#expressionsRemoved(org.eclipse.debug.core.model.IExpression[])
+ */
+ public void expressionsRemoved(IExpression[] expressions) {
+ update();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.IExpressionsListener#expressionsChanged(org.eclipse.debug.core.model.IExpression[])
+ */
+ public void expressionsChanged(IExpression[] expressions) {
+ }
+}
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/actions/selection/RemoveAllTerminatedAction.java
index 17b80999a..c3e1b51fe 100644
--- 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/actions/selection/RemoveAllTerminatedAction.java
@@ -8,60 +8,37 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.debug.internal.ui.actions;
+package org.eclipse.debug.internal.ui.actions.selection;
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.jface.viewers.ISelectionChangedListener;
-import org.eclipse.ui.IViewPart;
+import org.eclipse.debug.core.ILaunchesListener2;
+import org.eclipse.jface.action.IAction;
/**
* Removes all terminated/detached launches from the
* active debug view.
*/
-public class RemoveAllTerminatedAction extends AbstractRemoveAllActionDelegate implements ILaunchesListener {
+public class RemoveAllTerminatedAction extends AbstractRemoveAllActionDelegate implements ILaunchesListener2 {
- /**
- * @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();
- }
- }
- }
-
- /**
- * Updates the enabled state of this action to enabled if at
- * least one launch is terminated and relative to the current perspective.
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.actions.selection.AbstractRemoveAllActionDelegate#isEnabled()
*/
- protected void update() {
+ protected boolean isEnabled() {
ILaunch[] launches = DebugPlugin.getDefault().getLaunchManager().getLaunches();
if (launches != null) {
for (int i= 0; i < launches.length; i++) {
if (launches[i].isTerminated()) {
- getAction().setEnabled(true);
- return;
+ return true;
}
}
}
- getAction().setEnabled(false);
- }
-
- protected void doAction() {
- ILaunch[] launches = DebugPlugin.getDefault().getLaunchManager().getLaunches();
- removeTerminatedLaunches(launches);
+ return false;
}
public static void removeTerminatedLaunches(ILaunch[] elements) {
@@ -78,47 +55,58 @@ public class RemoveAllTerminatedAction extends AbstractRemoveAllActionDelegate i
}
}
- /**
- * @see IViewActionDelegate#init(IViewPart)
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.actions.selection.AbstractRemoveAllActionDelegate#initialize()
*/
- public void init(IViewPart view) {
- super.init(view);
+ protected void initialize() {
DebugPlugin.getDefault().getLaunchManager().addLaunchListener(this);
- DebugPlugin.getDefault().addDebugEventListener(this);
}
- /**
- * @see IWorkbenchWindowActionDelegate#dispose()
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.actions.selection.AbstractRemoveAllActionDelegate#dispose()
*/
public void dispose() {
- //removes as a debug event listener
super.dispose();
DebugPlugin.getDefault().getLaunchManager().removeLaunchListener(this);
- IViewPart view = getView();
- if (view != null) {
- view.getSite().getSelectionProvider().removeSelectionChangedListener((ISelectionChangedListener) getAction());
- }
}
-
- /**
- * @see ILaunchesListener#launchesAdded(ILaunch[])
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.ILaunchesListener#launchesAdded(org.eclipse.debug.core.ILaunch[])
*/
public void launchesAdded(ILaunch[] launches) {
}
- /**
- * @see ILaunchesListener#launchesChanged(ILaunch[])
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.ILaunchesListener#launchesChanged(org.eclipse.debug.core.ILaunch[])
*/
public void launchesChanged(ILaunch[] launches) {
}
- /**
- * @see ILaunchesListener#launchesRemoved(ILaunch[])
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.ILaunchesListener#launchesRemoved(org.eclipse.debug.core.ILaunch[])
*/
public void launchesRemoved(ILaunch[] launches) {
- if (getAction().isEnabled()) {
- update();
+ IAction action = getAction();
+ if (action != null) {
+ if (action.isEnabled()) {
+ update();
+ }
}
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.ILaunchesListener2#launchesTerminated(org.eclipse.debug.core.ILaunch[])
+ */
+ public void launchesTerminated(ILaunch[] launches) {
+ update();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
+ */
+ public void run(IAction action) {
+ ILaunch[] launches = DebugPlugin.getDefault().getLaunchManager().getLaunches();
+ removeTerminatedLaunches(launches);
+ }
}
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/actions/selection/RemoveBreakpointAction.java
index 3fb9528de..360d99d40 100644
--- 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/actions/selection/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.actions.selection;
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;
@@ -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,20 +101,13 @@ 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]);
}
}
}
- /* (non-Javadoc)
- * @see org.eclipse.debug.internal.ui.actions.AbstractDebugActionDelegate#doAction(java.lang.Object)
- */
- protected void doAction(Object element) {
- //not used
- }
-
protected boolean isEnabledFor(Object element) {
if (element instanceof BreakpointContainer)
return ((BreakpointContainer)element).getChildren().length > 0;
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/selection/RemoveExpressionAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/selection/RemoveExpressionAction.java
new file mode 100644
index 000000000..263cb50ec
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/selection/RemoveExpressionAction.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * 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.actions.selection;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+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.TreePath;
+import org.eclipse.debug.internal.ui.viewers.TreeSelection;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.ui.progress.WorkbenchJob;
+
+public class RemoveExpressionAction extends AbstractRemoveActionDelegate {
+
+ protected IExpression[] getExpressions() {
+ TreeSelection selection = (TreeSelection) getSelection();
+ TreePath[] paths = selection.getPaths();
+ List expressions = new ArrayList();
+ for (int i = paths.length-1; i >=0; i--) {
+ TreePath path = paths[i];
+ Object segment = path.getSegment(1);
+ if (segment instanceof IExpression) {
+ expressions.add(segment);
+ }
+ }
+ return (IExpression[]) expressions.toArray(new IExpression[expressions.size()]);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
+ */
+ public void run(IAction action) {
+ WorkbenchJob job = new WorkbenchJob("remove expression") { //$NON-NLS-1$
+ public IStatus runInUIThread(IProgressMonitor monitor) {
+ IExpressionManager manager = DebugPlugin.getDefault().getExpressionManager();
+ IExpression[] exp = getExpressions();
+ if (exp != null) {
+ manager.removeExpressions(exp);
+ }
+ return Status.OK_STATUS;
+ }
+ };
+ job.setSystem(true);
+ schedule(job);
+ }
+}
+
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/selection/SelectAllAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/selection/SelectAllAction.java
new file mode 100644
index 000000000..6b9dcb49d
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/selection/SelectAllAction.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * 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.actions.selection;
+
+import org.eclipse.debug.internal.ui.viewers.AsynchronousTreeViewer;
+import org.eclipse.debug.ui.IDebugView;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.ui.IViewPart;
+
+public abstract class SelectAllAction extends AbstractRemoveAllActionDelegate {
+
+ private IViewPart fView;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.actions.selection.AbstractSelectionActionDelegate#init(org.eclipse.ui.IViewPart)
+ */
+ public void init(IViewPart view) {
+ fView = view;
+ IDebugView debugView = (IDebugView) getView().getAdapter(IDebugView.class);
+ if (debugView != null) {
+ debugView.setAction(getActionId(), getAction());
+ }
+ super.init(view);
+ }
+
+ protected IViewPart getView() {
+ return fView;
+ }
+
+ protected abstract String getActionId();
+
+ /**
+ * @see IActionDelegate#run(IAction)
+ */
+ public void run(IAction action){
+ if (!(getView() instanceof IDebugView)) {
+ return;
+ }
+ Viewer viewer = ((IDebugView) getView()).getViewer();
+ Control control = viewer.getControl();
+ if (control instanceof Tree) {
+ ((Tree)control).selectAll();
+ }
+ }
+
+}
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/actions/selection/SelectAllBreakpointsAction.java
index fb1b285bd..87e680d5f 100644
--- 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/actions/selection/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.actions.selection;
import org.eclipse.core.resources.IMarkerDelta;
import org.eclipse.debug.core.DebugPlugin;
@@ -17,31 +16,30 @@ import org.eclipse.debug.core.IBreakpointsListener;
import org.eclipse.debug.core.model.IBreakpoint;
import org.eclipse.debug.internal.ui.views.breakpoints.BreakpointsView;
import org.eclipse.debug.ui.IDebugView;
+import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.CheckboxTreeViewer;
-import org.eclipse.ui.IViewPart;
public class SelectAllBreakpointsAction extends SelectAllAction implements IBreakpointsListener {
- protected void update() {
- getAction().setEnabled(
- DebugPlugin.getDefault().getBreakpointManager().hasBreakpoints());
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.actions.selection.AbstractRemoveAllActionDelegate#isEnabled()
+ */
+ protected boolean isEnabled() {
+ return DebugPlugin.getDefault().getBreakpointManager().hasBreakpoints();
}
- /**
- * @see AbstractDebugActionDelegate#doAction(Object)
- */
- protected void doAction(Object element) {
+ public void run(IAction action) {
if (!(getView() instanceof BreakpointsView)) {
return;
}
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());
}
-
- /**
- * @see IBreakpointsListener#breakpointsAdded(IBreakpoint[])breakpointAdded(IBreakpoint)
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.IBreakpointsListener#breakpointsAdded(org.eclipse.debug.core.model.IBreakpoint[])
*/
public void breakpointsAdded(IBreakpoint[] breakpoints) {
if (getAction() != null && !getAction().isEnabled()) {
@@ -49,34 +47,39 @@ public class SelectAllBreakpointsAction extends SelectAllAction implements IBrea
}
}
- /**
- * @see IBreakpointsListener#breakpointsChanged(IBreakpoint[], IMarkerDelta[])breakpointChanged(IBreakpoint, IMarkerDelta)
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.IBreakpointsListener#breakpointsChanged(org.eclipse.debug.core.model.IBreakpoint[], org.eclipse.core.resources.IMarkerDelta[])
*/
public void breakpointsChanged(IBreakpoint[] breakpoints, IMarkerDelta[] deltas) {
}
- /**
- * @see IBreakpointsListener#breakpointsRemoved(IBreakpoint[], IMarkerDelta[])
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.IBreakpointsListener#breakpointsRemoved(org.eclipse.debug.core.model.IBreakpoint[], org.eclipse.core.resources.IMarkerDelta[])
*/
public void breakpointsRemoved(IBreakpoint[] breakpoints, IMarkerDelta[] deltas) {
if (getAction() != null) {
update();
}
}
-
- /**
- * @see IViewActionDelegate#init(IViewPart)
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.actions.selection.AbstractRemoveAllActionDelegate#initialize()
*/
- public void init(IViewPart view) {
- super.init(view);
+ protected void initialize() {
DebugPlugin.getDefault().getBreakpointManager().addBreakpointListener(this);
}
-
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.actions.selection.AbstractRemoveAllActionDelegate#dispose()
+ */
public void dispose() {
- DebugPlugin.getDefault().getBreakpointManager().removeBreakpointListener(this);
+ DebugPlugin.getDefault().getBreakpointManager().removeBreakpointListener(this);
super.dispose();
}
-
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.actions.selection.SelectAllAction#getActionId()
+ */
protected String getActionId() {
return IDebugView.SELECT_ALL_ACTION;
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/selection/SelectAllExpressionsAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/selection/SelectAllExpressionsAction.java
new file mode 100644
index 000000000..8b7f49c4c
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/selection/SelectAllExpressionsAction.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * 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.actions.selection;
+
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.IExpressionsListener;
+import org.eclipse.debug.core.model.IExpression;
+import org.eclipse.debug.ui.IDebugView;
+
+public class SelectAllExpressionsAction extends SelectAllAction implements IExpressionsListener {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.actions.selection.AbstractRemoveAllActionDelegate#isEnabled()
+ */
+ protected boolean isEnabled() {
+ return DebugPlugin.getDefault().getExpressionManager().hasExpressions();
+ }
+
+ protected String getActionId() {
+ return IDebugView.SELECT_ALL_ACTION + ".Variables"; //$NON-NLS-1$
+ }
+
+ protected void initialize() {
+ DebugPlugin.getDefault().getExpressionManager().addExpressionListener(this);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.IExpressionsListener#expressionsAdded(org.eclipse.debug.core.model.IExpression[])
+ */
+ public void expressionsAdded(IExpression[] expressions) {
+ update();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.IExpressionsListener#expressionsRemoved(org.eclipse.debug.core.model.IExpression[])
+ */
+ public void expressionsRemoved(IExpression[] expressions) {
+ update();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.IExpressionsListener#expressionsChanged(org.eclipse.debug.core.model.IExpression[])
+ */
+ public void expressionsChanged(IExpression[] expressions) {
+ }
+}
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/actions/selection/SelectAllVariablesAction.java
index 88af02d21..c11ae6906 100644
--- 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/actions/selection/SelectAllVariablesAction.java
@@ -8,24 +8,28 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.debug.internal.ui.actions;
+package org.eclipse.debug.internal.ui.actions.selection;
-
import org.eclipse.debug.ui.IDebugView;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-
+
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);
- }
protected String getActionId() {
return IDebugView.SELECT_ALL_ACTION + ".Variables"; //$NON-NLS-1$
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.actions.selection.AbstractRemoveAllActionDelegate#initialize()
+ */
+ protected void initialize() {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.actions.selection.AbstractRemoveAllActionDelegate#isEnabled()
+ */
+ protected boolean isEnabled() {
+ // TODO: only enable when stuff present
+ return true;
+ }
}
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..57175af45
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/DebugWindowContextService.java
@@ -0,0 +1,277 @@
+/*******************************************************************************
+ * 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.commands.util.ListenerList;
+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.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();
+
+ private static final int ACTIVATED = 1;
+ private static final int CHANGED = 2;
+
+ 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(id, part);
+ 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))) {
+ notify(ACTIVATED);
+ }
+ 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) {
+ notify(ACTIVATED);
+ }
+ }
+ 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 notify(int type) {
+ if (fProviders.isEmpty()) {
+ notify(type, null, null);
+ } else {
+ IDebugContextProvider provider = (IDebugContextProvider) fProviders.get(0);
+ notify(type, provider.getActiveContext(), provider.getPart());
+ }
+ }
+
+ protected void notify(int type, ISelection context, IWorkbenchPart part) {
+ notify(type, getListeners(null), context, part);
+ if (part != null) {
+ notify(type, getListeners(part), context, part);
+ }
+ }
+ protected void notify(final int type, 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 {
+ if (type == ACTIVATED) {
+ listener.contextActivated(context, part);
+ } else {
+ listener.contextChanged(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()) {
+ return ((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);
+ notify(ACTIVATED);
+ }
+ }
+
+ }
+
+ /* (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) {
+ }
+
+ /* (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) {
+ notify(ACTIVATED);
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.contexts.IDebugContextListener#contextChanged(org.eclipse.jface.viewers.ISelection, org.eclipse.ui.IWorkbenchPart)
+ */
+ public void contextChanged(ISelection selection, IWorkbenchPart part) {
+ if (!fProviders.isEmpty()) {
+ IDebugContextProvider provider = (IDebugContextProvider) fProviders.get(0);
+ if (provider.getPart() == part) {
+ notify(CHANGED);
+ }
+ }
+ }
+
+
+}
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/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..d9a8be54c
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/ExpressionTreeContentAdapter.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * 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.IErrorReportingExpression;
+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 {
+ 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();
+ 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 {
+ if (element instanceof IErrorReportingExpression) {
+ IErrorReportingExpression expression = (IErrorReportingExpression) element;
+ if (expression.hasErrors()) {
+ return true;
+ }
+ }
+
+ if (element instanceof IExpression) {
+ IValue value = ((IExpression) element).getValue();
+ if (value != null) {
+ return value.hasVariables();
+ }
+ }
+
+ return false;
+ }
+
+}
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..fbfbc79d7
--- /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_EXPRESSION_VIEW) || 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/importexport/breakpoints/EmbeddedBreakpointsViewer.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/EmbeddedBreakpointsViewer.java
index 9f4c9a554..55d40eed9 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/EmbeddedBreakpointsViewer.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/EmbeddedBreakpointsViewer.java
@@ -37,6 +37,7 @@ import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.swt.widgets.Widget;
import org.eclipse.ui.IViewPart;
/**
@@ -205,7 +206,37 @@ public class EmbeddedBreakpointsViewer {
public BreakpointsViewer getViewer() {
return fViewer;
}//end getViewer
-
+
+ /**
+ * finds all occurrences of a widget to update
+ * @param element the element to search for when finding occurrences
+ * @return a list of widget occurrences to update or an empty list
+ */
+ private Widget[] searchItems(Object element) {
+ ArrayList list = new ArrayList();
+ TreeItem[] items = fTree.getItems();
+ for (int i = 0; i < items.length; i++) {
+ findAllOccurrences(items[i], element, list);
+ }//end for
+ return (Widget[]) list.toArray(new Widget[0]);
+ }
+
+ /**
+ * performs the actual search for items in the tree
+ * @param list the list to add matches to
+ * @param item the item in the tree
+ * @param element the element to compare
+ */
+ private void findAllOccurrences(TreeItem item, Object element, ArrayList list) {
+ if (element.equals(item.getData())) {
+ list.add(item);
+ }//end if
+ TreeItem[] items = item.getItems();
+ for (int i = 0; i < items.length; i++) {
+ findAllOccurrences(items[i], element, list);
+ }
+ }
+
/**
* Update the checked state of the given element and all of its children.
*
@@ -214,10 +245,10 @@ public class EmbeddedBreakpointsViewer {
*/
private void updateCheckedState(Object obj, boolean enable) {
if (obj instanceof IBreakpoint) {
- ArrayList list = findAllItemOccurances(obj);
+ Widget[] list = searchItems(obj);
TreeItem item = null;
- for(int i = 0; i < list.size(); i++) {
- item = (TreeItem)list.get(i);
+ for(int i = 0; i < list.length; i++) {
+ item = (TreeItem)list[i];
item.setChecked(enable);
refreshParents(item);
}//end for
@@ -231,7 +262,7 @@ public class EmbeddedBreakpointsViewer {
}//end if
//refreshParents(item);
- }//end updateCheckedState
+ }//end updateCheckedState
/**
* refreshes the grayed/checked state of the parents of item
@@ -293,25 +324,4 @@ public class EmbeddedBreakpointsViewer {
}//end for
return count;
}//end allChildrenChecked
-
- /**
- * Finds all of the objects in the current tree view based on what is showing, not on findItem
- * which only finds the first occurance of the object in the tree
- * @param object the object to look for
- * @return the list of objects or an empty list, never null
- *
- */
- private ArrayList findAllItemOccurances(Object object) {
- ArrayList results = new ArrayList();
- fTree.selectAll();
- TreeItem[] items = fTree.getSelection();
- fTree.deselectAll();
- for(int i = 0; i < items.length; i++) {
- if(object.equals(items[i].getData())) {
- results.add(items[i]);
- }//end if
- }//end for
- return results;
- }
-
}//end class
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..34c6f5eac 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
@@ -89,6 +89,8 @@ public class PerspectiveManager implements ILaunchListener, IDebugEventSetListen
*/
private boolean fPrompting;
private PerspectiveSwitchLock fPerspectiveSwitchLock = new PerspectiveSwitchLock();
+
+ private int fNumLaunches = 0;
/**
* Lock used to synchronize perspective switching with view activation.
@@ -134,7 +136,6 @@ public class PerspectiveManager implements ILaunchListener, IDebugEventSetListen
public void startup() {
DebugPlugin plugin = DebugPlugin.getDefault();
plugin.getLaunchManager().addLaunchListener(this);
- plugin.addDebugEventListener(this);
}
/**
@@ -145,15 +146,21 @@ public class PerspectiveManager implements ILaunchListener, IDebugEventSetListen
public void shutdown() {
DebugPlugin plugin = DebugPlugin.getDefault();
plugin.getLaunchManager().removeLaunchListener(this);
- plugin.removeDebugEventListener(this);
}
/**
- * Do nothing.
+ * If there are no launches, remove the Suspend Trigger Listener
*
* @see ILaunchListener#launchRemoved(ILaunch)
*/
- public void launchRemoved(ILaunch launch) {
+ public synchronized void launchRemoved(ILaunch launch) {
+ fNumLaunches --;
+ if (fNumLaunches == 0) {
+ ISuspendTrigger trigger = (ISuspendTrigger) launch.getAdapter(ISuspendTrigger.class);
+ if (trigger != null) {
+ trigger.removeSuspendTriggerListener(this);
+ }
+ }
}
/**
@@ -170,10 +177,17 @@ public class PerspectiveManager implements ILaunchListener, IDebugEventSetListen
*
* @see ILaunchListener#launchAdded(ILaunch)
*/
- public void launchAdded(ILaunch launch) {
-
- fPerspectiveSwitchLock.startSwitch();
-
+ public synchronized void launchAdded(ILaunch launch) {
+ if (fNumLaunches == 0) {
+ ISuspendTrigger trigger = (ISuspendTrigger) launch.getAdapter(ISuspendTrigger.class);
+ if (trigger != null) {
+ trigger.addSuspendTriggerListener(this);
+ }
+ }
+
+ fNumLaunches ++;
+ fPerspectiveSwitchLock.startSwitch();
+
String perspectiveId = null;
// check event filters
try {
@@ -264,25 +278,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 +327,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 +337,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 +802,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..374578325
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupService.java
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * 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;
+
+ 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);
+ }
+ }
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.contexts.IDebugContextListener#contextChanged(org.eclipse.jface.viewers.ISelection, org.eclipse.ui.IWorkbenchPart)
+ */
+ public void contextChanged(ISelection selection, IWorkbenchPart part) {
+ }
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AbstractAddRemoveRequestMonitor.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AbstractAddRemoveRequestMonitor.java
new file mode 100644
index 000000000..a0a8cd019
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AbstractAddRemoveRequestMonitor.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * 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;
+
+/**
+ * Common function for adds and removes.
+ *
+ * @since 3.2
+ */
+abstract class AbstractAddRemoveRequestMonitor extends AsynchronousRequestMonitor {
+
+ private TreePath fPath;
+
+ /**
+ * Constructs a request to add/reomve an element from the tree
+ *
+ * @param widget
+ * @param path path to the element in the tree
+ * @param viewer
+ *
+ */
+ AbstractAddRemoveRequestMonitor(Widget widget, TreePath path, AsynchronousTreeViewer viewer) {
+ super(widget, viewer);
+ fPath = path;
+ }
+
+ protected TreePath getPath() {
+ return fPath;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.viewers.AsynchronousRequestMonitor#contains(org.eclipse.debug.internal.ui.viewers.AsynchronousRequestMonitor)
+ */
+ protected boolean contains(AsynchronousRequestMonitor update) {
+ if (update instanceof AbstractAddRemoveRequestMonitor) {
+ ((AbstractAddRemoveRequestMonitor)update).getPath().equals(getPath());
+ }
+ return false;
+ }
+
+}
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/AddRequestMonitor.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AddRequestMonitor.java
new file mode 100644
index 000000000..2b0b27f5c
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AddRequestMonitor.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.viewers;
+
+import org.eclipse.swt.widgets.Widget;
+
+/**
+ * Request to add an item to a tree.
+ *
+ * @since 3.2
+ */
+class AddRequestMonitor extends AbstractAddRemoveRequestMonitor {
+
+ /**
+ * Adds the given child to the specified parent.
+ *
+ * @param parent
+ * @param path path to the child in the tree@param child
+ * @param viewer
+ *
+ */
+ AddRequestMonitor(Widget parent, TreePath path, AsynchronousTreeViewer viewer) {
+ super(parent, path, viewer);
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.viewers.AsynchronousRequestMonitor#performUpdate()
+ */
+ protected void performUpdate() {
+ ((AsynchronousTreeViewer)getViewer()).add(getWidget(), getPath().getLastSegment());
+ }
+
+}
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..35678c0ca
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousTreeContentAdapter.java
@@ -0,0 +1,148 @@
+/*******************************************************************************
+ * 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.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..90ec23ea5
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousTreeViewer.java
@@ -0,0 +1,957 @@
+/*******************************************************************************
+ * 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);
+ }
+ if (!path.get(0).equals(getInput())) {
+ 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();
+ }
+
+ /**
+ * Adds a child at end of parent.
+ *
+ * @param parent
+ * @param child
+ */
+ synchronized void add(Widget parent, Object child) {
+ // refresh vs. add if not expanded
+ boolean expanded = true;
+ if (parent instanceof TreeItem) {
+ expanded = ((TreeItem)parent).getExpanded();
+ }
+ if (expanded) {
+ Object[] objects = filter(new Object[]{child});
+ if (objects.length == 1) {
+ child = objects[0];
+ TreeItem item = newTreeItem(parent);
+ map(child, item);
+ internalRefresh(child, item);
+ }
+ } else {
+ internalRefresh(parent.getData(), parent);
+ }
+ }
+
+ /**
+ * 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);
+ }
+
+ /**
+ * Creates a new tree item as a child of the given widget as last.
+ *
+ * @param parent parent widget - a Tree or TreeItem
+ * @return tree item
+ */
+ protected TreeItem newTreeItem(Widget parent) {
+ if (parent instanceof Tree) {
+ return new TreeItem((Tree) parent, SWT.NONE);
+ }
+ return new TreeItem((TreeItem) parent, SWT.NONE);
+ }
+
+ /**
+ * 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.debug.internal.ui.viewers.AsynchronousViewer#newSelectionFromWidget()
+ */
+ protected ISelection newSelectionFromWidget() {
+ 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 synchronized 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]);
+ }
+
+ /**
+ * Adds the item specified by the given tree path to this tree.
+ * Can be called in a non-UI thread.
+ *
+ * @param treePath
+ */
+ public synchronized void add(TreePath treePath) {
+ int parentIndex = treePath.getSegmentCount() - 2;
+ if (parentIndex >= 0) {
+ // find the paths to the parent, if it's present
+ Object parent = treePath.getSegment(parentIndex);
+ TreePath[] paths = getTreePaths(parent);
+ if (paths != null) {
+ // find the right path
+ for (int i = 0; i < paths.length; i++) {
+ TreePath path = paths[i];
+ if (treePath.startsWith(path)) {
+ Widget widget = path.getTreeItem();
+ if (widget == null) {
+ widget = getTree();
+ }
+ AddRequestMonitor addRequest = new AddRequestMonitor(widget, treePath, this);
+ schedule(addRequest);
+ addRequest.done();
+ return;
+ }
+ }
+ }
+ // refresh the leaf parent, if any
+ for (int i = parentIndex -1; i >= 0; i++) {
+ parent = treePath.getSegment(i);
+ paths = getTreePaths(parent);
+ if (paths != null) {
+ for (int j = 0; j < paths.length; j++) {
+ TreePath path = paths[j];
+ if (treePath.startsWith(path)) {
+ Widget widget = path.getTreeItem();
+ if (widget == null) {
+ widget = getTree();
+ }
+ internalRefresh(parent, widget);
+ return;
+ }
+ }
+ }
+ }
+ }
+ }
+
+
+ /**
+ * Removes the item specified in the given tree path from this tree.
+ * Can be called in a non-UI thread.
+ *
+ * @param treePath
+ */
+ public synchronized void remove(TreePath treePath) {
+ if (treePath.getSegmentCount() > 1) {
+ // find the paths to the element, if it's present
+ Object element = treePath.getLastSegment();
+ TreePath[] paths = getTreePaths(element);
+ if (paths != null) {
+ // find the right path
+ for (int i = 0; i < paths.length; i++) {
+ TreePath path = paths[i];
+ if (treePath.equals(path)) {
+ TreeItem item = path.getTreeItem();
+ RemoveRequestMonitor request = new RemoveRequestMonitor(item, treePath, this);
+ schedule(request);
+ request.done();
+ return;
+ }
+ }
+ }
+ // refresh the parent, if present
+ if (treePath.getSegmentCount() >= 2) {
+ element = treePath.getSegment(treePath.getSegmentCount() - 2);
+ paths = getTreePaths(element);
+ if (paths != null) {
+ // find the right path
+ for (int i = 0; i < paths.length; i++) {
+ TreePath path = paths[i];
+ if (treePath.startsWith(path)) {
+ Widget widget = path.getTreeItem();
+ if (widget == null) {
+ widget = getTree();
+ }
+ internalRefresh(element, widget);
+ return;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ synchronized void remove(final Widget widget) {
+ preservingSelection(new Runnable() {
+ public void run() {
+ Object element = widget.getData();
+ unmap(element, widget);
+ widget.dispose();
+ }
+ });
+ }
+
+ 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..1ffcf994f
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousViewer.java
@@ -0,0 +1,940 @@
+/*******************************************************************************
+ * 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.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.events.SelectionEvent;
+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());
+ }
+
+ /**
+ * 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();
+ if (fUpdatePolicy != null) {
+ fUpdatePolicy.dispose();
+ }
+
+ unmapAllElements();
+ fPendingUpdates.clear();
+ }
+
+ /**
+ * Unintalls all update policies installed in this viewer
+ */
+ private void disposeAllModelProxies() {
+ synchronized(fModelProxies) {
+ Iterator updatePolicies = fModelProxies.values().iterator();
+ while (updatePolicies.hasNext()) {
+ IModelProxy proxy = (IModelProxy)updatePolicies.next();
+ if (fUpdatePolicy instanceof IModelChangedListener) {
+ proxy.removeModelChangedListener((IModelChangedListener)fUpdatePolicy);
+ }
+ 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 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) {
+ if (fUpdatePolicy == null) {
+ fUpdatePolicy = createUpdatePolicy();
+ }
+ 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 IUpdatePolicy createUpdatePolicy() {
+ DefaultUpdatePolicy policy = new DefaultUpdatePolicy();
+ policy.init(this);
+ return policy;
+ }
+
+ /**
+ * 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());
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.StructuredViewer#getSelection()
+ */
+ public ISelection getSelection() {
+ Control control = getControl();
+ if (control == null || control.isDisposed() || fCurrentSelection == null) {
+ return StructuredSelection.EMPTY;
+ }
+ return fCurrentSelection;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.StructuredViewer#handleSelect(org.eclipse.swt.events.SelectionEvent)
+ */
+ protected void handleSelect(SelectionEvent event) {
+ // handle case where an earlier selection listener disposed the control.
+ Control control = getControl();
+ if (control != null && !control.isDisposed()) {
+ updateSelection(newSelectionFromWidget());
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.StructuredViewer#handlePostSelect(org.eclipse.swt.events.SelectionEvent)
+ */
+ protected void handlePostSelect(SelectionEvent e) {
+ SelectionChangedEvent event = new SelectionChangedEvent(this, newSelectionFromWidget());
+ firePostSelectionChanged(event);
+ }
+
+ /**
+ * Creates and returns a new seletion from this viewer, based on the selected
+ * elements in the widget.
+ *
+ * @return a new selection
+ */
+ protected abstract ISelection newSelectionFromWidget();
+
+ /**
+ * 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 = newSelectionFromWidget();
+ if (isSuppressEqualSelections() && currentSelection.equals(fCurrentSelection)) {
+ return;
+ }
+ updateSelection(currentSelection);
+ }
+ }
+
+ /**
+ * Controls whether selection change notification is sent even when
+ * successive selections are equal.
+ *
+ * TODO: what we really want is to fire selection change on ACTIVATE
+ * model change, even when selection is the same.
+ *
+ * @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 StructuredSelection();
+ }
+ 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 = newSelectionFromWidget();
+ 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);
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.StructuredViewer#updateSelection(org.eclipse.jface.viewers.ISelection)
+ */
+ protected synchronized void updateSelection(ISelection selection) {
+ fCurrentSelection = selection;
+ super.updateSelection(selection);
+ }
+
+
+
+}
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..d43f0686d
--- /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 be 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/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/RemoveRequestMonitor.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/RemoveRequestMonitor.java
new file mode 100644
index 000000000..33b004951
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/RemoveRequestMonitor.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * 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;
+
+/**
+ * Request to remove an item from a tree.
+ *
+ * @since 3.2
+ */
+class RemoveRequestMonitor extends AbstractAddRemoveRequestMonitor {
+
+ /**
+ * Removes the given widget from the given tree.
+ *
+ * @param widget
+ * @param path path to the element to remove
+ * @param viewer
+ */
+ RemoveRequestMonitor(Widget widget, TreePath path, AsynchronousTreeViewer viewer) {
+ super(widget, path, viewer);
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.viewers.AsynchronousRequestMonitor#performUpdate()
+ */
+ protected void performUpdate() {
+ ((AsynchronousTreeViewer)getViewer()).remove(getWidget());
+ }
+
+}
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..bd60addfd
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/TreePath.java
@@ -0,0 +1,182 @@
+/*******************************************************************************
+ * 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;
+ }
+ int thisLength = getSegmentCount();
+ int otherLength = treePath.getSegmentCount();
+ if (otherLength == thisLength) {
+ return treePath.equals(this);
+ }
+ if (otherLength > thisLength) {
+ return false;
+ }
+ 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..5d0ce8399
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/TreeSelection.java
@@ -0,0 +1,159 @@
+/*******************************************************************************
+ * 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;
+ }
+ } else if (obj instanceof IStructuredSelection) {
+ if (isEmpty() && ((IStructuredSelection)obj).isEmpty()) {
+ 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..b9f1d60bb
--- /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) {
+ // do nothing unless the suspend times out
+ }
+
+ /**
+ * 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..9965cc40b
--- /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) {
+ // do nothing - launch change notification handles this
+ }
+
+ protected void handleResume(DebugEvent event) {
+ fireDelta((IDebugTarget) event.getSource(), IModelDelta.CHANGED | IModelDelta.CONTENT | 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..604616c9c
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DebugTargetProxy.java
@@ -0,0 +1,30 @@
+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.IDebugTarget;
+
+public class DebugTargetProxy extends EventHandlerModelProxy {
+
+ private IDebugTarget fDebugTarget;
+
+ private DebugEventHandler[] fDebugEventHandlers = new DebugEventHandler[] { new DebugTargetEventHandler(this), new ThreadEventHandler(this) };
+
+ public DebugTargetProxy(IDebugTarget target) {
+ fDebugTarget = target;
+ }
+
+ protected boolean containsEvent(DebugEvent event) {
+ Object source = event.getSource();
+ if (source instanceof IDebugElement) {
+ IDebugTarget debugTarget = ((IDebugElement) source).getDebugTarget();
+ return fDebugTarget.equals(debugTarget);
+ }
+ return false;
+ }
+
+ protected DebugEventHandler[] createEventHandlers() {
+ return fDebugEventHandlers;
+ }
+
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DefaultExpressionModelProxy.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DefaultExpressionModelProxy.java
new file mode 100644
index 000000000..210e58f92
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DefaultExpressionModelProxy.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * 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.IExpression;
+import org.eclipse.debug.core.model.IVariable;
+
+/**
+ * @since 3.2
+ *
+ */
+public class DefaultExpressionModelProxy extends EventHandlerModelProxy {
+
+ private IExpression fExpression;
+
+ public DefaultExpressionModelProxy(IExpression expression) {
+ fExpression = expression;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.viewers.update.EventHandlerModelProxy#dispose()
+ */
+ public synchronized void dispose() {
+ super.dispose();
+ fExpression = null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.viewers.update.EventHandlerModelProxy#createEventHandlers()
+ */
+ protected DebugEventHandler[] createEventHandlers() {
+ return new DebugEventHandler[]{new ExpressionEventHandler(this)};
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.viewers.update.EventHandlerModelProxy#containsEvent(org.eclipse.debug.core.DebugEvent)
+ */
+ protected boolean containsEvent(DebugEvent event) {
+ if (fExpression.equals(event.getSource())) {
+ return true;
+ }
+ // have to consider change events on variables
+ return event.getKind() == DebugEvent.CHANGE && event.getSource() instanceof IVariable;
+ }
+
+ protected IExpression getExpression() {
+ return fExpression;
+ }
+
+}
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..f0cbcaca3
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DefaultModelProxyFactory.java
@@ -0,0 +1,61 @@
+package org.eclipse.debug.internal.ui.viewers.update;
+
+import org.eclipse.debug.core.IExpressionManager;
+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.IExpression;
+import org.eclipse.debug.core.model.IProcess;
+import org.eclipse.debug.core.model.IStackFrame;
+import org.eclipse.debug.core.model.IWatchExpression;
+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;
+import org.eclipse.ui.IWorkbenchPart;
+
+public class DefaultModelProxyFactory implements IModelProxyFactory {
+
+ public IModelProxy createModelProxy(Object element, IPresentationContext context) {
+ IWorkbenchPart part = context.getPart();
+ if (part != null) {
+ String id = part.getSite().getId();
+ if (IDebugUIConstants.ID_DEBUG_VIEW.equals(id)) {
+ if (element instanceof IDebugTarget) {
+ return new DebugTargetProxy((IDebugTarget)element);
+ }
+ 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);
+ }
+ }
+ if (IDebugUIConstants.ID_EXPRESSION_VIEW.equals(id)) {
+ if (element instanceof IExpressionManager) {
+ return new ExpressionManagerModelProxy();
+ } if (element instanceof IWatchExpression) {
+ return new DefaultWatchExpressionModelProxy((IWatchExpression)element, part.getSite().getWorkbenchWindow());
+ }
+ if (element instanceof IExpression) {
+ return new DefaultExpressionModelProxy((IExpression)element);
+ }
+ }
+ if (IDebugUIConstants.ID_REGISTER_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..516e298e3
--- /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()) || !isSticky(existing);
+ }
+ 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..55e90eadc
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DefaultUpdatePolicy.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 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;
+
+/**
+ * Default update policy updates a viewer based on model deltas.
+ *
+ * @since 3.2
+ */
+public class DefaultUpdatePolicy extends AbstractUpdatePolicy implements IModelChangedListener {
+
+ public void modelChanged(IModelDelta delta) {
+ IModelDeltaNode[] nodes = delta.getNodes();
+ updateNodes(nodes);
+ }
+
+ protected 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);
+ }
+ }
+ }
+
+ protected 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));
+ }
+ }
+ }
+
+ protected 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));
+ }
+ }
+
+ protected void handleRemove(IModelDeltaNode node) {
+ TreePath treePath = getTreePath(node);
+ ((AsynchronousTreeViewer) getViewer()).remove(treePath);
+ }
+
+ protected 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/DefaultVariableViewModelProxy.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DefaultVariableViewModelProxy.java
new file mode 100644
index 000000000..4189d5791
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DefaultVariableViewModelProxy.java
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * 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.IDebugTarget;
+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() {
+ super.dispose();
+ fFrame = null;
+ }
+
+ protected DebugEventHandler[] createEventHandlers() {
+ return new DebugEventHandler[] { new VariablesViewEventHandler(this, fFrame) };
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.viewers.update.EventHandlerModelProxy#containsEvent(org.eclipse.debug.core.DebugEvent)
+ */
+ protected boolean containsEvent(DebugEvent event) {
+ Object source = event.getSource();
+ if (source instanceof IDebugElement) {
+ IDebugTarget debugTarget = ((IDebugElement) source).getDebugTarget();
+ return debugTarget.equals(fFrame.getDebugTarget());
+ }
+ return false;
+ }
+
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DefaultWatchExpressionModelProxy.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DefaultWatchExpressionModelProxy.java
new file mode 100644
index 000000000..be37402c3
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DefaultWatchExpressionModelProxy.java
@@ -0,0 +1,80 @@
+/*******************************************************************************
+ * 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.ILaunch;
+import org.eclipse.debug.core.model.IDebugElement;
+import org.eclipse.debug.core.model.IWatchExpression;
+import org.eclipse.debug.internal.ui.contexts.DebugContextManager;
+import org.eclipse.debug.ui.contexts.IDebugContextListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+
+/**
+ * @since 3.2
+ *
+ */
+public class DefaultWatchExpressionModelProxy extends DefaultExpressionModelProxy implements IDebugContextListener {
+
+ private IWorkbenchWindow fWindow;
+
+ public DefaultWatchExpressionModelProxy(IWatchExpression expression, IWorkbenchWindow window) {
+ super(expression);
+ fWindow = window;
+ DebugContextManager.getDefault().addDebugContextListener(this, window);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.viewers.update.DefaultExpressionModelProxy#dispose()
+ */
+ public synchronized void dispose() {
+ super.dispose();
+ DebugContextManager.getDefault().removeDebugContextListener(this, fWindow);
+ fWindow = null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.viewers.update.EventHandlerModelProxy#createEventHandlers()
+ */
+ protected DebugEventHandler[] createEventHandlers() {
+ return new DebugEventHandler[]{new ExpressionEventHandler(this)};
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.contexts.IDebugContextListener#contextActivated(org.eclipse.jface.viewers.ISelection, org.eclipse.ui.IWorkbenchPart)
+ */
+ public void contextActivated(ISelection selection, IWorkbenchPart part) {
+ if (fWindow != null) {
+ if (selection instanceof IStructuredSelection) {
+ IDebugElement context = null;
+ IStructuredSelection ss = (IStructuredSelection)selection;
+ if (ss.size() < 2) {
+ Object object = ss.getFirstElement();
+ if (object instanceof IDebugElement) {
+ context= (IDebugElement) object;
+ } else if (object instanceof ILaunch) {
+ context= ((ILaunch) object).getDebugTarget();
+ }
+ }
+ ((IWatchExpression)getExpression()).setExpressionContext(context);
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.contexts.IDebugContextListener#contextChanged(org.eclipse.jface.viewers.ISelection, org.eclipse.ui.IWorkbenchPart)
+ */
+ public void contextChanged(ISelection selection, IWorkbenchPart part) {
+ }
+
+}
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..0fc66cd6c
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/EventHandlerModelProxy.java
@@ -0,0 +1,253 @@
+/*******************************************************************************
+ * 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 abstract 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 abstract DebugEventHandler[] createEventHandlers();
+
+ 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();
+ }
+ }
+
+ 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];
+ if (containsEvent(event)) {
+ 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;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ protected boolean containsEvent(DebugEvent event) {
+ return true;
+ }
+
+ 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/ExpressionEventHandler.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/ExpressionEventHandler.java
new file mode 100644
index 000000000..898cbe203
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/ExpressionEventHandler.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.DebugPlugin;
+import org.eclipse.debug.core.model.IExpression;
+import org.eclipse.debug.internal.ui.viewers.IModelDelta;
+import org.eclipse.debug.internal.ui.viewers.IModelDeltaNode;
+import org.eclipse.debug.internal.ui.viewers.IModelProxy;
+
+/**
+ * Event handler for an expression.
+ *
+ * @since 3.2
+ *
+ */
+public class ExpressionEventHandler extends DebugEventHandler {
+
+ public ExpressionEventHandler(IModelProxy proxy) {
+ super(proxy);
+ }
+
+ protected boolean handlesEvent(DebugEvent event) {
+ return event.getKind() == DebugEvent.CHANGE;
+ }
+
+ protected void handleChange(DebugEvent event) {
+ ModelDelta delta = new ModelDelta();
+ IModelDeltaNode node = delta.addNode(DebugPlugin.getDefault().getExpressionManager(), IModelDelta.NOCHANGE);
+ IExpression expression = null;
+ if (event.getSource() instanceof IExpression) {
+ expression = (IExpression) event.getSource();
+ } else {
+ expression = ((DefaultExpressionModelProxy)getModelProxy()).getExpression();
+ }
+ if (expression != null) {
+ node.addNode(expression, IModelDelta.CHANGED | IModelDelta.CONTENT | IModelDelta.STATE);
+ getModelProxy().fireModelChanged(delta);
+ }
+ }
+
+ protected void refreshRoot(DebugEvent event) {
+ ModelDelta delta = new ModelDelta();
+ delta.addNode(DebugPlugin.getDefault().getExpressionManager(), IModelDelta.CHANGED | IModelDelta.CONTENT);
+ getModelProxy().fireModelChanged(delta);
+ }
+
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/ExpressionManagerModelProxy.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/ExpressionManagerModelProxy.java
new file mode 100644
index 000000000..2ac72ec69
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/ExpressionManagerModelProxy.java
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * 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.DebugPlugin;
+import org.eclipse.debug.core.IExpressionsListener;
+import org.eclipse.debug.core.model.IExpression;
+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 ExpressionManagerModelProxy extends AbstractModelProxy implements IExpressionsListener {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.viewers.update.EventHandlerModelProxy#init(org.eclipse.debug.internal.ui.viewers.IPresentationContext)
+ */
+ public void init(IPresentationContext context) {
+ DebugPlugin.getDefault().getExpressionManager().addExpressionListener(this);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.viewers.update.EventHandlerModelProxy#dispose()
+ */
+ public synchronized void dispose() {
+ DebugPlugin.getDefault().getExpressionManager().removeExpressionListener(this);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.IExpressionsListener#expressionsAdded(org.eclipse.debug.core.model.IExpression[])
+ */
+ public void expressionsAdded(IExpression[] expressions) {
+ updateExpressions(expressions, IModelDelta.ADDED);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.IExpressionsListener#expressionsRemoved(org.eclipse.debug.core.model.IExpression[])
+ */
+ public void expressionsRemoved(IExpression[] expressions) {
+ updateExpressions(expressions, IModelDelta.REMOVED);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.IExpressionsListener#expressionsChanged(org.eclipse.debug.core.model.IExpression[])
+ */
+ public void expressionsChanged(IExpression[] expressions) {
+ updateExpressions(expressions, IModelDelta.CHANGED | IModelDelta.CONTENT | IModelDelta.STATE);
+ }
+
+ private void updateExpressions(IExpression[] expressions, int flags) {
+ ModelDelta delta = new ModelDelta();
+ IModelDeltaNode node = delta.addNode(DebugPlugin.getDefault() .getExpressionManager(), IModelDelta.NOCHANGE);
+ for (int i = 0; i < expressions.length; i++) {
+ IExpression expression = expressions[i];
+ node.addNode(expression, flags);
+ }
+ fireModelChanged(delta);
+ }
+
+
+}
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..b4848c040
--- /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.NOCHANGE);
+ 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..019cbc320
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/LaunchProxy.java
@@ -0,0 +1,59 @@
+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) {
+ }
+
+ public void launchesAdded(ILaunch[] launches) {
+ }
+
+ 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..e0c474d50
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/ProcessProxy.java
@@ -0,0 +1,44 @@
+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.IProcess;
+import org.eclipse.debug.internal.ui.viewers.IModelDelta;
+import org.eclipse.debug.internal.ui.viewers.IModelDeltaNode;
+
+public class ProcessProxy extends EventHandlerModelProxy {
+
+ private IProcess fProcess;
+
+ private DebugEventHandler fProcessEventHandler = new DebugEventHandler(this) {
+ protected boolean handlesEvent(DebugEvent event) {
+ return fProcess.equals(event.getSource());
+ }
+
+ protected void handleChange(DebugEvent event) {
+ 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);
+
+ }
+
+ protected void handleCreate(DebugEvent event) {
+ // do nothing - Launch change notification handles this
+ }
+
+ };
+
+ public ProcessProxy(IProcess process) {
+ fProcess = process;
+ }
+
+ protected synchronized boolean containsEvent(DebugEvent event) {
+ return fProcess.equals(event.getSource());
+ }
+
+ protected DebugEventHandler[] createEventHandlers() {
+ return new DebugEventHandler[] {fProcessEventHandler};
+ }
+}
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..ef540778a
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/ThreadEventHandler.java
@@ -0,0 +1,192 @@
+/*******************************************************************************
+ * 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.LinkedHashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.debug.core.DebugEvent;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.model.IStackFrame;
+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 {
+
+ /**
+ * Queue of suspended threads to choose from when needing
+ * to select a thread when another is resumed. Threads
+ * are added in the order they suspend.
+ */
+ private Set fThreadQueue = new LinkedHashSet();
+
+ /**
+ * Map of previous TOS per thread
+ */
+ private Map fLastTopFrame = new HashMap();
+ /**
+ * Constructs and event handler for a threads in the given viewer.
+ *
+ * @param viewer
+ */
+ public ThreadEventHandler(IModelProxy proxy) {
+ super(proxy);
+ }
+
+ public void dispose() {
+ synchronized (fLastTopFrame) {
+ fLastTopFrame.clear();
+ }
+ synchronized (fThreadQueue) {
+ fThreadQueue.clear();
+ }
+ super.dispose();
+ }
+
+ protected void handleSuspend(DebugEvent event) {
+ IThread thread = (IThread) event.getSource();
+ if (event.isEvaluation()) {
+ ModelDelta delta = new ModelDelta();
+ IModelDeltaNode node = buildBaseDelta(delta, thread);
+ try {
+ IStackFrame frame = thread.getTopStackFrame();
+ node.addNode(frame, IModelDelta.CHANGED | IModelDelta.STATE);
+ getModelProxy().fireModelChanged(delta);
+ } catch (DebugException e) {
+ }
+ } else {
+ queueSuspendedThread(event);
+ fireDeltaUpdatingTopFrame(thread, IModelDelta.NOCHANGE);
+ }
+ }
+
+ private boolean isEqual(Object o1, Object o2) {
+ if (o1 == o2) {
+ return true;
+ }
+ if (o1 == null) {
+ return false;
+ }
+ return o1.equals(o2);
+ }
+
+ protected void handleResume(DebugEvent event) {
+ IThread thread = removeSuspendedThread(event);
+ fireDeltaAndClearTopFrame(thread, IModelDelta.CHANGED | IModelDelta.STATE | IModelDelta.CONTENT);
+ thread = getNextSuspendedThread();
+ if (thread != null) {
+ fireDeltaUpdatingTopFrame(thread, IModelDelta.NOCHANGE);
+ }
+ }
+
+ protected void handleCreate(DebugEvent event) {
+ fireDeltaAndClearTopFrame((IThread) event.getSource(), IModelDelta.ADDED | IModelDelta.STATE);
+ }
+
+ protected void handleTerminate(DebugEvent event) {
+ fireDeltaAndClearTopFrame((IThread) event.getSource(), IModelDelta.REMOVED);
+ }
+
+ protected void handleChange(DebugEvent event) {
+ fireDeltaUpdatingTopFrame((IThread) event.getSource(), IModelDelta.CHANGED | IModelDelta.STATE);
+ }
+
+ protected void handleLateSuspend(DebugEvent suspend, DebugEvent resume) {
+ IThread thread = queueSuspendedThread(suspend);
+ fireDeltaUpdatingTopFrame(thread, IModelDelta.CHANGED | IModelDelta.CONTENT | IModelDelta.EXPAND);
+ }
+
+ protected void handleSuspendTimeout(DebugEvent event) {
+ IThread thread = removeSuspendedThread(event);
+ fireDeltaAndClearTopFrame(thread, IModelDelta.CHANGED | IModelDelta.CONTENT);
+ }
+
+ private IModelDeltaNode buildBaseDelta(ModelDelta delta, IThread thread) {
+ IModelDeltaNode node = delta.addNode(DebugPlugin.getDefault().getLaunchManager(), IModelDelta.NOCHANGE);
+ node = node.addNode(thread.getLaunch(), IModelDelta.NOCHANGE);
+ node = node.addNode(thread.getDebugTarget(), IModelDelta.NOCHANGE);
+ return node;
+ }
+
+ private void fireDeltaAndClearTopFrame(IThread thread, int flags) {
+ ModelDelta delta = new ModelDelta();
+ IModelDeltaNode node = buildBaseDelta(delta, thread);
+ node.addNode(thread, flags);
+ synchronized (fLastTopFrame) {
+ fLastTopFrame.remove(thread);
+ }
+ getModelProxy().fireModelChanged(delta);
+ }
+
+ private void fireDeltaUpdatingTopFrame(IThread thread, int flags) {
+ ModelDelta delta = new ModelDelta();
+ IModelDeltaNode node = buildBaseDelta(delta, thread);
+ IStackFrame prev = null;
+ synchronized (fLastTopFrame) {
+ prev = (IStackFrame) fLastTopFrame.get(thread);
+ }
+ IStackFrame frame = null;
+ try {
+ frame = thread.getTopStackFrame();
+ } catch (DebugException e) {
+ }
+ if (isEqual(frame, prev)) {
+ node = node.addNode(thread, flags | IModelDelta.NOCHANGE); // TODO: expand?
+ } else {
+ node = node.addNode(thread, flags | IModelDelta.CHANGED | IModelDelta.CONTENT | IModelDelta.EXPAND);
+ }
+ if (frame != null) {
+ node.addNode(frame, IModelDelta.CHANGED | IModelDelta.SELECT);
+ }
+ synchronized (fLastTopFrame) {
+ fLastTopFrame.put(thread, frame);
+ }
+ getModelProxy().fireModelChanged(delta);
+ }
+
+ protected boolean handlesEvent(DebugEvent event) {
+ return event.getSource() instanceof IThread;
+ }
+
+ protected IThread queueSuspendedThread(DebugEvent event) {
+ IThread thread = (IThread) event.getSource();
+ synchronized (fThreadQueue) {
+ fThreadQueue.add(thread);
+ }
+ return thread;
+ }
+
+ protected IThread removeSuspendedThread(DebugEvent event) {
+ IThread thread = (IThread)event.getSource();
+ synchronized (fThreadQueue) {
+ fThreadQueue.remove(thread);
+ }
+ return thread;
+ }
+
+ protected IThread getNextSuspendedThread() {
+ synchronized (fThreadQueue) {
+ if (!fThreadQueue.isEmpty()) {
+ return (IThread) fThreadQueue.iterator().next();
+ }
+ }
+ return null;
+ }
+
+}
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..fde9729ff
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/VariablesViewEventHandler.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * 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?)
+ }
+ }
+
+}
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
deleted file mode 100644
index deac03e1e..000000000
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/AbstractDebugEventHandler.java
+++ /dev/null
@@ -1,352 +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.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.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.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.ui.progress.UIJob;
-
-/**
- * Handles debug events, updating a view and viewer.
- */
-public abstract class AbstractDebugEventHandler implements IDebugEventSetListener {
-
- /**
- * This event handler's view
- */
- private AbstractDebugView fView;
-
- /**
- * Queued debug event sets (arrays of events) to process.
- */
- private List fEventSetQueue = new ArrayList();
-
- /**
- * Queued data associated with event sets. Entries may be <code>null</code>.
- */
- private List fDataQueue = new ArrayList();
-
- /**
- * Lock to add to/remove from data and event queues.
- */
- private Object LOCK = new Object();
-
- /**
- * Update job
- */
- private EventProcessingJob fUpdateJob = new EventProcessingJob();
-
- /**
- * Empty event set constant
- */
- protected static final DebugEvent[] EMPTY_EVENT_SET = new DebugEvent[0];
-
- private Object NULL = new Object();
-
- /**
- * Job to dispatch debug event sets
- */
- private class EventProcessingJob extends UIJob {
-
- private static final int TIMEOUT = 200;
-
- public EventProcessingJob() {
- super(DebugUIViewsMessages.AbstractDebugEventHandler_0);
- setSystem(true);
- setPriority(Job.INTERACTIVE);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor)
- */
- public IStatus runInUIThread(IProgressMonitor monitor) {
- boolean more = true;
- long start = System.currentTimeMillis();
- // to avoid blocking the UI thread, process a max of 50 event sets at once
- while (more) {
- DebugEvent[] eventSet = null;
- Object data = null;
- synchronized (LOCK) {
- if (fEventSetQueue.isEmpty()) {
- return Status.OK_STATUS;
- }
- eventSet = (DebugEvent[]) fEventSetQueue.remove(0);
- more = !fEventSetQueue.isEmpty();
- data = fDataQueue.remove(0);
- if (data == NULL) {
- data = null;
- }
- }
- if (isAvailable()) {
- if (isViewVisible()) {
- doHandleDebugEvents(eventSet, data);
- }
- updateForDebugEvents(eventSet, data);
- }
-
- if (more) {
- long current = System.currentTimeMillis();
- if (current - start > TIMEOUT) {
- break;
- }
- }
- }
- if (more) {
- // re-schedule with a delay if there are still events to process
- schedule(50);
- }
- return Status.OK_STATUS;
- }
-
- }
- /**
- * Constructs an event handler for the given view.
- *
- * @param view debug view
- */
- public AbstractDebugEventHandler(AbstractDebugView view) {
- setView(view);
- DebugPlugin plugin= DebugPlugin.getDefault();
- plugin.addDebugEventListener(this);
- }
-
- /**
- * @see IDebugEventSetListener#handleDebugEvents(DebugEvent[])
- */
- public void handleDebugEvents(DebugEvent[] events) {
- if (!isAvailable()) {
- return;
- }
- // filter events
- events = filterEvents(events);
- if (events.length == 0) {
- return;
- }
- synchronized (LOCK) {
- events = doPreprocessEvents(events);
- if (events.length == 0) {
- return;
- }
- // add the event set to the queue and schedule update
- fEventSetQueue.add(events);
- if (fDataQueue.size() < fEventSetQueue.size()) {
- fDataQueue.add(NULL);
- }
- }
- fUpdateJob.schedule();
- }
-
- protected void queueData(Object data) {
- synchronized (LOCK) {
- fDataQueue.add(data);
- }
- }
-
- protected DebugEvent[] doPreprocessEvents(DebugEvent[] events) {
- return events;
- }
-
- /**
- * Filters the given events before processing.
- *
- * @param events event set received for processing
- * @return events to be processed
- */
- protected DebugEvent[] filterEvents(DebugEvent[] events) {
- return events;
- }
-
- /**
- * Updates this view for the given debug events. Unlike
- * doHandleDebugEvents(DebugEvent[]) which is only called if the view is
- * visible, this method is always called. This allows the view to perform
- * updating that must always be performed, even when the view is not
- * visible.
- */
- protected void updateForDebugEvents(DebugEvent[] events, Object data) {
- }
-
- /**
- * Implementation specific handling of debug events.
- * Subclasses should override.
- */
- protected abstract void doHandleDebugEvents(DebugEvent[] events, Object data);
-
- /**
- * Helper method for inserting the given element - must be called in UI thread
- */
- 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);
- }
- }
- }
-
- /**
- * Helper method to remove the given element - must be called in UI thread.
- */
- protected void remove(Object element) {
- if (isAvailable()) {
- getView().showViewer();
- getTreeViewer().remove(element);
- }
- }
-
- /**
- * Helper method to update the label of the given element - must be called in UI thread
- */
- protected void labelChanged(Object element) {
- if (isAvailable()) {
- getView().showViewer();
- getTreeViewer().update(element, new String[] {IBasicPropertyConstants.P_TEXT});
- }
- }
-
- /**
- * Refresh the given element in the viewer - must be called in UI thread.
- */
- protected void refresh(Object element) {
- if (isAvailable()) {
- getView().showViewer();
- getTreeViewer().refresh(element);
- }
- }
-
- /**
- * Refresh the viewer - must be called in UI thread.
- */
- public void refresh() {
- if (isAvailable()) {
- getView().showViewer();
- getTreeViewer().refresh();
- }
- }
-
- /**
- * Helper method to select and reveal the given element - must be called in UI thread
- */
- protected void selectAndReveal(Object element) {
- if (isAvailable()) {
- getViewer().setSelection(new StructuredSelection(element), true);
- }
- }
-
- /**
- * De-registers this event handler from the debug model.
- */
- public void dispose() {
- DebugPlugin plugin= DebugPlugin.getDefault();
- plugin.removeDebugEventListener(this);
- synchronized (LOCK) {
- fEventSetQueue.clear();
- fDataQueue.clear();
- }
- }
-
- /**
- * Returns the view this event handler is
- * updating.
- *
- * @return debug view
- */
- protected AbstractDebugView getView() {
- return fView;
- }
-
- /**
- * Sets the view this event handler is updating.
- *
- * @param view debug view
- */
- private void setView(AbstractDebugView view) {
- fView = view;
- }
-
- /**
- * Returns the viewer this event handler is
- * updating.
- *
- * @return viewer
- */
- protected Viewer getViewer() {
- return getView().getViewer();
- }
-
- /**
- * Returns this event handler's viewer as a tree
- * viewer or <code>null</code> if none.
- *
- * @return this event handler's viewer as a tree
- * viewer or <code>null</code> if none
- */
- protected TreeViewer getTreeViewer() {
- if (getViewer() instanceof TreeViewer) {
- return (TreeViewer)getViewer();
- }
- return null;
- }
-
- /**
- * Returns whether this event handler's viewer is
- * currently available.
- *
- * @return whether this event handler's viewer is
- * currently available
- */
- protected boolean isAvailable() {
- return getView().isAvailable();
- }
-
- /**
- * Returns whether this event handler's view is currently visible.
- *
- * @return whether this event handler's view is currently visible
- */
- protected boolean isViewVisible() {
- return getView().isVisible();
- }
-
- /**
- * Called when this event handler's view becomes visible. Default behavior
- * is to refresh the view.
- */
- protected void viewBecomesVisible() {
- refresh();
- }
-
- /**
- * Called when this event handler's view becomes hidden. Default behavior is
- * to do nothing. Subclasses may override.
- */
- protected void viewBecomesHidden() {
- }
-}
-
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
deleted file mode 100644
index 8cb5f3991..000000000
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/AbstractDebugEventHandlerView.java
+++ /dev/null
@@ -1,78 +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 org.eclipse.debug.ui.AbstractDebugView;
-import org.eclipse.jface.action.IStatusLineManager;
-
-/**
- * A debug view that uses an event handler to update its
- * view/viewer.
- */
-public abstract class AbstractDebugEventHandlerView extends AbstractDebugView {
-
- /**
- * Event handler for this view
- */
- private AbstractDebugEventHandler fEventHandler;
-
- /**
- * Sets the event handler for this view
- *
- * @param eventHandler event handler
- */
- protected void setEventHandler(AbstractDebugEventHandler eventHandler) {
- fEventHandler = eventHandler;
- }
-
- /**
- * Returns the event handler for this view
- *
- * @return The event handler for this view
- */
- protected AbstractDebugEventHandler getEventHandler() {
- return fEventHandler;
- }
-
- /**
- * @see IWorkbenchPart#dispose()
- */
- public void dispose() {
- super.dispose();
- if (getEventHandler() != null) {
- getEventHandler().dispose();
- }
- }
-
- /**
- * @see org.eclipse.debug.ui.AbstractDebugView#becomesHidden()
- */
- protected void becomesHidden() {
- super.becomesHidden();
- getEventHandler().viewBecomesHidden();
- }
-
- /**
- * @see org.eclipse.debug.ui.AbstractDebugView#becomesVisible()
- */
- protected void becomesVisible() {
- super.becomesVisible();
- getEventHandler().viewBecomesVisible();
- }
-
- protected void clearStatusLine() {
- IStatusLineManager manager = getViewSite().getActionBars().getStatusLineManager();
- manager.setErrorMessage(null);
- manager.setMessage(null);
- }
-
-}
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/DebugUIViewsMessages.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/DebugUIViewsMessages.java
index cd741c553..7fe92b285 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/DebugUIViewsMessages.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/DebugUIViewsMessages.java
@@ -69,4 +69,6 @@ public class DebugUIViewsMessages extends NLS {
}
public static String InspectPopupDialog_0;
+
+ public static String InspectPopupDialog_1;
} \ No newline at end of file
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/DebugUIViewsMessages.properties b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/DebugUIViewsMessages.properties
index e83a1cf30..03afb7e28 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/DebugUIViewsMessages.properties
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/DebugUIViewsMessages.properties
@@ -58,3 +58,4 @@ WorkingSetCategory_0=\ (default)
RemoteTreeViewer_0=Restore Viewer State
RemoteTreeContentManager_0=Fetching children from debug target
InspectPopupDialog_0=Move to Expressions View
+InspectPopupDialog_1=Press {0} to {1}
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/breakpoints/BreakpointsViewer.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointsViewer.java
index 0e5fe4000..a697cef9d 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointsViewer.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointsViewer.java
@@ -142,11 +142,44 @@ public class BreakpointsViewer extends CheckboxTreeViewer {
* @param element
*/
public void updateCheckedState(Object element) {
- Widget widget = searchItem(element);
- if (widget != null) {
- updateCheckedState((TreeItem)widget);
+ Widget[] widgets = searchItems(element);
+ for (int i = 0; i < widgets.length; i++) {
+ Widget widget = widgets[i];
+ if (widget != null) {
+ updateCheckedState((TreeItem)widget);
+ }
}
}
+
+ /**
+ * finds all occurrences of a widget to update
+ * @param element the element to search for when finding occurrences
+ * @return a list of widget occurrences to update or an empty list
+ */
+ private Widget[] searchItems(Object element) {
+ ArrayList list = new ArrayList();
+ TreeItem[] items = getTree().getItems();
+ for (int i = 0; i < items.length; i++) {
+ findAllOccurrences(items[i], element, list);
+ }//end for
+ return (Widget[]) list.toArray(new Widget[0]);
+ }
+
+ /**
+ * performs the actual search for items in the tree
+ * @param list the list to add matches to
+ * @param item the item in the tree
+ * @param element the element to compare
+ */
+ private void findAllOccurrences(TreeItem item, Object element, ArrayList list) {
+ if (element.equals(item.getData())) {
+ list.add(item);
+ }//end if
+ TreeItem[] items = item.getItems();
+ for (int i = 0; i < items.length; i++) {
+ findAllOccurrences(items[i], element, list);
+ }
+ }
/**
* Update the checked state up the given element and all of its children.
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..a6caeba01 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.actions.selection.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..b28c65d4f 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.actions.context.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..850516a53 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
@@ -12,37 +12,21 @@ 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.AbstractViewerState;
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;
import org.eclipse.debug.ui.IDebugUIConstants;
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,61 +37,7 @@ 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.
- *
- * @return an event handler
- */
- protected VariablesViewEventHandler createEventHandler() {
- return new ExpressionViewEventHandler(this);
- }
+ private AbstractViewerState fState;
/**
* @see AbstractDebugView#getHelpContextId()
@@ -153,38 +83,10 @@ public class ExpressionView extends VariablesView {
menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
}
- /**
- * The <code>ExpressionView</code> listens for selection changes in the <code>LaunchesView</code>
- * to correctly set the editable state of the details pane. Updates the context of
- * watch expressions.
- *
- * @see ISelectionListener#selectionChanged(IWorkbenchPart, ISelection)
- */
- public void selectionChanged(IWorkbenchPart part, ISelection selection) {
+ public void contextActivated(ISelection selection, IWorkbenchPart part) {
if (!isVisible()) {
return;
}
- if (selection instanceof IStructuredSelection) {
- IDebugElement context = null;
- IStructuredSelection ss = (IStructuredSelection)selection;
- if (ss.size() < 2) {
- Object object = ss.getFirstElement();
- if (object instanceof IDebugElement) {
- context= (IDebugElement) object;
- } else if (object instanceof ILaunch) {
- context= ((ILaunch) object).getDebugTarget();
- }
- }
- // update watch expressions with new context
- IExpression[] expressions = DebugPlugin.getDefault().getExpressionManager().getExpressions();
- for (int i = 0; i < expressions.length; i++) {
- IExpression expression = expressions[i];
- if (expression instanceof IWatchExpression) {
- ((IWatchExpression)expression).setExpressionContext(context);
- }
- }
- }
-
// update actions
updateAction("ContentAssist"); //$NON-NLS-1$
}
@@ -195,7 +97,7 @@ public class ExpressionView extends VariablesView {
*
* @see VariablesView#setViewerInput(IStructuredSelection)
*/
- protected void setViewerInput(IStructuredSelection ssel) {
+ protected void setViewerInput(Object obj) {
}
/* (non-Javadoc)
@@ -243,10 +145,42 @@ public class ExpressionView extends VariablesView {
* @see org.eclipse.debug.internal.ui.views.variables.VariablesView#restoreState()
*/
protected void restoreState() {
+ if (fState != null) {
+ fState.restoreState(getVariablesViewer());
+ }
}
+
/* (non-Javadoc)
* @see org.eclipse.ui.IViewPart#saveState(org.eclipse.ui.IMemento)
*/
public void saveState(IMemento memento) {
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.views.variables.VariablesView#dispose()
+ */
+ public void dispose() {
+ super.dispose();
+ fState = null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.views.variables.VariablesView#becomesHidden()
+ */
+ protected void becomesHidden() {
+ fState = getViewerState();
+ super.becomesHidden();
+ getViewer().setInput(null);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.views.variables.VariablesView#becomesVisible()
+ */
+ protected void becomesVisible() {
+ super.becomesVisible();
+ setInitialContent();
+ restoreState();
+ }
+
+
}
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
deleted file mode 100644
index f87c70047..000000000
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionViewEventHandler.java
+++ /dev/null
@@ -1,180 +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 java.util.List;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.debug.core.DebugEvent;
-import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.IExpressionsListener;
-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.IExpression;
-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;
-
-/**
- * Updates the expression view
- */
-public class ExpressionViewEventHandler extends VariablesViewEventHandler implements IExpressionsListener {
-
- /**
- * Also update expressions if a target terminates
- *
- * @see org.eclipse.debug.internal.ui.views.variables.VariablesViewEventHandler#doHandleTerminateEvent(org.eclipse.debug.core.DebugEvent)
- */
- protected void doHandleTerminateEvent(DebugEvent event) {
- super.doHandleTerminateEvent(event);
- if (event.getSource() instanceof IDebugTarget) {
- IExpression[] expressions = DebugPlugin.getDefault().getExpressionManager().getExpressions();
- IAdaptable object = DebugUITools.getDebugContext();
- IDebugElement context= null;
- if (object instanceof IDebugElement) {
- context= (IDebugElement) object;
- } else if (object instanceof ILaunch) {
- context= ((ILaunch) object).getDebugTarget();
- }
- for (int i = 0; i < expressions.length; i++) {
- IExpression expression = expressions[i];
- if (expression instanceof IWatchExpression) {
- ((IWatchExpression)expression).setExpressionContext(context);
- }
- }
- }
- }
-
- /**
- * Constructs a new event handler on the given view
- *
- * @param view variables view
- */
- public ExpressionViewEventHandler(AbstractDebugView view) {
- super(view);
- DebugPlugin plugin= DebugPlugin.getDefault();
- plugin.getExpressionManager().addExpressionListener(this);
- }
-
- /**
- * De-registers this event handler from the debug model.
- */
- public void dispose() {
- DebugPlugin plugin= DebugPlugin.getDefault();
- plugin.getExpressionManager().removeExpressionListener(this);
- super.dispose();
- }
-
- /**
- * @see IExpressionsListener#expressionsAdded(IExpression[])
- */
- public void expressionsAdded(final IExpression[] expressions) {
- Runnable r = new Runnable() {
- public void run() {
- if (isAvailable()) {
- getTreeViewer().refresh();
- if (expressions.length > 0) {
- ISelection selection = new StructuredSelection(expressions[0]);
- getTreeViewer().setSelection(selection, true);
- }
- }
- }
- };
- getView().asyncExec(r);
- }
-
- /**
- * @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);
- }
-
- /**
- * @see IExpressionsListener#expressionsChanged(IExpression[])
- */
- public void expressionsChanged(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];
- refresh(expression);
- // update details if selected
- IStructuredSelection selection = (IStructuredSelection)getViewer().getSelection();
- if (selection.size() == 1 && selection.getFirstElement().equals(expression)) {
- getVariablesView().populateDetailPane();
- }
- }
- getTreeViewer().getControl().setRedraw(true);
- }
- }
- };
- getView().asyncExec(r);
- }
-
- /**
- * Override the superclass method. Do nothing.
- */
- protected void doHandleResumeEvent(DebugEvent event) {
- }
- /**
- * @see org.eclipse.debug.internal.ui.views.variables.VariablesViewEventHandler#doHandleChangeEvent(org.eclipse.debug.core.DebugEvent)
- */
- protected void doHandleChangeEvent(DebugEvent event) {
- if (event.getSource() instanceof IExpression) {
- refresh(event.getSource());
- getVariablesView().populateDetailPane();
- } else {
- super.doHandleChangeEvent(event);
- }
- }
-
- protected boolean isFiltered(DebugEvent event) {
- // TODO Auto-generated method stub
- return false;
- }
-
-
-
-}
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..f0bf6f2ee 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,26 @@ 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.update.DefaultModelProxyFactory;
+import org.eclipse.debug.internal.ui.viewers.update.DefaultSelectionPolicy;
+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 +50,23 @@ import org.eclipse.ui.progress.IDeferredWorkbenchAdapter;
* DebugElementAdapterFactory
*/
public class DebugElementAdapterFactory implements IAdapterFactory {
+
+ 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 +75,64 @@ 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;
+ return fgVariableLabelAdapter;
}
- if (adaptableObject instanceof IExpression) {
- return fgExpressionAdapter;
- }
- if (adaptableObject instanceof IRegisterGroup) {
- return fgRegisterGroupAdapter;
+ return fgDebugLabelAdapter;
+ }
+
+ if (adapterType.equals(IModelProxyFactory.class)) {
+ if (adaptableObject instanceof ILaunch || adaptableObject instanceof IDebugTarget ||
+ adaptableObject instanceof IProcess || adaptableObject instanceof ILaunchManager ||
+ adaptableObject instanceof IStackFrame || adaptableObject instanceof IExpressionManager ||
+ adaptableObject instanceof IExpression)
+ 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 +142,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,
+ 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 ((I