7242bd4867cdeb4acd171dd36f496fee395af09c
[phpeclipse.git] /
1 /**
2  * 
3  */
4 package net.sourceforge.phpeclipse.xdebug.php.model;
5
6 import net.sourceforge.phpeclipse.xdebug.core.ResponseData;
7 import net.sourceforge.phpeclipse.xdebug.php.launching.IXDebugConstants;
8
9 import org.eclipse.core.runtime.PlatformObject;
10 import org.eclipse.debug.core.DebugEvent;
11 import org.eclipse.debug.core.DebugException;
12 import org.eclipse.debug.core.DebugPlugin;
13 import org.eclipse.debug.core.ILaunch;
14 import org.eclipse.debug.core.model.IDebugElement;
15 import org.eclipse.debug.core.model.IDebugTarget;
16
17 /**
18  * @author Christian
19  * 
20  */
21 public class XDebugElement extends PlatformObject implements IDebugElement {
22
23         // containing target
24         protected XDebugTarget fTarget;
25
26         /**
27          * Constructs a new debug element contained in the given debug target.
28          * 
29          * @param target
30          *            debug target (PDA VM)
31          */
32         public XDebugElement(XDebugTarget target) {
33                 fTarget = target;
34         }
35
36         /*
37          * (non-Javadoc)
38          * 
39          * @see org.eclipse.debug.core.model.IDebugElement#getModelIdentifier()
40          */
41         public String getModelIdentifier() {
42                 return IXDebugConstants.ID_PHP_DEBUG_MODEL;
43         }
44
45         /*
46          * (non-Javadoc)
47          * 
48          * @see org.eclipse.debug.core.model.IDebugElement#getDebugTarget()
49          */
50         public IDebugTarget getDebugTarget() {
51                 return fTarget;
52         }
53
54         /*
55          * (non-Javadoc)
56          * 
57          * @see org.eclipse.debug.core.model.IDebugElement#getLaunch()
58          */
59         public ILaunch getLaunch() {
60                 return getDebugTarget().getLaunch();
61         }
62
63         /*
64          * (non-Javadoc)
65          * 
66          * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
67          */
68         public Object getAdapter(Class adapter) {
69                 if (adapter == IDebugElement.class) {
70                         return this;
71                 }
72                 return super.getAdapter(adapter);
73         }
74
75         protected void abort(String message, Throwable e) throws DebugException {
76                 /*
77                  * Axel auskommentiert throw new DebugException(new
78                  * Status(IStatus.ERROR,
79                  * DebugExamplesPlugin.getDefault().getDescriptor().getUniqueIdentifier(),
80                  * DebugPlugin.INTERNAL_ERROR, message, e));
81                  */
82         }
83
84         /**
85          * Fires a debug event
86          * 
87          * @param event
88          *            the event to be fired
89          */
90         protected void fireEvent(DebugEvent event) {
91                 DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] { event });
92         }
93
94         /**
95          * Fires a <code>CREATE</code> event for this element.
96          */
97         public void fireCreationEvent() {
98                 fireEvent(new DebugEvent(this, DebugEvent.CREATE));
99         }
100
101         /**
102          * Fires a <code>RESUME</code> event for this element with the given
103          * detail.
104          * 
105          * @param detail
106          *            event detail code
107          */
108         public void fireResumeEvent(int detail) {
109                 fireEvent(new DebugEvent(this, DebugEvent.RESUME, detail));
110         }
111
112         /**
113          * Fires a <code>SUSPEND</code> event for this element with the given
114          * detail.
115          * 
116          * @param detail
117          *            event detail code
118          */
119         public void fireSuspendEvent(int detail) {
120                 fireEvent(new DebugEvent(this, DebugEvent.SUSPEND, detail));
121         }
122
123         /**
124          * Fires a <code>TERMINATE</code> event for this element.
125          */
126         protected void fireTerminateEvent() {
127                 fireEvent(new DebugEvent(this, DebugEvent.TERMINATE));
128         }
129
130         public void fireDebugResponseEvent(ResponseData data) {
131                 DebugEvent de = new DebugEvent(this, DebugEvent.MODEL_SPECIFIC);
132                 de.setData(data);
133                 fireEvent(de);
134         }
135 }