Bläddra i källkod

Debug View: Refresh Stack Frames after State change occured

Andreas Mülder 14 år sedan
förälder
incheckning
76d4c4c9ed

+ 12 - 6
plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/debugmodel/SCTDebugElement.java

@@ -10,23 +10,29 @@
  */
 package org.yakindu.sct.simulation.core.debugmodel;
 
-import org.eclipse.core.runtime.PlatformObject;
+import org.eclipse.debug.core.model.DebugElement;
+import org.eclipse.debug.core.model.IDebugTarget;
+
 /**
  * 
  * @author andreas muelder - Initial contribution and API
- *
+ * 
  */
-public class SCTDebugElement extends PlatformObject {
-
-	private String resourceString;
+public class SCTDebugElement extends DebugElement {
 
-	public SCTDebugElement(String resourceString) {
+	public SCTDebugElement(IDebugTarget target, String resourceString) {
+		super(target);
 		this.resourceString = resourceString;
 	}
 
+	private String resourceString;
+
 	public String getResourceString() {
 		return resourceString;
 	}
 
+	public String getModelIdentifier() {
+		return IDebugConstants.ID_DEBUG_MODEL;
+	}
 
 }

+ 1 - 4
plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/debugmodel/SCTDebugTarget.java

@@ -40,7 +40,7 @@ public class SCTDebugTarget extends SCTDebugElement implements IDebugTarget {
 
 	public SCTDebugTarget(ILaunch launch, ISGraphExecutionFacade facade,
 			String resourceString) throws CoreException {
-		super(resourceString);
+		super(null,resourceString);
 		this.launch = launch;
 		this.facade = facade;
 		thread = new SCTDebugThread(this, facade, resourceString);
@@ -135,9 +135,6 @@ public class SCTDebugTarget extends SCTDebugElement implements IDebugTarget {
 		return launch;
 	}
 
-	public String getModelIdentifier() {
-		return IDebugConstants.ID_DEBUG_MODEL;
-	}
 
 	public IDebugTarget getDebugTarget() {
 		return this;

+ 5 - 30
plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/debugmodel/SCTDebugThread.java

@@ -16,10 +16,7 @@ import java.util.List;
 
 import org.eclipse.debug.core.DebugEvent;
 import org.eclipse.debug.core.DebugException;
-import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.ILaunch;
 import org.eclipse.debug.core.model.IBreakpoint;
-import org.eclipse.debug.core.model.IDebugTarget;
 import org.eclipse.debug.core.model.IStackFrame;
 import org.eclipse.debug.core.model.IThread;
 import org.yakindu.sct.model.sgraph.Transition;
@@ -41,14 +38,12 @@ public class SCTDebugThread extends SCTDebugElement implements IThread,
 	private boolean suspended = false;
 	private Thread thread;
 	private SGraphSimulationSession session;
-	private final SCTDebugTarget target;
 	private final ISGraphExecutionFacade facade;
 	private List<Vertex> activeStates = new ArrayList<Vertex>();
 
 	public SCTDebugThread(SCTDebugTarget target, ISGraphExecutionFacade facade,
 			String resourceString) {
-		super(resourceString);
-		this.target = target;
+		super(target, resourceString);
 		this.facade = facade;
 		session = new SGraphSimulationSession(facade);
 		facade.addExecutionListener(this);
@@ -63,7 +58,6 @@ public class SCTDebugThread extends SCTDebugElement implements IThread,
 
 	public IStackFrame[] getStackFrames() throws DebugException {
 		List<IStackFrame> stackFrames = new ArrayList<IStackFrame>();
-
 		for (int i = activeStates.size() - 1; i >= 0; i--) {
 			stackFrames.add(new SCTStackFrame(this, activeStates.get(i),
 					getResourceString()));
@@ -75,33 +69,25 @@ public class SCTDebugThread extends SCTDebugElement implements IThread,
 		return true;
 	}
 
-	
-	public String getModelIdentifier() {
-		return IDebugConstants.ID_DEBUG_MODEL;
-	}
-
-	
 	public void stateEntered(Vertex vertex) {
 		activeStates.add(vertex);
+		fireChangeEvent(DebugEvent.CONTENT);
 	}
 
-	
 	public void stateLeft(Vertex vertex) {
 		activeStates.remove(vertex);
+		fireChangeEvent(DebugEvent.CONTENT);
 
 	}
 
-	
 	public void transitionFired(Transition transition) {
 		// Nothing to do
 	}
 
-	
 	public void variableValueChanged(String variableName, Object value) {
 		// Nothing to do
 	}
 
-	
 	public void eventRaised(String eventName) {
 		// Nothing to do
 	}
@@ -128,12 +114,14 @@ public class SCTDebugThread extends SCTDebugElement implements IThread,
 
 	public void resume() throws DebugException {
 		fireEvent(new DebugEvent(this, DebugEvent.RESUME));
+		fireChangeEvent(DebugEvent.CONTENT);
 		session.resume();
 		suspended = false;
 	}
 
 	public void suspend() throws DebugException {
 		fireEvent(new DebugEvent(this, DebugEvent.SUSPEND));
+		fireChangeEvent(DebugEvent.CONTENT);
 		session.suspend();
 		suspended = true;
 	}
@@ -185,19 +173,6 @@ public class SCTDebugThread extends SCTDebugElement implements IThread,
 		return null;
 	}
 
-	public ILaunch getLaunch() {
-		return getDebugTarget().getLaunch();
-	}
-
-	protected void fireEvent(DebugEvent event) {
-		DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] { event });
-	}
-
-	public IDebugTarget getDebugTarget() {
-		return target;
-	}
-
-	
 	public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
 		if (adapter == SGraphSimulationSession.class)
 			return session;

+ 5 - 25
plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/debugmodel/SCTStackFrame.java

@@ -14,6 +14,7 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
+import org.eclipse.debug.core.DebugEvent;
 import org.eclipse.debug.core.DebugException;
 import org.eclipse.debug.core.ILaunch;
 import org.eclipse.debug.core.model.IRegisterGroup;
@@ -39,7 +40,7 @@ public class SCTStackFrame extends SCTDebugElement implements IStackFrame {
 
 	public SCTStackFrame(SCTDebugThread thread, Vertex state,
 			String resourceString) {
-		super(resourceString);
+		super(thread.getDebugTarget(), resourceString);
 		this.thread = thread;
 		this.state = state;
 	}
@@ -60,98 +61,82 @@ public class SCTStackFrame extends SCTDebugElement implements IStackFrame {
 		return thread.canStepReturn();
 	}
 
-	
 	public boolean isStepping() {
 		return thread.isStepping();
 	}
 
-	
 	public void stepInto() throws DebugException {
 		thread.stepInto();
 	}
 
-	
 	public void stepOver() throws DebugException {
 		thread.stepOver();
 	}
 
-	
 	public void stepReturn() throws DebugException {
 		thread.stepReturn();
 	}
 
-	
 	public boolean canResume() {
 		return thread.canResume();
 	}
 
-	
 	public boolean canSuspend() {
 		return thread.canSuspend();
 	}
 
-	
 	public boolean isSuspended() {
 		return thread.isSuspended();
 	}
 
-	
 	public void resume() throws DebugException {
 		thread.resume();
+		fireEvent(new DebugEvent(this, DebugEvent.RESUME));
 
 	}
 
-	
 	public void suspend() throws DebugException {
 		thread.suspend();
+		fireEvent(new DebugEvent(this, DebugEvent.SUSPEND));
 	}
 
-	
 	public boolean canTerminate() {
 		return thread.canTerminate();
 	}
 
-	
 	public boolean isTerminated() {
 		return thread.isTerminated();
 	}
 
-	
 	public void terminate() throws DebugException {
 		thread.terminate();
+		fireEvent(new DebugEvent(this, DebugEvent.TERMINATE));
 	}
 
-	
 	public SCTDebugThread getThread() {
 		return thread;
 	}
 
-	
 	public IVariable[] getVariables() throws DebugException {
 		return new IVariable[] {};
 	}
 
-	
 	public boolean hasVariables() throws DebugException {
 		return false;
 	}
 
-	
 	public int getLineNumber() throws DebugException {
 		return -1;
 	}
 
-	
 	public int getCharStart() throws DebugException {
 		return -1;
 	}
 
-	
 	public int getCharEnd() throws DebugException {
 		return -1;
 	}
 
-	
 	public String getName() throws DebugException {
 		List<String> qfnFragments = new ArrayList<String>();
 		qfnFragments.add(state.getName());
@@ -185,12 +170,10 @@ public class SCTStackFrame extends SCTDebugElement implements IStackFrame {
 
 	}
 
-	
 	public IRegisterGroup[] getRegisterGroups() throws DebugException {
 		return new IRegisterGroup[] {};
 	}
 
-	
 	public boolean hasRegisterGroups() throws DebugException {
 		return false;
 	}
@@ -199,7 +182,6 @@ public class SCTStackFrame extends SCTDebugElement implements IStackFrame {
 		return (SCTDebugTarget) thread.getDebugTarget();
 	}
 
-	
 	public ILaunch getLaunch() {
 		return thread.getLaunch();
 	}
@@ -208,12 +190,10 @@ public class SCTStackFrame extends SCTDebugElement implements IStackFrame {
 		return state;
 	}
 
-	
 	public String getResourceString() {
 		return state.eResource().getURI().toPlatformString(true);
 	}
 
-	
 	public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
 		if (adapter == SGraphSimulationSession.class)
 			return thread.getAdapter(SGraphSimulationSession.class);