diff options
author | Mike Rennie | 2012-02-16 18:14:42 +0000 |
---|---|---|
committer | Mike Rennie | 2012-02-16 18:14:42 +0000 |
commit | d8f49676d0842da03089b2ab50c237f16c66f1e4 (patch) | |
tree | 356764c8d893001ffd769161df17eae7739ba891 | |
parent | d1d5476fcc2cadd0ee6ff5e5f235f0a8df842287 (diff) | |
download | eclipse.platform.debug-d8f49676d0842da03089b2ab50c237f16c66f1e4.tar.gz eclipse.platform.debug-d8f49676d0842da03089b2ab50c237f16c66f1e4.tar.xz eclipse.platform.debug-d8f49676d0842da03089b2ab50c237f16c66f1e4.zip |
Bug 346615 - Simple way to disable breakpoint and access breakpoint
properties
3 files changed, 116 insertions, 37 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/IToggleBreakpointsTargetExtension2.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/IToggleBreakpointsTargetExtension2.java new file mode 100644 index 000000000..6bec4561c --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/IToggleBreakpointsTargetExtension2.java @@ -0,0 +1,57 @@ +/******************************************************************************* + * Copyright (c) 2012 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.ui.actions; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.swt.widgets.Event; +import org.eclipse.ui.IWorkbenchPart; + +/** + * Extension interface for {@link org.eclipse.debug.ui.actions.IToggleBreakpointsTargetExtension}. + * This interface provides the ability to inspect the key modifiers + * being used when toggling a breakpoint. This allows targets to choose the type of breakpoint to create + * when the user double-clicks in the vertical ruler. + * <p> + * Clients implementing <code>IToggleBreakpointsTarget</code> or <code>IToggleBreakpointsTargetExtension</code> may optionally + * implement this interface. + * </p> + * @since 3.8 + * @see org.eclipse.debug.ui.actions.ToggleBreakpointAction + */ +public interface IToggleBreakpointsTargetExtension2 extends IToggleBreakpointsTargetExtension { + + /** + * Creates or removes existing breakpoints based on any modifiers in the given {@link Event}. + * 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 line breakpoints should be toggled + * @param event the key event from the double-click in the editor gutter + * @throws CoreException if unable to perform the action + */ + public void toggleBreakpointsWithEvent(IWorkbenchPart part, ISelection selection, Event event) throws CoreException; + + /** + * Returns whether breakpoints can be toggled on the given selection with the given {@link Event}. + * 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 line breakpoints should be toggled + * @param event the key event from the double-click in the editor gutter + * @return whether breakpoints can be toggled on the given selection with the given modifiers + */ + public boolean canToggleBreakpointsWithEvent(IWorkbenchPart part, ISelection selection, Event event); +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RulerToggleBreakpointActionDelegate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RulerToggleBreakpointActionDelegate.java index 54380ed3a..ff93f5af1 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RulerToggleBreakpointActionDelegate.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RulerToggleBreakpointActionDelegate.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2008 IBM Corporation and others. + * Copyright (c) 2005, 2012 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 @@ -119,6 +119,8 @@ public class RulerToggleBreakpointActionDelegate extends AbstractRulerActionDele * @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); + if(fDelegate != null) { + fDelegate.runWithEvent(event); + } } } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ToggleBreakpointAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ToggleBreakpointAction.java index d67ffa51f..4d850119f 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ToggleBreakpointAction.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ToggleBreakpointAction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2009 IBM Corporation and others. + * Copyright (c) 2005, 2012 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 @@ -25,6 +25,7 @@ import org.eclipse.jface.text.TextSelection; import org.eclipse.jface.text.source.IVerticalRulerInfo; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionProvider; +import org.eclipse.swt.widgets.Event; import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.texteditor.IDocumentProvider; import org.eclipse.ui.texteditor.ITextEditor; @@ -71,48 +72,67 @@ public class ToggleBreakpointAction extends Action implements IUpdate { fRulerInfo = rulerInfo; ToggleBreakpointsTargetManager.getDefault().addChangedListener(fListener); } + /* * (non-Javadoc) * @see org.eclipse.jface.action.IAction#run() */ public void run() { + doIt(null); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.action.Action#runWithEvent(org.eclipse.swt.widgets.Event) + */ + public void runWithEvent(Event event) { + doIt(event); + } + + /** + * Delegate method to perform the toggling + * @param event the event, possibly <code>null</code> + * + * @since 3.8 + */ + void doIt(Event event) { IDocument document= getDocument(); - if (document == null) { - return; - } - - int line = fRulerInfo.getLineOfLastMouseButtonActivity(); - - // Test if line is valid - if (line == -1) - return; - - try { - ITextSelection selection = getTextSelection(document, line); - IToggleBreakpointsTarget toggleTarget = - ToggleBreakpointsTargetManager.getDefault().getToggleBreakpointsTarget(fPart, selection); - if (toggleTarget == null) { - return; - } - - if (toggleTarget instanceof IToggleBreakpointsTargetExtension) { - IToggleBreakpointsTargetExtension extension = (IToggleBreakpointsTargetExtension) toggleTarget; - if (extension.canToggleBreakpoints(fPart, selection)) { - extension.toggleBreakpoints(fPart, selection); - return; + if (document != null) { + int line = fRulerInfo.getLineOfLastMouseButtonActivity(); + if(line > -1) { + try { + ITextSelection selection = getTextSelection(document, line); + IToggleBreakpointsTarget target = ToggleBreakpointsTargetManager.getDefault().getToggleBreakpointsTarget(fPart, selection); + if (target != null) { + if(target instanceof IToggleBreakpointsTargetExtension2) { + IToggleBreakpointsTargetExtension2 ext = (IToggleBreakpointsTargetExtension2) target; + if(ext.canToggleBreakpointsWithEvent(fPart, selection, event)) { + ext.toggleBreakpointsWithEvent(fPart, selection, event); + return; + } + } + if (target instanceof IToggleBreakpointsTargetExtension) { + IToggleBreakpointsTargetExtension extension = (IToggleBreakpointsTargetExtension) target; + if (extension.canToggleBreakpoints(fPart, selection)) { + extension.toggleBreakpoints(fPart, selection); + return; + } + } + if (target.canToggleLineBreakpoints(fPart, selection)) { + target.toggleLineBreakpoints(fPart, selection); + } else if (target.canToggleWatchpoints(fPart, selection)) { + target.toggleWatchpoints(fPart, selection); + } else if (target.canToggleMethodBreakpoints(fPart, selection)) { + target.toggleMethodBreakpoints(fPart, selection); + } + } + } + catch(BadLocationException ble) { + reportException(ble); + } + catch(CoreException ce) { + reportException(ce); } } - if (toggleTarget.canToggleLineBreakpoints(fPart, selection)) { - toggleTarget.toggleLineBreakpoints(fPart, selection); - } else if (toggleTarget.canToggleWatchpoints(fPart, selection)) { - toggleTarget.toggleWatchpoints(fPart, selection); - } else if (toggleTarget.canToggleMethodBreakpoints(fPart, selection)) { - toggleTarget.toggleMethodBreakpoints(fPart, selection); - } - } catch (BadLocationException e) { - reportException(e); - } catch (CoreException e) { - reportException(e); } } |