Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarin Wright2005-02-24 19:07:06 +0000
committerDarin Wright2005-02-24 19:07:06 +0000
commit5edcb0572bde3dae73081acc7dbb5d8b7aa25701 (patch)
treeced4f7f7134bea808727d4655472e4c0f6312332 /org.eclipse.debug.ui
parent669f6d871288f15c9a9925ba18700e9c02b3e821 (diff)
downloadeclipse.platform.debug-5edcb0572bde3dae73081acc7dbb5d8b7aa25701.tar.gz
eclipse.platform.debug-5edcb0572bde3dae73081acc7dbb5d8b7aa25701.tar.xz
eclipse.platform.debug-5edcb0572bde3dae73081acc7dbb5d8b7aa25701.zip
Bug 83464 - [API] Make RunToLineActionDelegate contributable to a view
Diffstat (limited to 'org.eclipse.debug.ui')
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RunToLineActionDelegate.java44
1 files changed, 31 insertions, 13 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RunToLineActionDelegate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RunToLineActionDelegate.java
index d1cecebd8..085860f2d 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RunToLineActionDelegate.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RunToLineActionDelegate.java
@@ -28,22 +28,24 @@ import org.eclipse.ui.IActionDelegate2;
import org.eclipse.ui.IEditorActionDelegate;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.ISelectionListener;
+import org.eclipse.ui.IViewActionDelegate;
+import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchPartSite;
/**
- * A run to line action that can be contributed to a an editor. The action
- * will perform the "run to line" operation for editors that provide
+ * A run to line action that can be contributed to a an editor or view. The action
+ * will perform the "run to line" operation for parts that provide
* an appropriate <code>IRunToLineTarget</code> adapter.
* <p>
- * Clients may reference/contribute this class as an editor action delegate
+ * Clients may reference/contribute this class as an action delegate
* in plug-in XML. This class is not intended to be subclassed.
* </p>
* @since 3.0
*/
-public class RunToLineActionDelegate implements IEditorActionDelegate, IActionDelegate2 {
+public class RunToLineActionDelegate implements IEditorActionDelegate, IActionDelegate2, IViewActionDelegate {
- private IEditorPart fActivePart = null;
+ private IWorkbenchPart fActivePart = null;
private IRunToLineTarget fPartTarget = null;
private IAction fAction = null;
private ISelectionListener fSelectionListener = new DebugSelectionListener();
@@ -142,22 +144,38 @@ public class RunToLineActionDelegate implements IEditorActionDelegate, IActionDe
*/
public void setActiveEditor(IAction action, IEditorPart targetEditor) {
init(action);
- if (fActivePart != null && !fActivePart.equals(targetEditor)) {
+ bindTo(targetEditor);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart)
+ */
+ public void init(IViewPart view) {
+ bindTo(view);
+ }
+
+ /**
+ * Binds this action to operate on the given part's run to line adapter.
+ *
+ * @param part
+ */
+ private void bindTo(IWorkbenchPart part) {
+ if (fActivePart != null && !fActivePart.equals(part)) {
fActivePart.getSite().getWorkbenchWindow().getSelectionService().removeSelectionListener(IDebugUIConstants.ID_DEBUG_VIEW, fSelectionListener);
}
fPartTarget = null;
- fActivePart = targetEditor;
- if (targetEditor != null) {
- targetEditor.getSite().getWorkbenchWindow().getSelectionService().addSelectionListener(IDebugUIConstants.ID_DEBUG_VIEW, fSelectionListener);
- fPartTarget = (IRunToLineTarget) targetEditor.getAdapter(IRunToLineTarget.class);
+ fActivePart = part;
+ if (part != null) {
+ part.getSite().getWorkbenchWindow().getSelectionService().addSelectionListener(IDebugUIConstants.ID_DEBUG_VIEW, fSelectionListener);
+ fPartTarget = (IRunToLineTarget) part.getAdapter(IRunToLineTarget.class);
if (fPartTarget == null) {
IAdapterManager adapterManager = Platform.getAdapterManager();
// TODO: we could restrict loading to cases when the debugging context is on
- if (adapterManager.hasAdapter(targetEditor, IRunToLineTarget.class.getName())) {
- fPartTarget = (IRunToLineTarget) adapterManager.loadAdapter(targetEditor, IRunToLineTarget.class.getName());
+ if (adapterManager.hasAdapter(part, IRunToLineTarget.class.getName())) {
+ fPartTarget = (IRunToLineTarget) adapterManager.loadAdapter(part, IRunToLineTarget.class.getName());
}
}
}
- update();
+ update();
}
}

Back to the top