2 * Created on 25.11.2004
4 * TODO To change the template for this generated file go to
5 * Window - Preferences - Java - Code Style - Code Templates
7 package net.sourceforge.phpeclipse.xdebug.php.model;
9 import java.util.HashMap;
12 import net.sourceforge.phpeclipse.xdebug.php.launching.IXDebugConstants;
14 import org.eclipse.core.resources.IMarker;
15 import org.eclipse.core.resources.IResource;
16 import org.eclipse.core.resources.IWorkspaceRunnable;
17 import org.eclipse.core.runtime.CoreException;
18 import org.eclipse.core.runtime.IProgressMonitor;
19 import org.eclipse.debug.core.DebugPlugin;
20 import org.eclipse.debug.core.model.IBreakpoint;
21 import org.eclipse.debug.core.model.LineBreakpoint;
26 * TODO To change the template for this generated type comment go to Window -
27 * Preferences - Java - Code Style - Code Templates
29 public class XDebugLineBreakpoint extends LineBreakpoint {
32 * Default constructor is required for the breakpoint manager to re-create
33 * persisted breakpoints. After instantiating a breakpoint, the
34 * <code>setMarker(...)</code> method is called to restore this
35 * breakpoint's attributes.
37 private static final String XDEBUG_LINE_BREAKPOINT = "net.sourceforge.phpeclipse.xdebug.core.XDebugLineBreakpoint"; //$NON-NLS-1$
40 * Breakpoint attribute storing the fully qualified name of the type this
41 * breakpoint is located in. (value
42 * <code>"net.sourceforge.phpeclipse.debug.typeName"</code>). This
43 * attribute is a <code>String</code>.
45 protected static final String TYPE_NAME = "net.sourceforge.phpeclipse.debug.typeName"; //$NON-NLS-1$
47 // public PHPLineBreakpoint() {
50 // public PHPLineBreakpoint(IResource resource, int lineNumber, int
51 // charStart, int charEnd, int hitCount, boolean add, Map attributes) throws
53 // this(resource, lineNumber, charStart, charEnd, hitCount, add, attributes,
54 // PHP_LINE_BREAKPOINT);
57 // public PHPLineBreakpoint(IResource resource, int lineNumber, int
58 // hitCount, boolean add, Map attributes) throws DebugException {
59 // this(resource, lineNumber, -1, -1, hitCount, add, attributes,
60 // PHP_LINE_BREAKPOINT);
63 public static final String BREAKPOINT_ID = "XDebugLineBreakpointID";
65 public XDebugLineBreakpoint() {
69 * Constructs a line breakpoint on the given resource at the given line
70 * number. The line number is 1-based (i.e. the first line of a file is line
74 * file on which to set the breakpoint
76 * 1-based line number of the breakpoint
77 * @throws CoreException
78 * if unable to create the breakpoint
80 public XDebugLineBreakpoint(final IResource resource, final int lineNumber)
81 throws CoreException {
83 // resource.createMarker("net.sourceforge.phpeclipse.xdebug.core.XDebugLineBreakpoint");
86 // XDebugCorePlugin.log(IStatus.INFO,"Markertype: "+ marker.getType());
87 // ensureMarker().setAttribute(IMarker.LINE_NUMBER, lineNumber);
88 // ensureMarker().setAttribute(IBreakpoint.ID,
89 // IXDebugConstants.ID_PHP_DEBUG_MODEL);
90 // ensureMarker().setAttribute(BREAKPOINT_ID,-1);
91 IWorkspaceRunnable wr = new IWorkspaceRunnable() {
92 public void run(IProgressMonitor monitor) throws CoreException {
95 setMarker(resource.createMarker(XDEBUG_LINE_BREAKPOINT));
98 Map attributes = new HashMap(10);
99 addLineBreakpointAttributes(attributes, getModelIdentifier(),
100 true, lineNumber, -1, -1);
103 ensureMarker().setAttributes(attributes);
105 // add to breakpoint manager if requested
109 run(getMarkerRule(resource), wr);
113 protected void register(boolean register) throws CoreException {
115 DebugPlugin.getDefault().getBreakpointManager().addBreakpoint(this);
117 setRegistered(false);
121 public void addLineBreakpointAttributes(Map attributes,
122 String modelIdentifier, boolean enabled, int lineNumber,
123 int charStart, int charEnd) {
124 attributes.put(IBreakpoint.ID, modelIdentifier);
125 attributes.put(IBreakpoint.ENABLED, new Boolean(enabled));
126 attributes.put(IMarker.LINE_NUMBER, new Integer(lineNumber));
127 if (charStart != -1) {
128 attributes.put(IMarker.CHAR_START, new Integer(charStart));
129 attributes.put(IMarker.CHAR_END, new Integer(charEnd));
131 attributes.put(TYPE_NAME, "typeName");
132 attributes.put(BREAKPOINT_ID, new Integer(-1));
138 * @see org.eclipse.debug.core.model.IBreakpoint#getModelIdentifier()
140 public String getModelIdentifier() {
141 return IXDebugConstants.ID_PHP_DEBUG_MODEL;
144 public void setID(int id) throws CoreException {
145 ensureMarker().setAttribute(BREAKPOINT_ID, id);
148 public int getID() throws CoreException {
149 return ensureMarker().getAttribute(BREAKPOINT_ID, -1);