2 * Created on 25.11.2004
4 package net.sourceforge.phpeclipse.xdebug.php.model;
7 import java.util.HashMap;
10 import net.sourceforge.phpeclipse.xdebug.php.launching.IXDebugConstants;
12 import org.eclipse.core.resources.IMarker;
13 import org.eclipse.core.resources.IResource;
14 import org.eclipse.core.resources.IWorkspaceRunnable;
15 import org.eclipse.core.runtime.CoreException;
16 import org.eclipse.core.runtime.IProgressMonitor;
17 import org.eclipse.debug.core.DebugPlugin;
18 //import org.eclipse.debug.core.model.Breakpoint;
19 import org.eclipse.debug.core.model.IBreakpoint;
20 import org.eclipse.debug.core.model.ILineBreakpoint;
21 //import org.eclipse.debug.core.model.LineBreakpoint;
27 * TODO To change the template for this generated type comment go to
28 * Window - Preferences - Java - Code Style - Code Templates
30 public class XDebugLineBreakpoint extends XDebugBreakpoint implements ILineBreakpoint /*extends LineBreakpoint*/ {
33 * Default constructor is required for the breakpoint manager
34 * to re-create persisted breakpoints. After instantiating a breakpoint,
35 * the <code>setMarker(...)</code> method is called to restore
36 * this breakpoint's attributes.
38 private static final String XDEBUG_LINE_BREAKPOINT = "net.sourceforge.phpeclipse.xdebug.core.XDebugLineBreakpoint"; //$NON-NLS-1$
41 * Breakpoint attribute storing the fully qualified name of the type
42 * this breakpoint is located in.
43 * (value <code>"net.sourceforge.phpeclipse.debug.typeName"</code>). This 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 charStart, int charEnd, int hitCount, boolean add, Map attributes) throws DebugException {
51 // this(resource, lineNumber, charStart, charEnd, hitCount, add, attributes, PHP_LINE_BREAKPOINT);
54 // public PHPLineBreakpoint(IResource resource, int lineNumber, int hitCount, boolean add, Map attributes) throws DebugException {
55 // this(resource, lineNumber, -1, -1, hitCount, add, attributes, PHP_LINE_BREAKPOINT);
59 public static final String BREAKPOINT_ID ="XDebugLineBreakpointID";
61 public XDebugLineBreakpoint() {
65 * Constructs a line breakpoint on the given resource at the given
66 * line number. The line number is 1-based (i.e. the first line of a
67 * file is line number 1).
69 * @param resource file on which to set the breakpoint
70 * @param lineNumber 1-based line number of the breakpoint
71 * @throws CoreException if unable to create the breakpoint
73 public XDebugLineBreakpoint(final IResource resource, final int lineNumber) throws CoreException {
74 IWorkspaceRunnable wr = new IWorkspaceRunnable() {
75 public void run(IProgressMonitor monitor) throws CoreException {
78 setMarker(resource.createMarker(XDEBUG_LINE_BREAKPOINT));
81 Map attributes = new HashMap(10);
82 addLineBreakpointAttributes(attributes, getModelIdentifier(), true, lineNumber, -1, -1);
85 ensureMarker().setAttributes(attributes);
87 // add to breakpoint manager if requested
91 run(getMarkerRule(resource), wr);
95 protected void register(boolean register) throws CoreException {
97 DebugPlugin.getDefault().getBreakpointManager().addBreakpoint(this);
103 public void addLineBreakpointAttributes(Map attributes, String modelIdentifier, boolean enabled, int lineNumber, int charStart, int charEnd) {
104 attributes.put(IBreakpoint.ID, modelIdentifier);
105 attributes.put(IBreakpoint.ENABLED, new Boolean(enabled));
106 attributes.put(IMarker.LINE_NUMBER, new Integer(lineNumber));
109 attributes.put(IMarker.CHAR_START, new Integer(charStart));
110 attributes.put(IMarker.CHAR_END, new Integer(charEnd));
112 attributes.put(TYPE_NAME, "typeName");
113 attributes.put(BREAKPOINT_ID,new Integer(-1));
118 * @see org.eclipse.debug.core.model.IBreakpoint#getModelIdentifier()
120 public String getModelIdentifier() {
121 return IXDebugConstants.ID_PHP_DEBUG_MODEL;
124 public void setID(int id) throws CoreException {
125 ensureMarker().setAttribute(BREAKPOINT_ID,id);
128 public int getID() throws CoreException {
129 return ensureMarker().getAttribute(BREAKPOINT_ID,-1);
132 public int getHitCount() throws CoreException {
133 return ensureMarker().getAttribute(HIT_COUNT,-1);
137 public void setHitCount(int newHitCount) throws CoreException {
138 ensureMarker().setAttribute(HIT_COUNT,newHitCount);
139 //fHitCount = newHitCount;
142 * @see ILineBreakpoint#getLineNumber()
144 public int getLineNumber() throws CoreException {
145 IMarker m = getMarker();
147 return m.getAttribute(IMarker.LINE_NUMBER, -1);
153 * @see ILineBreakpoint#getCharStart()
155 public int getCharStart() throws CoreException {
156 IMarker m = getMarker();
158 return m.getAttribute(IMarker.CHAR_START, -1);
164 * @see ILineBreakpoint#getCharEnd()
166 public int getCharEnd() throws CoreException {
167 IMarker m = getMarker();
169 return m.getAttribute(IMarker.CHAR_END, -1);