1) Added parameter 'parent' to XDebugVariable, so we can determine whether a variable...
[phpeclipse.git] / net.sourceforge.phpeclipse.xdebug.core / src / net / sourceforge / phpeclipse / xdebug / php / model / XDebugConditionalBreakpoint.java
1
2 /*
3  * Created on 25.11.2004
4  *
5  * TODO To change the template for this generated file go to
6  * Window - Preferences - Java - Code Style - Code Templates
7  */
8 package net.sourceforge.phpeclipse.xdebug.php.model;
9
10
11 import java.util.HashMap;
12 import java.util.Map;
13
14 //import net.sourceforge.phpeclipse.xdebug.php.launching.IXDebugConstants;
15
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.Breakpoint;
23 import org.eclipse.debug.core.model.IBreakpoint;
24 //import org.eclipse.debug.core.model.ILineBreakpoint;
25 //import org.eclipse.debug.core.model.LineBreakpoint;
26
27
28 /**
29  * @author Axel
30  *
31  * TODO To change the template for this generated type comment go to
32  * Window - Preferences - Java - Code Style - Code Templates
33  */
34 public class XDebugConditionalBreakpoint extends XDebugLineBreakpoint /*implements ILineBreakpoint*/ /*extends LineBreakpoint*/ {
35
36         /**
37          * Default constructor is required for the breakpoint manager
38          * to re-create persisted breakpoints. After instantiating a breakpoint,
39          * the <code>setMarker(...)</code> method is called to restore
40          * this breakpoint's attributes.
41          */
42         private static final String XDEBUG_CONDITIONAL_BREAKPOINT = "net.sourceforge.phpeclipse.xdebug.core.XDebugLineBreakpoint"; //$NON-NLS-1$
43
44         /**
45          * Breakpoint attribute storing the fully qualified name of the type
46          * this breakpoint is located in.
47          * (value <code>"net.sourceforge.phpeclipse.debug.typeName"</code>). This attribute is a <code>String</code>.
48          */
49         protected static final String TYPE_NAME = "net.sourceforge.phpeclipse.debug.typeName"; //$NON-NLS-1$            
50
51         public static final String BREAKPOINT_ID ="XDebugConditionalBreakpointID";
52         
53 /*      public XDebugConditionalBreakpoint() {
54         }*/
55         
56         /**
57          * Constructs a line breakpoint on the given resource at the given
58          * line number. The line number is 1-based (i.e. the first line of a
59          * file is line number 1).
60          * 
61          * @param resource file on which to set the breakpoint
62          * @param lineNumber 1-based line number of the breakpoint
63          * @throws CoreException if unable to create the breakpoint
64          */
65         public XDebugConditionalBreakpoint(final IResource resource, final int lineNumber) throws CoreException {
66                 IWorkspaceRunnable wr = new IWorkspaceRunnable() {
67                         public void run(IProgressMonitor monitor) throws CoreException {
68         
69                                 // create the marker
70                                 setMarker(resource.createMarker(XDEBUG_CONDITIONAL_BREAKPOINT));
71
72                                 // add attributes
73                                 Map attributes = new HashMap(10);
74                                 addLineBreakpointAttributes(attributes, getModelIdentifier(), true, lineNumber, -1, -1);
75
76                                 // set attributes
77                                 ensureMarker().setAttributes(attributes);
78                                 
79                                 // add to breakpoint manager if requested
80                                 register(true);         
81                         }
82                 };
83                 run(getMarkerRule(resource), wr);
84
85         }
86         
87         /*protected void register(boolean register) throws CoreException {
88                 if (register) {
89                         DebugPlugin.getDefault().getBreakpointManager().addBreakpoint(this);
90                 } else {
91                         setRegistered(false);
92                 }
93         }*/
94         
95         public void addLineBreakpointAttributes(Map attributes, String modelIdentifier, boolean enabled, int lineNumber, int charStart, int charEnd) {
96                 attributes.put(IBreakpoint.ID, modelIdentifier);
97                 attributes.put(IBreakpoint.ENABLED, new Boolean(enabled));
98                 attributes.put(IMarker.LINE_NUMBER, new Integer(lineNumber));
99                 if (charStart!=-1)
100                 {
101                         attributes.put(IMarker.CHAR_START, new Integer(charStart));
102                         attributes.put(IMarker.CHAR_END, new Integer(charEnd));
103                 }
104                 attributes.put(TYPE_NAME, "typeName");
105                 attributes.put(BREAKPOINT_ID,new Integer(-1));
106         }               
107 }