Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.debug.ui/icons/full/obj16/readwrite_obj.gifbin0 -> 231 bytes
-rw-r--r--org.eclipse.debug.ui/icons/full/obj16/readwrite_obj_disabled.gifbin0 -> 135 bytes
-rw-r--r--org.eclipse.debug.ui/plugin.properties2
-rw-r--r--org.eclipse.debug.ui/plugin.xml44
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/IToggleBreakpointsTarget.java47
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RetargetAction.java40
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RetargetMethodBreakpointAction.java37
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RetargetWatchpointAction.java37
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RunToLineActionDelegate.java63
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ToggleBreakpointObjectActionDelegate.java121
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ToggleMethodBreakpointObjectActionDelegate.java29
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ToggleWatchpointObjectActionDelegate.java29
12 files changed, 399 insertions, 50 deletions
diff --git a/org.eclipse.debug.ui/icons/full/obj16/readwrite_obj.gif b/org.eclipse.debug.ui/icons/full/obj16/readwrite_obj.gif
new file mode 100644
index 000000000..0b1184d72
--- /dev/null
+++ b/org.eclipse.debug.ui/icons/full/obj16/readwrite_obj.gif
Binary files differ
diff --git a/org.eclipse.debug.ui/icons/full/obj16/readwrite_obj_disabled.gif b/org.eclipse.debug.ui/icons/full/obj16/readwrite_obj_disabled.gif
new file mode 100644
index 000000000..8eba2e1c2
--- /dev/null
+++ b/org.eclipse.debug.ui/icons/full/obj16/readwrite_obj_disabled.gif
Binary files differ
diff --git a/org.eclipse.debug.ui/plugin.properties b/org.eclipse.debug.ui/plugin.properties
index 86079ab59..83ff10c25 100644
--- a/org.eclipse.debug.ui/plugin.properties
+++ b/org.eclipse.debug.ui/plugin.properties
@@ -106,6 +106,8 @@ TerminateAction.tooltip=Terminate
TerminateAllAction.label=Termi&nate All
TerminateAndRemoveAction.label=Terminate and Remo&ve
ToggleBreakpointAction.label=Toggle Line Brea&kpoint
+ToggleMethodBreakpointAction.label=Toggle &Method Breakpoint
+ToggleWatchpointAction.label=Toggle &Watchpoint
VariablesView.name=Variables
StringVariablePreferencePage.name=String Substitution
diff --git a/org.eclipse.debug.ui/plugin.xml b/org.eclipse.debug.ui/plugin.xml
index e15359285..694c9e38c 100644
--- a/org.eclipse.debug.ui/plugin.xml
+++ b/org.eclipse.debug.ui/plugin.xml
@@ -387,6 +387,26 @@
</groupMarker>
</menu>
<action
+ definitionId="org.eclipse.debug.ui.commands.ToggleWatchpoint"
+ label="%ToggleWatchpointAction.label"
+ icon="icons/full/obj16/readwrite_obj.gif"
+ disabledIcon="icons/full/obj16/readwrite_obj_disabled.gif"
+ helpContextId="toggle_watchpoint_action_context"
+ class="org.eclipse.debug.internal.ui.actions.RetargetWatchpointAction"
+ menubarPath="org.eclipse.ui.run/breakpointGroup"
+ id="org.eclipse.debug.ui.actions.ToggleWatchpoint">
+ </action>
+ <action
+ definitionId="org.eclipse.debug.ui.commands.ToggleMethodBreakpoint"
+ label="%ToggleMethodBreakpointAction.label"
+ icon="icons/full/obj16/brkp_obj.gif"
+ disabledIcon="icons/full/obj16/brkpd_obj.gif"
+ helpContextId="toggle_method_breakpoint_action_context"
+ class="org.eclipse.debug.internal.ui.actions.RetargetMethodBreakpointAction"
+ menubarPath="org.eclipse.ui.run/breakpointGroup"
+ id="org.eclipse.debug.ui.actions.ToggleMethodBreakpoint">
+ </action>
+ <action
definitionId="org.eclipse.debug.ui.commands.ToggleBreakpoint"
label="%ToggleBreakpointAction.label"
icon="icons/full/obj16/brkp_obj.gif"
@@ -1408,6 +1428,30 @@
scope="org.eclipse.ui.globalScope"
command="org.eclipse.debug.ui.commands.ToggleBreakpoint"
configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
+ </keyBinding>
+ <command
+ name="%ActionDefinition.toggleWatchpoint.name"
+ description="%ActionDefinition.toggleWatchpoint.description"
+ category="org.eclipse.debug.ui.category.run"
+ id="org.eclipse.debug.ui.commands.ToggleWatchpoint">
+ </command>
+ <keyBinding
+ string=""
+ scope="org.eclipse.ui.globalScope"
+ command="org.eclipse.debug.ui.commands.ToggleWatchpoint"
+ configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
+ </keyBinding>
+ <command
+ name="%ActionDefinition.toggleMethodBreakpoint.name"
+ description="%ActionDefinition.toggleMethodBreakpoint.description"
+ category="org.eclipse.debug.ui.category.run"
+ id="org.eclipse.debug.ui.commands.ToggleMethodBreakpoint">
+ </command>
+ <keyBinding
+ string=""
+ scope="org.eclipse.ui.globalScope"
+ command="org.eclipse.debug.ui.commands.ToggleMethodBreakpoint"
+ configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
</keyBinding>
</extension>
<extension
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/IToggleBreakpointsTarget.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/IToggleBreakpointsTarget.java
index 4bc8b502f..39c30ba8d 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/IToggleBreakpointsTarget.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/IToggleBreakpointsTarget.java
@@ -63,5 +63,52 @@ public interface IToggleBreakpointsTarget {
* @return whether line breakpoints can be toggled on the given selection
*/
public boolean canToggleLineBreakpoints(IWorkbenchPart part, ISelection selection);
+
+ /**
+ * Creates new method breakpoints or removes existing breakpoints.
+ * The selection varies depending on the given part. For example,
+ * a text selection is provided for text editors, and a structured
+ * selection is provided for tree views, and may be a multi-selection.
+ *
+ * @param part the part on which the action has been invoked
+ * @param selection selection on which method breakpoints should be toggled
+ * @throws CoreException if unable to perform the action
+ */
+ public void toggleMethodBreakpoints(IWorkbenchPart part, ISelection selection) throws CoreException;
+
+ /**
+ * Returns whether method breakpoints can be toggled on the given selection.
+ * The selection varies depending on the given part. For example,
+ * a text selection is provided for text editors, and a structured
+ * selection is provided for tree views, and may be a multi-selection.
+ *
+ * @param part the part on which the action has been invoked
+ * @param selection selection on which method breakpoints may be toggled
+ * @return whether method breakpoints can be toggled on the given selection
+ */
+ public boolean canToggleMethodBreakpoints(IWorkbenchPart part, ISelection selection);
+ /**
+ * Creates new watchpoints or removes existing breakpoints.
+ * The selection varies depending on the given part. For example,
+ * a text selection is provided for text editors, and a structured
+ * selection is provided for tree views, and may be a multi-selection.
+ *
+ * @param part the part on which the action has been invoked
+ * @param selection selection on which watchpoints should be toggled
+ * @throws CoreException if unable to perform the action
+ */
+ public void toggleWatchpoints(IWorkbenchPart part, ISelection selection) throws CoreException;
+
+ /**
+ * Returns whether watchpoints can be toggled on the given selection.
+ * The selection varies depending on the given part. For example,
+ * a text selection is provided for text editors, and a structured
+ * selection is provided for tree views, and may be a multi-selection.
+ *
+ * @param part the part on which the action has been invoked
+ * @param selection selection on which watchpoints may be toggled
+ * @return whether watchpoints can be toggled on the given selection
+ */
+ public boolean canToggleWatchpoints(IWorkbenchPart part, ISelection selection);
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RetargetAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RetargetAction.java
index 7c1e9cdbf..593e4ba60 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RetargetAction.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RetargetAction.java
@@ -11,12 +11,14 @@
package org.eclipse.debug.internal.ui.actions;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IAdapterManager;
import org.eclipse.core.runtime.Platform;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IPartListener;
import org.eclipse.ui.IPartService;
import org.eclipse.ui.IWorkbenchPart;
@@ -33,7 +35,7 @@ public abstract class RetargetAction implements IWorkbenchWindowActionDelegate,
protected IWorkbenchWindow window = null;
private IWorkbenchPart activePart = null;
- private Object partTarget = null;
+ private Object targetAdapter = null;
private IAction action = null;
private static final ISelection EMPTY_SELECTION = new EmptySelection();
@@ -70,7 +72,7 @@ public abstract class RetargetAction implements IWorkbenchWindowActionDelegate,
public void dispose() {
window.getPartService().removePartListener(this);
activePart = null;
- partTarget = null;
+ targetAdapter = null;
}
/* (non-Javadoc)
@@ -89,9 +91,9 @@ public abstract class RetargetAction implements IWorkbenchWindowActionDelegate,
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
*/
public void run(IAction action) {
- if (partTarget != null) {
+ if (targetAdapter != null) {
try {
- performAction(partTarget, getTargetSelection(), activePart);
+ performAction(targetAdapter, getTargetSelection(), activePart);
} catch (CoreException e) {
DebugUIPlugin.errorDialog(window.getShell(), ActionMessages.getString("RetargetAction.2"), ActionMessages.getString("RetargetAction.3"), e.getStatus()); //$NON-NLS-1$ //$NON-NLS-2$
}
@@ -112,6 +114,16 @@ public abstract class RetargetAction implements IWorkbenchWindowActionDelegate,
*/
public void selectionChanged(IAction action, ISelection selection) {
this.action = action;
+ // if the active part did not provide an adapter, see if the selectoin does
+ if (targetAdapter == null && selection instanceof IStructuredSelection) {
+ IStructuredSelection ss = (IStructuredSelection) selection;
+ if (!ss.isEmpty()) {
+ Object object = ss.getFirstElement();
+ if (object instanceof IAdaptable) {
+ targetAdapter = getAdapter((IAdaptable) object);
+ }
+ }
+ }
update();
}
@@ -120,16 +132,20 @@ public abstract class RetargetAction implements IWorkbenchWindowActionDelegate,
*/
public void partActivated(IWorkbenchPart part) {
activePart = part;
- partTarget = null;
- partTarget = part.getAdapter(getAdapterClass());
- if (partTarget == null) {
+ targetAdapter = getAdapter(part);
+ update();
+ }
+
+ protected Object getAdapter(IAdaptable adaptable) {
+ Object adapter = adaptable.getAdapter(getAdapterClass());
+ if (adapter == null) {
IAdapterManager adapterManager = Platform.getAdapterManager();
// TODO: we could restrict loading to cases when the debugging context is on
- if (adapterManager.hasAdapter(part, getAdapterClass().getName())) { //$NON-NLS-1$
- partTarget = adapterManager.loadAdapter(part, getAdapterClass().getName()); //$NON-NLS-1$
+ if (adapterManager.hasAdapter(adaptable, getAdapterClass().getName())) { //$NON-NLS-1$
+ targetAdapter = adapterManager.loadAdapter(adaptable, getAdapterClass().getName()); //$NON-NLS-1$
}
}
- update();
+ return adapter;
}
/**
@@ -166,8 +182,8 @@ public abstract class RetargetAction implements IWorkbenchWindowActionDelegate,
if (action == null) {
return;
}
- if (partTarget != null) {
- action.setEnabled(canPerformAction(partTarget, getTargetSelection(), activePart));
+ if (targetAdapter != null) {
+ action.setEnabled(canPerformAction(targetAdapter, getTargetSelection(), activePart));
} else {
action.setEnabled(false);
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RetargetMethodBreakpointAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RetargetMethodBreakpointAction.java
new file mode 100644
index 000000000..1003d82fd
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RetargetMethodBreakpointAction.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.actions;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.IWorkbenchPart;
+
+
+/**
+ * Global retargettable toggle method breakpoint action.
+ *
+ * @since 3.0
+ */
+public class RetargetMethodBreakpointAction extends RetargetBreakpointAction {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.actions.RetargetBreakpointAction#performAction(java.lang.Object, org.eclipse.jface.viewers.ISelection, org.eclipse.ui.IWorkbenchPart)
+ */
+ protected void performAction(Object target, ISelection selection, IWorkbenchPart part) throws CoreException {
+ ((IToggleBreakpointsTarget)target).toggleMethodBreakpoints(part, selection);
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.actions.RetargetBreakpointAction#canPerformAction(java.lang.Object, org.eclipse.jface.viewers.ISelection, org.eclipse.ui.IWorkbenchPart)
+ */
+ protected boolean canPerformAction(Object target, ISelection selection, IWorkbenchPart part) {
+ return ((IToggleBreakpointsTarget)target).canToggleMethodBreakpoints(part, selection);
+ }
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RetargetWatchpointAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RetargetWatchpointAction.java
new file mode 100644
index 000000000..97c09e82a
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RetargetWatchpointAction.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.actions;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.IWorkbenchPart;
+
+
+/**
+ * Global retargettable toggle watchpoint action.
+ *
+ * @since 3.0
+ */
+public class RetargetWatchpointAction extends RetargetBreakpointAction {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.actions.RetargetBreakpointAction#performAction(java.lang.Object, org.eclipse.jface.viewers.ISelection, org.eclipse.ui.IWorkbenchPart)
+ */
+ protected void performAction(Object target, ISelection selection, IWorkbenchPart part) throws CoreException {
+ ((IToggleBreakpointsTarget)target).toggleWatchpoints(part, selection);
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.actions.RetargetBreakpointAction#canPerformAction(java.lang.Object, org.eclipse.jface.viewers.ISelection, org.eclipse.ui.IWorkbenchPart)
+ */
+ protected boolean canPerformAction(Object target, ISelection selection, IWorkbenchPart part) {
+ return ((IToggleBreakpointsTarget)target).canToggleWatchpoints(part, selection);
+ }
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RunToLineActionDelegate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RunToLineActionDelegate.java
index 021451c26..256f0db18 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RunToLineActionDelegate.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RunToLineActionDelegate.java
@@ -25,24 +25,23 @@ 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;
/**
- * A run to line action that can be contributed to a view or editor. The action
- * will perform the 'run to line' operation for views that provide
+ * 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
* an appropriate 'run to line' adapter (<code>IRunToLineTarget</code>).
* <p>
* EXPERIMENTAL
* </p>
* <p>
- * Clients may instantiate this class. This class is not intended to
+ * Clients may instantiate this class, or contribute it as an editor
+ * action delegate in plug-in XML. This class is not intended to
* be subclassed.
* </p>
* @since 3.0
*/
-public class RunToLineActionDelegate implements IViewActionDelegate, IEditorActionDelegate, IActionDelegate2 {
+public class RunToLineActionDelegate implements IEditorActionDelegate, IActionDelegate2 {
private IWorkbenchPart activePart = null;
private IRunToLineTarget partTarget = null;
@@ -71,8 +70,8 @@ public class RunToLineActionDelegate implements IViewActionDelegate, IEditorActi
}
- /* (non-Javadoc)
- * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose()
+ /*(non-Javadoc)
+ * @see org.eclipse.ui.IActionDelegate2#dispose()
*/
public void dispose() {
activePart.getSite().getWorkbenchWindow().getSelectionService().removeSelectionListener(IDebugUIConstants.ID_DEBUG_VIEW, selectionListener);
@@ -101,11 +100,6 @@ public class RunToLineActionDelegate implements IViewActionDelegate, IEditorActi
}
/* (non-Javadoc)
- * @see org.eclipse.ui.IPartListener#partOpened(org.eclipse.ui.IWorkbenchPart)
- */
- public void partOpened(IWorkbenchPart part) {
- }
- /* (non-Javadoc)
* @see org.eclipse.ui.texteditor.IUpdate#update()
*/
public void update() {
@@ -118,30 +112,7 @@ public class RunToLineActionDelegate implements IViewActionDelegate, IEditorActi
action.setEnabled(false);
}
}
- /* (non-Javadoc)
- * @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart)
- */
- public void init(IViewPart view) {
- init((IWorkbenchPart)view);
- }
-
- protected void init(IWorkbenchPart view) {
- partTarget = null;
- activePart = view;
- if (view != null) {
- view.getSite().getWorkbenchWindow().getSelectionService().addSelectionListener(IDebugUIConstants.ID_DEBUG_VIEW, selectionListener);
- partTarget = (IRunToLineTarget) view.getAdapter(IRunToLineTarget.class);
- if (partTarget == null) {
- IAdapterManager adapterManager = Platform.getAdapterManager();
- // TODO: we could restrict loading to cases when the debugging context is on
- if (adapterManager.hasAdapter(view, "org.eclipse.debug.internal.ui.actions.IRunToLineTarget")) { //$NON-NLS-1$
- partTarget = (IRunToLineTarget) adapterManager.loadAdapter(view, "org.eclipse.debug.internal.ui.actions.IRunToLineTarget"); //$NON-NLS-1$
- }
- }
- }
- update();
- }
-
+
/* (non-Javadoc)
* @see org.eclipse.ui.IActionDelegate2#init(org.eclipse.jface.action.IAction)
*/
@@ -164,6 +135,22 @@ public class RunToLineActionDelegate implements IViewActionDelegate, IEditorActi
*/
public void setActiveEditor(IAction action, IEditorPart targetEditor) {
init(action);
- init(targetEditor);
+ if (activePart != null && !activePart.equals(targetEditor)) {
+ activePart.getSite().getWorkbenchWindow().getSelectionService().removeSelectionListener(IDebugUIConstants.ID_DEBUG_VIEW, selectionListener);
+ }
+ partTarget = null;
+ activePart = targetEditor;
+ if (targetEditor != null) {
+ targetEditor.getSite().getWorkbenchWindow().getSelectionService().addSelectionListener(IDebugUIConstants.ID_DEBUG_VIEW, selectionListener);
+ partTarget = (IRunToLineTarget) targetEditor.getAdapter(IRunToLineTarget.class);
+ if (partTarget == null) {
+ IAdapterManager adapterManager = Platform.getAdapterManager();
+ // TODO: we could restrict loading to cases when the debugging context is on
+ if (adapterManager.hasAdapter(targetEditor, "org.eclipse.debug.internal.ui.actions.IRunToLineTarget")) { //$NON-NLS-1$
+ partTarget = (IRunToLineTarget) adapterManager.loadAdapter(targetEditor, "org.eclipse.debug.internal.ui.actions.IRunToLineTarget"); //$NON-NLS-1$
+ }
+ }
+ }
+ update();
}
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ToggleBreakpointObjectActionDelegate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ToggleBreakpointObjectActionDelegate.java
new file mode 100644
index 000000000..d807b7242
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ToggleBreakpointObjectActionDelegate.java
@@ -0,0 +1,121 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.actions;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IAdapterManager;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.ui.IActionDelegate2;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+
+/**
+ * A toggle breakpoint action that can be contributed to an object. The action
+ * will perform a toggle breakpoint operation for a selected object.
+ * <p>
+ * EXPERIMENTAL
+ * </p>
+ * <p>
+ * Clients may subclass this class.
+ * </p>
+ * @since 3.0
+ */
+public abstract class ToggleBreakpointObjectActionDelegate implements IObjectActionDelegate, IActionDelegate2 {
+
+ private IWorkbenchPart part;
+ private IStructuredSelection selection;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction, org.eclipse.ui.IWorkbenchPart)
+ */
+ public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+ part = targetPart;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
+ */
+ public void run(IAction action) {
+ IAdaptable adaptable = (IAdaptable) selection.getFirstElement();
+ IToggleBreakpointsTarget target = (IToggleBreakpointsTarget) adaptable.getAdapter(IToggleBreakpointsTarget.class);
+ if (target == null) {
+ IAdapterManager adapterManager = Platform.getAdapterManager();
+ target = (IToggleBreakpointsTarget) adapterManager.loadAdapter(adaptable, IToggleBreakpointsTarget.class.getName());
+ }
+ if (target != null) {
+ try {
+ performAction(target, part, selection);
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+
+ /**
+ * Performs the operation specific to this action.
+ *
+ * @param target adapter to toggle breakpoints
+ * @param part the active part
+ * @param selection the seleciton in the active part
+ * @exception CoreException if an exception occurrs
+ */
+ protected abstract void performAction(IToggleBreakpointsTarget target, IWorkbenchPart part, ISelection selection) throws CoreException;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
+ */
+ public void selectionChanged(IAction action, ISelection selection) {
+ boolean enabled = false;
+ if (selection instanceof IStructuredSelection) {
+ IStructuredSelection ss = (IStructuredSelection) selection;
+ this.selection = ss;
+ if (!ss.isEmpty()) {
+ Object object = ss.getFirstElement();
+ if (object instanceof IAdaptable) {
+ IAdaptable adaptable = (IAdaptable) object;
+ IToggleBreakpointsTarget target = (IToggleBreakpointsTarget) adaptable.getAdapter(IToggleBreakpointsTarget.class);
+ if (target == null) {
+ IAdapterManager adapterManager = Platform.getAdapterManager();
+ enabled = adapterManager.hasAdapter(adaptable, IToggleBreakpointsTarget.class.getName());
+ } else {
+ enabled = true;
+ }
+ }
+ }
+ }
+ action.setEnabled(enabled);
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IActionDelegate2#init(org.eclipse.jface.action.IAction)
+ */
+ public void init(IAction action) {
+ // TODO Auto-generated method stub
+
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IActionDelegate2#dispose()
+ */
+ public void dispose() {
+ selection = null;
+ part = null;
+ }
+ /* (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);
+ }
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ToggleMethodBreakpointObjectActionDelegate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ToggleMethodBreakpointObjectActionDelegate.java
new file mode 100644
index 000000000..38ddc58ba
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ToggleMethodBreakpointObjectActionDelegate.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.actions;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.IWorkbenchPart;
+
+/**
+ * Action to toggle method breakpoints.
+ *
+ * @since 3.0
+ */
+public class ToggleMethodBreakpointObjectActionDelegate extends ToggleBreakpointObjectActionDelegate {
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.actions.ToggleBreakpointObjectActionDelegate#performAction(org.eclipse.debug.internal.ui.actions.IToggleBreakpointsTarget, org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
+ */
+ protected void performAction(IToggleBreakpointsTarget target, IWorkbenchPart part, ISelection selection) throws CoreException {
+ target.toggleMethodBreakpoints(part, selection);
+ }
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ToggleWatchpointObjectActionDelegate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ToggleWatchpointObjectActionDelegate.java
new file mode 100644
index 000000000..61e77892b
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ToggleWatchpointObjectActionDelegate.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.actions;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.IWorkbenchPart;
+
+/**
+ * Action to toggle watchpoints.
+ *
+ * @since 3.0
+ */
+public class ToggleWatchpointObjectActionDelegate extends ToggleBreakpointObjectActionDelegate {
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.actions.ToggleBreakpointObjectActionDelegate#performAction(org.eclipse.debug.internal.ui.actions.IToggleBreakpointsTarget, org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
+ */
+ protected void performAction(IToggleBreakpointsTarget target, IWorkbenchPart part, ISelection selection) throws CoreException {
+ target.toggleWatchpoints(part, selection);
+ }
+}

Back to the top