1 | /** |
2 | * |
3 | */ |
4 | package de.uka.ipd.sdq.codegen.simucontroller.debug; |
5 | |
6 | import org.eclipse.core.runtime.PlatformObject; |
7 | import org.eclipse.debug.core.DebugEvent; |
8 | import org.eclipse.debug.core.DebugPlugin; |
9 | import org.eclipse.debug.core.ILaunch; |
10 | import org.eclipse.debug.core.model.IDebugElement; |
11 | import org.eclipse.debug.core.model.IDebugTarget; |
12 | import org.eclipse.emf.common.notify.Adapter; |
13 | import org.eclipse.emf.common.notify.Notification; |
14 | import org.eclipse.emf.common.notify.Notifier; |
15 | |
16 | /** |
17 | * @author Snowball |
18 | * |
19 | */ |
20 | public abstract class SimulationDebugElement extends PlatformObject implements IDebugElement, Adapter { |
21 | |
22 | protected IDebugTarget myDebugTarget = null; |
23 | protected ILaunch launch = null; |
24 | private Notifier adapterTarget; |
25 | |
26 | public SimulationDebugElement(IDebugTarget myDebugTarget, ILaunch launch) { |
27 | super(); |
28 | |
29 | this.myDebugTarget = myDebugTarget; |
30 | this.launch = launch; |
31 | } |
32 | |
33 | /* (non-Javadoc) |
34 | * @see org.eclipse.debug.core.model.IDebugElement#getDebugTarget() |
35 | */ |
36 | public IDebugTarget getDebugTarget() { |
37 | return myDebugTarget; |
38 | } |
39 | |
40 | /* (non-Javadoc) |
41 | * @see org.eclipse.debug.core.model.IDebugElement#getLaunch() |
42 | */ |
43 | public ILaunch getLaunch() { |
44 | return launch; |
45 | } |
46 | |
47 | /* (non-Javadoc) |
48 | * @see org.eclipse.debug.core.model.IDebugElement#getModelIdentifier() |
49 | */ |
50 | public String getModelIdentifier() { |
51 | return "de.uka.ipd.sdq.pcm.simucom.SimuComDebugModel"; |
52 | } |
53 | |
54 | /* (non-Javadoc) |
55 | * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) |
56 | */ |
57 | @SuppressWarnings("unchecked") |
58 | public Object getAdapter(Class adapter) { |
59 | if (adapter == IDebugElement.class) { |
60 | return this; |
61 | } |
62 | return super.getAdapter(adapter); |
63 | } |
64 | |
65 | /** |
66 | * Fires a debug event |
67 | * |
68 | * @param event the event to be fired |
69 | */ |
70 | protected void fireEvent(DebugEvent event) { |
71 | DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] {event}); |
72 | } |
73 | |
74 | /** |
75 | * Fires a debug event |
76 | * |
77 | * @param event the event to be fired |
78 | */ |
79 | protected void fireEvent(Object source, int eventKind) { |
80 | DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] {new DebugEvent(source,eventKind)}); |
81 | } |
82 | |
83 | public Notifier getTarget() { |
84 | return this.adapterTarget; |
85 | } |
86 | |
87 | public boolean isAdapterForType(Object type) { |
88 | return true; |
89 | } |
90 | |
91 | public abstract void notifyChanged(Notification notification); |
92 | |
93 | public void setTarget(Notifier newTarget) { |
94 | this.adapterTarget = newTarget; |
95 | } |
96 | } |