3 * Created on 25.11.2004
5 * TODO To change the template for this generated file go to
6 * Window - Preferences - Java - Code Style - Code Templates
8 package net.sourceforge.phpeclipse.xdebug.php.model;
11 import java.util.HashMap;
14 import net.sourceforge.phpeclipse.xdebug.php.launching.IXDebugConstants;
16 import org.eclipse.core.resources.IMarker;
17 import org.eclipse.core.resources.IResource;
18 import org.eclipse.core.resources.IWorkspaceRunnable;
19 import org.eclipse.core.runtime.CoreException;
20 import org.eclipse.core.runtime.IProgressMonitor;
21 import org.eclipse.debug.core.DebugPlugin;
22 import org.eclipse.debug.core.model.IBreakpoint;
23 import org.eclipse.debug.core.model.LineBreakpoint;
29 * TODO To change the template for this generated type comment go to
30 * Window - Preferences - Java - Code Style - Code Templates
32 public class XDebugLineBreakpoint extends LineBreakpoint {
35 * Default constructor is required for the breakpoint manager
36 * to re-create persisted breakpoints. After instantiating a breakpoint,
37 * the <code>setMarker(...)</code> method is called to restore
38 * this breakpoint's attributes.
40 private static final String XDEBUG_LINE_BREAKPOINT = "net.sourceforge.phpeclipse.xdebug.core.XDebugLineBreakpoint"; //$NON-NLS-1$
43 * Breakpoint attribute storing the fully qualified name of the type
44 * this breakpoint is located in.
45 * (value <code>"net.sourceforge.phpeclipse.debug.typeName"</code>). This attribute is a <code>String</code>.
47 protected static final String TYPE_NAME = "net.sourceforge.phpeclipse.debug.typeName"; //$NON-NLS-1$
49 // public PHPLineBreakpoint() {
52 // public PHPLineBreakpoint(IResource resource, int lineNumber, int charStart, int charEnd, int hitCount, boolean add, Map attributes) throws DebugException {
53 // this(resource, lineNumber, charStart, charEnd, hitCount, add, attributes, PHP_LINE_BREAKPOINT);
56 // public PHPLineBreakpoint(IResource resource, int lineNumber, int hitCount, boolean add, Map attributes) throws DebugException {
57 // this(resource, lineNumber, -1, -1, hitCount, add, attributes, PHP_LINE_BREAKPOINT);
61 public static final String BREAKPOINT_ID ="XDebugLineBreakpointID";
63 public XDebugLineBreakpoint() {
67 * Constructs a line breakpoint on the given resource at the given
68 * line number. The line number is 1-based (i.e. the first line of a
69 * file is line number 1).
71 * @param resource file on which to set the breakpoint
72 * @param lineNumber 1-based line number of the breakpoint
73 * @throws CoreException if unable to create the breakpoint
75 public XDebugLineBreakpoint(final IResource resource, final int lineNumber) throws CoreException {
76 // IMarker marker = resource.createMarker("net.sourceforge.phpeclipse.xdebug.core.XDebugLineBreakpoint");
79 // XDebugCorePlugin.log(IStatus.INFO,"Markertype: "+ marker.getType());
80 // ensureMarker().setAttribute(IMarker.LINE_NUMBER, lineNumber);
81 // ensureMarker().setAttribute(IBreakpoint.ID, IXDebugConstants.ID_PHP_DEBUG_MODEL);
82 // ensureMarker().setAttribute(BREAKPOINT_ID,-1);
83 IWorkspaceRunnable wr= new IWorkspaceRunnable() {
84 public void run(IProgressMonitor monitor) throws CoreException {
87 setMarker(resource.createMarker(XDEBUG_LINE_BREAKPOINT));
90 Map attributes = new HashMap(10);
91 addLineBreakpointAttributes(attributes, getModelIdentifier(), true, lineNumber, -1, -1);
94 ensureMarker().setAttributes(attributes);
96 // add to breakpoint manager if requested
100 run(getMarkerRule(resource), wr);
104 protected void register(boolean register) throws CoreException {
106 DebugPlugin.getDefault().getBreakpointManager().addBreakpoint(this);
108 setRegistered(false);
112 public void addLineBreakpointAttributes(Map attributes, String modelIdentifier, boolean enabled, int lineNumber, int charStart, int charEnd) {
113 attributes.put(IBreakpoint.ID, modelIdentifier);
114 attributes.put(IBreakpoint.ENABLED, new Boolean(enabled));
115 attributes.put(IMarker.LINE_NUMBER, new Integer(lineNumber));
118 attributes.put(IMarker.CHAR_START, new Integer(charStart));
119 attributes.put(IMarker.CHAR_END, new Integer(charEnd));
121 attributes.put(TYPE_NAME, "typeName");
122 attributes.put(BREAKPOINT_ID,new Integer(-1));
127 * @see org.eclipse.debug.core.model.IBreakpoint#getModelIdentifier()
129 public String getModelIdentifier() {
130 return IXDebugConstants.ID_PHP_DEBUG_MODEL;
133 public void setID(int id) throws CoreException
135 ensureMarker().setAttribute(BREAKPOINT_ID,id);
137 public int getID() throws CoreException
139 return ensureMarker().getAttribute(BREAKPOINT_ID,-1);