| 1 | package de.uka.ipd.sdq.codegen.simucontroller.debug; |
| 2 | |
| 3 | import org.eclipse.debug.core.DebugEvent; |
| 4 | import org.eclipse.debug.core.DebugException; |
| 5 | import org.eclipse.debug.core.ILaunch; |
| 6 | import org.eclipse.debug.core.model.IBreakpoint; |
| 7 | import org.eclipse.debug.core.model.IDebugTarget; |
| 8 | import org.eclipse.debug.core.model.IStackFrame; |
| 9 | import org.eclipse.debug.core.model.IThread; |
| 10 | import org.eclipse.emf.common.notify.Adapter; |
| 11 | import org.eclipse.emf.common.notify.Notification; |
| 12 | import org.eclipse.emf.common.notify.Notifier; |
| 13 | |
| 14 | import de.uka.ipd.sdq.simucomframework.simucomstatus.Process; |
| 15 | import de.uka.ipd.sdq.simucomframework.simucomstatus.SimucomstatusPackage; |
| 16 | |
| 17 | public class SimuComProcessDebugThread extends SimulationDebugElement implements IThread, Adapter { |
| 18 | |
| 19 | private Process myProcess; |
| 20 | |
| 21 | public SimuComProcessDebugThread(IDebugTarget myDebugTarget, ILaunch launch, Process p) { |
| 22 | super(myDebugTarget, launch); |
| 23 | this.myProcess = p; |
| 24 | p.eAdapters().add(this); |
| 25 | } |
| 26 | |
| 27 | public IBreakpoint[] getBreakpoints() { |
| 28 | return new IBreakpoint[]{}; |
| 29 | } |
| 30 | |
| 31 | public String getName() throws DebugException { |
| 32 | return myProcess.getId()+": "+new ProcessActionPrintVisitor().doSwitch(myProcess.getCurrentAction()); |
| 33 | } |
| 34 | |
| 35 | public int getPriority() throws DebugException { |
| 36 | return 0; |
| 37 | } |
| 38 | |
| 39 | public IStackFrame[] getStackFrames() throws DebugException { |
| 40 | return new IStackFrame[]{}; |
| 41 | } |
| 42 | |
| 43 | public IStackFrame getTopStackFrame() throws DebugException { |
| 44 | return null; |
| 45 | } |
| 46 | |
| 47 | public boolean hasStackFrames() throws DebugException { |
| 48 | return false; |
| 49 | } |
| 50 | |
| 51 | public ILaunch getLaunch() { |
| 52 | return this.launch; |
| 53 | } |
| 54 | |
| 55 | public boolean canResume() { |
| 56 | return true; |
| 57 | } |
| 58 | |
| 59 | public boolean canSuspend() { |
| 60 | return true; |
| 61 | } |
| 62 | |
| 63 | public boolean isSuspended() { |
| 64 | return this.myDebugTarget.isSuspended(); |
| 65 | } |
| 66 | |
| 67 | public void resume() throws DebugException { |
| 68 | this.myDebugTarget.resume(); |
| 69 | } |
| 70 | |
| 71 | public void suspend() throws DebugException { |
| 72 | this.myDebugTarget.suspend(); |
| 73 | } |
| 74 | |
| 75 | public boolean canStepInto() { |
| 76 | return false; |
| 77 | } |
| 78 | |
| 79 | public boolean canStepOver() { |
| 80 | return false; |
| 81 | } |
| 82 | |
| 83 | public boolean canStepReturn() { |
| 84 | return false; |
| 85 | } |
| 86 | |
| 87 | public boolean isStepping() { |
| 88 | return false; |
| 89 | } |
| 90 | |
| 91 | public void stepInto() throws DebugException { |
| 92 | } |
| 93 | |
| 94 | public void stepOver() throws DebugException { |
| 95 | } |
| 96 | |
| 97 | public void stepReturn() throws DebugException { |
| 98 | } |
| 99 | |
| 100 | public boolean canTerminate() { |
| 101 | return false; |
| 102 | } |
| 103 | |
| 104 | public boolean isTerminated() { |
| 105 | return this.myDebugTarget.isTerminated(); |
| 106 | } |
| 107 | |
| 108 | public void terminate() throws DebugException { |
| 109 | } |
| 110 | |
| 111 | public Notifier getTarget() { |
| 112 | return this.myProcess; |
| 113 | } |
| 114 | |
| 115 | public boolean isAdapterForType(Object type) { |
| 116 | return true; |
| 117 | } |
| 118 | |
| 119 | public void notifyChanged(Notification notification) { |
| 120 | if (myDebugTarget.isSuspended()){ |
| 121 | if (notification.getEventType() == Notification.SET) { |
| 122 | if (notification.getFeature() == SimucomstatusPackage.eINSTANCE.getProcess_CurrentAction()){ |
| 123 | this.fireEvent(this, DebugEvent.CHANGE); |
| 124 | } |
| 125 | } |
| 126 | } |
| 127 | } |
| 128 | |
| 129 | public void setTarget(Notifier newTarget) { |
| 130 | } |
| 131 | |
| 132 | public void dispose() { |
| 133 | this.myProcess.eAdapters().remove(this); |
| 134 | } |
| 135 | |
| 136 | public Process getProcess() { |
| 137 | return this.myProcess; |
| 138 | } |
| 139 | |
| 140 | } |