1 /**********************************************************************
2 Copyright (c) 2000, 2002 IBM Corp. and others.
3 All rights reserved. This program and the accompanying materials
4 are made available under the terms of the Common Public License v1.0
5 which accompanies this distribution, and is available at
6 http://www.eclipse.org/legal/cpl-v10.html
9 Vicente Fernando - Initial implementation - www.alfersoft.com.ar
10 **********************************************************************/
11 package net.sourceforge.phpdt.internal.debug.core.breakpoints;
15 import org.eclipse.core.resources.IMarker;
16 import org.eclipse.core.resources.IResource;
17 import org.eclipse.core.resources.IWorkspaceRunnable;
18 import org.eclipse.core.runtime.CoreException;
19 import org.eclipse.core.runtime.IProgressMonitor;
20 import org.eclipse.debug.core.DebugException;
21 import org.eclipse.debug.core.model.IBreakpoint;
22 import org.eclipse.debug.core.model.ILineBreakpoint;
25 * A breakpoint that can be located at a specific line of source code.
27 public class PHPLineBreakpoint extends PHPBreakpoint implements IBreakpoint,
30 private static final String PHP_LINE_BREAKPOINT = "net.sourceforge.phpeclipse.debug.core.phpLineBreakpointMarker"; //$NON-NLS-1$
32 public PHPLineBreakpoint() {
35 public PHPLineBreakpoint(IResource resource, int lineNumber, int charStart,
36 int charEnd, int hitCount, boolean add, Map attributes)
37 throws DebugException {
38 this(resource, lineNumber, charStart, charEnd, hitCount, add,
39 attributes, PHP_LINE_BREAKPOINT);
42 public PHPLineBreakpoint(IResource resource, int lineNumber, int hitCount,
43 boolean add, Map attributes) throws DebugException {
44 this(resource, lineNumber, -1, -1, hitCount, add, attributes,
48 protected PHPLineBreakpoint(final IResource resource, final int lineNumber,
49 final int charStart, final int charEnd, final int hitCount,
50 final boolean add, final Map attributes, final String markerType)
51 throws DebugException {
52 IWorkspaceRunnable wr = new IWorkspaceRunnable() {
53 public void run(IProgressMonitor monitor) throws CoreException {
56 setMarker(resource.createMarker(markerType));
59 addLineBreakpointAttributes(attributes, getModelIdentifier(),
60 true, lineNumber, charStart, charEnd, hitCount);
63 ensureMarker().setAttributes(attributes);
65 // add to breakpoint manager if requested
72 public void addLineBreakpointAttributes(Map attributes,
73 String modelIdentifier, boolean enabled, int lineNumber,
74 int charStart, int charEnd, int hitCount) {
75 attributes.put(IBreakpoint.ID, modelIdentifier);
76 attributes.put(IBreakpoint.ENABLED, new Boolean(enabled));
77 attributes.put(IMarker.LINE_NUMBER, new Integer(lineNumber));
78 if (charStart != -1) {
79 attributes.put(IMarker.CHAR_START, new Integer(charStart));
80 attributes.put(IMarker.CHAR_END, new Integer(charEnd));
82 attributes.put(TYPE_NAME, "typeName");
83 attributes.put(PHPBreakpoint.HIT_COUNT, new Integer(hitCount));
84 attributes.put(PHPBreakpoint.CONDITION, new String(""));
85 attributes.put(PHPBreakpoint.CONDITION_ENABLED, new Boolean(false));
86 attributes.put(PHPBreakpoint.CHANGE_ID, new Integer(0));
90 * @see ILineBreakpoint#getLineNumber()
92 public int getLineNumber() throws CoreException {
93 return ensureMarker().getAttribute(IMarker.LINE_NUMBER, -1);
97 * @see ILineBreakpoint#getCharStart()
99 public int getCharStart() throws CoreException {
100 return ensureMarker().getAttribute(IMarker.CHAR_START, -1);
104 * @see ILineBreakpoint#getCharEnd()
106 public int getCharEnd() throws CoreException {
107 return ensureMarker().getAttribute(IMarker.CHAR_END, -1);
111 * Returns the type of marker associated with Java line breakpoints
113 public static String getMarkerType() {
114 return PHP_LINE_BREAKPOINT;
117 public int getHitCount() throws CoreException {
118 return ensureMarker().getAttribute(PHPBreakpoint.HIT_COUNT, 1);
121 public int getChangeID() throws CoreException {
122 return ensureMarker().getAttribute(CHANGE_ID, 1);
125 public void setChangeID(int changeID) throws CoreException {
126 ensureMarker().setAttribute(CHANGE_ID, changeID);
129 public String getCondition() throws CoreException {
130 return ensureMarker().getAttribute(CONDITION, "");
133 public void setCondition(String condition) throws CoreException {
134 ensureMarker().setAttribute(CONDITION, condition);
137 public void setConditionEnabled(boolean enabled) throws CoreException {
138 ensureMarker().setAttribute(CONDITION_ENABLED, enabled);
141 public boolean isConditionEnabled() throws CoreException {
142 return ensureMarker().getAttribute(CONDITION_ENABLED, false);