1) updateThreads is needed.
[phpeclipse.git] / net.sourceforge.phpeclipse.debug.core / src / net / sourceforge / phpdt / internal / debug / core / model / PHPDebugElement.java
1 /*******************************************************************************
2  * Copyright (c) 2004 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  *
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *     Bjorn Freeman-Benson - initial API and implementation
11  *******************************************************************************/
12 package net.sourceforge.phpdt.internal.debug.core.model;
13
14 import org.eclipse.core.runtime.IStatus;
15 import org.eclipse.core.runtime.PlatformObject;
16 import org.eclipse.core.runtime.Status;
17 import org.eclipse.debug.core.DebugEvent;
18 import org.eclipse.debug.core.DebugException;
19 import org.eclipse.debug.core.DebugPlugin;
20 import org.eclipse.debug.core.ILaunch;
21 import org.eclipse.debug.core.model.IDebugElement;
22 import org.eclipse.debug.core.model.IDebugTarget;
23
24 /**
25  * Common function of PHP debug model elements
26  */
27 public abstract class PHPDebugElement extends PlatformObject implements
28                 IDebugElement {
29
30         // containing target
31         protected PHPDebugTarget fTarget;
32
33         /**
34          * Constructs a new debug element contained in the given debug target.
35          * 
36          * @param target
37          *            debug target (PHP VM)
38          */
39         public PHPDebugElement(PHPDebugTarget target) {
40                 fTarget = target;
41         }
42
43         /*
44          * (non-Javadoc)
45          * 
46          * @see org.eclipse.debug.core.model.IDebugElement#getModelIdentifier()
47          */
48         public String getModelIdentifier() {
49                 return null;
50                 // return PHPDebugCorePlugin.PLUGIN_ID;
51                 // return IPDAConstants.ID_PDA_DEBUG_MODEL;
52         }
53
54         /*
55          * (non-Javadoc)
56          * 
57          * @see org.eclipse.debug.core.model.IDebugElement#getDebugTarget()
58          */
59         public IDebugTarget getDebugTarget() {
60                 return fTarget;
61         }
62
63         /*
64          * (non-Javadoc)
65          * 
66          * @see org.eclipse.debug.core.model.IDebugElement#getLaunch()
67          */
68         public ILaunch getLaunch() {
69                 return getDebugTarget().getLaunch();
70         }
71
72         /*
73          * (non-Javadoc)
74          * 
75          * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
76          */
77         public Object getAdapter(Class adapter) {
78                 if (adapter == IDebugElement.class) {
79                         return this;
80                 }
81                 return super.getAdapter(adapter);
82         }
83
84         protected void abort(String message, Throwable e) throws DebugException {
85                 throw new DebugException(
86                                 new Status(
87                                                 IStatus.ERROR,
88                                                 null /* DebugExamplesPlugin.getDefault().getDescriptor().getUniqueIdentifier() */,
89                                                 DebugPlugin.INTERNAL_ERROR, message, e));
90         }
91
92         /**
93          * Fires a debug event
94          * 
95          * @param event
96          *            the event to be fired
97          */
98         protected void fireEvent(DebugEvent event) {
99                 DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] { event });
100         }
101
102         /**
103          * Fires a <code>CREATE</code> event for this element.
104          */
105 //      protected void fireCreationEvent() {
106 //              fireEvent(new DebugEvent(this, DebugEvent.CREATE));
107 //      }
108
109         /**
110          * Fires a <code>RESUME</code> event for this element with the given
111          * detail.
112          * 
113          * @param detail
114          *            event detail code
115          */
116 //      public void fireResumeEvent(int detail) {
117 //              fireEvent(new DebugEvent(this, DebugEvent.RESUME, detail));
118 //      }
119
120         /**
121          * Fires a <code>SUSPEND</code> event for this element with the given
122          * detail.
123          * 
124          * @param detail
125          *            event detail code
126          */
127 //      public void fireSuspendEvent(int detail) {
128 //              fireEvent(new DebugEvent(this, DebugEvent.SUSPEND, detail));
129 //      }
130
131         /**
132          * Fires a <code>TERMINATE</code> event for this element.
133          */
134         protected void fireTerminateEvent() {
135                 fireEvent(new DebugEvent(this, DebugEvent.TERMINATE));
136         }
137 }