diff options
Diffstat (limited to 'dsf/org.eclipse.cdt.dsf.ui')
10 files changed, 412 insertions, 15 deletions
diff --git a/dsf/org.eclipse.cdt.dsf.ui/plugin.properties b/dsf/org.eclipse.cdt.dsf.ui/plugin.properties index fa604141f8f..996feae9d4d 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/plugin.properties +++ b/dsf/org.eclipse.cdt.dsf.ui/plugin.properties @@ -31,8 +31,9 @@ commandContext.name= In Disassembly commandContext.description= When debugging in assembly mode # actions -action.breakpointProperties.label = Breakpoint Properties... -action.toggleBreakpoint.label = Toggle Breakpoint +action.breakpointProperties.label = Breakpoint Properties...\Ctrl+Double Click +action.toggleBreakpoint.label = Toggle Breakpoint\tDouble Click +action.addBreakpoint.label = Add Breakpoint...\tCtrl+Double Click menu.updatePolicy = Update Policy menu.threadsUpdatePolicy = Threads Update Policy diff --git a/dsf/org.eclipse.cdt.dsf.ui/plugin.xml b/dsf/org.eclipse.cdt.dsf.ui/plugin.xml index 5233ceaa15a..b3bda1e7b55 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/plugin.xml +++ b/dsf/org.eclipse.cdt.dsf.ui/plugin.xml @@ -581,6 +581,12 @@ menubarPath="debug"> </action> <action + class="org.eclipse.cdt.dsf.debug.internal.ui.disassembly.actions.AddBreakpointRulerActionDelegate" + id="org.eclipse.debug.ui.actions.RulerAddBreakpointAction" + label="%action.addBreakpoint.label" + menubarPath="debug"> + </action> + <action class="org.eclipse.cdt.dsf.debug.internal.ui.disassembly.actions.RulerToggleBreakpointActionDelegate" definitionId="org.eclipse.cdt.dsf.debug.ui.disassembly.commands.rulerToggleBreakpoint" id="org.eclipse.debug.ui.actions.RulerToggleBreakpointAction" diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/DisassemblyToggleBreakpointsTarget.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/DisassemblyToggleBreakpointsTarget.java index 90651cd1d25..29f6d8ff96b 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/DisassemblyToggleBreakpointsTarget.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/DisassemblyToggleBreakpointsTarget.java @@ -10,12 +10,17 @@ *******************************************************************************/ package org.eclipse.cdt.dsf.debug.internal.ui; +import java.util.HashMap; +import java.util.Map; + import org.eclipse.cdt.core.IAddress; import org.eclipse.cdt.debug.core.CDIDebugModel; import org.eclipse.cdt.debug.core.model.ICBreakpointType; +import org.eclipse.cdt.debug.core.model.ICLineBreakpoint; import org.eclipse.cdt.dsf.debug.ui.actions.AbstractDisassemblyBreakpointsTarget; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; +import org.eclipse.ui.IWorkbenchPart; /** * Toggle breakpoint target implementation for the disassembly part. @@ -30,6 +35,17 @@ public class DisassemblyToggleBreakpointsTarget extends AbstractDisassemblyBreak CDIDebugModel.createLineBreakpoint( sourceHandle, resource, getBreakpointType(), lineNumber, true, 0, "", true ); //$NON-NLS-1$ } + @Override + protected void createLineBreakpointInteractive(IWorkbenchPart part, String sourceHandle, IResource resource, + int lineNumber) throws CoreException + { + ICLineBreakpoint lineBp = CDIDebugModel.createBlankLineBreakpoint(); + Map<String, Object> attributes = new HashMap<String, Object>(); + CDIDebugModel.setLineBreakpointAttributes( + attributes, sourceHandle, getBreakpointType(), lineNumber, true, 0, "" ); //$NON-NLS-1$ + openBreakpointPropertiesDialog(lineBp, part, resource, attributes); + } + /* (non-Javadoc) * @see org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.AbstractDisassemblyBreakpointsTarget#createAddressBreakpoint(org.eclipse.core.resources.IResource, org.eclipse.cdt.core.IAddress) */ @@ -38,6 +54,17 @@ public class DisassemblyToggleBreakpointsTarget extends AbstractDisassemblyBreak CDIDebugModel.createAddressBreakpoint( null, null, resource, getBreakpointType(), address, true, 0, "", true ); //$NON-NLS-1$ } + @Override + protected void createAddressBreakpointInteractive(IWorkbenchPart part, IResource resource, IAddress address) + throws CoreException + { + ICLineBreakpoint lineBp = CDIDebugModel.createBlankAddressBreakpoint(); + Map<String, Object> attributes = new HashMap<String, Object>(); + CDIDebugModel.setAddressBreakpointAttributes( + attributes, null, null, getBreakpointType(), -1, address, true, 0, "" ); //$NON-NLS-1$ + openBreakpointPropertiesDialog(lineBp, part, resource, attributes); + } + protected int getBreakpointType() { return ICBreakpointType.REGULAR; } diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyMessages.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyMessages.java index 909f8e9f931..cb73691e57e 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyMessages.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyMessages.java @@ -83,7 +83,10 @@ public final class DisassemblyMessages extends NLS { public static String Disassembly_Error_Dialog_title; public static String Disassembly_Error_Dialog_ok_button; public static String DisassemblyBackendDsf_error_UnableToRetrieveData; - + public static String Disassembly_action_AddBreakpoint_label; + public static String Disassembly_action_AddBreakpoint_errorTitle; + public static String Disassembly_action_AddBreakpoint_errorMessage; + static { NLS.initializeMessages(DisassemblyMessages.class.getName(), DisassemblyMessages.class); } diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyMessages.properties b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyMessages.properties index a4098d6aa1b..fbe8b0b165f 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyMessages.properties +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyMessages.properties @@ -18,13 +18,16 @@ Disassembly_action_GotoPC_tooltip=Go to Current Program Counter Disassembly_action_GotoAddress_label=Go to Address... Disassembly_action_Copy_label=&Copy Disassembly_action_SelectAll_label=Select &All -Disassembly_action_BreakpointProperties_label=Breakpoint Properties... -Disassembly_action_DisableBreakpoint_label=Disable Breakpoint -Disassembly_action_EnableBreakpoint_label=Enable Breakpoint +Disassembly_action_BreakpointProperties_label=Breakpoint Properties...\tCtrl+Double Click +Disassembly_action_DisableBreakpoint_label=Disable Breakpoint\tShift+Double Click +Disassembly_action_EnableBreakpoint_label=Enable Breakpoint\tShift+Double Click Disassembly_action_RefreshView_label=Re&fresh View Disassembly_action_OpenPreferences_label=&Preferences... Disassembly_action_Sync_label=Link with Active Debug Context Disassembly_action_TrackExpression_label=Track Expression +Disassembly_action_AddBreakpoint_label=Add Breakpoint...\tCtrl+Double Click +Disassembly_action_AddBreakpoint_errorTitle=Error +Disassembly_action_AddBreakpoint_errorMessage=Unable to create breakpoint Disassembly_GotoAddressDialog_title=Go to Address Disassembly_GotoAddressDialog_label=Address expression: diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyPart.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyPart.java index 308999dadbc..4b1187a6a07 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyPart.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyPart.java @@ -156,6 +156,7 @@ import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Menu; import org.eclipse.swt.widgets.ToolBar; import org.eclipse.ui.IActionBars; @@ -1309,12 +1310,23 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem fActionToggleSource.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(DsfUIPlugin.PLUGIN_ID, "icons/source.gif")); //$NON-NLS-1$ fVerticalRuler.getControl().addMouseListener(new MouseAdapter() { @Override - public void mouseDoubleClick(MouseEvent e) { + public void mouseDoubleClick(final MouseEvent e) { // invoke toggle breakpoint IHandlerService handlerService = (IHandlerService) getSite().getService(IHandlerService.class); if (handlerService != null) { try { - handlerService.executeCommand(COMMAND_ID_TOGGLE_BREAKPOINT, null); + Event event= new Event(); + event.display = e.display; + event.widget = e.widget; + event.time = e.time; + event.data = e.data; + event.x = e.x; + event.y = e.y; + event.button = e.button; + event.stateMask = e.stateMask; + event.count = e.count; + + handlerService.executeCommand(COMMAND_ID_TOGGLE_BREAKPOINT, event); } catch (org.eclipse.core.commands.ExecutionException exc) { DsfUIPlugin.log(exc); } catch (NotDefinedException exc) { diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/actions/AddBreakpointRulerAction.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/actions/AddBreakpointRulerAction.java new file mode 100644 index 00000000000..7e4df04046d --- /dev/null +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/actions/AddBreakpointRulerAction.java @@ -0,0 +1,136 @@ +/******************************************************************************* + * Copyright (c) 2008, 2012 Wind River Systems, Inc. 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.dsf.debug.internal.ui.disassembly.actions; + +import org.eclipse.cdt.debug.internal.ui.actions.ActionMessages; +import org.eclipse.cdt.debug.ui.CDebugUIPlugin; +import org.eclipse.cdt.debug.ui.breakpoints.IToggleBreakpointsTargetCExtension; +import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.DisassemblyMessages; +import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.IDisassemblyPart; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.debug.ui.DebugUITools; +import org.eclipse.debug.ui.actions.IToggleBreakpointsTarget; +import org.eclipse.debug.ui.actions.IToggleBreakpointsTargetManager; +import org.eclipse.jface.dialogs.ErrorDialog; +import org.eclipse.jface.text.BadLocationException; +import org.eclipse.jface.text.IDocument; +import org.eclipse.jface.text.IRegion; +import org.eclipse.jface.text.ITextSelection; +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.jface.viewers.StructuredSelection; +import org.eclipse.ui.IWorkbenchPart; + +/** + * Ruler action to add breakpoint with a dialog properties. + */ +public class AddBreakpointRulerAction extends AbstractDisassemblyBreakpointRulerAction { + + + protected AddBreakpointRulerAction(IDisassemblyPart disassemblyPart, IVerticalRulerInfo rulerInfo) { + super(disassemblyPart, rulerInfo); + setText(DisassemblyMessages.Disassembly_action_AddBreakpoint_label); + } + + /* + * @see org.eclipse.cdt.dsf.debug.internal.ui.disassembly.actions.AbstractDisassemblyAction#run() + */ + @Override + public void run() { + IWorkbenchPart part = getDisassemblyPart(); + ISelection selection = getSelection(); + IToggleBreakpointsTargetCExtension toggleTarget = getToggleTarget(selection); + if (toggleTarget != null) { + try { + if (toggleTarget.canCreateLineBreakpointsInteractive(part, selection)) { + toggleTarget.createLineBreakpointsInteractive(part, selection); + } + } catch (CoreException e) { + reportException(e); + } + } + } + + @Override + public void update() { + IDisassemblyPart part = getDisassemblyPart(); + if (part != null && part.isConnected()) { + ISelection selection = getSelection(); + IToggleBreakpointsTargetCExtension toggleTarget = getToggleTarget(selection); + if (toggleTarget != null) { + setEnabled( toggleTarget.canCreateLineBreakpointsInteractive(part, selection) ); + return; + } + } + setEnabled(false); + } + + private IToggleBreakpointsTargetCExtension getToggleTarget(ISelection selection) { + IToggleBreakpointsTargetManager toggleMgr = DebugUITools.getToggleBreakpointsTargetManager(); + IToggleBreakpointsTarget toggleTarget = toggleMgr.getToggleBreakpointsTarget(getDisassemblyPart(), selection); + if (toggleTarget instanceof IToggleBreakpointsTargetCExtension) { + return (IToggleBreakpointsTargetCExtension)toggleTarget; + } + return null; + } + + /** + * Report an error to the user. + * + * @param e underlying exception + */ + private void reportException(Exception e) { + IStatus status= new Status(IStatus.ERROR, CDebugUIPlugin.PLUGIN_ID, "Error creating breakpoint: ", e); //$NON-NLS-1$ + ErrorDialog.openError( + getDisassemblyPart().getSite().getShell(), + ActionMessages.getString("DisassemblyMessages.Disassembly_action_AddBreakpoint_errorTitle"), //$NON-NLS-1$ + ActionMessages.getString("DisassemblyMessages.Disassembly_action_AddBreakpoint_errorMessage"), //$NON-NLS-1$ + status); + CDebugUIPlugin.log(status); // + } + + /** + * Determines the text selection for the breakpoint action. If clicking on the ruler inside + * the highlighted text, return the text selection for the highlighted text. Otherwise, + * return a text selection representing the start of the line. + * + * @return An ISelection as described. + * @throws BadLocationException If underlying operations throw. + */ + private ISelection getSelection() { + IDocument document = getDocument(); + if (document != null) { + int line = getRulerInfo().getLineOfLastMouseButtonActivity(); + + try { + IRegion region = getDocument().getLineInformation(line); + ITextSelection textSelection = new TextSelection(document, region.getOffset(), 0); + ISelectionProvider provider = getDisassemblyPart().getSite().getSelectionProvider(); + if (provider != null){ + ISelection selection = provider.getSelection(); + if (selection instanceof ITextSelection + && ((ITextSelection) selection).getStartLine() <= line + && ((ITextSelection) selection).getEndLine() >= line) { + textSelection = (ITextSelection) selection; + } + } + return textSelection; + } catch (BadLocationException e) { + } + } + return StructuredSelection.EMPTY; + } + +} diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/actions/AddBreakpointRulerActionDelegate.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/actions/AddBreakpointRulerActionDelegate.java new file mode 100644 index 00000000000..6a1791aa7a6 --- /dev/null +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/actions/AddBreakpointRulerActionDelegate.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * Copyright (c) 2008, 2012 Wind River Systems, Inc. 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.dsf.debug.internal.ui.disassembly.actions; + +import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.IDisassemblyPart; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.text.source.IVerticalRulerInfo; + +/** + * Ruler action delegate for the "Add Breakpoint..." action. + */ +public class AddBreakpointRulerActionDelegate extends AbstractDisassemblyRulerActionDelegate { + + /* + * @see org.eclipse.cdt.dsf.debug.internal.ui.disassembly.actions.AbstractDisassemblyRulerActionDelegate#createAction(org.eclipse.cdt.dsf.debug.internal.ui.disassembly.IDisassemblyPart, org.eclipse.jface.text.source.IVerticalRulerInfo) + */ + @Override + protected IAction createAction(IDisassemblyPart disassemblyPart, IVerticalRulerInfo rulerInfo) { + return new AddBreakpointRulerAction(disassemblyPart, rulerInfo); + } + +} diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/actions/RulerToggleBreakpointHandler.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/actions/RulerToggleBreakpointHandler.java index fdfcd6ef466..1e56cfd7200 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/actions/RulerToggleBreakpointHandler.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/actions/RulerToggleBreakpointHandler.java @@ -17,6 +17,7 @@ import org.eclipse.core.commands.ExecutionException; import org.eclipse.debug.ui.actions.ToggleBreakpointAction; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.source.IVerticalRulerInfo; +import org.eclipse.swt.widgets.Event; import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.handlers.HandlerUtil; @@ -39,7 +40,14 @@ public class RulerToggleBreakpointHandler extends AbstractHandler { final ToggleBreakpointAction toggleBpAction= new ToggleBreakpointAction(part, document, rulerInfo); toggleBpAction.update(); if (toggleBpAction.isEnabled()) { - toggleBpAction.run(); + if (event.getTrigger() instanceof Event) { + // Pass through the event that triggered the action. + // This will give toggle action access to key modifiers + // (shift, ctrl, etc.) + toggleBpAction.runWithEvent((Event)event.getTrigger()); + } else { + toggleBpAction.run(); + } } } } diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/actions/AbstractDisassemblyBreakpointsTarget.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/actions/AbstractDisassemblyBreakpointsTarget.java index db70e81e714..7221649161d 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/actions/AbstractDisassemblyBreakpointsTarget.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/actions/AbstractDisassemblyBreakpointsTarget.java @@ -15,8 +15,14 @@ import java.net.URI; import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import java.util.Map; import org.eclipse.cdt.core.IAddress; +import org.eclipse.cdt.debug.core.model.ICBreakpoint; +import org.eclipse.cdt.debug.internal.ui.CDebugUIUtils; +import org.eclipse.cdt.debug.internal.ui.breakpoints.CBreakpointContext; +import org.eclipse.cdt.debug.ui.CDebugUIPlugin; +import org.eclipse.cdt.debug.ui.breakpoints.IToggleBreakpointsTargetCExtension; import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.DisassemblySelection; import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.IDisassemblyPart; import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.IDisassemblySelection; @@ -28,21 +34,28 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.model.IBreakpoint; -import org.eclipse.debug.ui.actions.IToggleBreakpointsTargetExtension; +import org.eclipse.debug.ui.DebugUITools; +import org.eclipse.debug.ui.actions.IToggleBreakpointsTargetExtension2; +import org.eclipse.jface.preference.PreferenceDialog; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.ITextSelection; import org.eclipse.jface.text.Position; import org.eclipse.jface.text.source.IAnnotationModel; import org.eclipse.jface.viewers.ISelection; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Event; import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.dialogs.PreferencesUtil; import org.eclipse.ui.texteditor.SimpleMarkerAnnotation; /** * Base class for toggle breakpoint targets for the disassembly part. * @since 2.2 */ -public abstract class AbstractDisassemblyBreakpointsTarget implements IToggleBreakpointsTargetExtension { +public abstract class AbstractDisassemblyBreakpointsTarget + implements IToggleBreakpointsTargetExtension2, IToggleBreakpointsTargetCExtension +{ /* (non-Javadoc) * @see org.eclipse.debug.ui.actions.IToggleBreakpointsTarget#toggleLineBreakpoints(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection) @@ -58,7 +71,7 @@ public abstract class AbstractDisassemblyBreakpointsTarget implements IToggleBre int line = disassemblySelection.getStartLine(); IBreakpoint[] bp = getBreakpointsAtLine( (IDisassemblyPart)part, line ); if ( bp == null || bp.length == 0 ) { - insertBreakpoint( disassemblySelection ); + insertBreakpoint(part, disassemblySelection, false); } else { for( int i = 0; i < bp.length; i++ ) { @@ -121,10 +134,126 @@ public abstract class AbstractDisassemblyBreakpointsTarget implements IToggleBre return canToggleLineBreakpoints( part, selection ); } + /** + * @since 2.3 + */ + @Override + public boolean canToggleBreakpointsWithEvent(IWorkbenchPart part, ISelection selection, Event event) { + return canToggleBreakpoints(part, selection); + } + + /** + * @since 2.3 + */ + @Override + public void toggleBreakpointsWithEvent(IWorkbenchPart part, ISelection selection, Event event) throws CoreException { + assert part instanceof IDisassemblyPart && selection instanceof ITextSelection; + + boolean mod1 = event != null && (event.stateMask & SWT.MOD1) > 0; + boolean mod2 = event != null && (event.stateMask & SWT.MOD2) > 0; + if ( !(selection instanceof IDisassemblySelection) ) { + selection = new DisassemblySelection( (ITextSelection)selection, (IDisassemblyPart)part ); + } + IDisassemblySelection disassemblySelection = (IDisassemblySelection)selection; + int line = disassemblySelection.getStartLine(); + IBreakpoint[] bp = getBreakpointsAtLine( (IDisassemblyPart)part, line ); + if ( bp == null || bp.length == 0 ) { + insertBreakpoint(part, disassemblySelection, mod1); + } + else { + if(mod2) { + toggleBreakpointEnabled(bp[0]); + return; + } else if (mod1 && bp[0] instanceof ICBreakpoint) { + CDebugUIUtils.editBreakpointProperties(part, (ICBreakpoint)bp[0]); + return; + } + + for( int i = 0; i < bp.length; i++ ) { + bp[i].delete(); + } + } + } + + /** + * @since 2.3 + */ + @Override + public boolean canCreateLineBreakpointsInteractive(IWorkbenchPart part, ISelection selection) { + return canToggleLineBreakpoints(part, selection); + } + + /** + * @since 2.3 + */ + @Override + public void createLineBreakpointsInteractive(IWorkbenchPart part, ISelection selection) throws CoreException { + assert part instanceof IDisassemblyPart && selection instanceof ITextSelection; + + if ( !(selection instanceof IDisassemblySelection) ) { + selection = new DisassemblySelection( (ITextSelection)selection, (IDisassemblyPart)part ); + } + IDisassemblySelection disassemblySelection = (IDisassemblySelection)selection; + insertBreakpoint(part, disassemblySelection, true); + } + + /** + * @since 2.3 + */ + @Override + public boolean canCreateFunctionBreakpointInteractive(IWorkbenchPart part, ISelection selection) { + return false; + } + + /** + * @since 2.3 + */ + @Override + public void createFunctionBreakpointInteractive(IWorkbenchPart part, ISelection selection) throws CoreException { + } + + /** + * @since 2.3 + */ + @Override + public boolean canCreateWatchpointsInteractive(IWorkbenchPart part, ISelection selection) { + return false; + } + + /** + * @since 2.3 + */ + @Override + public void createWatchpointsInteractive(IWorkbenchPart part, ISelection selection) throws CoreException { + } + + + private void toggleBreakpointEnabled(IBreakpoint bp) { + try { + bp.setEnabled(!bp.isEnabled()); + } catch (CoreException e) { + CDebugUIPlugin.log(e.getStatus()); + } + } + protected abstract void createLineBreakpoint( String sourceHandle, IResource resource, int lineNumber ) throws CoreException; + /** + * @since 2.3 + */ + protected void createLineBreakpointInteractive(IWorkbenchPart part, String sourceHandle, IResource resource, int lineNumber ) throws CoreException { + createLineBreakpoint(sourceHandle, resource, lineNumber); + } + protected abstract void createAddressBreakpoint( IResource resource, IAddress address ) throws CoreException; + /** + * @since 2.3 + */ + protected void createAddressBreakpointInteractive(IWorkbenchPart part, IResource resource, IAddress address ) throws CoreException { + createAddressBreakpoint(resource, address); + } + private IBreakpoint[] getBreakpointsAtLine( IDisassemblyPart part, int line ) { List<IBreakpoint> breakpoints = new ArrayList<IBreakpoint>(); IAnnotationModel annotationModel = part.getTextViewer().getAnnotationModel(); @@ -159,7 +288,7 @@ public abstract class AbstractDisassemblyBreakpointsTarget implements IToggleBre return breakpoints.toArray( breakpointsArray ); } - private void insertBreakpoint( IDisassemblySelection selection ) throws CoreException { + private void insertBreakpoint(IWorkbenchPart part, IDisassemblySelection selection, boolean interactive) throws CoreException { IAddress address = selection.getStartAddress(); if ( address == null ) { return; @@ -180,11 +309,53 @@ public abstract class AbstractDisassemblyBreakpointsTarget implements IToggleBre filePath = URIUtil.toPath( fileUri ).toOSString(); } int srcLine = selection.getSourceLine(); - createLineBreakpoint( filePath, resource, srcLine + 1 ); + if (interactive) { + createLineBreakpointInteractive(part, filePath, resource, srcLine + 1 ); + } else { + createLineBreakpoint( filePath, resource, srcLine + 1 ); + } } else { IResource resource = ResourcesPlugin.getWorkspace().getRoot(); - createAddressBreakpoint( resource, address ); + if (interactive) { + createAddressBreakpointInteractive(part, resource, address ); + } else { + createAddressBreakpoint( resource, address ); + } } } + + /** + * Opens the properties dialog for the given breakpoint. This method can be + * used on an existing breakpoint or on a blank breakpoint which doesn't + * have an associated marker yet. + * + * @param bp + * The breakpoint to edit. This breakpoint may not have an + * associated marker yet. + * @param part + * Workbench part where the action was invoked. + * @param resource + * Workbench resource to create the breakpoint on. + * @param attributes + * Breakpoint attributes to show in properties dialog. If the + * breakpoint already exists, this attribute map can be used to + * override the attributes currently in the breakpoint. Can be + * <code>null</code>. + * @since 2.3 + */ + protected void openBreakpointPropertiesDialog(ICBreakpoint bp, IWorkbenchPart part, IResource resource, + Map<String, Object> attributes) + { + ISelection debugContext = DebugUITools.getDebugContextManager() + .getContextService(part.getSite().getWorkbenchWindow()).getActiveContext(part.getSite().getId()); + CBreakpointContext bpContext = new CBreakpointContext(bp, debugContext, resource, attributes); + + PreferenceDialog dialog = PreferencesUtil.createPropertyDialogOn(part.getSite().getShell(), bpContext, null, + null, null); + if (dialog != null) { + dialog.open(); + } + } + } |