null
+ * if no such breakpoint is registered
+ * @exception CoreException if unable to retrieve the associated marker
+ * attributes (line number).
+ */
+ public static ICLineBreakpoint lineBreakpointExists( String fileName, int lineNumber ) throws CoreException
+ {
+ String modelId = getPluginIdentifier();
+ String markerType = CLineBreakpoint.getMarkerType();
+ IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager();
+ IBreakpoint[] breakpoints = manager.getBreakpoints( modelId );
+ for ( int i = 0; i < breakpoints.length; i++ )
+ {
+ if ( !( breakpoints[i] instanceof ICLineBreakpoint ) )
+ {
+ continue;
+ }
+ ICLineBreakpoint breakpoint = (ICLineBreakpoint)breakpoints[i];
+ if ( breakpoint.getMarker().getType().equals( markerType ) )
+ {
+ if ( breakpoint.getMarker().getResource().getLocation().toString().equals( fileName ) )
+ {
+ if ( breakpoint.getLineNumber() == lineNumber )
+ {
+ return breakpoint;
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Creates and returns a line breakpoint in the file with the
+ * given name, at the given line number. The marker associated with the
+ * breakpoint will be created on the specified resource. If a character
+ * range within the line is known, it may be specified by charStart/charEnd.
+ * If ignoreCount is > 0, the breakpoint will suspend execution when it is
+ * "hit" the specified number of times.
+ *
+ * @param resource the resource on which to create the associated breakpoint
+ * marker
+ * @param typeName the fully qualified name of the type the breakpoint is
+ * to be installed in. If the breakpoint is to be installed in an inner type,
+ * it is sufficient to provide the name of the top level enclosing type.
+ * If an inner class name is specified, it should be formatted as the
+ * associated class file name (i.e. with $
). For example,
+ * example.SomeClass$InnerType
, could be specified, but
+ * example.SomeClass
is sufficient.
+ * @param lineNumber the lineNumber on which the breakpoint is set - line
+ * numbers are 1 based, associated with the source file in which
+ * the breakpoint is set
+ * @param charStart the first character index associated with the breakpoint,
+ * or -1 if unspecified, in the source file in which the breakpoint is set
+ * @param charEnd the last character index associated with the breakpoint,
+ * or -1 if unspecified, in the source file in which the breakpoint is set
+ * @param hitCount the number of times the breakpoint will be hit before
+ * suspending execution - 0 if it should always suspend
+ * @param register whether to add this breakpoint to the breakpoint manager
+ * @param attributes a map of client defined attributes that should be assigned
+ * to the underlying breakpoint marker on creation, or null
if none.
+ * @return a line breakpoint
+ * @exception DebugException If this method fails. Reasons include:
+ */
+ public static ICLineBreakpoint createLineBreakpoint( IResource resource,
+ int lineNumber,
+ boolean enabled,
+ int ignoreCount,
+ String condition,
+ boolean add ) throws DebugException
+ {
+ HashMap attributes = new HashMap( 10 );
+ attributes.put( ICBreakpoint.ID, getPluginIdentifier() );
+ attributes.put( IMarker.LINE_NUMBER, new Integer( lineNumber ) );
+ attributes.put( ICBreakpoint.ENABLED, new Boolean( enabled ) );
+ attributes.put( ICBreakpoint.IGNORE_COUNT, new Integer( ignoreCount ) );
+ attributes.put( ICBreakpoint.CONDITION, condition );
+ return new CLineBreakpoint( resource, attributes, add );
+ }
+
}
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICBreakpoint.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICBreakpoint.java
index df43e3095fa..fb207fb3d45 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICBreakpoint.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICBreakpoint.java
@@ -24,6 +24,14 @@ import org.eclipse.debug.core.model.IBreakpoint;
*/
public interface ICBreakpoint extends IBreakpoint
{
+ /*
+ * C Breakpoint attributes
+ */
+ public static final String CONDITION = "condition"; //$NON-NLS-1$
+ public static final String IGNORE_COUNT = "ignoreCount"; //$NON-NLS-1$
+ public static final String THREAD_ID = "threadId"; //$NON-NLS-1$
+ public static final String INSTALL_COUNT = "installCount"; //$NON-NLS-1$
+
/**
* Returns whether this breakpoint is installed in at least
* one debug target.
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 a01f0f1c89a..0363f63702f 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
@@ -5,9 +5,13 @@
*/
package org.eclipse.cdt.debug.internal.core.breakpoints;
+import java.util.Map;
+
import org.eclipse.cdt.debug.core.ICAddressBreakpoint;
import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.DebugException;
/**
*
@@ -17,6 +21,8 @@ import org.eclipse.core.runtime.CoreException;
*/
public class CAddressBreakpoint extends CBreakpoint implements ICAddressBreakpoint
{
+ private static final String C_ADDRESS_BREAKPOINT = "org.eclipse.jdt.debug.cAddressBreakpointMarker"; //$NON-NLS-1$
+
/**
* Breakpoint attribute storing the address this breakpoint suspends
* execution at (value "org.eclipse.cdt.debug.core.address"
).
@@ -27,9 +33,9 @@ public class CAddressBreakpoint extends CBreakpoint implements ICAddressBreakpoi
/**
* Constructor for CAddressBreakpoint.
*/
- public CAddressBreakpoint()
+ public CAddressBreakpoint( IResource resource, Map attributes, boolean add ) throws DebugException
{
- super();
+ super( resource, C_ADDRESS_BREAKPOINT, attributes, add );
}
/* (non-Javadoc)
@@ -71,4 +77,12 @@ public class CAddressBreakpoint extends CBreakpoint implements ICAddressBreakpoi
{
return ensureMarker().getAttribute( IMarker.CHAR_END, -1 );
}
+
+ /**
+ * Returns the type of marker associated with this type of breakpoints
+ */
+ public static String getMarkerType()
+ {
+ return C_ADDRESS_BREAKPOINT;
+ }
}
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 54820fb4fe8..4eb3a7a081b 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
@@ -6,10 +6,20 @@
package org.eclipse.cdt.debug.internal.core.breakpoints;
+import java.text.MessageFormat;
+import java.util.Map;
+
import org.eclipse.cdt.debug.core.CDebugModel;
import org.eclipse.cdt.debug.core.ICBreakpoint;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.debug.core.DebugEvent;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.IDebugEventSetListener;
import org.eclipse.debug.core.model.Breakpoint;
@@ -54,9 +64,26 @@ public abstract class CBreakpoint extends Breakpoint
/**
* Constructor for CBreakpoint.
*/
- public CBreakpoint()
+ public CBreakpoint( final IResource resource, final String markerType, final Map attributes, final boolean add ) throws DebugException
{
- super();
+ IWorkspaceRunnable wr= new IWorkspaceRunnable()
+ {
+ public void run( IProgressMonitor monitor ) throws CoreException
+ {
+ // create the marker
+ setMarker( resource.createMarker( markerType ) );
+
+ // set attributes
+ ensureMarker().setAttributes( attributes );
+
+ //set the marker message
+ setAttribute( IMarker.MESSAGE, getMarkerMessage() );
+
+ // add to breakpoint manager if requested
+ register( add );
+ }
+ };
+ run( wr );
}
/* (non-Javadoc)
@@ -129,4 +156,40 @@ public abstract class CBreakpoint extends Breakpoint
public void handleDebugEvents( DebugEvent[] events )
{
}
+
+ /**
+ * Execute the given workspace runnable
+ */
+ protected void run( IWorkspaceRunnable wr ) throws DebugException
+ {
+ try
+ {
+ ResourcesPlugin.getWorkspace().run( wr, null );
+ }
+ catch ( CoreException e )
+ {
+ throw new DebugException( e.getStatus() );
+ }
+ }
+
+ /**
+ * Add this breakpoint to the breakpoint manager,
+ * or sets it as unregistered.
+ */
+ protected void register( boolean register ) throws CoreException
+ {
+ if ( register )
+ {
+ DebugPlugin.getDefault().getBreakpointManager().addBreakpoint( this );
+ }
+ else
+ {
+ setRegistered( false );
+ }
+ }
+
+ protected String getMarkerMessage() throws CoreException
+ {
+ return null;
+ }
}
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 6cda614e8aa..87e71b1de05 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
@@ -5,9 +5,13 @@
*/
package org.eclipse.cdt.debug.internal.core.breakpoints;
+import java.util.Map;
+
import org.eclipse.cdt.debug.core.ICFunctionBreakpoint;
import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.DebugException;
/**
*
@@ -17,6 +21,8 @@ import org.eclipse.core.runtime.CoreException;
*/
public class CFunctionBreakpoint extends CBreakpoint implements ICFunctionBreakpoint
{
+ private static final String C_FUNCTION_BREAKPOINT = "org.eclipse.jdt.debug.cFunctionBreakpointMarker"; //$NON-NLS-1$
+
/**
* Breakpoint attribute storing the function this breakpoint suspends
* execution in (value "org.eclipse.cdt.debug.core.function"
).
@@ -27,10 +33,11 @@ public class CFunctionBreakpoint extends CBreakpoint implements ICFunctionBreakp
/**
* Constructor for CFunctionBreakpoint.
*/
- public CFunctionBreakpoint()
+ public CFunctionBreakpoint( IResource resource, Map attributes, boolean add ) throws DebugException
{
- super();
+ super( resource, C_FUNCTION_BREAKPOINT, attributes, add );
}
+
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.ICFunctionBreakpoint#getFunction()
*/
@@ -70,4 +77,12 @@ public class CFunctionBreakpoint extends CBreakpoint implements ICFunctionBreakp
{
return ensureMarker().getAttribute( IMarker.CHAR_END, -1 );
}
+
+ /**
+ * Returns the type of marker associated with this type of breakpoints
+ */
+ public static String getMarkerType()
+ {
+ return C_FUNCTION_BREAKPOINT;
+ }
}
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 e3ffa8fad62..fa27a0f4ddf 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
@@ -5,9 +5,15 @@
*/
package org.eclipse.cdt.debug.internal.core.breakpoints;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.cdt.debug.core.ICBreakpoint;
import org.eclipse.cdt.debug.core.ICLineBreakpoint;
import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.DebugException;
/**
*
@@ -17,12 +23,14 @@ import org.eclipse.core.runtime.CoreException;
*/
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()
+ public CLineBreakpoint( IResource resource, Map attributes, boolean add ) throws DebugException
{
- super();
+ super( resource, getMarkerType(), attributes, add );
}
/* (non-Javadoc)
@@ -48,4 +56,12 @@ public class CLineBreakpoint extends CBreakpoint implements ICLineBreakpoint
{
return ensureMarker().getAttribute( IMarker.CHAR_END, -1 );
}
+
+ /**
+ * Returns the type of marker associated with this type of breakpoints
+ */
+ public static String getMarkerType()
+ {
+ return C_LINE_BREAKPOINT;
+ }
}
diff --git a/debug/org.eclipse.cdt.debug.ui/icons/full/ovr16/installed_ovr.gif b/debug/org.eclipse.cdt.debug.ui/icons/full/ovr16/installed_ovr.gif
new file mode 100644
index 00000000000..7f4a31ee7eb
Binary files /dev/null and b/debug/org.eclipse.cdt.debug.ui/icons/full/ovr16/installed_ovr.gif differ
diff --git a/debug/org.eclipse.cdt.debug.ui/icons/full/ovr16/installed_ovr_disabled.gif b/debug/org.eclipse.cdt.debug.ui/icons/full/ovr16/installed_ovr_disabled.gif
new file mode 100644
index 00000000000..9325bc10473
Binary files /dev/null and b/debug/org.eclipse.cdt.debug.ui/icons/full/ovr16/installed_ovr_disabled.gif differ
diff --git a/debug/org.eclipse.cdt.debug.ui/plugin.properties b/debug/org.eclipse.cdt.debug.ui/plugin.properties
index a1b98474da7..0d980e62263 100644
--- a/debug/org.eclipse.cdt.debug.ui/plugin.properties
+++ b/debug/org.eclipse.cdt.debug.ui/plugin.properties
@@ -18,3 +18,4 @@ RestartAction.tooltip=Restart
AddBreakpoint.label=Add/Remove &Breakpoint
EnableBreakpoint.label=T&oggle Breakpoint
+BreakpointProperties.label=Breakpoint &Properties...
\ 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 e949545d760..6312b8a570c 100644
--- a/debug/org.eclipse.cdt.debug.ui/plugin.xml
+++ b/debug/org.eclipse.cdt.debug.ui/plugin.xml
@@ -111,6 +111,13 @@
ImageDescriptors
to Image
.
+ *
+ * @since Aug 30, 2002
+ */
+public class CDebugImageDescriptorRegistry
+{
+ private HashMap fRegistry = new HashMap(10);
+ private Display fDisplay;
+
+ /**
+ * Creates a new image descriptor registry for the current or default display,
+ * respectively.
+ */
+ public CDebugImageDescriptorRegistry()
+ {
+ this( CDebugUIPlugin.getStandardDisplay() );
+ }
+
+ /**
+ * Creates a new image descriptor registry for the given display. All images
+ * managed by this registry will be disposed when the display gets disposed.
+ *
+ * @param diaplay the display the images managed by this registry are allocated for
+ */
+ public CDebugImageDescriptorRegistry( Display display )
+ {
+ fDisplay = display;
+ Assert.isNotNull( fDisplay );
+ hookDisplay();
+ }
+
+ /**
+ * Returns the image associated with the given image descriptor.
+ *
+ * @param descriptor the image descriptor for which the registry manages an image
+ * @return the image associated with the image descriptor or null
+ * if the image descriptor can't create the requested image.
+ */
+ public Image get( ImageDescriptor descriptor )
+ {
+ if ( descriptor == null )
+ descriptor = ImageDescriptor.getMissingImageDescriptor();
+
+ Image result = (Image)fRegistry.get( descriptor );
+ if ( result != null )
+ return result;
+
+ Assert.isTrue( fDisplay == CDebugUIPlugin.getStandardDisplay(), "Allocating image for wrong display" );
+ result = descriptor.createImage();
+ if ( result != null )
+ fRegistry.put( descriptor, result );
+ return result;
+ }
+
+ /**
+ * Disposes all images managed by this registry.
+ */
+ public void dispose()
+ {
+ for ( Iterator iter = fRegistry.values().iterator(); iter.hasNext(); )
+ {
+ Image image = (Image)iter.next();
+ image.dispose();
+ }
+ fRegistry.clear();
+ }
+
+ private void hookDisplay()
+ {
+ fDisplay.disposeExec( new Runnable()
+ {
+ public void run()
+ {
+ dispose();
+ }
+ } );
+ }
+}
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
new file mode 100644
index 00000000000..391e6f5378f
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java
@@ -0,0 +1,172 @@
+/*
+ *(c) Copyright QNX Software Systems Ltd. 2002.
+ * All Rights Reserved.
+ *
+ */
+package org.eclipse.cdt.debug.internal.ui;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ *
+ * Bundle of most images used by the C/C++ debug plug-in.
+ *
+ * @since Aug 30, 2002
+ */
+public class CDebugImages
+{
+ private static final String NAME_PREFIX = "org.eclipse.jdt.debug.ui."; //$NON-NLS-1$
+ private static final int NAME_PREFIX_LENGTH = NAME_PREFIX.length();
+
+ private static URL fgIconBaseURL = null;
+
+ static
+ {
+ String pathSuffix = "icons/full/"; //$NON-NLS-1$
+ try
+ {
+ fgIconBaseURL = new URL( CDebugUIPlugin.getDefault().getDescriptor().getInstallURL(), pathSuffix );
+ }
+ catch( MalformedURLException e )
+ {
+ CDebugUIPlugin.log( e );
+ }
+ }
+
+ // The plugin registry
+ private final static ImageRegistry IMAGE_REGISTRY = new ImageRegistry( CDebugUIPlugin.getStandardDisplay() );
+
+ /*
+ * Available cached Images in the C/C++ debug plug-in image registry.
+ */
+ public static final String IMG_OBJS_BREAKPOINT_INSTALLED = NAME_PREFIX + "installed_ovr.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_BREAKPOINT_INSTALLED_DISABLED = NAME_PREFIX + "installed_ovr_disabled.gif"; //$NON-NLS-1$
+
+ /*
+ * Set of predefined Image Descriptors.
+ */
+ private static final String T_OBJ = "obj16"; //$NON-NLS-1$
+ private static final String T_OVR = "ovr16"; //$NON-NLS-1$
+ private static final String T_WIZBAN = "wizban"; //$NON-NLS-1$
+ private static final String T_LCL = "clcl16"; //$NON-NLS-1$
+ private static final String T_CTOOL = "ctool16"; //$NON-NLS-1$
+ private static final String T_CVIEW = "cview16"; //$NON-NLS-1$
+ private static final String T_DTOOL = "dtool16"; //$NON-NLS-1$
+ private static final String T_ETOOL = "etool16"; //$NON-NLS-1$
+
+ public static final ImageDescriptor DESC_OBJS_BREAKPOINT_INSTALLED = createManaged( T_OVR, IMG_OBJS_BREAKPOINT_INSTALLED );
+ public static final ImageDescriptor DESC_OBJS_BREAKPOINT_INSTALLED_DISABLED = createManaged( T_OVR, IMG_OBJS_BREAKPOINT_INSTALLED_DISABLED );
+
+ /**
+ * Returns the image managed under the given key in this registry.
+ *
+ * @param key the image's key
+ * @return the image managed under the given key
+ */
+ public static Image get( String key )
+ {
+ return IMAGE_REGISTRY.get( key );
+ }
+
+ /**
+ * Sets the three image descriptors for enabled, disabled, and hovered to an action. The actions
+ * are retrieved from the *tool16 folders.
+ */
+ public static void setToolImageDescriptors( IAction action, String iconName )
+ {
+ setImageDescriptors( action, "tool16", iconName ); //$NON-NLS-1$
+ }
+
+ /**
+ * Sets the three image descriptors for enabled, disabled, and hovered to an action. The actions
+ * are retrieved from the *lcl16 folders.
+ */
+ public static void setLocalImageDescriptors( IAction action, String iconName )
+ {
+ setImageDescriptors( action, "lcl16", iconName ); //$NON-NLS-1$
+ }
+
+ /*
+ * Helper method to access the image registry from the JDIDebugUIPlugin class.
+ */
+ /* package */
+ static ImageRegistry getImageRegistry()
+ {
+ return IMAGE_REGISTRY;
+ }
+
+ //---- Helper methods to access icons on the file system --------------------------------------
+
+ private static void setImageDescriptors( IAction action, String type, String relPath )
+ {
+ try
+ {
+ ImageDescriptor id = ImageDescriptor.createFromURL( makeIconFileURL( "d" + type, relPath ) ); //$NON-NLS-1$
+ if ( id != null )
+ action.setDisabledImageDescriptor( id );
+ }
+ catch( MalformedURLException e )
+ {
+ CDebugUIPlugin.log( e );
+ }
+
+ try
+ {
+ ImageDescriptor id = ImageDescriptor.createFromURL( makeIconFileURL( "c" + type, relPath ) ); //$NON-NLS-1$
+ if ( id != null )
+ action.setHoverImageDescriptor( id );
+ }
+ catch( MalformedURLException e )
+ {
+ CDebugUIPlugin.log( e );
+ }
+
+ action.setImageDescriptor( create( "e" + type, relPath ) ); //$NON-NLS-1$
+ }
+
+ private static ImageDescriptor createManaged( String prefix, String name )
+ {
+ try
+ {
+ ImageDescriptor result = ImageDescriptor.createFromURL( makeIconFileURL( prefix, name.substring( NAME_PREFIX_LENGTH ) ) );
+ IMAGE_REGISTRY.put( name, result );
+ return result;
+ }
+ catch( MalformedURLException e )
+ {
+ CDebugUIPlugin.log( e );
+ return ImageDescriptor.getMissingImageDescriptor();
+ }
+ }
+
+ private static ImageDescriptor create( String prefix, String name )
+ {
+ try
+ {
+ return ImageDescriptor.createFromURL( makeIconFileURL( prefix, name ) );
+ }
+ catch( MalformedURLException e )
+ {
+ CDebugUIPlugin.log( e );
+ return ImageDescriptor.getMissingImageDescriptor();
+ }
+ }
+
+ private static URL makeIconFileURL( String prefix, String name ) throws MalformedURLException
+ {
+ if ( fgIconBaseURL == null )
+ throw new MalformedURLException();
+
+ StringBuffer buffer = new StringBuffer( prefix );
+ buffer.append( '/' );
+ buffer.append( name );
+ return new URL( fgIconBaseURL, buffer.toString() );
+ }
+}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CImageDescriptor.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CImageDescriptor.java
new file mode 100644
index 00000000000..caa6a0abd6b
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CImageDescriptor.java
@@ -0,0 +1,159 @@
+/*
+ *(c) Copyright QNX Software Systems Ltd. 2002.
+ * All Rights Reserved.
+ *
+ */
+package org.eclipse.cdt.debug.internal.ui;
+
+import org.eclipse.jface.resource.CompositeImageDescriptor;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.graphics.ImageData;
+import org.eclipse.swt.graphics.Point;
+
+/**
+ *
+ * A CImageDescriptor consists of a main icon and several adornments. The adornments
+ * are computed according to flags set on creation of the descriptor.
+ *
+ * @since Aug 30, 2002
+ */
+public class CImageDescriptor extends CompositeImageDescriptor
+{
+ /** Flag to render the is out of synch adornment */
+ public final static int IS_OUT_OF_SYNCH = 0x001;
+ /** Flag to render the may be out of synch adornment */
+ public final static int MAY_BE_OUT_OF_SYNCH = 0x002;
+ /** Flag to render the installed breakpoint adornment */
+ public final static int INSTALLED = 0x004;
+ /** Flag to render the entry method breakpoint adornment */
+ public final static int ENTRY = 0x008;
+ /** Flag to render the exit method breakpoint adornment */
+ public final static int EXIT = 0x010;
+ /** Flag to render the enabled breakpoint adornment */
+ public final static int ENABLED = 0x020;
+ /** Flag to render the conditional breakpoint adornment */
+ public final static int CONDITIONAL = 0x040;
+ /** Flag to render the caught breakpoint adornment */
+ public final static int CAUGHT = 0x080;
+ /** Flag to render the uncaught breakpoint adornment */
+ public final static int UNCAUGHT = 0x100;
+ /** Flag to render the scoped breakpoint adornment */
+ public final static int SCOPED = 0x200;
+
+ private ImageDescriptor fBaseImage;
+ private int fFlags;
+ private Point fSize;
+
+ /**
+ * Create a new CImageDescriptor.
+ *
+ * @param baseImage an image descriptor used as the base image
+ * @param flags flags indicating which adornments are to be rendered
+ *
+ */
+ public CImageDescriptor( ImageDescriptor baseImage, int flags )
+ {
+ setBaseImage( baseImage );
+ setFlags( flags );
+ }
+
+ /**
+ * @see CompositeImageDescriptor#getSize()
+ */
+ protected Point getSize()
+ {
+ if ( fSize == null )
+ {
+ ImageData data = getBaseImage().getImageData();
+ setSize( new Point( data.width, data.height ) );
+ }
+ return fSize;
+ }
+
+ /**
+ * @see Object#equals(java.lang.Object)
+ */
+ public boolean equals( Object object )
+ {
+ if ( !( object instanceof CImageDescriptor ) )
+ {
+ return false;
+ }
+
+ CImageDescriptor other = (CImageDescriptor)object;
+ return ( getBaseImage().equals( other.getBaseImage() ) && getFlags() == other.getFlags() );
+ }
+
+ /**
+ * @see Object#hashCode()
+ */
+ public int hashCode()
+ {
+ return getBaseImage().hashCode() | getFlags();
+ }
+
+ /**
+ * @see CompositeImageDescriptor#drawCompositeImage(int, int)
+ */
+ protected void drawCompositeImage( int width, int height )
+ {
+ ImageData bg = getBaseImage().getImageData();
+ if ( bg == null )
+ {
+ bg = DEFAULT_IMAGE_DATA;
+ }
+ drawImage( bg, 0, 0 );
+ drawOverlays();
+ }
+
+ /**
+ * Add any overlays to the image as specified in the flags.
+ */
+ protected void drawOverlays()
+ {
+ int flags = getFlags();
+ int x = 0;
+ int y = 0;
+ ImageData data = null;
+ if ( ( flags & INSTALLED ) != 0 )
+ {
+ x = 0;
+ y = getSize().y;
+ if ( ( flags & ENABLED ) != 0 )
+ {
+ data = CDebugImages.DESC_OBJS_BREAKPOINT_INSTALLED.getImageData();
+ }
+ else
+ {
+ data = CDebugImages.DESC_OBJS_BREAKPOINT_INSTALLED_DISABLED.getImageData();
+ }
+ y -= data.height;
+ drawImage( data, x, y );
+ }
+ }
+
+ protected ImageDescriptor getBaseImage()
+ {
+ return fBaseImage;
+ }
+
+ protected void setBaseImage( ImageDescriptor baseImage )
+ {
+ fBaseImage = baseImage;
+ }
+
+ protected int getFlags()
+ {
+ return fFlags;
+ }
+
+ protected void setFlags( int flags )
+ {
+ fFlags = flags;
+ }
+
+ protected void setSize( Point size )
+ {
+ fSize = size;
+ }
+}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/BreakpointLocationVerifier.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/BreakpointLocationVerifier.java
new file mode 100644
index 00000000000..9ac68e79815
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/BreakpointLocationVerifier.java
@@ -0,0 +1,28 @@
+/*
+ *(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 Aug 29, 2002
+ */
+public class BreakpointLocationVerifier
+{
+ /**
+ * Returns the line number closest to the given line number that represents a
+ * valid location for a breakpoint in the given document, or -1 if a valid location
+ * cannot be found.
+ */
+ public int getValidBreakpointLocation( IDocument doc, int lineNumber )
+ {
+ // for now
+ return lineNumber + 1;
+ }
+}
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 f20c41c9a99..d12416c307c 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,8 +6,13 @@
package org.eclipse.cdt.debug.internal.ui.actions;
import org.eclipse.cdt.debug.core.ICBreakpoint;
+import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.model.ILineBreakpoint;
import org.eclipse.jface.preference.FieldEditor;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
+import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.IntegerFieldEditor;
import org.eclipse.jface.preference.StringFieldEditor;
import org.eclipse.jface.resource.ImageDescriptor;
@@ -234,36 +239,13 @@ public class CBreakpointPreferencePage extends FieldEditorPreferencePage
/**
* Constructor for CBreakpointPreferencePage.
- * @param style
+ * @param breakpoint
*/
public CBreakpointPreferencePage( ICBreakpoint breakpoint )
{
super( GRID );
setBreakpoint( breakpoint );
- }
-
- /**
- * Constructor for CBreakpointPreferencePage.
- * @param title
- * @param style
- */
- public CBreakpointPreferencePage(String title, int style)
- {
- super(title, style);
- }
-
- /**
- * Constructor for CBreakpointPreferencePage.
- * @param title
- * @param image
- * @param style
- */
- public CBreakpointPreferencePage(
- String title,
- ImageDescriptor image,
- int style)
- {
- super(title, image, style);
+ noDefaultAndApplyButton();
}
/* (non-Javadoc)
@@ -271,6 +253,88 @@ 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() ) );
+ }
+ }
+ IPreferenceStore store = getPreferenceStore();
+
+ try
+ {
+ String condition= breakpoint.getCondition();
+ if ( condition == null )
+ {
+ condition = "";
+ }
+ store.setValue( CBreakpointPreferenceStore.CONDITION, condition );
+
+ createConditionEditor( getFieldEditorParent() );
+
+ store.setValue( CBreakpointPreferenceStore.ENABLED, breakpoint.isEnabled() );
+ int ignoreCount = breakpoint.getIgnoreCount();
+ store.setValue( CBreakpointPreferenceStore.IGNORE_COUNT, ( ignoreCount >= 0 ) ? ignoreCount : 0 );
+
+ createIgnoreCountEditor( getFieldEditorParent() );
+ }
+ catch( CoreException ce )
+ {
+ CDebugUIPlugin.log( ce );
+ }
+ }
+
+ protected void createConditionEditor( Composite parent )
+ {
+ fCondition = new BreakpointStringFieldEditor( CBreakpointPreferenceStore.CONDITION, "&Condition", parent );
+ fConditionTextControl = fCondition.getTextControl(parent);
+ fCondition.setEmptyStringAllowed( true );
+ fCondition.setErrorMessage( "Invalid_condition" );
+ addField( fCondition );
+ }
+
+ protected void createIgnoreCountEditor( Composite parent )
+ {
+ fIgnoreCount = new BreakpointIntegerFieldEditor( CBreakpointPreferenceStore.IGNORE_COUNT, "&Ignore Count: ", parent );
+ fIgnoreCount.setValidRange( 0, Integer.MAX_VALUE );
+ fIgnoreCountTextControl = fIgnoreCount.getTextControl( parent );
+ try
+ {
+ fIgnoreCountTextControl.setEnabled( getBreakpoint().getIgnoreCount() >= 0 );
+ }
+ catch (CoreException ce)
+ {
+ CDebugUIPlugin.log( ce );
+ }
+ addField( fIgnoreCount );
+ }
+
+ protected FieldEditor createLabelEditor( Composite parent, String title, String value )
+ {
+ return new LabelFieldEditor( parent, title, value );
}
protected ICBreakpoint getBreakpoint()
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/CBreakpointPreferenceStore.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/CBreakpointPreferenceStore.java
index b00f58d25e4..eb1a9eec9a2 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/CBreakpointPreferenceStore.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/CBreakpointPreferenceStore.java
@@ -306,8 +306,15 @@ public class CBreakpointPreferenceStore implements IPreferenceStore
/* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferenceStore#setValue(String, String)
*/
- public void setValue(String name, String value)
+ public void setValue( String name, String newValue )
{
+ Object oldValue = fProperties.get( name );
+ if ( oldValue == null || !oldValue.equals( newValue ) )
+ {
+ fProperties.put( name, newValue );
+ setDirty( true );
+ firePropertyChangeEvent( name, oldValue, newValue );
+ }
}
/* (non-Javadoc)
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
new file mode 100644
index 00000000000..754418c55cb
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/CBreakpointPropertiesDialog.java
@@ -0,0 +1,484 @@
+/*
+ *(c) Copyright QNX Software Systems Ltd. 2002.
+ * All Rights Reserved.
+ *
+ */
+package org.eclipse.cdt.debug.internal.ui.actions;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.cdt.debug.core.ICBreakpoint;
+import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.preference.IPreferencePageContainer;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceDialog;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.jface.resource.JFaceColors;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CLabel;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Layout;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ *
+ *
+ * @since Aug 29, 2002
+ */
+public class CBreakpointPropertiesDialog extends Dialog
+ implements IPreferencePageContainer
+{
+ /**
+ * Layout for the page container.
+ *
+ * @see CBreakpointPropertiesDialog#createPageContainer(Composite, int)
+ */
+ private class PageLayout extends Layout
+ {
+ public void layout( Composite composite, boolean force )
+ {
+ Rectangle rect = composite.getClientArea();
+ Control[] children = composite.getChildren();
+ for ( int i = 0; i < children.length; i++ )
+ {
+ children[i].setSize( rect.width, rect.height );
+ }
+ }
+ public Point computeSize( Composite composite, int wHint, int hHint, boolean force )
+ {
+ if ( wHint != SWT.DEFAULT && hHint != SWT.DEFAULT )
+ return new Point( wHint, hHint );
+ int x = fMinimumPageSize.x;
+ int y = fMinimumPageSize.y;
+
+ Control[] children = composite.getChildren();
+ for ( int i = 0; i < children.length; i++ )
+ {
+ Point size = children[i].computeSize( SWT.DEFAULT, SWT.DEFAULT, force );
+ x = Math.max( x, size.x );
+ y = Math.max( y, size.y );
+ }
+ if ( wHint != SWT.DEFAULT )
+ x = wHint;
+ if ( hHint != SWT.DEFAULT )
+ y = hHint;
+ return new Point( x, y );
+ }
+ }
+
+ private Composite fTitleArea;
+ private Label fTitleImage;
+ private CLabel fMessageLabel;
+
+ private String fMessage;
+ private Color fNormalMsgAreaBackground;
+ private Image fErrorMsgImage;
+
+
+ private CBreakpointPreferencePage fPage;
+
+ private Button fOkButton;
+
+ /**
+ * Must declare our own images as the JFaceResource images will not be created unless
+ * a property/preference dialog has been shown
+ */
+ protected static final String PREF_DLG_TITLE_IMG = "breakpoint_preference_dialog_title_image"; //$NON-NLS-1$
+ protected static final String PREF_DLG_IMG_TITLE_ERROR = "breakpoint_preference_dialog_title_error_image"; //$NON-NLS-1$
+ static
+ {
+ ImageRegistry reg = CDebugUIPlugin.getDefault().getImageRegistry();
+ reg.put( PREF_DLG_TITLE_IMG, ImageDescriptor.createFromFile( PreferenceDialog.class, "images/pref_dialog_title.gif" ) ); //$NON-NLS-1$
+ reg.put( PREF_DLG_IMG_TITLE_ERROR, ImageDescriptor.createFromFile( Dialog.class, "images/message_error.gif" ) ); //$NON-NLS-1$
+ }
+
+ /**
+ * The Composite in which a page is shown.
+ */
+ private Composite fPageContainer;
+
+ /**
+ * The minimum page size; 200 by 200 by default.
+ *
+ * @see #setMinimumPageSize(Point)
+ */
+ private Point fMinimumPageSize = new Point(200,200);
+
+ /**
+ * The breakpoint that this dialog is operating on
+ */
+ private ICBreakpoint fBreakpoint;
+
+ /**
+ * The "fake" preference store used to interface between
+ * the breakpoint and the breakpoint preference page.
+ */
+ private CBreakpointPreferenceStore fCBreakpointPreferenceStore;
+
+ /**
+ * Constructor for CBreakpointPropertiesDialog.
+ * @param parentShell
+ */
+ public CBreakpointPropertiesDialog( Shell parentShell, ICBreakpoint breakpoint )
+ {
+ super( parentShell );
+ setBreakpoint( breakpoint );
+ fCBreakpointPreferenceStore= new CBreakpointPreferenceStore();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.preference.IPreferencePageContainer#getPreferenceStore()
+ */
+ public IPreferenceStore getPreferenceStore()
+ {
+ return fCBreakpointPreferenceStore;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.preference.IPreferencePageContainer#updateButtons()
+ */
+ public void updateButtons()
+ {
+ if ( fOkButton != null )
+ {
+ fOkButton.setEnabled( fPage.isValid() );
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.preference.IPreferencePageContainer#updateMessage()
+ */
+ public void updateMessage()
+ {
+ String pageMessage = fPage.getMessage();
+ String pageErrorMessage = fPage.getErrorMessage();
+
+ // Adjust the font
+ if ( pageMessage == null && pageErrorMessage == null )
+ fMessageLabel.setFont( JFaceResources.getBannerFont() );
+ else
+ fMessageLabel.setFont( JFaceResources.getDialogFont() );
+
+ // Set the message and error message
+ if ( pageMessage == null )
+ {
+ setMessage( fPage.getTitle() );
+ }
+ else
+ {
+ setMessage( pageMessage );
+ }
+ setErrorMessage( pageErrorMessage );
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.preference.IPreferencePageContainer#updateTitle()
+ */
+ public void updateTitle()
+ {
+ setTitle( fPage.getTitle() );
+ }
+
+ /**
+ * Display the given error message. The currently displayed message
+ * is saved and will be redisplayed when the error message is set
+ * to null
.
+ *
+ * @param errorMessage the errorMessage to display or null
+ */
+ public void setErrorMessage( String errorMessage )
+ {
+ if ( errorMessage == null )
+ {
+ if ( fMessageLabel.getImage() != null )
+ {
+ // we were previously showing an error
+ fMessageLabel.setBackground( fNormalMsgAreaBackground );
+ fMessageLabel.setImage( null );
+ fTitleImage.setImage( CDebugUIPlugin.getDefault().getImageRegistry().get( PREF_DLG_TITLE_IMG ) );
+ fTitleArea.layout( true );
+ }
+ // show the message
+ setMessage( fMessage );
+ }
+ else
+ {
+ fMessageLabel.setText( errorMessage );
+ if ( fMessageLabel.getImage() == null )
+ {
+ // we were not previously showing an error
+
+ // lazy initialize the error background color and image
+ if ( fErrorMsgImage == null )
+ {
+ fErrorMsgImage = CDebugUIPlugin.getDefault().getImageRegistry().get( PREF_DLG_IMG_TITLE_ERROR );
+ }
+
+ // show the error
+ fNormalMsgAreaBackground = fMessageLabel.getBackground();
+ fMessageLabel.setBackground( JFaceColors.getErrorBackground( fMessageLabel.getDisplay() ) );
+ fMessageLabel.setImage( fErrorMsgImage );
+ fTitleImage.setImage( null );
+ fTitleArea.layout( true );
+ }
+ }
+ }
+
+ /**
+ * Set the message text. If the message line currently displays an error,
+ * the message is stored and will be shown after a call to clearErrorMessage
+ */
+ public void setMessage( String newMessage )
+ {
+ fMessage = newMessage;
+ if ( fMessage == null )
+ {
+ fMessage = ""; //$NON-NLS-1$
+ }
+ if ( fMessageLabel.getImage() == null )
+ {
+ // we are not showing an error
+ fMessageLabel.setText( fMessage );
+ }
+ }
+
+ /**
+ * Sets the title for this dialog.
+ *
+ * @param title the title.
+ */
+ public void setTitle( String title )
+ {
+ Shell shell = getShell();
+ if ( ( shell != null ) && !shell.isDisposed() )
+ {
+ shell.setText( title );
+ }
+ }
+
+ /**
+ * @see Dialog#okPressed()
+ */
+ protected void okPressed()
+ {
+ final List changedProperties = new ArrayList( 5 );
+ getPreferenceStore().addPropertyChangeListener(
+ new IPropertyChangeListener()
+ {
+ /**
+ * @see IPropertyChangeListener#propertyChange(PropertyChangeEvent)
+ */
+ public void propertyChange( PropertyChangeEvent event )
+ {
+ changedProperties.add( event.getProperty() );
+ }
+ } );
+ fPage.performOk();
+ setBreakpointProperties( changedProperties );
+ super.okPressed();
+ }
+
+ /**
+ * All of the properties that the user has changed via the dialog
+ * are written through to the breakpoint.
+ */
+ protected void setBreakpointProperties( final List changedProperties )
+ {
+ IWorkspaceRunnable wr = new IWorkspaceRunnable()
+ {
+ public void run( IProgressMonitor monitor ) throws CoreException
+ {
+ }
+ };
+
+ try
+ {
+ ResourcesPlugin.getWorkspace().run( wr, null );
+ }
+ catch( CoreException ce )
+ {
+ CDebugUIPlugin.log( ce );
+ }
+ }
+
+ protected ICBreakpoint getBreakpoint()
+ {
+ return fBreakpoint;
+ }
+
+ protected void setBreakpoint( ICBreakpoint breakpoint )
+ {
+ fBreakpoint = breakpoint;
+ }
+
+ /**
+ * @see Dialog#createDialogArea(Composite)
+ */
+ protected Control createDialogArea( Composite parent )
+ {
+ GridData gd;
+ Composite composite = (Composite) super.createDialogArea( parent );
+ ((GridLayout)composite.getLayout()).numColumns = 1;
+
+ // Build the title area and separator line
+ Composite titleComposite = new Composite( composite, SWT.NONE );
+ GridLayout layout = new GridLayout();
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ layout.verticalSpacing = 0;
+ layout.horizontalSpacing = 0;
+ titleComposite.setLayout( layout );
+ titleComposite.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
+
+ createTitleArea( titleComposite );
+
+ Label titleBarSeparator = new Label( titleComposite, SWT.HORIZONTAL | SWT.SEPARATOR );
+ gd = new GridData( GridData.FILL_HORIZONTAL );
+ titleBarSeparator.setLayoutData( gd );
+
+ // Build the Page container
+ fPageContainer = createPageContainer( composite, 2 );
+ fPageContainer.setLayoutData( new GridData( GridData.FILL_BOTH ) );
+ fPageContainer.setFont( parent.getFont() );
+
+ fPage = new CBreakpointPreferencePage( getBreakpoint() );
+ fPage.setContainer( this );
+ fPage.createControl( fPageContainer );
+
+ // Build the separator line
+ Label separator = new Label( composite, SWT.HORIZONTAL | SWT.SEPARATOR );
+ gd = new GridData( GridData.FILL_HORIZONTAL );
+ gd.horizontalSpan = 2;
+ separator.setLayoutData( gd );
+
+ return composite;
+ }
+
+ /**
+ * Creates the dialog's title area.
+ *
+ * @param parent the SWT parent for the title area composite
+ * @return the created title area composite
+ */
+ private Composite createTitleArea( Composite parent )
+ {
+ // Create the title area which will contain
+ // a title, message, and image.
+ fTitleArea = new Composite( parent, SWT.NONE );
+ GridLayout layout = new GridLayout();
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ layout.verticalSpacing = 0;
+ layout.horizontalSpacing = 0;
+ layout.numColumns = 2;
+
+ // Get the colors for the title area
+ Display display = parent.getDisplay();
+ Color bg = JFaceColors.getBannerBackground( display );
+ Color fg = JFaceColors.getBannerForeground( display );
+
+ GridData layoutData = new GridData( GridData.FILL_BOTH );
+ fTitleArea.setLayout( layout );
+ fTitleArea.setLayoutData( layoutData );
+ fTitleArea.setBackground( bg );
+
+ // Message label
+ fMessageLabel = new CLabel( fTitleArea, SWT.LEFT );
+ fMessageLabel.setBackground( bg );
+ fMessageLabel.setForeground( fg );
+ fMessageLabel.setText( " " ); //$NON-NLS-1$
+ fMessageLabel.setFont( JFaceResources.getBannerFont() );
+
+ final IPropertyChangeListener fontListener =
+ new IPropertyChangeListener()
+ {
+ public void propertyChange( PropertyChangeEvent event )
+ {
+ if ( JFaceResources.BANNER_FONT.equals( event.getProperty() ) ||
+ JFaceResources.DIALOG_FONT.equals( event.getProperty() ) )
+ {
+ updateMessage();
+ }
+ }
+ };
+
+ fMessageLabel.addDisposeListener(
+ new DisposeListener()
+ {
+ public void widgetDisposed( DisposeEvent event )
+ {
+ JFaceResources.getFontRegistry().removeListener( fontListener );
+ }
+ } );
+
+ JFaceResources.getFontRegistry().addListener( fontListener );
+
+ GridData gd = new GridData( GridData.FILL_BOTH );
+ fMessageLabel.setLayoutData( gd );
+
+ // Title image
+ fTitleImage = new Label( fTitleArea, SWT.LEFT );
+ fTitleImage.setBackground( bg );
+ fTitleImage.setImage( CDebugUIPlugin.getDefault().getImageRegistry().get( PREF_DLG_TITLE_IMG ) );
+ gd = new GridData();
+ gd.horizontalAlignment = gd.END;
+ fTitleImage.setLayoutData( gd );
+
+ return fTitleArea;
+ }
+
+ /**
+ * Creates the inner page container.
+ */
+ private Composite createPageContainer( Composite parent, int numColumns )
+ {
+ Composite result = new Composite( parent, SWT.NULL );
+ result.setLayout( new PageLayout() );
+ return result;
+ }
+
+ /**
+ * Sets the minimum page size.
+ *
+ * @param size the page size encoded as
+ * new Point(width,height)
+ * @see #setMinimumPageSize(int,int)
+ */
+ public void setMinimumPageSize( Point size )
+ {
+ fMinimumPageSize.x = size.x;
+ fMinimumPageSize.y = size.y;
+ }
+
+ /**
+ * @see Dialog#createButtonsForButtonBar(Composite)
+ */
+ protected void createButtonsForButtonBar( Composite parent )
+ {
+ fOkButton = createButton( parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true );
+ createButton( parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false );
+ }
+}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/CBreakpointPropertiesRulerAction.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/CBreakpointPropertiesRulerAction.java
new file mode 100644
index 00000000000..7fd83dd6153
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/CBreakpointPropertiesRulerAction.java
@@ -0,0 +1,57 @@
+/*
+ *(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.dialogs.Dialog;
+import org.eclipse.jface.text.source.IVerticalRulerInfo;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+/**
+ *
+ * Presents a custom properties dialog to configure the attibutes of
+ * a C/C++ breakpoint from the ruler popup menu of a text editor.
+ *
+ * @since Aug 29, 2002
+ */
+public class CBreakpointPropertiesRulerAction extends AbstractBreakpointRulerAction
+{
+ /**
+ * Creates the action to enable/disable breakpoints
+ */
+ public CBreakpointPropertiesRulerAction( ITextEditor editor, IVerticalRulerInfo info )
+ {
+ setInfo( info );
+ setTextEditor( editor );
+ setText( "Breakpoint &Properties..." );
+ }
+ /**
+ * @see Action#run()
+ */
+ public void run()
+ {
+ if (getBreakpoint() != null)
+ {
+ Dialog d = new CBreakpointPropertiesDialog( getTextEditor().getEditorSite().getShell(), (ICBreakpoint)getBreakpoint() );
+ d.open();
+ }
+ }
+
+ /**
+ * @see IUpdate#update()
+ */
+ public void update()
+ {
+ setBreakpoint( determineBreakpoint() );
+ if ( getBreakpoint() == null || !( getBreakpoint() instanceof ICBreakpoint ) )
+ {
+ setBreakpoint( null );
+ setEnabled( false );
+ return;
+ }
+ setEnabled( true );
+ }
+}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/CBreakpointPropertiesRulerActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/CBreakpointPropertiesRulerActionDelegate.java
new file mode 100644
index 00000000000..dd3cf374237
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/CBreakpointPropertiesRulerActionDelegate.java
@@ -0,0 +1,28 @@
+/*
+ *(c) Copyright QNX Software Systems Ltd. 2002.
+ * All Rights Reserved.
+ *
+ */
+package org.eclipse.cdt.debug.internal.ui.actions;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.text.source.IVerticalRulerInfo;
+import org.eclipse.ui.texteditor.AbstractRulerActionDelegate;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+/**
+ *
+ * Enter type comment.
+ *
+ * @since Aug 29, 2002
+ */
+public class CBreakpointPropertiesRulerActionDelegate extends AbstractRulerActionDelegate
+{
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.texteditor.AbstractRulerActionDelegate#createAction(ITextEditor, IVerticalRulerInfo)
+ */
+ protected IAction createAction( ITextEditor editor, IVerticalRulerInfo rulerInfo )
+ {
+ return new CBreakpointPropertiesRulerAction( editor, rulerInfo );
+ }
+}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ManageBreakpointRulerAction.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ManageBreakpointRulerAction.java
index 0bd8edf6397..bf7d2c6c02b 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ManageBreakpointRulerAction.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ManageBreakpointRulerAction.java
@@ -6,9 +6,12 @@
package org.eclipse.cdt.debug.internal.ui.actions;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
+import org.eclipse.cdt.debug.core.CDebugModel;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
@@ -16,16 +19,19 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.IBreakpointManager;
import org.eclipse.debug.core.model.IBreakpoint;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.Position;
import org.eclipse.jface.text.source.IAnnotationModel;
import org.eclipse.jface.text.source.IVerticalRulerInfo;
import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel;
import org.eclipse.ui.texteditor.IDocumentProvider;
import org.eclipse.ui.texteditor.ITextEditor;
@@ -228,7 +234,44 @@ public class ManageBreakpointRulerAction extends Action implements IUpdate
IEditorInput editorInput = getTextEditor().getEditorInput();
IDocument document = getDocument();
int rulerLine = getVerticalRulerInfo().getLineOfLastMouseButtonActivity();
- // create breakpoint
+ try
+ {
+ BreakpointLocationVerifier bv = new BreakpointLocationVerifier();
+ int lineNumber = bv.getValidBreakpointLocation( document, rulerLine );
+ if ( lineNumber > 0 )
+ {
+ IRegion line = document.getLineInformation( lineNumber - 1 );
+ String fileName = null;
+ if ( editorInput instanceof IFileEditorInput )
+ {
+ fileName = ((IFileEditorInput)editorInput).getFile().getLocation().toString();
+ }
+ if ( fileName != null )
+ {
+ if ( CDebugModel.lineBreakpointExists( fileName, lineNumber ) == null )
+ {
+ CDebugModel.createLineBreakpoint( ((IFileEditorInput)editorInput).getFile(),
+ lineNumber,
+ true,
+ 0,
+ "",
+ true );
+ }
+ }
+ }
+ }
+ catch( DebugException e )
+ {
+ CDebugUIPlugin.errorDialog( "Cannot add breakpoint", e );
+ }
+ catch( CoreException e )
+ {
+ CDebugUIPlugin.errorDialog( "Cannot add breakpoint", e );
+ }
+ catch( BadLocationException e )
+ {
+ CDebugUIPlugin.errorDialog( "Cannot add breakpoint", e );
+ }
}
protected void removeMarkers( List markers )
@@ -245,7 +288,7 @@ public class ManageBreakpointRulerAction extends Action implements IUpdate
}
catch( CoreException e )
{
-// CDebugUIPlugin.errorDialog( ActionMessages.getString("ManageBreakpointRulerAction.error.removing.message1"), e); //$NON-NLS-1$
+ CDebugUIPlugin.errorDialog( "Cannot remove breakpoint", e );
}
}
}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/CDebugUIPlugin.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/CDebugUIPlugin.java
index 3ff61789550..940ca33c882 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/CDebugUIPlugin.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/CDebugUIPlugin.java
@@ -8,6 +8,7 @@ import java.util.ResourceBundle;
import org.eclipse.cdt.debug.core.IFormattedMemoryBlock;
import org.eclipse.cdt.debug.core.IFormattedMemoryRetrieval;
import org.eclipse.cdt.debug.internal.ui.CDTDebugModelPresentation;
+import org.eclipse.cdt.debug.internal.ui.CDebugImageDescriptorRegistry;
import org.eclipse.cdt.debug.internal.ui.ColorManager;
import org.eclipse.cdt.debug.internal.ui.preferences.MemoryViewPreferencePage;
import org.eclipse.core.resources.IWorkspace;
@@ -18,11 +19,15 @@ import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IPluginDescriptor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
-import org.eclipse.debug.internal.ui.DebugUIMessages;
import org.eclipse.debug.ui.ILaunchConfigurationTab;
+import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.plugin.AbstractUIPlugin;
/**
@@ -36,6 +41,9 @@ public class CDebugUIPlugin extends AbstractUIPlugin
private ResourceBundle resourceBundle;
protected Map fDebuggerPageMap;
+
+ private CDebugImageDescriptorRegistry fImageDescriptorRegistry;
+
/**
* The constructor.
*/
@@ -202,4 +210,98 @@ public class CDebugUIPlugin extends AbstractUIPlugin
fDebuggerPageMap.put(id, infos[i]);
}
}
+
+ public static void errorDialog( String message, IStatus status )
+ {
+ log( status );
+ Shell shell = getActiveWorkbenchShell();
+ if ( shell != null )
+ {
+ ErrorDialog.openError( shell, "Error", message, status );
+ }
+ }
+
+ public static void errorDialog( String message, Throwable t )
+ {
+ log( t );
+ Shell shell = getActiveWorkbenchShell();
+ if ( shell != null )
+ {
+ IStatus status = new Status( IStatus.ERROR, getUniqueIdentifier(), ICDebugUIConstants.INTERNAL_ERROR, "Error logged from CDT Debug UI: ", t ); //$NON-NLS-1$
+ ErrorDialog.openError( shell, "Error", message, status );
+ }
+ }
+
+ /**
+ * Returns the active workbench window
+ *
+ * @return the active workbench window
+ */
+ public static IWorkbenchWindow getActiveWorkbenchWindow()
+ {
+ return getDefault().getWorkbench().getActiveWorkbenchWindow();
+ }
+
+ public static IWorkbenchPage getActivePage()
+ {
+ IWorkbenchWindow w = getActiveWorkbenchWindow();
+ if ( w != null )
+ {
+ return w.getActivePage();
+ }
+ return null;
+ }
+
+ /**
+ * Returns the active workbench shell or null
if none
+ *
+ * @return the active workbench shell or null
if none
+ */
+ public static Shell getActiveWorkbenchShell()
+ {
+ IWorkbenchWindow window = getActiveWorkbenchWindow();
+ if ( window != null )
+ {
+ return window.getShell();
+ }
+ return null;
+ }
+
+ /**
+ * Returns the standard display to be used. The method first checks, if
+ * the thread calling this method has an associated display. If so, this
+ * display is returned. Otherwise the method returns the default display.
+ */
+ public static Display getStandardDisplay()
+ {
+ Display display;
+ display = Display.getCurrent();
+ if ( display == null )
+ display = Display.getDefault();
+ return display;
+ }
+
+ /**
+ * Returns the image descriptor registry used for this plugin.
+ */
+ public static CDebugImageDescriptorRegistry getImageDescriptorRegistry()
+ {
+ if ( getDefault().fImageDescriptorRegistry == null )
+ {
+ getDefault().fImageDescriptorRegistry = new CDebugImageDescriptorRegistry();
+ }
+ return getDefault().fImageDescriptorRegistry;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.runtime.Plugin#shutdown()
+ */
+ public void shutdown() throws CoreException
+ {
+ if ( fImageDescriptorRegistry != null )
+ {
+ fImageDescriptorRegistry.dispose();
+ }
+ super.shutdown();
+ }
}