From dd069579ac0131db85c7673c43556ecbb9b7432b Mon Sep 17 00:00:00 2001 From: Pawel Piech Date: Fri, 16 Mar 2012 15:45:09 -0700 Subject: Bug 360588 - [breakpoints] Allow user to edit all its properties prior to creating the breakpoint. - Added support for double-click action modifiers in the Disassembly view. - Added an "Add Breakpoint..." action to the Disassembly view as well. - Converted the Breakpoints view's "Add Watchpoint (C/C++)" action to use a full breakpoint properties dialog when creating a watchpoint. - Added an "Add Function Breakpoint (C/C++)" action to the Breakpoints view. The action opens the full properties dialog and allows user to enter the function name. --- .../org.eclipse.cdt.debug.ui/META-INF/MANIFEST.MF | 2 +- debug/org.eclipse.cdt.debug.ui/plugin.properties | 2 + debug/org.eclipse.cdt.debug.ui/plugin.xml | 9 + .../internal/ui/actions/ActionMessages.properties | 5 +- .../AddFunctionBreakpointActionDelegate.java | 75 ++++++++ .../breakpoints/AddWatchpointActionDelegate.java | 10 +- .../actions/breakpoints/AddWatchpointDialog.java | 1 + .../CAddBreakpointInteractiveRulerAction.java | 6 +- .../CToggleMethodBreakpointActionDelegate.java | 4 +- .../breakpoints/ToggleBreakpointAdapter.java | 19 +- .../ui/breakpoints/BreakpointsMessages.properties | 41 +++-- .../ui/breakpoints/CBreakpointContext.java | 54 +++++- .../ui/breakpoints/CBreakpointPreferenceStore.java | 18 +- .../ui/breakpoints/CBreakpointPropertyPage.java | 191 +++++++++++++-------- .../AbstractToggleBreakpointAdapter.java | 43 ++++- .../IToggleBreakpointsTargetCExtension.java | 84 ++++++++- 16 files changed, 407 insertions(+), 157 deletions(-) create mode 100644 debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/AddFunctionBreakpointActionDelegate.java (limited to 'debug') diff --git a/debug/org.eclipse.cdt.debug.ui/META-INF/MANIFEST.MF b/debug/org.eclipse.cdt.debug.ui/META-INF/MANIFEST.MF index aecef9f25a2..11eba71e802 100644 --- a/debug/org.eclipse.cdt.debug.ui/META-INF/MANIFEST.MF +++ b/debug/org.eclipse.cdt.debug.ui/META-INF/MANIFEST.MF @@ -7,7 +7,7 @@ Bundle-Activator: org.eclipse.cdt.debug.ui.CDebugUIPlugin Bundle-Vendor: %providerName Bundle-Localization: plugin Export-Package: - org.eclipse.cdt.debug.internal.ui;x-internal:=true, + org.eclipse.cdt.debug.internal.ui;x-internal:x-friends:="org.eclipse.cdt.dsf.ui";x-friends:="org.eclipse.cdt.dsf.ui", org.eclipse.cdt.debug.internal.ui.actions;x-friends:="org.eclipse.cdt.dsf.ui,org.eclipse.cdt.debug.ui.memory.memorybrowser", org.eclipse.cdt.debug.internal.ui.actions.breakpoints;x-internal:=true, org.eclipse.cdt.debug.internal.ui.breakpoints;x-internal:=true, diff --git a/debug/org.eclipse.cdt.debug.ui/plugin.properties b/debug/org.eclipse.cdt.debug.ui/plugin.properties index f1e2a313406..e2bd92dc753 100644 --- a/debug/org.eclipse.cdt.debug.ui/plugin.properties +++ b/debug/org.eclipse.cdt.debug.ui/plugin.properties @@ -58,6 +58,8 @@ AddWatchpoint.label=Add Watchpoint (C/C++)... AddWatchpoint.tooltip=Add Watchpoint (C/C++) AddEventBreakpoint.label=Add Event Breakpoint (C/C++)... AddEventBreakpoint.tooltip=Add Event Breakpoint (C/C++) +AddFunctionBreakpoint.label=Add Function Breakpoint (C/C++)... +AddFunctionBreakpoint.tooltip=Add Function Breakpoint (C/C++) AddGlobalsAction.label=Add Global Variables... AddGlobalsAction.tooltip=Add Global Variables diff --git a/debug/org.eclipse.cdt.debug.ui/plugin.xml b/debug/org.eclipse.cdt.debug.ui/plugin.xml index 934e2a7caea..afdcbfac5a5 100644 --- a/debug/org.eclipse.cdt.debug.ui/plugin.xml +++ b/debug/org.eclipse.cdt.debug.ui/plugin.xml @@ -970,6 +970,15 @@ style="push" tooltip="%AddEventBreakpoint.tooltip"> + attributes = new HashMap(); - CDIDebugModel.setWatchPointAttributes(attributes, sourceHandle, resource, true, false, - expression, "", new BigInteger("0"), true, 0, ""); //$NON-NLS-1$ - openBreakpointPropertiesDialog(bp, part, resource, attributes); - } + ICWatchpoint bp = CDIDebugModel.createBlankWatchpoint(); + Map attributes = new HashMap(); + CDIDebugModel.setWatchPointAttributes(attributes, sourceHandle, resource, true, false, + expression, "", new BigInteger("0"), true, 0, ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + openBreakpointPropertiesDialog(bp, part, resource, attributes); } protected int getBreakpointType() { diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/BreakpointsMessages.properties b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/BreakpointsMessages.properties index daea7c8da8e..ecc61aa6bf0 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/BreakpointsMessages.properties +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/BreakpointsMessages.properties @@ -12,26 +12,29 @@ ############################################################################### CBreakpointPropertyPage.0=Ignore count must be a nonnegative integer -CBreakpointPropertyPage.1=Not available +CBreakpointPropertyPage.function_valueNotAvailable_label=Not available CBreakpointPropertyPage.function_label=Function name: -CBreakpointPropertyPage.3=C/C++ function breakpoint -CBreakpointPropertyPage.4=Not available +CBreakpointPropertyPage.function_value_errorMessage=Enter a function expression: +CBreakpointPropertyPage.breakpointType_function_label=C/C++ Function Breakpoint +CBreakpointPropertyPage.address_valueNotAvailable_label=Not available CBreakpointPropertyPage.address_label=Address: -CBreakpointPropertyPage.6=C/C++ address breakpoint -CBreakpointPropertyPage.7=File: -CBreakpointPropertyPage.8=C/C++ line breakpoint -CBreakpointPropertyPage.9=Line number: -CBreakpointPropertyPage.10=Project: -CBreakpointPropertyPage.11=C/C++ read watchpoint -CBreakpointPropertyPage.12=C/C++ watchpoint -CBreakpointPropertyPage.13=C/C++ access watchpoint -CBreakpointPropertyPage.14=Expression to watch: -CBreakpointPropertyPage.15=&Condition: -CBreakpointPropertyPage.16=Invalid condition. -CBreakpointPropertyPage.17=&Ignore count: -CBreakpointPropertyPage.18=Class: -CBreakpointPropertyPage.19=Enabled -CBreakpointPropertyPage.20=File: -CBreakpointPropertyPage.21=C/C++ Event Breakpoint +CBreakpointPropertyPage.breakpointType_address_label=C/C++ Address Breakpoint +CBreakpointPropertyPage.sourceHandle_label=File: +CBreakpointPropertyPage.breakpointType_line_label=C/C++ Line Breakpoint +CBreakpointPropertyPage.lineNumber_label=Line number: +CBreakpointPropertyPage.breakpointType_event_label=C/C++ Event Breakpoint +CBreakpointPropertyPage.project_label=Project: +CBreakpointPropertyPage.breakpointType_watchpoint_label=C/C++ Watchpoint +CBreakpointPropertyPage.breakpointType_watchpoint_read_label=C/C++ Read Watchpoint +CBreakpointPropertyPage.breakpointType_watchpoint_access_label=C/C++ Access Watchpoint +CBreakpointPropertyPage.watchpointType_read_label=Read +CBreakpointPropertyPage.watchpointType_write_label=Write +CBreakpointPropertyPage.watchpoint_expression_label=Expression to watch: +CBreakpointPropertyPage.watchpoint_expression_errorMessage=Enter the expression to watch: +CBreakpointPropertyPage.condition_label=&Condition: +CBreakpointPropertyPage.condition_invalidValue_message=Invalid condition. +CBreakpointPropertyPage.ignoreCount_label=&Ignore count: +CBreakpointPropertyPage.breakpointType_label=Class: +CBreakpointPropertyPage.enabled_label=Enabled ThreadFilterEditor.0=&Restrict to Selected Targets and Threads: diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/CBreakpointContext.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/CBreakpointContext.java index d1d359322ef..bc179355e35 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/CBreakpointContext.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/CBreakpointContext.java @@ -13,8 +13,14 @@ package org.eclipse.cdt.debug.internal.ui.breakpoints; import java.util.Map; +import org.eclipse.cdt.debug.core.CDIDebugModel; +import org.eclipse.cdt.debug.core.model.ICAddressBreakpoint; import org.eclipse.cdt.debug.core.model.ICBreakpoint; +import org.eclipse.cdt.debug.core.model.ICEventBreakpoint; +import org.eclipse.cdt.debug.core.model.ICFunctionBreakpoint; +import org.eclipse.cdt.debug.core.model.ICLineBreakpoint; import org.eclipse.cdt.debug.core.model.ICTracepoint; +import org.eclipse.cdt.debug.core.model.ICWatchpoint; import org.eclipse.cdt.debug.ui.breakpoints.ICBreakpointContext; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.IAdaptable; @@ -26,10 +32,12 @@ import org.eclipse.debug.core.model.IDebugElement; import org.eclipse.debug.core.model.IDebugModelProvider; import org.eclipse.debug.ui.contexts.IDebugContextListener; import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.ui.IActionFilter; import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.model.IWorkbenchAdapter; /** * Input for breakpoint properties dialog. It captures both the @@ -148,6 +156,43 @@ class CBreakpointContextActionFilter implements IActionFilter { } } +class CBreakpointContextWorkbenchAdapter implements IWorkbenchAdapter { + @Override + public String getLabel(Object o) { + if (o instanceof ICBreakpointContext) { + ICBreakpoint bp = ((ICBreakpointContext)o).getBreakpoint(); + return getBreakpointMainLabel(bp); + } + return ""; //$NON-NLS-1$ + } + + @Override + public Object[] getChildren(Object o) { return null; } + + @Override + public ImageDescriptor getImageDescriptor(Object object) { return null; } + + @Override + public Object getParent(Object o) { return null; } + + private String getBreakpointMainLabel(ICBreakpoint breakpoint) { + if (breakpoint instanceof ICFunctionBreakpoint) { + return BreakpointsMessages.getString("CBreakpointPropertyPage.breakpointType_function_label"); //$NON-NLS-1$ + } else if (breakpoint instanceof ICAddressBreakpoint) { + return BreakpointsMessages.getString("CBreakpointPropertyPage.breakpointType_address_label"); //$NON-NLS-1$ + } else if (breakpoint instanceof ICLineBreakpoint) { + return BreakpointsMessages.getString("CBreakpointPropertyPage.breakpointType_line_label"); //$NON-NLS-1$ + } else if (breakpoint instanceof ICEventBreakpoint) { + return BreakpointsMessages.getString("CBreakpointPropertyPage.breakpointType_event_label"); //$NON-NLS-1$ + } else if (breakpoint instanceof ICWatchpoint) { + return BreakpointsMessages.getString("CBreakpointPropertyPage.breakpointType_watchpoint_label"); //$NON-NLS-1$ + } + // default main label is the label of marker type for the breakpoint + return CDIDebugModel.calculateMarkerType(breakpoint); + } + +} + /** * Adapter factory which returns the breakpoint object and the action * filter for the CBreakpointContext type. @@ -155,10 +200,12 @@ class CBreakpointContextActionFilter implements IActionFilter { class CBreakpointContextAdapterFactory implements IAdapterFactory { private static final Class[] fgAdapterList = new Class[] { - IBreakpoint.class, ICBreakpoint.class, ICTracepoint.class, IActionFilter.class, IPreferenceStore.class + IBreakpoint.class, ICBreakpoint.class, ICTracepoint.class, IActionFilter.class, IPreferenceStore.class, + IWorkbenchAdapter.class, }; private static final IActionFilter fgActionFilter = new CBreakpointContextActionFilter(); + private static final IWorkbenchAdapter fgWorkbenchAdapter = new CBreakpointContextWorkbenchAdapter(); @Override public Object getAdapter(Object obj, @SuppressWarnings("rawtypes") Class adapterType) { @@ -178,6 +225,11 @@ class CBreakpointContextAdapterFactory implements IAdapterFactory { if (IActionFilter.class.equals(adapterType)) { return fgActionFilter; } + + if (IWorkbenchAdapter.class.equals(adapterType)) { + return fgWorkbenchAdapter; + } + return null; } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/CBreakpointPreferenceStore.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/CBreakpointPreferenceStore.java index dc250b872d6..c558db83b63 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/CBreakpointPreferenceStore.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/CBreakpointPreferenceStore.java @@ -40,14 +40,6 @@ import org.eclipse.jface.util.PropertyChangeEvent; */ public class CBreakpointPreferenceStore implements IPersistentPreferenceStore { -// protected final static String ENABLED = "ENABLED"; //$NON-NLS-1$ -// -// protected final static String CONDITION = "CONDITION"; //$NON-NLS-1$ -// -// protected final static String IGNORE_COUNT = "IGNORE_COUNT"; //$NON-NLS-1$ -// -// protected final static String LINE = "LINE"; //$NON-NLS-1$ - // This map is the current properties/values being maintained/manipulated private HashMap fProperties = new HashMap(); @@ -149,7 +141,7 @@ public class CBreakpointPreferenceStore implements IPersistentPreferenceStore { breakpoint.getMarker().setAttribute(ICLineBreakpoint2.REQUESTED_LINE, getInt(IMarker.LINE_NUMBER)); } else { // this allow set attributes contributed by other plugins - String value = getPropertyAsString(property); + Object value = fProperties.get(property); if ( value != null ) { marker.setAttribute(property, value); } @@ -175,14 +167,6 @@ public class CBreakpointPreferenceStore implements IPersistentPreferenceStore { } } - private String getPropertyAsString(String property) { - if (fProperties.containsKey(property)) { - return getString(property); - } else { - return null; - } - } - /////////////////////////////////////////////////////////////////////// // IPreferenceStore diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/CBreakpointPropertyPage.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/CBreakpointPropertyPage.java index b6c9e377e5a..587abcbfa04 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/CBreakpointPropertyPage.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/CBreakpointPropertyPage.java @@ -15,7 +15,6 @@ package org.eclipse.cdt.debug.internal.ui.breakpoints; import org.eclipse.cdt.debug.core.CDIDebugModel; import org.eclipse.cdt.debug.core.model.ICAddressBreakpoint; import org.eclipse.cdt.debug.core.model.ICBreakpoint; -import org.eclipse.cdt.debug.core.model.ICEventBreakpoint; import org.eclipse.cdt.debug.core.model.ICFunctionBreakpoint; import org.eclipse.cdt.debug.core.model.ICLineBreakpoint; import org.eclipse.cdt.debug.core.model.ICWatchpoint; @@ -26,6 +25,7 @@ import org.eclipse.cdt.debug.ui.breakpoints.ICBreakpointsUIContribution; import org.eclipse.cdt.debug.ui.preferences.ReadOnlyFieldEditor; import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.debug.core.model.ILineBreakpoint; @@ -38,6 +38,7 @@ import org.eclipse.jface.preference.StringFieldEditor; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.IWorkbenchPropertyPage; +import org.eclipse.ui.model.IWorkbenchAdapter; /** * The preference page used to present the properties of a breakpoint as preferences. A CBreakpointPreferenceStore is used to interface between this page and @@ -232,8 +233,11 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement } private void createMainLabel(ICBreakpoint breakpoint) { - addField( createLabelEditor( getFieldEditorParent(), BreakpointsMessages.getString( "CBreakpointPropertyPage.18" ), //$NON-NLS-1$ - getBreakpointMainLabel(breakpoint) ) ); + String label = getBreakpointMainLabel(breakpoint); + addField( createLabelEditor( + getFieldEditorParent(), + BreakpointsMessages.getString( "CBreakpointPropertyPage.breakpointType_label" ), //$NON-NLS-1$ + label) ); } /** @@ -244,52 +248,37 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement private void createTypeSpecificLabelFieldEditors( ICBreakpoint breakpoint ) { if ( breakpoint instanceof ICFunctionBreakpoint ) { - ICFunctionBreakpoint fbrkpt = (ICFunctionBreakpoint)breakpoint; - String function = BreakpointsMessages.getString( "CBreakpointPropertyPage.1" ); //$NON-NLS-1$ - try { - function = fbrkpt.getFunction(); - } - catch( CoreException e ) { - } - catch( NumberFormatException e ) { - } - if ( function != null ) { - addField( createLabelEditor( getFieldEditorParent(), BreakpointsMessages.getString( "CBreakpointPropertyPage.function_label" ), function ) ); //$NON-NLS-1$ - } + createFunctionEditor(getFieldEditorParent()); } else if ( breakpoint instanceof ICAddressBreakpoint ) { - ICAddressBreakpoint abrkpt = (ICAddressBreakpoint)breakpoint; - String address = BreakpointsMessages.getString( "CBreakpointPropertyPage.4" ); //$NON-NLS-1$ - try { - address = abrkpt.getAddress(); - } - catch( CoreException e ) { - } - if ( address != null ) { - addField( createLabelEditor( getFieldEditorParent(), BreakpointsMessages.getString( "CBreakpointPropertyPage.address_label" ), address ) ); //$NON-NLS-1$ - } + String title = BreakpointsMessages.getString( "CBreakpointPropertyPage.address_label" ); //$NON-NLS-1$ + + String address = getPreferenceStore().getString(ICLineBreakpoint.ADDRESS); + if (address == null || address.trim().length() == 0) { + address = BreakpointsMessages.getString( "CBreakpointPropertyPage.address_valueNotAvailable_label" ); //$NON-NLS-1$ + } + addField( createLabelEditor( getFieldEditorParent(), title, address ) ); } else if ( breakpoint instanceof ICWatchpoint ) { - ICWatchpoint watchpoint = (ICWatchpoint)breakpoint; - String expression = getPreferenceStore().getString(ICWatchpoint.EXPRESSION); - - IMarker marker = breakpoint.getMarker(); - if (marker != null) { - IProject project = marker.getResource().getProject(); + IResource resource = getResource(); + if (resource != null) { + IProject project = resource.getProject(); if ( project != null ) { - addField( createLabelEditor( getFieldEditorParent(), BreakpointsMessages.getString( "CBreakpointPropertyPage.10" ), project.getName() ) ); //$NON-NLS-1$ + addField( createLabelEditor( getFieldEditorParent(), BreakpointsMessages.getString( "CBreakpointPropertyPage.project_label" ), project.getName() ) ); //$NON-NLS-1$ } } String filename = getPreferenceStore().getString(ICBreakpoint.SOURCE_HANDLE); - if (!"".equals(filename)) { //$NON-NLS-1$ - addField( createLabelEditor( getFieldEditorParent(), BreakpointsMessages.getString( "CBreakpointPropertyPage.20" ), filename ) ); //$NON-NLS-1$ + if (filename != null && !"".equals(filename)) { //$NON-NLS-1$ + addField( createLabelEditor( getFieldEditorParent(), BreakpointsMessages.getString( "CBreakpointPropertyPage.sourceHandle_label" ), filename ) ); //$NON-NLS-1$ } - addField( createLabelEditor( getFieldEditorParent(), BreakpointsMessages.getString( "CBreakpointPropertyPage.14" ), expression ) ); //$NON-NLS-1$ + createWatchExpressionEditor(getFieldEditorParent()); + createWatchTypeEditors(getFieldEditorParent()); + } else if ( breakpoint instanceof ILineBreakpoint ) { String fileName = getPreferenceStore().getString(ICBreakpoint.SOURCE_HANDLE); if ( fileName != null ) { - addField( createLabelEditor( getFieldEditorParent(), BreakpointsMessages.getString( "CBreakpointPropertyPage.7" ), fileName ) ); //$NON-NLS-1$ + addField( createLabelEditor( getFieldEditorParent(), BreakpointsMessages.getString( "CBreakpointPropertyPage.sourceHandle_label" ), fileName ) ); //$NON-NLS-1$ } int lNumber = getPreferenceStore().getInt(IMarker.LINE_NUMBER); if (lNumber > 0) { @@ -300,58 +289,101 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement } private String getBreakpointMainLabel(ICBreakpoint breakpoint) { - if (breakpoint instanceof ICFunctionBreakpoint) - return BreakpointsMessages.getString("CBreakpointPropertyPage.3"); //$NON-NLS-1$ - if (breakpoint instanceof ICAddressBreakpoint) - return BreakpointsMessages.getString("CBreakpointPropertyPage.4"); //$NON-NLS-1$ - if (breakpoint instanceof ICLineBreakpoint) - return BreakpointsMessages.getString("CBreakpointPropertyPage.8"); //$NON-NLS-1$ - if (breakpoint instanceof ICEventBreakpoint) - return BreakpointsMessages.getString("CBreakpointPropertyPage.21"); //$NON-NLS-1$ - if (breakpoint instanceof ICWatchpoint) { - String type = ""; //$NON-NLS-1$ - boolean isReadType = getPreferenceStore().getBoolean(ICWatchpoint.READ); - boolean isWriteType = getPreferenceStore().getBoolean(ICWatchpoint.WRITE); - if (isReadType && !isWriteType) - type = BreakpointsMessages.getString("CBreakpointPropertyPage.11"); //$NON-NLS-1$ - else if (!isReadType && isWriteType) - type = BreakpointsMessages.getString("CBreakpointPropertyPage.12"); //$NON-NLS-1$ - else - type = BreakpointsMessages.getString("CBreakpointPropertyPage.13"); //$NON-NLS-1$ - - return type; - } - // default main label is the label of marker type for the breakpoint - return CDIDebugModel.calculateMarkerType(breakpoint); + if (breakpoint instanceof ICWatchpoint && breakpoint.getMarker() != null) { + // For an existing breakpoint, calculate watchpoint label based + // on read/write type. + boolean isReadType = getPreferenceStore().getBoolean(ICWatchpoint.READ); + boolean isWriteType = getPreferenceStore().getBoolean(ICWatchpoint.WRITE); + if (isReadType && !isWriteType) { + return BreakpointsMessages.getString("CBreakpointPropertyPage.breakpointType_watchpoint_read_label"); //$NON-NLS-1$ + } else if (!isReadType && isWriteType) { + return BreakpointsMessages.getString("CBreakpointPropertyPage.breakpointType_watchpoint_label"); //$NON-NLS-1$ + } else { + return BreakpointsMessages.getString("CBreakpointPropertyPage.watchpointType_breakpointType_watchpoint_access_label"); //$NON-NLS-1$ + } + } + + IWorkbenchAdapter labelProvider = (IWorkbenchAdapter)getElement().getAdapter(IWorkbenchAdapter.class); + if (labelProvider != null) { + return labelProvider.getLabel(getElement()); + } + // default main label is the label of marker type for the breakpoint + return CDIDebugModel.calculateMarkerType(breakpoint); } + + protected void createFunctionEditor( Composite parent ) { + + ICBreakpoint breakpoint = getBreakpoint(); + String title = BreakpointsMessages.getString("CBreakpointPropertyPage.function_label"); //$NON-NLS-1$ + if (breakpoint == null || breakpoint.getMarker() == null) { + BreakpointStringFieldEditor expressionEditor = new BreakpointStringFieldEditor( + ICLineBreakpoint.FUNCTION, title, parent); + expressionEditor.setErrorMessage(BreakpointsMessages.getString("CBreakpointPropertyPage.function_value_errorMessage")); //$NON-NLS-1$ + expressionEditor.setEmptyStringAllowed(false); + addField(expressionEditor); + } else { + String function = getPreferenceStore().getString(ICLineBreakpoint.FUNCTION); + if ( function == null ) { + function = BreakpointsMessages.getString( "CBreakpointPropertyPage.function_valueNotAvailable_label" ); //$NON-NLS-1$ + } + addField( createLabelEditor( getFieldEditorParent(), BreakpointsMessages.getString( "CBreakpointPropertyPage.function_label" ), function ) ); //$NON-NLS-1$ + } + } + protected void createLineNumberEditor( Composite parent ) { - String title = BreakpointsMessages.getString( "CBreakpointPropertyPage.9" ); //$NON-NLS-1$ + String title = BreakpointsMessages.getString( "CBreakpointPropertyPage.lineNumber_label" ); //$NON-NLS-1$ BreakpointIntegerFieldEditor labelFieldEditor =new BreakpointIntegerFieldEditor( IMarker.LINE_NUMBER ,title, parent); labelFieldEditor.setValidRange( 1, Integer.MAX_VALUE ); addField( labelFieldEditor ); } - - protected void createAddressEditor( Composite parent ) { - String title = BreakpointsMessages.getString( "CBreakpointPropertyPage.addressLabel" ); //$NON-NLS-1$ - StringFieldEditor fe =new StringFieldEditor( ICLineBreakpoint.ADDRESS ,title, parent); - fe.setEmptyStringAllowed(false); - addField( fe ); - } + + protected void createWatchExpressionEditor( Composite parent ) { + ICBreakpoint breakpoint = getBreakpoint(); + if (breakpoint == null || breakpoint.getMarker() == null) { + BreakpointStringFieldEditor expressionEditor =new BreakpointStringFieldEditor( + ICWatchpoint.EXPRESSION, + BreakpointsMessages.getString("CBreakpointPropertyPage.watchpoint_expression_label"), //$NON-NLS-1$ + parent); + expressionEditor.setErrorMessage(BreakpointsMessages.getString("CBreakpointPropertyPage.watchpoint_expression_errorMessage")); //$NON-NLS-1$ + expressionEditor.setEmptyStringAllowed(false); + addField(expressionEditor); + } else { + addField(createLabelEditor( + parent, + BreakpointsMessages.getString("CBreakpointPropertyPage.watchpoint_expression_label"), //$NON-NLS-1$ + getPreferenceStore().getString(ICWatchpoint.EXPRESSION) )); + } + } + + protected void createWatchTypeEditors( Composite parent ) { + // Edit read/write options only when creating the breakpoint. + ICBreakpoint breakpoint = getBreakpoint(); + if (breakpoint != null && breakpoint.getMarker() == null) { + addField( new BooleanFieldEditor( + ICWatchpoint.READ, + BreakpointsMessages.getString("CBreakpointPropertyPage.watchpointType_read_label"), //$NON-NLS-1$ + parent) ); + addField( new BooleanFieldEditor( + ICWatchpoint.WRITE, + BreakpointsMessages.getString("CBreakpointPropertyPage.watchpointType_write_label"), //$NON-NLS-1$ + parent) ); + } + } protected void createEnabledField( Composite parent ) { - fEnabled = new BooleanFieldEditor( ICBreakpoint.ENABLED, BreakpointsMessages.getString( "CBreakpointPropertyPage.19" ), parent ); //$NON-NLS-1$ + fEnabled = new BooleanFieldEditor( ICBreakpoint.ENABLED, BreakpointsMessages.getString( "CBreakpointPropertyPage.enabled_label" ), parent ); //$NON-NLS-1$ addField( fEnabled ); } protected void createConditionEditor( Composite parent ) { - fCondition = new BreakpointStringFieldEditor( ICBreakpoint.CONDITION, BreakpointsMessages.getString( "CBreakpointPropertyPage.15" ), parent ); //$NON-NLS-1$ + fCondition = new BreakpointStringFieldEditor( ICBreakpoint.CONDITION, BreakpointsMessages.getString( "CBreakpointPropertyPage.condition_label" ), parent ); //$NON-NLS-1$ fCondition.setEmptyStringAllowed( true ); - fCondition.setErrorMessage( BreakpointsMessages.getString( "CBreakpointPropertyPage.16" ) ); //$NON-NLS-1$ + fCondition.setErrorMessage( BreakpointsMessages.getString( "CBreakpointPropertyPage.condition_invalidValue_message" ) ); //$NON-NLS-1$ addField( fCondition ); } protected void createIgnoreCountEditor( Composite parent ) { - fIgnoreCount = new BreakpointIntegerFieldEditor( ICBreakpoint.IGNORE_COUNT, BreakpointsMessages.getString( "CBreakpointPropertyPage.17" ), parent ); //$NON-NLS-1$ + fIgnoreCount = new BreakpointIntegerFieldEditor( ICBreakpoint.IGNORE_COUNT, BreakpointsMessages.getString( "CBreakpointPropertyPage.ignoreCount_label" ), parent ); //$NON-NLS-1$ fIgnoreCount.setValidRange( 0, Integer.MAX_VALUE ); fIgnoreCountTextControl = fIgnoreCount.getTextControl( parent ); fIgnoreCountTextControl.setEnabled( getPreferenceStore().getInt(ICBreakpoint.IGNORE_COUNT) >= 0 ); @@ -366,12 +398,25 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement IAdaptable element = getElement(); if (element instanceof ICBreakpoint) { return (ICBreakpoint)element; - } else if (element instanceof CBreakpointContext) { - return ((CBreakpointContext)element).getBreakpoint(); + } else if (element instanceof ICBreakpointContext) { + return ((ICBreakpointContext)element).getBreakpoint(); } else { return (ICBreakpoint)element.getAdapter(ICBreakpoint.class); } } + + protected IResource getResource() { + IAdaptable element = getElement(); + if (element instanceof ICBreakpoint) { + IMarker marker = ((ICBreakpoint)element).getMarker(); + if (marker != null) { + return marker.getResource(); + } + } else if (element instanceof ICBreakpointContext) { + return ((ICBreakpointContext)element).getResource(); + } + return null; + } public IPreferenceStore getPreferenceStore() { IAdaptable element = getElement(); diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/AbstractToggleBreakpointAdapter.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/AbstractToggleBreakpointAdapter.java index 0c79dc3945a..22dd8d73e79 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/AbstractToggleBreakpointAdapter.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/AbstractToggleBreakpointAdapter.java @@ -151,25 +151,54 @@ abstract public class AbstractToggleBreakpointAdapter } @Override - public boolean canCreateBreakpointsInteractive(IWorkbenchPart part, ISelection selection) { - return canToggleBreakpoints( part, selection ); + public boolean canCreateLineBreakpointsInteractive(IWorkbenchPart part, ISelection selection) { + return canToggleLineBreakpoints( part, selection ); } @Override - public void createBreakpointsInteractive(IWorkbenchPart part, ISelection selection) throws CoreException { - updateBreakpoints(false, true, part, selection); + public void createLineBreakpointsInteractive(IWorkbenchPart part, ISelection selection) throws CoreException { + updateLineBreakpoints(false, true, part, selection); } @Override - public boolean canCreateWatchpoingsInteractive(IWorkbenchPart part, ISelection selection) { + public boolean canCreateWatchpointsInteractive(IWorkbenchPart part, ISelection selection) { + // Gather all input from user if needed. return true; } @Override - public void createWatchpoingsInteractive(IWorkbenchPart part, ISelection selection) throws CoreException { - createWatchpoint(true, part, null, ResourcesPlugin.getWorkspace().getRoot(), -1, -1, -1, ""); + public void createWatchpointsInteractive(IWorkbenchPart part, ISelection selection) throws CoreException { + ICElement element = getCElementFromSelection( part, selection ); + if (element instanceof IVariable) { + updateVariableWatchpoint(false, true, part, (IVariable)element); + } else { + String text = ""; //$NON-NLS-1$ + if (selection instanceof ITextSelection) { + text = ((ITextSelection)selection).getText(); + } + createWatchpoint(true, part, null, ResourcesPlugin.getWorkspace().getRoot(), -1, -1, -1, text); + } } + @Override + public boolean canCreateFunctionBreakpointInteractive(IWorkbenchPart part, ISelection selection) { + return true; + } + + @Override + public void createFunctionBreakpointInteractive(IWorkbenchPart part, ISelection selection) throws CoreException { + ICElement element = getCElementFromSelection( part, selection ); + if ( element instanceof IFunction || element instanceof IMethod ) { + updateMethodBreakpoints(false, true, part, (IDeclaration)element); + } else { + String text = ""; //$NON-NLS-1$ + if (selection instanceof ITextSelection) { + text = ((ITextSelection)selection).getText(); + } + createFunctionBreakpoint(true, part, null, ResourcesPlugin.getWorkspace().getRoot(), text, -1, -1, -1); + } + } + /** * Updates the breakpoint for given part and selection. * Depending on the flags and on whether a breakpoint exists, this method diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/IToggleBreakpointsTargetCExtension.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/IToggleBreakpointsTargetCExtension.java index 3963ae4fb28..ed7fa04d634 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/IToggleBreakpointsTargetCExtension.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/IToggleBreakpointsTargetCExtension.java @@ -30,7 +30,7 @@ import org.eclipse.ui.IWorkbenchPart; public interface IToggleBreakpointsTargetCExtension extends IToggleBreakpointsTargetExtension { /** - * Returns whether the toggle target can create a a breakpoint at the + * Returns whether the toggle target can create a line breakpoint at the * given location. If the implementation does not support creating the * breakpoint interactively then it should return false. *

@@ -43,12 +43,15 @@ public interface IToggleBreakpointsTargetCExtension extends IToggleBreakpointsTa * @return Returns true if toggle target is able interactively * create a breakpoint(s) at the given location. */ - public boolean canCreateBreakpointsInteractive(IWorkbenchPart part, ISelection selection); + public boolean canCreateLineBreakpointsInteractive(IWorkbenchPart part, ISelection selection); /** - * Creates new breakpoints interactively. The implementation should allows - * the user to edit all of the breakpoint's settings prior to creating the - * breakpoint. + * Creates new line breakpoints interactively. The implementation should + * allows the user to edit all of the breakpoint's settings prior to + * creating the breakpoint. Unlike the + * {@link #toggleLineBreakpoints(IWorkbenchPart, ISelection)} + * method, this method does not remove the existing breakpoint at given + * location. It always creates a new breakpoint *

* The selection varies depending on the given part. For example, * a text selection is provided for text editors, and a structured @@ -58,10 +61,73 @@ public interface IToggleBreakpointsTargetCExtension extends IToggleBreakpointsTa * @param selection selection on which line breakpoints should be toggled * @throws CoreException if unable to perform the action */ - public void createBreakpointsInteractive(IWorkbenchPart part, ISelection selection) throws CoreException; + public void createLineBreakpointsInteractive(IWorkbenchPart part, ISelection selection) throws CoreException; - public boolean canCreateWatchpoingsInteractive(IWorkbenchPart part, ISelection selection); - - public void createWatchpoingsInteractive(IWorkbenchPart part, ISelection selection) throws CoreException; + /** + * Returns whether the toggle target can create a watchpoint at the + * given location. If the implementation does not support creating the + * breakpoint interactively then it should return false. + *

+ * 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 + * @return Returns true if toggle target is able interactively + * create a breakpoint(s) at the given location. + */ + public boolean canCreateWatchpointsInteractive(IWorkbenchPart part, ISelection selection); + /** + * Creates new watchpoint interactively. The implementation should + * allows the user to edit all of the breakpoint's settings prior to + * creating the breakpoint. Unlike the + * {@link #toggleLineBreakpoints(IWorkbenchPart, ISelection)} + * method, this method does not remove the existing breakpoint at given + * location. It always creates a new breakpoint + *

+ * 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 + * @throws CoreException if unable to perform the action + */ + public void createWatchpointsInteractive(IWorkbenchPart part, ISelection selection) throws CoreException; + + /** + * Returns whether the toggle target can create a function breakpoint at the + * given location. If the implementation does not support creating the + * breakpoint interactively then it should return false. + *

+ * 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 + * @return Returns true if toggle target is able interactively + * create a breakpoint(s) at the given location. + */ + public boolean canCreateFunctionBreakpointInteractive(IWorkbenchPart part, ISelection selection); + + /** + * Creates new function breakpoint interactively. The implementation should + * allows the user to edit all of the breakpoint's settings prior to + * creating the breakpoint. Unlike the + * {@link #toggleLineBreakpoints(IWorkbenchPart, ISelection)} + * method, this method does not remove the existing breakpoint at given + * location. It always creates a new breakpoint + *

+ * 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 + * @throws CoreException if unable to perform the action + */ + public void createFunctionBreakpointInteractive(IWorkbenchPart part, ISelection selection) throws CoreException; } -- cgit v1.2.3