diff --git a/debug/org.eclipse.cdt.debug.core/plugin.xml b/debug/org.eclipse.cdt.debug.core/plugin.xml index 35aca2f7481..35bbfb4fcc7 100644 --- a/debug/org.eclipse.cdt.debug.core/plugin.xml +++ b/debug/org.eclipse.cdt.debug.core/plugin.xml @@ -50,6 +50,9 @@ + + + value="true"> @@ -103,17 +106,17 @@ 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 89912517cdc..3b4bdfaa835 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 @@ -159,7 +159,7 @@ public class CDebugModel ICLineBreakpoint breakpoint = (ICLineBreakpoint)breakpoints[i]; if ( breakpoint.getMarker().getType().equals( markerType ) ) { - if ( breakpoint.getMarker().getResource().getLocation().toString().equals( fileName ) ) + if ( breakpoint.getMarker().getResource().getLocation().toOSString().equals( fileName ) ) { if ( breakpoint.getLineNumber() == lineNumber ) { diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CAddressBreakpoint.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CAddressBreakpoint.java index 0363f63702f..449713b46bd 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CAddressBreakpoint.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CAddressBreakpoint.java @@ -30,6 +30,13 @@ public class CAddressBreakpoint extends CBreakpoint implements ICAddressBreakpoi */ protected static final String ADDRESS = "org.eclipse.cdt.debug.core.address"; //$NON-NLS-1$ + /** + * Constructor for CAddressBreakpoint. + */ + public CAddressBreakpoint() + { + } + /** * Constructor for CAddressBreakpoint. */ diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CBreakpoint.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CBreakpoint.java index 035e637f31d..a39341f4c99 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CBreakpoint.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CBreakpoint.java @@ -61,6 +61,13 @@ public abstract class CBreakpoint extends Breakpoint */ protected static final String THREAD_ID = "org.eclipse.cdt.debug.core.threadId"; //$NON-NLS-1$ + /** + * Constructor for CBreakpoint. + */ + public CBreakpoint() + { + } + /** * Constructor for CBreakpoint. */ diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CFunctionBreakpoint.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CFunctionBreakpoint.java index 87e71b1de05..a8801764b16 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CFunctionBreakpoint.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CFunctionBreakpoint.java @@ -30,6 +30,13 @@ public class CFunctionBreakpoint extends CBreakpoint implements ICFunctionBreakp */ protected static final String FUNCTION = "org.eclipse.cdt.debug.core.function"; //$NON-NLS-1$ + /** + * Constructor for CFunctionBreakpoint. + */ + public CFunctionBreakpoint() + { + } + /** * Constructor for CFunctionBreakpoint. */ diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CLineBreakpoint.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CLineBreakpoint.java index fa27a0f4ddf..8b412b65aa4 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CLineBreakpoint.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CLineBreakpoint.java @@ -25,6 +25,13 @@ public class CLineBreakpoint extends CBreakpoint implements ICLineBreakpoint { private static final String C_LINE_BREAKPOINT = "org.eclipse.cdt.debug.core.cLineBreakpointMarker"; //$NON-NLS-1$ + /** + * Constructor for CLineBreakpoint. + */ + public CLineBreakpoint() + { + } + /** * Constructor for CLineBreakpoint. */ diff --git a/debug/org.eclipse.cdt.debug.ui/icons/full/obj16/brkpi_obj.gif b/debug/org.eclipse.cdt.debug.ui/icons/full/obj16/brkpi_obj.gif new file mode 100644 index 00000000000..afcf4b89103 Binary files /dev/null and b/debug/org.eclipse.cdt.debug.ui/icons/full/obj16/brkpi_obj.gif differ diff --git a/debug/org.eclipse.cdt.debug.ui/plugin.properties b/debug/org.eclipse.cdt.debug.ui/plugin.properties index 0d980e62263..6c77d2c81ce 100644 --- a/debug/org.eclipse.cdt.debug.ui/plugin.properties +++ b/debug/org.eclipse.cdt.debug.ui/plugin.properties @@ -18,4 +18,6 @@ RestartAction.tooltip=Restart AddBreakpoint.label=Add/Remove &Breakpoint EnableBreakpoint.label=T&oggle Breakpoint -BreakpointProperties.label=Breakpoint &Properties... \ No newline at end of file +BreakpointProperties.label=Breakpoint P&roperties... +ManageBreakpointAction.label=Add/Remove C/C++ Brea&kpoint +BreakpointPropertiesAction.label=P&roperties... \ No newline at end of file diff --git a/debug/org.eclipse.cdt.debug.ui/plugin.xml b/debug/org.eclipse.cdt.debug.ui/plugin.xml index 6312b8a570c..091f6b20c41 100644 --- a/debug/org.eclipse.cdt.debug.ui/plugin.xml +++ b/debug/org.eclipse.cdt.debug.ui/plugin.xml @@ -90,6 +90,26 @@ helpContextId="restart_action_context" label="%RestartAction.label" menubarPath="org.eclipse.ui.run/stepGroup"> + + + + + + + + + + @@ -133,6 +153,18 @@ id="org.eclipse.cdt.debug.internal.ui.actions.ManageBreakpointRulerActionDelegate"> + + + + @@ -153,5 +185,18 @@ + + + + + + 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 5ff9553498b..620081ad451 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 @@ -118,6 +118,8 @@ public class CDTDebugModelPresentation extends LabelProvider } if ( element instanceof IFile ) file = (IFile)element; + if ( element instanceof ICLineBreakpoint ) + file = (IFile)((ICLineBreakpoint)element).getMarker().getResource().getAdapter( IFile.class ); if ( file != null ) return new FileEditorInput( file ); /* diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/CBreakpointPropertiesAction.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/CBreakpointPropertiesAction.java new file mode 100644 index 00000000000..c217fbaf98d --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/CBreakpointPropertiesAction.java @@ -0,0 +1,91 @@ +/* + *(c) Copyright QNX Software Systems Ltd. 2002. + * All Rights Reserved. + * + */ +package org.eclipse.cdt.debug.internal.ui.actions; + +import org.eclipse.cdt.debug.core.ICBreakpoint; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.ui.IObjectActionDelegate; +import org.eclipse.ui.IWorkbenchPart; + +/** + * + * Presents a custom properties dialog to configure the attibutes of a C/C++ breakpoint. + * + * @since Sep 3, 2002 + */ +public class CBreakpointPropertiesAction implements IObjectActionDelegate +{ + private IWorkbenchPart fPart; + private ICBreakpoint fBreakpoint; + + /** + * Constructor for CBreakpointPropertiesAction. + */ + public CBreakpointPropertiesAction() + { + super(); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart) + */ + public void setActivePart( IAction action, IWorkbenchPart targetPart ) + { + fPart = targetPart; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IActionDelegate#run(IAction) + */ + public void run( IAction action ) + { + Dialog d = new CBreakpointPropertiesDialog( getActivePart().getSite().getShell(), getBreakpoint() ); + d.open(); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IActionDelegate#selectionChanged(IAction, ISelection) + */ + public void selectionChanged( IAction action, ISelection selection ) + { + if ( selection instanceof IStructuredSelection ) + { + IStructuredSelection ss = (IStructuredSelection)selection; + if ( ss.isEmpty() || ss.size() > 1 ) + { + return; + } + Object element = ss.getFirstElement(); + if ( element instanceof ICBreakpoint ) + { + setBreakpoint( (ICBreakpoint)element ); + } + } + } + + protected IWorkbenchPart getActivePart() + { + return fPart; + } + + protected void setActivePart( IWorkbenchPart part ) + { + fPart = part; + } + + protected ICBreakpoint getBreakpoint() + { + return fBreakpoint; + } + + protected void setBreakpoint( ICBreakpoint breakpoint ) + { + fBreakpoint = breakpoint; + } +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/CBreakpointPropertiesDialog.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/CBreakpointPropertiesDialog.java index 754418c55cb..0ad260d1f93 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/CBreakpointPropertiesDialog.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/CBreakpointPropertiesDialog.java @@ -6,6 +6,7 @@ package org.eclipse.cdt.debug.internal.ui.actions; import java.util.ArrayList; +import java.util.Iterator; import java.util.List; import org.eclipse.cdt.debug.core.ICBreakpoint; @@ -311,6 +312,20 @@ public class CBreakpointPropertiesDialog extends Dialog { public void run( IProgressMonitor monitor ) throws CoreException { + ICBreakpoint breakpoint = getBreakpoint(); + Iterator changed = changedProperties.iterator(); + while ( changed.hasNext() ) + { + String property = (String)changed.next(); + if ( property.equals( CBreakpointPreferenceStore.IGNORE_COUNT ) ) + { + breakpoint.setIgnoreCount( getPreferenceStore().getInt( CBreakpointPreferenceStore.IGNORE_COUNT ) ); + } + else if ( property.equals( CBreakpointPreferenceStore.CONDITION ) ) + { + breakpoint.setCondition( getPreferenceStore().getString( CBreakpointPreferenceStore.CONDITION ) ); + } + } } }; 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 new file mode 100644 index 00000000000..458403ff65c --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ManageBreakpointActionDelegate.java @@ -0,0 +1,316 @@ +/* + *(c) Copyright QNX Software Systems Ltd. 2002. + * All Rights Reserved. + * + */ +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; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.debug.core.DebugPlugin; +import org.eclipse.jface.action.IAction; +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.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 breakpoints at a line in the source file + * shown in the active C/C++ Editor. + * + * @since Sep 3, 2002 + */ +public class ManageBreakpointActionDelegate implements IWorkbenchWindowActionDelegate, + IPartListener +{ + private boolean fInitialized = false; + private IAction fAction = null; + private int fLineNumber; + private ITextEditor fTextEditor = null; + private IWorkbenchWindow fWorkbenchWindow = null; + private IFile fFile = null; + + /** + * Constructor for ManageBreakpointActionDelegate. + */ + public ManageBreakpointActionDelegate() + { + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose() + */ + public void dispose() + { + getWorkbenchWindow().getPartService().removePartListener( this ); + } + + /* (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.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 ); + } + } + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IActionDelegate#run(IAction) + */ + public void run( IAction action ) + { + if ( getTextEditor() != null ) + { + update(); + manageBreakpoint( getTextEditor().getEditorInput() ); + } + } + + protected void update( ISelection selection ) + { + setEnabledState( getTextEditor() ); + } + + protected void update() + { + IAction action = getAction(); + if ( action != null ) + { + if ( getTextEditor() != null ) + { + breakpointExists( getTextEditor().getEditorInput() ); + } + action.setEnabled( getTextEditor() != null && getFile() != null ); + } + } + + /* (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 ); + update( getTextEditor().getSelectionProvider().getSelection() ); + } + } + } + fInitialized = true; + } + update( selection ); + } + + /** + * Manages a breakpoint. + */ + protected void manageBreakpoint( IEditorInput editorInput ) + { + ISelectionProvider sp = getTextEditor().getSelectionProvider(); + if ( sp == null || getFile() == null ) + { + beep(); + return; + } + ISelection selection = sp.getSelection(); + if ( selection instanceof ITextSelection ) + { + if ( getFile() == null ) + return; + IDocument document = getTextEditor().getDocumentProvider().getDocument( editorInput ); + BreakpointLocationVerifier bv = new BreakpointLocationVerifier(); + int lineNumber = bv.getValidBreakpointLocation( document, ((ITextSelection)selection).getStartLine()); + if ( lineNumber > -1 ) + { + try + { + ICLineBreakpoint breakpoint = CDebugModel.lineBreakpointExists( getFile().getLocation().toOSString(), lineNumber ); + if ( breakpoint != null ) + { + DebugPlugin.getDefault().getBreakpointManager().removeBreakpoint( breakpoint, true ); + } + else + { + CDebugModel.createLineBreakpoint( getFile(), + lineNumber, + true, + 0, + "", + true ); + } + } + catch( CoreException ce ) + { + CDebugUIPlugin.errorDialog( "Cannot add breakpoint", ce ); + } + } + } + } + + /** + * Determines if a breakpoint exists on the line of the current selection. + */ + protected boolean breakpointExists(IEditorInput editorInput) + { + if ( getFile() != null ) + { + try + { + return CDebugModel.lineBreakpointExists( getFile().getLocation().toOSString(), getLineNumber() ) == null; + } + catch (CoreException ce) + { + CDebugUIPlugin.log( ce ); + } + } + + return false; + } + + protected IWorkbenchWindow getWorkbenchWindow() + { + return fWorkbenchWindow; + } + + protected void setWorkbenchWindow( IWorkbenchWindow workbenchWindow ) + { + fWorkbenchWindow = workbenchWindow; + } + + protected ITextEditor getTextEditor() + { + return fTextEditor; + } + + protected void setTextEditor( ITextEditor editor ) + { + fTextEditor = editor; + IEditorInput input = fTextEditor.getEditorInput(); + fFile = (IFile)input.getAdapter( IFile.class ); + setEnabledState( editor ); + } + + protected void setEnabledState( ITextEditor editor ) + { + if ( getAction() != null ) + { + getAction().setEnabled( editor != null ); + } + } + + protected void beep() + { + if ( CDebugUIPlugin.getActiveWorkbenchShell() != null ) + { + CDebugUIPlugin.getActiveWorkbenchShell().getDisplay().beep(); + } + } + + protected int getLineNumber() + { + return fLineNumber; + } + + protected void setLineNumber( int lineNumber ) + { + fLineNumber = lineNumber; + } + + protected IAction getAction() + { + return fAction; + } + + protected void setAction( IAction action ) + { + fAction = action; + } + + protected IFile getFile() + { + return fFile; + } + + protected void setFile( IFile file ) + { + fFile = file; + } +}