1) Fixed bug #1366994 . bool and resource variables has not been added to main variab...
[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 IDebugElement {
28
29         // containing target
30   protected PHPDebugTarget fTarget;
31
32         /**
33          * Constructs a new debug element contained in the given
34          * debug target.
35          *
36    * @param target debug target (PHP VM)
37          */
38   public PHPDebugElement(PHPDebugTarget target) {
39                 fTarget = target;
40         }
41
42         /* (non-Javadoc)
43          * @see org.eclipse.debug.core.model.IDebugElement#getModelIdentifier()
44          */
45         public String getModelIdentifier() {
46                 return null;
47     // return PHPDebugCorePlugin.PLUGIN_ID;
48     // return IPDAConstants.ID_PDA_DEBUG_MODEL;
49         }
50         /* (non-Javadoc)
51          * @see org.eclipse.debug.core.model.IDebugElement#getDebugTarget()
52          */
53         public IDebugTarget getDebugTarget() {
54                 return fTarget;
55         }
56         /* (non-Javadoc)
57          * @see org.eclipse.debug.core.model.IDebugElement#getLaunch()
58          */
59         public ILaunch getLaunch() {
60                 return getDebugTarget().getLaunch();
61         }
62         /* (non-Javadoc)
63          * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
64          */
65         public Object getAdapter(Class adapter) {
66                 if (adapter == IDebugElement.class) {
67                         return this;
68                 }
69                 return super.getAdapter(adapter);
70         }
71
72         protected void abort(String message, Throwable e) throws DebugException {
73                 throw new DebugException(new Status(IStatus.ERROR, null /*DebugExamplesPlugin.getDefault().getDescriptor().getUniqueIdentifier()*/,
74                                 DebugPlugin.INTERNAL_ERROR, message, e));
75         }
76
77         /**
78          * Fires a debug event
79          *
80          * @param event the event to be fired
81          */
82         protected void fireEvent(DebugEvent event) {
83                 DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] {event});
84         }
85
86         /**
87          * Fires a <code>CREATE</code> event for this element.
88          */
89         protected void fireCreationEvent() {
90                 fireEvent(new DebugEvent(this, DebugEvent.CREATE));
91         }
92
93         /**
94          * Fires a <code>RESUME</code> event for this element with
95          * the given detail.
96          *
97          * @param detail event detail code
98          */
99         public void fireResumeEvent(int detail) {
100                 fireEvent(new DebugEvent(this, DebugEvent.RESUME, detail));
101         }
102
103         /**
104          * Fires a <code>SUSPEND</code> event for this element with
105          * the given detail.
106          *
107          * @param detail event detail code
108          */
109         public void fireSuspendEvent(int detail) {
110                 fireEvent(new DebugEvent(this, DebugEvent.SUSPEND, detail));
111         }
112
113         /**
114          * Fires a <code>TERMINATE</code> event for this element.
115          */
116         protected void fireTerminateEvent() {
117                 fireEvent(new DebugEvent(this, DebugEvent.TERMINATE));
118         }
119 }