diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugModel.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugModel.java index 574dd75b512..ec820aa1d9d 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugModel.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugModel.java @@ -231,6 +231,31 @@ public class CDebugModel return new CLineBreakpoint( resource, attributes, add ); } + public static ICWatchpoint watchpointExists( IResource resource, boolean write, boolean read, String expression ) throws CoreException + { + String modelId = getPluginIdentifier(); + String markerType = CWatchpoint.getMarkerType(); + IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager(); + IBreakpoint[] breakpoints = manager.getBreakpoints( modelId ); + for ( int i = 0; i < breakpoints.length; i++ ) + { + if ( !( breakpoints[i] instanceof ICWatchpoint ) ) + { + continue; + } + ICWatchpoint breakpoint = (ICWatchpoint)breakpoints[i]; + if ( breakpoint.getMarker().getType().equals( markerType )&& + breakpoint.getMarker().getResource().equals( resource ) && + breakpoint.isWriteType() == write && + breakpoint.isReadType() == read && + breakpoint.getExpression().equals( expression ) ) + { + return breakpoint; + } + } + return null; +} + public static ICWatchpoint createWatchpoint( IResource resource, boolean writeAccess, boolean readAccess, @@ -245,6 +270,9 @@ public class CDebugModel attributes.put( ICBreakpoint.ENABLED, new Boolean( enabled ) ); attributes.put( ICBreakpoint.IGNORE_COUNT, new Integer( ignoreCount ) ); attributes.put( ICBreakpoint.CONDITION, condition ); + attributes.put( ICWatchpoint.EXPRESSION, expression ); + attributes.put( ICWatchpoint.READ, new Boolean( readAccess ) ); + attributes.put( ICWatchpoint.WRITE, new Boolean( writeAccess ) ); return new CWatchpoint( resource, attributes, add ); } } diff --git a/debug/org.eclipse.cdt.debug.ui/icons/full/obj16/read_obj.gif b/debug/org.eclipse.cdt.debug.ui/icons/full/obj16/read_obj.gif new file mode 100644 index 00000000000..793b189d849 Binary files /dev/null and b/debug/org.eclipse.cdt.debug.ui/icons/full/obj16/read_obj.gif differ diff --git a/debug/org.eclipse.cdt.debug.ui/icons/full/obj16/read_obj_disabled.gif b/debug/org.eclipse.cdt.debug.ui/icons/full/obj16/read_obj_disabled.gif new file mode 100644 index 00000000000..d9c0c91a040 Binary files /dev/null and b/debug/org.eclipse.cdt.debug.ui/icons/full/obj16/read_obj_disabled.gif differ diff --git a/debug/org.eclipse.cdt.debug.ui/icons/full/obj16/write_obj.gif b/debug/org.eclipse.cdt.debug.ui/icons/full/obj16/write_obj.gif new file mode 100644 index 00000000000..b5fa352bb51 Binary files /dev/null and b/debug/org.eclipse.cdt.debug.ui/icons/full/obj16/write_obj.gif differ diff --git a/debug/org.eclipse.cdt.debug.ui/icons/full/obj16/write_obj_disabled.gif b/debug/org.eclipse.cdt.debug.ui/icons/full/obj16/write_obj_disabled.gif new file mode 100644 index 00000000000..c4f8b8b7a89 Binary files /dev/null and b/debug/org.eclipse.cdt.debug.ui/icons/full/obj16/write_obj_disabled.gif differ diff --git a/debug/org.eclipse.cdt.debug.ui/plugin.properties b/debug/org.eclipse.cdt.debug.ui/plugin.properties index 07f869df99a..0f17eaacbbf 100644 --- a/debug/org.eclipse.cdt.debug.ui/plugin.properties +++ b/debug/org.eclipse.cdt.debug.ui/plugin.properties @@ -12,6 +12,7 @@ MemoryView.name=Memory MemoryPreferencePage.name=Memory Views CDebuggerPage.name=C Debugger UI Page +RunMenu.label=&Run DebugActionSet.label=C/C++ Debug RestartAction.label=Restart diff --git a/debug/org.eclipse.cdt.debug.ui/plugin.xml b/debug/org.eclipse.cdt.debug.ui/plugin.xml index 9970c4e8501..f039b62c19b 100644 --- a/debug/org.eclipse.cdt.debug.ui/plugin.xml +++ b/debug/org.eclipse.cdt.debug.ui/plugin.xml @@ -80,6 +80,14 @@ + + + + diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDTDebugModelPresentation.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDTDebugModelPresentation.java index 1aa02d0666f..791f92b400f 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDTDebugModelPresentation.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDTDebugModelPresentation.java @@ -13,6 +13,7 @@ import org.eclipse.cdt.debug.core.ICAddressBreakpoint; import org.eclipse.cdt.debug.core.ICBreakpoint; import org.eclipse.cdt.debug.core.ICFunctionBreakpoint; import org.eclipse.cdt.debug.core.ICLineBreakpoint; +import org.eclipse.cdt.debug.core.ICWatchpoint; import org.eclipse.cdt.debug.core.IStackFrameInfo; import org.eclipse.cdt.debug.core.IState; import org.eclipse.cdt.debug.core.cdi.ICDIBreakpointHit; @@ -384,6 +385,10 @@ public class CDTDebugModelPresentation extends LabelProvider { return getLineBreakpointImage( (ICLineBreakpoint)breakpoint ); } + if ( breakpoint instanceof ICWatchpoint ) + { + return getWatchpointImage( (ICWatchpoint)breakpoint ); + } return null; } @@ -402,6 +407,31 @@ public class CDTDebugModelPresentation extends LabelProvider return fDebugImageRegistry.get( descriptor ); } + protected Image getWatchpointImage( ICWatchpoint watchpoint ) throws CoreException + { + int flags = computeBreakpointAdornmentFlags( watchpoint ); + CImageDescriptor descriptor = null; + if ( watchpoint.isEnabled() ) + { + if ( watchpoint.isReadType() && !watchpoint.isWriteType() ) + descriptor = new CImageDescriptor( CDebugImages.DESC_OBJS_READ_WATCHPOINT_ENABLED, flags ); + else if ( !watchpoint.isReadType() && watchpoint.isWriteType() ) + descriptor = new CImageDescriptor( CDebugImages.DESC_OBJS_WRITE_WATCHPOINT_ENABLED, flags ); + else + descriptor = new CImageDescriptor( CDebugImages.DESC_OBJS_WATCHPOINT_ENABLED, flags ); + } + else + { + if ( watchpoint.isReadType() && !watchpoint.isWriteType() ) + descriptor = new CImageDescriptor( CDebugImages.DESC_OBJS_READ_WATCHPOINT_DISABLED, flags ); + else if ( !watchpoint.isReadType() && watchpoint.isWriteType() ) + descriptor = new CImageDescriptor( CDebugImages.DESC_OBJS_WRITE_WATCHPOINT_DISABLED, flags ); + else + descriptor = new CImageDescriptor( CDebugImages.DESC_OBJS_WATCHPOINT_DISABLED, flags ); + } + return fDebugImageRegistry.get( descriptor ); + } + protected IBreakpoint getBreakpoint( IMarker marker ) { return DebugPlugin.getDefault().getBreakpointManager().getBreakpoint( marker ); @@ -422,6 +452,10 @@ public class CDTDebugModelPresentation extends LabelProvider { return getFunctionBreakpointText( (ICFunctionBreakpoint)breakpoint, qualified ); } + if ( breakpoint instanceof ICWatchpoint ) + { + return getWatchpointText( (ICWatchpoint)breakpoint, qualified ); + } return ""; //$NON-NLS-1$ } @@ -435,6 +469,16 @@ public class CDTDebugModelPresentation extends LabelProvider return label.toString(); } + protected String getWatchpointText( ICWatchpoint watchpoint, boolean qualified ) throws CoreException + { + StringBuffer label = new StringBuffer(); + appendResourceName( watchpoint, label, qualified ); + appendWatchExpression( watchpoint, label ); + appendIgnoreCount( watchpoint, label ); + appendCondition( watchpoint, label ); + return label.toString(); + } + protected String getAddressBreakpointText( ICAddressBreakpoint breakpoint, boolean qualified ) throws CoreException { return null; @@ -445,7 +489,7 @@ public class CDTDebugModelPresentation extends LabelProvider return null; } - protected StringBuffer appendResourceName( ICLineBreakpoint breakpoint, StringBuffer label, boolean qualified ) throws CoreException + protected StringBuffer appendResourceName( ICBreakpoint breakpoint, StringBuffer label, boolean qualified ) throws CoreException { IPath path = breakpoint.getMarker().getResource().getLocation(); if ( !path.isEmpty() ) @@ -481,7 +525,7 @@ public class CDTDebugModelPresentation extends LabelProvider return label; } - protected void appendCondition( ICLineBreakpoint breakpoint, StringBuffer buffer ) throws CoreException + protected void appendCondition( ICBreakpoint breakpoint, StringBuffer buffer ) throws CoreException { String condition = breakpoint.getCondition(); if ( condition != null && condition.length() > 0 ) @@ -491,6 +535,17 @@ public class CDTDebugModelPresentation extends LabelProvider } } + private void appendWatchExpression( ICWatchpoint watchpoint, StringBuffer label ) throws CoreException + { + String expression = watchpoint.getExpression(); + if ( expression != null && expression.length() > 0 ) + { + label.append( " at \'" ); + label.append( expression ); + label.append( '\'' ); + } + } + /** * Returns the adornment flags for the given breakpoint. * These flags are used to render appropriate overlay diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java index 74db72e0f96..a6755f702a1 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java @@ -22,7 +22,7 @@ import org.eclipse.swt.graphics.Image; */ public class CDebugImages { - private static final String NAME_PREFIX = "org.eclipse.jdt.debug.ui."; //$NON-NLS-1$ + private static final String NAME_PREFIX = "org.eclipse.cdt.debug.ui."; //$NON-NLS-1$ private static final int NAME_PREFIX_LENGTH = NAME_PREFIX.length(); private static URL fgIconBaseURL = null; @@ -50,6 +50,10 @@ public class CDebugImages public static final String IMG_OBJS_BREAKPOINT_INSTALLED_DISABLED = NAME_PREFIX + "installed_ovr_disabled.gif"; //$NON-NLS-1$ public static final String IMG_OBJS_WATCHPOINT_ENABLED = NAME_PREFIX + "readwrite_obj.gif"; //$NON-NLS-1$ public static final String IMG_OBJS_WATCHPOINT_DISABLED = NAME_PREFIX + "readwrite_obj_disabled.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_READ_WATCHPOINT_ENABLED = NAME_PREFIX + "read_obj.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_READ_WATCHPOINT_DISABLED = NAME_PREFIX + "read_obj_disabled.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_WRITE_WATCHPOINT_ENABLED = NAME_PREFIX + "write_obj.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_WRITE_WATCHPOINT_DISABLED = NAME_PREFIX + "write_obj_disabled.gif"; //$NON-NLS-1$ /* * Set of predefined Image Descriptors. @@ -67,6 +71,10 @@ public class CDebugImages public static final ImageDescriptor DESC_OBJS_BREAKPOINT_INSTALLED_DISABLED = createManaged( T_OVR, IMG_OBJS_BREAKPOINT_INSTALLED_DISABLED ); public static final ImageDescriptor DESC_OBJS_WATCHPOINT_ENABLED = createManaged( T_OBJ, IMG_OBJS_WATCHPOINT_ENABLED ); public static final ImageDescriptor DESC_OBJS_WATCHPOINT_DISABLED = createManaged( T_OBJ, IMG_OBJS_WATCHPOINT_DISABLED ); + public static final ImageDescriptor DESC_OBJS_READ_WATCHPOINT_ENABLED = createManaged( T_OBJ, IMG_OBJS_READ_WATCHPOINT_ENABLED ); + public static final ImageDescriptor DESC_OBJS_READ_WATCHPOINT_DISABLED = createManaged( T_OBJ, IMG_OBJS_READ_WATCHPOINT_DISABLED ); + public static final ImageDescriptor DESC_OBJS_WRITE_WATCHPOINT_ENABLED = createManaged( T_OBJ, IMG_OBJS_WRITE_WATCHPOINT_ENABLED ); + public static final ImageDescriptor DESC_OBJS_WRITE_WATCHPOINT_DISABLED = createManaged( T_OBJ, IMG_OBJS_WRITE_WATCHPOINT_DISABLED ); /** * Returns the image managed under the given key in this registry. diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddWatchpointActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddWatchpointActionDelegate.java new file mode 100644 index 00000000000..403fa71b307 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddWatchpointActionDelegate.java @@ -0,0 +1,279 @@ +/* + *(c) Copyright QNX Software Systems Ltd. 2002. + * All Rights Reserved. + * + */ +package org.eclipse.cdt.debug.internal.ui.actions; + +import org.eclipse.cdt.debug.core.CDebugModel; +import org.eclipse.cdt.debug.core.ICWatchpoint; +import org.eclipse.cdt.debug.ui.CDebugUIPlugin; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.text.IDocument; +import org.eclipse.jface.text.ITextSelection; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.ISelectionProvider; +import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IFileEditorInput; +import org.eclipse.ui.IPartListener; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.IWorkbenchWindowActionDelegate; +import org.eclipse.ui.texteditor.ITextEditor; + +/** + * + * Action for adding/removing watchpoints at a selection in the active + * C/C++ or assembly editor. + * + * @since Sep 4, 2002 + */ +public class AddWatchpointActionDelegate implements IWorkbenchWindowActionDelegate, + IPartListener +{ + private boolean fInitialized = false; + private IAction fAction = null; + private ITextEditor fTextEditor = null; + private IWorkbenchWindow fWorkbenchWindow = null; + private IProject fProject = null; + + /** + * Constructor for AddWatchpointActionDelegate. + */ + public AddWatchpointActionDelegate() + { + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose() + */ + public void dispose() + { + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(IWorkbenchWindow) + */ + public void init( IWorkbenchWindow window ) + { + setWorkbenchWindow( window ); + window.getPartService().addPartListener( this ); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IActionDelegate#run(IAction) + */ + public void run( IAction action ) + { + String expression = getSelectedExpression(); + AddWatchpointDialog dlg = new AddWatchpointDialog( CDebugUIPlugin.getActiveWorkbenchShell(), + true, + false, + expression ); + if ( dlg.open() != Dialog.OK ) + return; + if ( getTextEditor() != null ) + { + update(); + addWatchpoint( getTextEditor().getEditorInput(), + dlg.getWriteAccess(), + dlg.getReadAccess(), + dlg.getExpression() ); + } + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IActionDelegate#selectionChanged(IAction, ISelection) + */ + public void selectionChanged( IAction action, ISelection selection ) + { + if ( !fInitialized ) + { + setAction( action ); + if ( getWorkbenchWindow() != null ) + { + IWorkbenchPage page = getWorkbenchWindow().getActivePage(); + if ( page != null ) + { + IEditorPart part = page.getActiveEditor(); + if ( part instanceof ITextEditor ) + { + setTextEditor( (ITextEditor)part ); + } + } + } + fInitialized = true; + } + } + + protected IAction getAction() + { + return fAction; + } + + protected void setAction( IAction action ) + { + fAction = action; + } + + protected IWorkbenchWindow getWorkbenchWindow() + { + return fWorkbenchWindow; + } + + protected void setWorkbenchWindow( IWorkbenchWindow workbenchWindow ) + { + fWorkbenchWindow = workbenchWindow; + } + + protected ITextEditor getTextEditor() + { + return fTextEditor; + } + + protected void setTextEditor( ITextEditor editor ) + { + fTextEditor = editor; + if ( fTextEditor != null ) + { + IEditorInput input = fTextEditor.getEditorInput(); + IFile file = ( input != null && input instanceof IFileEditorInput ) ? ((IFileEditorInput)input).getFile() : null; + setProject( ( file != null ) ? file.getProject() : null ); + } + setEnabledState( editor ); + } + + protected String getSelectedExpression() + { + if ( getTextEditor() != null ) + { + ISelectionProvider sp = getTextEditor().getSelectionProvider(); + if ( sp != null ) + { + ISelection s = sp.getSelection(); + if ( s instanceof ITextSelection ) + { + return ((ITextSelection)s).getText().trim(); + } + } + } + return ""; + } + + protected void update( ISelection selection ) + { + setEnabledState( getTextEditor() ); + } + + protected void update() + { + IAction action = getAction(); + if ( action != null ) + { + action.setEnabled( getTextEditor() != null ); + } + } + + protected void setEnabledState( ITextEditor editor ) + { + if ( getAction() != null ) + { + getAction().setEnabled( editor != null ); + } + } + + protected IProject getProject() + { + return fProject; + } + + protected void setProject( IProject project ) + { + fProject = project; + } + + protected void addWatchpoint( IEditorInput editorInput, boolean write, boolean read, String expression ) + { + if ( getProject() == null ) + return; + IDocument document = getTextEditor().getDocumentProvider().getDocument( editorInput ); + WatchpointExpressionVerifier wev = new WatchpointExpressionVerifier(); + if ( wev.isValidExpression( document, expression ) ) + { + try + { + CDebugModel.createWatchpoint( getProject(), + write, + read, + expression, + true, + 0, + "", + true ); + } + catch( CoreException ce ) + { + CDebugUIPlugin.errorDialog( "Cannot add watchpoint", ce ); + } + } + } + /* (non-Javadoc) + * @see org.eclipse.ui.IPartListener#partActivated(IWorkbenchPart) + */ + public void partActivated( IWorkbenchPart part ) + { + if ( part instanceof ITextEditor ) + { + setTextEditor( (ITextEditor)part ); + } + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IPartListener#partBroughtToTop(IWorkbenchPart) + */ + public void partBroughtToTop( IWorkbenchPart part ) + { + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IPartListener#partClosed(IWorkbenchPart) + */ + public void partClosed( IWorkbenchPart part ) + { + if ( part == getTextEditor() ) + { + setTextEditor( null ); + if ( getAction() != null ) + { + getAction().setEnabled( false ); + } + } + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IPartListener#partDeactivated(IWorkbenchPart) + */ + public void partDeactivated( IWorkbenchPart part ) + { + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IPartListener#partOpened(IWorkbenchPart) + */ + public void partOpened( IWorkbenchPart part ) + { + if ( part instanceof ITextEditor ) + { + if ( getTextEditor() == null ) + { + setTextEditor( (ITextEditor)part ); + } + } + } +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddWatchpointDialog.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddWatchpointDialog.java index fecd440b916..6def2c629f2 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddWatchpointDialog.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddWatchpointDialog.java @@ -45,9 +45,13 @@ public class AddWatchpointDialog extends Dialog * Constructor for AddWatchpointDialog. * @param parentShell */ - public AddWatchpointDialog( Shell parentShell ) + public AddWatchpointDialog( Shell parentShell, boolean write, boolean read, String expression ) { super( parentShell ); + fWrite = write; + fRead = read; + if ( expression != null ) + fExpression = expression; } protected void configureShell( Shell shell ) @@ -89,9 +93,9 @@ public class AddWatchpointDialog extends Dialog private void initializeDataWidgets() { - fTextExpression.setText( "" ); - fChkBtnRead.setSelection( false ); - fChkBtnWrite.setSelection( true ); + fTextExpression.setText( fExpression ); + fChkBtnRead.setSelection( fRead ); + fChkBtnWrite.setSelection( fWrite ); setOkButtonState(); } @@ -174,4 +178,13 @@ public class AddWatchpointDialog extends Dialog { return fRead; } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.Dialog#okPressed() + */ + protected void okPressed() + { + storeData(); + super.okPressed(); + } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/CBreakpointPreferencePage.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/CBreakpointPreferencePage.java index d12416c307c..8be3f3918da 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/CBreakpointPreferencePage.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/CBreakpointPreferencePage.java @@ -6,6 +6,7 @@ package org.eclipse.cdt.debug.internal.ui.actions; import org.eclipse.cdt.debug.core.ICBreakpoint; +import org.eclipse.cdt.debug.core.ICWatchpoint; import org.eclipse.cdt.debug.ui.CDebugUIPlugin; import org.eclipse.core.resources.IMarker; import org.eclipse.core.runtime.CoreException; @@ -254,34 +255,9 @@ public class CBreakpointPreferencePage extends FieldEditorPreferencePage protected void createFieldEditors() { ICBreakpoint breakpoint = getBreakpoint(); - String fileName = breakpoint.getMarker().getResource().getLocation().toOSString(); - if ( fileName != null ) - { - addField( createLabelEditor( getFieldEditorParent(), "File: ", fileName ) ); - } - if ( breakpoint instanceof ILineBreakpoint ) - { - setTitle( "C/C++ Line Breakpoint Properties" ); - ILineBreakpoint lBreakpoint = (ILineBreakpoint)breakpoint; - StringBuffer lineNumber = new StringBuffer( 4 ); - try - { - int lNumber = lBreakpoint.getLineNumber(); - if ( lNumber > 0 ) - { - lineNumber.append( lNumber ); - } - } - catch( CoreException ce ) - { - CDebugUIPlugin.log( ce ); - } - if ( lineNumber.length() > 0 ) - { - addField( createLabelEditor( getFieldEditorParent(), "Line Number: ", lineNumber.toString() ) ); - } - } + createTypeSpecificLabelFieldEditors( breakpoint ); + IPreferenceStore store = getPreferenceStore(); try @@ -307,6 +283,68 @@ public class CBreakpointPreferencePage extends FieldEditorPreferencePage } } + /** + * Method createTypeSpecificLabelFieldEditors. + * @param breakpoint + */ + private void createTypeSpecificLabelFieldEditors( ICBreakpoint breakpoint ) + { + if ( breakpoint instanceof ILineBreakpoint ) + { + String fileName = breakpoint.getMarker().getResource().getLocation().toOSString(); + if ( fileName != null ) + { + addField( createLabelEditor( getFieldEditorParent(), "File: ", fileName ) ); + } + setTitle( "C/C++ Line Breakpoint Properties" ); + ILineBreakpoint lBreakpoint = (ILineBreakpoint)breakpoint; + StringBuffer lineNumber = new StringBuffer( 4 ); + try + { + int lNumber = lBreakpoint.getLineNumber(); + if ( lNumber > 0 ) + { + lineNumber.append( lNumber ); + } + } + catch( CoreException ce ) + { + CDebugUIPlugin.log( ce ); + } + if ( lineNumber.length() > 0 ) + { + addField( createLabelEditor( getFieldEditorParent(), "Line Number: ", lineNumber.toString() ) ); + } + } + else if ( breakpoint instanceof ICWatchpoint ) + { + String projectName = breakpoint.getMarker().getResource().getLocation().toOSString(); + if ( projectName != null ) + { + addField( createLabelEditor( getFieldEditorParent(), "Project: ", projectName ) ); + } + ICWatchpoint watchpoint = (ICWatchpoint)breakpoint; + String title = ""; + String expression = ""; + try + { + if ( watchpoint.isReadType() && !watchpoint.isWriteType() ) + title = "C/C++ Read Watchpoint Properties"; + else if ( !watchpoint.isReadType() && watchpoint.isWriteType() ) + title = "C/C++ Watchpoint Properties"; + else + title = "C/C++ Access Watchpoint Properties"; + expression = watchpoint.getExpression(); + } + catch( CoreException ce ) + { + CDebugUIPlugin.log( ce ); + } + setTitle( title ); + addField( createLabelEditor( getFieldEditorParent(), "Expression To Watch: ", expression ) ); + } + } + protected void createConditionEditor( Composite parent ) { fCondition = new BreakpointStringFieldEditor( CBreakpointPreferenceStore.CONDITION, "&Condition", parent ); diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ManageBreakpointActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ManageBreakpointActionDelegate.java index 458403ff65c..e6e654f2f4e 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ManageBreakpointActionDelegate.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ManageBreakpointActionDelegate.java @@ -5,9 +5,6 @@ */ package org.eclipse.cdt.debug.internal.ui.actions; -import java.util.HashMap; -import java.util.Map; - import org.eclipse.cdt.debug.core.CDebugModel; import org.eclipse.cdt.debug.core.ICLineBreakpoint; import org.eclipse.cdt.debug.ui.CDebugUIPlugin; @@ -21,6 +18,7 @@ import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IFileEditorInput; import org.eclipse.ui.IPartListener; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchPart; @@ -263,8 +261,11 @@ public class ManageBreakpointActionDelegate implements IWorkbenchWindowActionDel protected void setTextEditor( ITextEditor editor ) { fTextEditor = editor; - IEditorInput input = fTextEditor.getEditorInput(); - fFile = (IFile)input.getAdapter( IFile.class ); + if ( fTextEditor != null ) + { + IEditorInput input = fTextEditor.getEditorInput(); + setFile( ( input != null && input instanceof IFileEditorInput ) ? ((IFileEditorInput)input).getFile() : null ); + } setEnabledState( editor ); } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ManageWatchpointActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ManageWatchpointActionDelegate.java deleted file mode 100644 index 63e71e4b748..00000000000 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ManageWatchpointActionDelegate.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - *(c) Copyright QNX Software Systems Ltd. 2002. - * All Rights Reserved. - * - */ -package org.eclipse.cdt.debug.internal.ui.actions; - -import org.eclipse.cdt.debug.ui.CDebugUIPlugin; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.ui.IPartListener; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.IWorkbenchWindowActionDelegate; - -/** - * - * Action for adding/removing watchpoints at a selection in the active - * C/C++ or assembly editor. - * - * @since Sep 4, 2002 - */ -public class ManageWatchpointActionDelegate implements IWorkbenchWindowActionDelegate, - IPartListener -{ - /** - * Constructor for ManageWatchpointActionDelegate. - */ - public ManageWatchpointActionDelegate() - { - super(); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose() - */ - public void dispose() - { - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(IWorkbenchWindow) - */ - public void init( IWorkbenchWindow window ) - { - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IPartListener#partActivated(IWorkbenchPart) - */ - public void partActivated( IWorkbenchPart part ) - { - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IPartListener#partBroughtToTop(IWorkbenchPart) - */ - public void partBroughtToTop( IWorkbenchPart part ) - { - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IPartListener#partClosed(IWorkbenchPart) - */ - public void partClosed( IWorkbenchPart part ) - { - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IPartListener#partDeactivated(IWorkbenchPart) - */ - public void partDeactivated( IWorkbenchPart part ) - { - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IPartListener#partOpened(IWorkbenchPart) - */ - public void partOpened( IWorkbenchPart part ) - { - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IActionDelegate#run(IAction) - */ - public void run( IAction action ) - { - Dialog dlg = new AddWatchpointDialog( CDebugUIPlugin.getActiveWorkbenchShell() ); - dlg.open(); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IActionDelegate#selectionChanged(IAction, ISelection) - */ - public void selectionChanged( IAction action, ISelection selection ) - { - } -} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/WatchpointExpressionVerifier.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/WatchpointExpressionVerifier.java new file mode 100644 index 00000000000..743af06f6ab --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/WatchpointExpressionVerifier.java @@ -0,0 +1,26 @@ +/* + *(c) Copyright QNX Software Systems Ltd. 2002. + * All Rights Reserved. + * + */ +package org.eclipse.cdt.debug.internal.ui.actions; + +import org.eclipse.jface.text.IDocument; + +/** + * + * Enter type comment. + * + * @since Sep 5, 2002 + */ +public class WatchpointExpressionVerifier +{ + /** + * Returns whether the specified expression is valid for a watchpoint. + */ + public boolean isValidExpression( IDocument doc, String expression ) + { + // for now + return expression.trim().length() > 0; + } +}