*** empty log message ***
[phpeclipse.git] / net.sourceforge.phpeclipse.xdebug.core / src / net / sourceforge / phpeclipse / xdebug / core / XDebugElement.java
1 /*
2  * Created on 23.11.2004
3  *
4  * TODO To change the template for this generated file go to
5  * Window - Preferences - Java - Code Style - Code Templates
6  */
7 package net.sourceforge.phpeclipse.xdebug.core;
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 Axel
19  *
20  * TODO To change the template for this generated type comment go to
21  * Window - Preferences - Java - Code Style - Code Templates
22  */
23 public abstract class XDebugElement extends PlatformObject implements IDebugElement {
24         
25         // containing target 
26         protected XDebugTarget fTarget;
27         
28         /**
29          * Constructs a new debug element contained in the given
30          * debug target.
31          * 
32          * @param target debug target (PDA VM)
33          */
34         public XDebugElement(XDebugTarget target) {
35                 fTarget = target;
36         }
37         
38         /* (non-Javadoc)
39          * @see org.eclipse.debug.core.model.IDebugElement#getModelIdentifier()
40          */
41         public String getModelIdentifier() {
42 //              return IPDAConstants.ID_PDA_DEBUG_MODEL;
43                 return null;
44         }
45         /* (non-Javadoc)
46          * @see org.eclipse.debug.core.model.IDebugElement#getDebugTarget()
47          */
48         public IDebugTarget getDebugTarget() {
49                 return fTarget;
50         }
51         /* (non-Javadoc)
52          * @see org.eclipse.debug.core.model.IDebugElement#getLaunch()
53          */
54         public ILaunch getLaunch() {
55                 return getDebugTarget().getLaunch();
56         }
57         /* (non-Javadoc)
58          * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
59          */
60         public Object getAdapter(Class adapter) {
61                 if (adapter == IDebugElement.class) {
62                         return this;
63                 }
64                 return super.getAdapter(adapter);
65         }
66         
67         protected void abort(String message, Throwable e) throws DebugException {
68 /*      Axel auskommentiert
69                 throw new DebugException(new Status(IStatus.ERROR, DebugExamplesPlugin.getDefault().getDescriptor().getUniqueIdentifier(), 
70                                 DebugPlugin.INTERNAL_ERROR, message, e));
71 */
72                 }
73         
74         /**
75          * Fires a debug event
76          * 
77          * @param event the event to be fired
78          */
79         protected void fireEvent(DebugEvent event) {
80                 DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] {event});
81         }
82         
83         /**
84          * Fires a <code>CREATE</code> event for this element.
85          */
86         protected void fireCreationEvent() {
87                 fireEvent(new DebugEvent(this, DebugEvent.CREATE));
88         }       
89         
90         /**
91          * Fires a <code>RESUME</code> event for this element with
92          * the given detail.
93          * 
94          * @param detail event detail code
95          */
96         public void fireResumeEvent(int detail) {
97                 fireEvent(new DebugEvent(this, DebugEvent.RESUME, detail));
98         }
99
100         /**
101          * Fires a <code>SUSPEND</code> event for this element with
102          * the given detail.
103          * 
104          * @param detail event detail code
105          */
106         public void fireSuspendEvent(int detail) {
107                 fireEvent(new DebugEvent(this, DebugEvent.SUSPEND, detail));
108         }
109         
110         /**
111          * Fires a <code>TERMINATE</code> event for this element.
112          */
113         protected void fireTerminateEvent() {
114                 fireEvent(new DebugEvent(this, DebugEvent.TERMINATE));
115         }       
116 }