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