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