瀏覽代碼

Simulation of submachine states, tighter integration with debugger infrastructure

Andreas Mülder 14 年之前
父節點
當前提交
0c9ae327a0
共有 35 個文件被更改,包括 833 次插入269 次删除
  1. 4 1
      plugins/org.yakindu.sct.simulation.core/META-INF/MANIFEST.MF
  2. 1 2
      plugins/org.yakindu.sct.simulation.core/plugin.xml
  3. 7 0
      plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/ISGraphExecutionFacade.java
  4. 5 5
      plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/SGraphSimulationSession.java
  5. 0 55
      plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/SGraphSimulationSessionRegistry.java
  6. 1 3
      plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/debugmodel/IDebugConstants.java
  7. 18 0
      plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/debugmodel/SCTDebugElement.java
  8. 22 7
      plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/debugmodel/SCTDebugTarget.java
  9. 70 12
      plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/debugmodel/SCTDebugThread.java
  10. 229 0
      plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/debugmodel/SCTStackFrame.java
  11. 1 1
      plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/launch/IStatechartLaunchConfigurationType.java
  12. 12 4
      plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/launch/StatechartLaunchConfigurationDelegate.java
  13. 1 1
      plugins/org.yakindu.sct.simulation.runtime/.settings/org.eclipse.core.resources.prefs
  14. 27 0
      plugins/org.yakindu.sct.simulation.runtime/src-gen/org/yakindu/sct/simulation/runtime/sgraph/RTEvent.java
  15. 0 1
      plugins/org.yakindu.sct.simulation.runtime/src-gen/org/yakindu/sct/simulation/runtime/sgraph/RTPseudostate.java
  16. 4 0
      plugins/org.yakindu.sct.simulation.runtime/src-gen/org/yakindu/sct/simulation/runtime/sgraph/RTSignalEvent.java
  17. 2 2
      plugins/org.yakindu.sct.simulation.runtime/src/org/yakindu/sct/simulation/runtime/ExecutionScope.java
  18. 1 1
      plugins/org.yakindu.sct.simulation.runtime/src/org/yakindu/sct/simulation/runtime/sgraph/ExecutionScopeAdapter.java
  19. 18 8
      plugins/org.yakindu.sct.simulation.runtime/src/org/yakindu/sct/simulation/runtime/sgraph/RTStatechart.java
  20. 23 3
      plugins/org.yakindu.sct.simulation.runtime/src/org/yakindu/sct/simulation/runtime/sgraph/builder/SGraphBuilder.java
  21. 2 2
      plugins/org.yakindu.sct.simulation.runtime/src/org/yakindu/sct/simulation/runtime/stext/RTScope.java
  22. 30 9
      plugins/org.yakindu.sct.simulation.runtime/src/org/yakindu/sct/simulation/runtime/stext/RTVariable.java
  23. 4 1
      plugins/org.yakindu.sct.simulation.ui/META-INF/MANIFEST.MF
  24. 26 1
      plugins/org.yakindu.sct.simulation.ui/plugin.xml
  25. 1 6
      plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/SimulationActivator.java
  26. 0 93
      plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/editor/HighlightingExecutionListener.java
  27. 17 2
      plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/editor/IHighlightingSupportAdapterFactory.java
  28. 156 0
      plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/model/presenter/SCTSourceDisplay.java
  29. 34 0
      plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/model/presenter/SCTSourceDisplayAdapterFactory.java
  30. 24 0
      plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/view/ActiveSessionProvider.java
  31. 74 36
      plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/view/DeclarationView.java
  32. 3 2
      plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/view/editing/BooleanEditingSupport.java
  33. 3 2
      plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/view/editing/IntegerEditingSupport.java
  34. 4 2
      plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/view/editing/RealEditingSupport.java
  35. 9 7
      plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/view/editing/ScopeSlotEditingSupport.java

+ 4 - 1
plugins/org.yakindu.sct.simulation.core/META-INF/MANIFEST.MF

@@ -8,8 +8,11 @@ Bundle-Vendor: YAKINDU
 Require-Bundle: org.eclipse.core.runtime,
  org.eclipse.debug.core;bundle-version="3.7.0",
  org.eclipse.emf.ecore;bundle-version="2.7.0",
- org.yakindu.sct.model.sgraph;bundle-version="1.0.0"
+ org.yakindu.sct.model.sgraph;bundle-version="1.0.0",
+ org.eclipse.jdt.debug;bundle-version="3.7.0"
 Bundle-RequiredExecutionEnvironment: J2SE-1.5
 Bundle-ActivationPolicy: lazy
 Export-Package: org.yakindu.sct.simulation.core,
+ org.yakindu.sct.simulation.core.debugmodel,
+ org.yakindu.sct.simulation.core.extensions,
  org.yakindu.sct.simulation.core.launch

+ 1 - 2
plugins/org.yakindu.sct.simulation.core/plugin.xml

@@ -8,8 +8,7 @@
           delegate="org.yakindu.sct.simulation.core.launch.StatechartLaunchConfigurationDelegate"
           id="org.yakindu.sct.simulation.core.launch.statechart"
           modes="run, debug"
-          name="YAKINDU Statechart">        
+          name="YAKINDU Statechart">
     </launchConfigurationType>
 </extension>
-
 </plugin>

+ 7 - 0
plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/ISGraphExecutionFacade.java

@@ -10,6 +10,10 @@
  */
 package org.yakindu.sct.simulation.core;
 
+import java.util.Set;
+
+import org.yakindu.sct.model.sgraph.Vertex;
+
 /**
  * Facade for executable statechart implementation.
  * 
@@ -29,4 +33,7 @@ public interface ISGraphExecutionFacade {
 	public void removeExecutionListener(ISGraphExecutionListener listener);
 
 	public ISGraphExecutionScope getExecutionScope();
+	
+	public Set<Vertex> getStateConfiguration(); 
+	
 }

+ 5 - 5
plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/SGraphSimulationSession.java

@@ -54,8 +54,6 @@ public class SGraphSimulationSession implements Runnable,
 	public void start() {
 		taskQueue.add(new Runnable() {
 			public void run() {
-				SGraphSimulationSessionRegistry.INSTANCE
-						.registerSimulationSession(SGraphSimulationSession.this);
 				changeSimulationState(SimulationState.STARTED);
 				facade.enter();
 				changeSimulationState(SimulationState.RUNNING);
@@ -93,8 +91,6 @@ public class SGraphSimulationSession implements Runnable,
 		taskQueue.add(new Runnable() {
 			public void run() {
 				changeSimulationState(SimulationState.TERMINATED);
-				SGraphSimulationSessionRegistry.INSTANCE
-						.unregisterSimulationSession(SGraphSimulationSession.this);
 			}
 		});
 	}
@@ -185,5 +181,9 @@ public class SGraphSimulationSession implements Runnable,
 	public ISGraphExecutionScope getExecutionScope() {
 		return facade.getExecutionScope();
 	}
-	
+
+	public SimulationState getCurrentState() {
+		return currentState;
+	}
+
 }

+ 0 - 55
plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/SGraphSimulationSessionRegistry.java

@@ -1,55 +0,0 @@
-/**
- * Copyright (c) 2011 committers of YAKINDU and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *     committers of YAKINDU - initial API and implementation
- */
-package org.yakindu.sct.simulation.core;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * 
- * @author andreas muelder - Initial contribution and API
- * 
- */
-public class SGraphSimulationSessionRegistry {
-
-	public static final SGraphSimulationSessionRegistry INSTANCE = new SGraphSimulationSessionRegistry();
-
-	private List<ISimulationSessionListener> sessionListener;
-
-	private List<SGraphSimulationSession> sessions;
-
-	private SGraphSimulationSessionRegistry() {
-		sessionListener = new ArrayList<ISimulationSessionListener>();
-		sessions = new ArrayList<SGraphSimulationSession>();
-	}
-
-	public void registerSimulationSession(SGraphSimulationSession session) {
-		session.getListeners().addAll(getListeners());
-		sessions.add(session);
-	}
-
-	public void unregisterSimulationSession(SGraphSimulationSession session) {
-		session.getListeners().clear();
-		sessions.remove(session);
-	}
-
-	public List<ISimulationSessionListener> getListeners() {
-		return sessionListener;
-	}
-
-	public SGraphSimulationSession getActiveSession() {
-		// TODO
-		if (sessions.isEmpty())
-			return null;
-		return sessions.get(0);
-	}
-
-}

+ 1 - 3
plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/debugmodel/IDebugConstants.java

@@ -2,7 +2,5 @@ package org.yakindu.sct.simulation.core.debugmodel;
 
 public interface IDebugConstants {
 
-	public static final String ID_DEBUG_MODEL = "sct_debug";
-	public static final String DEBUG_TARGET = "YAKINDU Statechart Simulation";
-	public static final String DEBUG_THREAD = "Thread[1]";
+	public static final String ID_DEBUG_MODEL = "org.yakindu.sct.debug";
 }

+ 18 - 0
plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/debugmodel/SCTDebugElement.java

@@ -0,0 +1,18 @@
+package org.yakindu.sct.simulation.core.debugmodel;
+
+import org.eclipse.core.runtime.PlatformObject;
+
+public class SCTDebugElement extends PlatformObject {
+
+	private String resourceString;
+
+	public SCTDebugElement(String resourceString) {
+		this.resourceString = resourceString;
+	}
+
+	public String getResourceString() {
+		return resourceString;
+	}
+
+
+}

+ 22 - 7
plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/debugmodel/SCTDebugTarget.java

@@ -2,7 +2,6 @@ package org.yakindu.sct.simulation.core.debugmodel;
 
 import org.eclipse.core.resources.IMarkerDelta;
 import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.PlatformObject;
 import org.eclipse.debug.core.DebugException;
 import org.eclipse.debug.core.DebugPlugin;
 import org.eclipse.debug.core.ILaunch;
@@ -12,13 +11,14 @@ import org.eclipse.debug.core.model.IMemoryBlock;
 import org.eclipse.debug.core.model.IProcess;
 import org.eclipse.debug.core.model.IThread;
 import org.yakindu.sct.simulation.core.ISGraphExecutionFacade;
+import org.yakindu.sct.simulation.core.SGraphSimulationSession;
 
 /**
  * 
  * @author andreas muelder - Initial contribution and API
  * 
  */
-public class SCTDebugTarget extends PlatformObject implements IDebugTarget {
+public class SCTDebugTarget extends SCTDebugElement implements IDebugTarget {
 
 	private IProcess process;
 
@@ -26,10 +26,14 @@ public class SCTDebugTarget extends PlatformObject implements IDebugTarget {
 
 	private SCTDebugThread thread;
 
-	public SCTDebugTarget(ILaunch launch, ISGraphExecutionFacade facade)
-			throws CoreException {
+	private final ISGraphExecutionFacade facade;
+
+	public SCTDebugTarget(ILaunch launch, ISGraphExecutionFacade facade,
+			String resourceString) throws CoreException {
+		super(resourceString);
 		this.launch = launch;
-		thread = new SCTDebugThread(this, facade);
+		this.facade = facade;
+		thread = new SCTDebugThread(this, facade, resourceString);
 		DebugPlugin.getDefault().getBreakpointManager()
 				.addBreakpointListener(this);
 	}
@@ -47,7 +51,7 @@ public class SCTDebugTarget extends PlatformObject implements IDebugTarget {
 	}
 
 	public String getName() throws DebugException {
-		return IDebugConstants.DEBUG_TARGET;
+		return facade.getId();
 	}
 
 	public boolean supportsBreakpoint(IBreakpoint breakpoint) {
@@ -111,6 +115,7 @@ public class SCTDebugTarget extends PlatformObject implements IDebugTarget {
 	public boolean supportsStorageRetrieval() {
 		return false;
 	}
+
 	public IMemoryBlock getMemoryBlock(long startAddress, long length)
 			throws DebugException {
 		return null;
@@ -121,10 +126,20 @@ public class SCTDebugTarget extends PlatformObject implements IDebugTarget {
 	}
 
 	public String getModelIdentifier() {
-		return IDebugConstants.DEBUG_TARGET;
+		return IDebugConstants.ID_DEBUG_MODEL;
 	}
 
 	public IDebugTarget getDebugTarget() {
 		return this;
 	}
+
+	@Override
+	public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
+		if (adapter == SGraphSimulationSession.class)
+			return thread.getAdapter(SGraphSimulationSession.class);
+		if (adapter == ISGraphExecutionFacade.class)
+			return facade;
+		return super.getAdapter(adapter);
+	}
+
 }

+ 70 - 12
plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/debugmodel/SCTDebugThread.java

@@ -1,6 +1,9 @@
 package org.yakindu.sct.simulation.core.debugmodel;
 
-import org.eclipse.core.runtime.PlatformObject;
+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.DebugPlugin;
@@ -9,7 +12,10 @@ 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;
+import org.yakindu.sct.model.sgraph.Vertex;
 import org.yakindu.sct.simulation.core.ISGraphExecutionFacade;
+import org.yakindu.sct.simulation.core.ISGraphExecutionListener;
 import org.yakindu.sct.simulation.core.SGraphSimulationSession;
 
 /**
@@ -17,7 +23,8 @@ import org.yakindu.sct.simulation.core.SGraphSimulationSession;
  * @author andreas muelder - Initial contribution and API
  * 
  */
-public class SCTDebugThread extends PlatformObject implements IThread {
+public class SCTDebugThread extends SCTDebugElement implements IThread,
+		ISGraphExecutionListener {
 
 	private boolean stepping = false;
 	private boolean terminated = false;
@@ -25,29 +32,72 @@ public class SCTDebugThread extends PlatformObject implements IThread {
 	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) {
+	public SCTDebugThread(SCTDebugTarget target, ISGraphExecutionFacade facade,
+			String resourceString) {
+		super(resourceString);
 		this.target = target;
+		this.facade = facade;
 		session = new SGraphSimulationSession(facade);
+		facade.addExecutionListener(this);
 		thread = new Thread(session);
 		thread.start();
 		session.start();
 	}
 
+	public int getPriority() throws DebugException {
+		return 0;
+	}
+
 	public IStackFrame[] getStackFrames() throws DebugException {
-		return new IStackFrame[] {};
+		List<IStackFrame> stackFrames = new ArrayList<IStackFrame>();
+
+		for (int i = activeStates.size() - 1; i >= 0; i--) {
+			stackFrames.add(new SCTStackFrame(this, activeStates.get(i),
+					getResourceString()));
+		}
+		return stackFrames.toArray(new IStackFrame[] {});
 	}
 
 	public boolean hasStackFrames() throws DebugException {
-		return false;
+		return true;
 	}
 
-	public int getPriority() throws DebugException {
-		return 0;
+	@Override
+	public String getModelIdentifier() {
+		return IDebugConstants.ID_DEBUG_MODEL;
+	}
+
+	@Override
+	public void stateEntered(Vertex vertex) {
+		activeStates.add(vertex);
+	}
+
+	@Override
+	public void stateLeft(Vertex vertex) {
+		activeStates.remove(vertex);
+
+	}
+
+	@Override
+	public void transitionFired(Transition transition) {
+		// Nothing to do
+	}
+
+	@Override
+	public void variableValueChanged(String variableName, Object value) {
+		// Nothing to do
+	}
+
+	@Override
+	public void eventRaised(String eventName) {
+		// Nothing to do
 	}
 
 	public String getName() throws DebugException {
-		return IDebugConstants.DEBUG_THREAD;
+		return "TODO";
 	}
 
 	public IBreakpoint[] getBreakpoints() {
@@ -114,6 +164,8 @@ public class SCTDebugThread extends PlatformObject implements IThread {
 	}
 
 	public void terminate() throws DebugException {
+		facade.removeExecutionListener(this);
+		activeStates = Collections.emptyList();
 		fireEvent(new DebugEvent(getDebugTarget(), DebugEvent.TERMINATE));
 		terminated = true;
 		session.terminate();
@@ -131,11 +183,17 @@ public class SCTDebugThread extends PlatformObject implements IThread {
 		DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] { event });
 	}
 
-	public String getModelIdentifier() {
-		return IDebugConstants.DEBUG_THREAD;
-	}
-
 	public IDebugTarget getDebugTarget() {
 		return target;
 	}
+
+	@Override
+	public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
+		if (adapter == SGraphSimulationSession.class)
+			return session;
+		if (adapter == ISGraphExecutionFacade.class)
+			return getDebugTarget().getAdapter(ISGraphExecutionFacade.class);
+		return super.getAdapter(adapter);
+	}
+
 }

+ 229 - 0
plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/debugmodel/SCTStackFrame.java

@@ -0,0 +1,229 @@
+/**
+ * Copyright (c) 2011 committers of YAKINDU and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     committers of YAKINDU - initial API and implementation
+ */
+package org.yakindu.sct.simulation.core.debugmodel;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.model.IRegisterGroup;
+import org.eclipse.debug.core.model.IStackFrame;
+import org.eclipse.debug.core.model.IVariable;
+import org.eclipse.emf.ecore.EObject;
+import org.yakindu.sct.model.sgraph.NamedElement;
+import org.yakindu.sct.model.sgraph.Statechart;
+import org.yakindu.sct.model.sgraph.Vertex;
+import org.yakindu.sct.simulation.core.ISGraphExecutionFacade;
+import org.yakindu.sct.simulation.core.SGraphSimulationSession;
+
+/**
+ * 
+ * @author andreas muelder - Initial contribution and API
+ * 
+ */
+public class SCTStackFrame extends SCTDebugElement implements IStackFrame {
+
+	private final SCTDebugThread thread;
+	// the active state that is entered
+	private final Vertex state;
+
+	public SCTStackFrame(SCTDebugThread thread, Vertex state,
+			String resourceString) {
+		super(resourceString);
+		this.thread = thread;
+		this.state = state;
+	}
+
+	@Override
+	public String getModelIdentifier() {
+		return IDebugConstants.ID_DEBUG_MODEL;
+	}
+
+	@Override
+	public boolean canStepInto() {
+		return thread.canStepInto();
+	}
+
+	@Override
+	public boolean canStepOver() {
+		return thread.canStepOver();
+	}
+
+	@Override
+	public boolean canStepReturn() {
+		return thread.canStepReturn();
+	}
+
+	@Override
+	public boolean isStepping() {
+		return thread.isStepping();
+	}
+
+	@Override
+	public void stepInto() throws DebugException {
+		thread.stepInto();
+	}
+
+	@Override
+	public void stepOver() throws DebugException {
+		thread.stepOver();
+	}
+
+	@Override
+	public void stepReturn() throws DebugException {
+		thread.stepReturn();
+	}
+
+	@Override
+	public boolean canResume() {
+		return thread.canResume();
+	}
+
+	@Override
+	public boolean canSuspend() {
+		return thread.canSuspend();
+	}
+
+	@Override
+	public boolean isSuspended() {
+		return thread.isSuspended();
+	}
+
+	@Override
+	public void resume() throws DebugException {
+		thread.resume();
+
+	}
+
+	@Override
+	public void suspend() throws DebugException {
+		thread.suspend();
+	}
+
+	@Override
+	public boolean canTerminate() {
+		return thread.canTerminate();
+	}
+
+	@Override
+	public boolean isTerminated() {
+		return thread.isTerminated();
+	}
+
+	@Override
+	public void terminate() throws DebugException {
+		thread.terminate();
+	}
+
+	@Override
+	public SCTDebugThread getThread() {
+		return thread;
+	}
+
+	@Override
+	public IVariable[] getVariables() throws DebugException {
+		return new IVariable[] {};
+	}
+
+	@Override
+	public boolean hasVariables() throws DebugException {
+		return false;
+	}
+
+	@Override
+	public int getLineNumber() throws DebugException {
+		return -1;
+	}
+
+	@Override
+	public int getCharStart() throws DebugException {
+		return -1;
+	}
+
+	@Override
+	public int getCharEnd() throws DebugException {
+		return -1;
+	}
+
+	@Override
+	public String getName() throws DebugException {
+		List<String> qfnFragments = new ArrayList<String>();
+		qfnFragments.add(state.getName());
+		EObject current = state;
+		while (!(current.eContainer() instanceof Statechart)) {
+			current = current.eContainer();
+			if (current instanceof NamedElement) {
+				String name = ((NamedElement) current).getName();
+				if (name != null) {
+					qfnFragments.add(name.replaceAll(" ", ""));
+				} else {
+					qfnFragments.add("<name>");
+				}
+			}
+		}
+		Collections.reverse(qfnFragments);
+		StringBuilder sb = new StringBuilder();
+
+		sb.append(state.getName());
+		sb.append("  (");
+		String sep = "";
+		for (String s : qfnFragments) {
+			sb.append(sep).append(s);
+			sep = ".";
+		}
+		sb.append(")");
+
+		sb.append(" resource: ");
+		sb.append(state.eResource().getURI().lastSegment());
+		return sb.toString();
+
+	}
+
+	@Override
+	public IRegisterGroup[] getRegisterGroups() throws DebugException {
+		return new IRegisterGroup[] {};
+	}
+
+	@Override
+	public boolean hasRegisterGroups() throws DebugException {
+		return false;
+	}
+
+	public SCTDebugTarget getDebugTarget() {
+		return (SCTDebugTarget) thread.getDebugTarget();
+	}
+
+	@Override
+	public ILaunch getLaunch() {
+		return thread.getLaunch();
+	}
+
+	public Vertex getState() {
+		return state;
+	}
+
+	@Override
+	public String getResourceString() {
+		return state.eResource().getURI().toPlatformString(true);
+	}
+
+	@Override
+	public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
+		if (adapter == SGraphSimulationSession.class)
+			return thread.getAdapter(SGraphSimulationSession.class);
+		if (adapter == ISGraphExecutionFacade.class)
+			return getDebugTarget().getAdapter(ISGraphExecutionFacade.class);
+		return super.getAdapter(adapter);
+	}
+
+}

+ 1 - 1
plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/launch/IStatechartLaunchConfigurationType.java

@@ -12,7 +12,7 @@ package org.yakindu.sct.simulation.core.launch;
 
 /**
  * 
- * @author andreas muelder
+ * @author andreas muelder - Initial contribution and API
  * 
  */
 public interface IStatechartLaunchConfigurationType {

+ 12 - 4
plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/launch/StatechartLaunchConfigurationDelegate.java

@@ -62,7 +62,7 @@ public class StatechartLaunchConfigurationDelegate implements
 			ILaunch launch, IProgressMonitor monitor) throws CoreException {
 		String filename = configuration.getAttribute(
 				IStatechartLaunchParameters.FILE_NAME, "");
-		//check for errors
+		// check for errors
 		IFile file = ResourcesPlugin.getWorkspace().getRoot()
 				.getFile(new Path(filename));
 		IMarker[] sgraphMarkers = file.findMarkers(SGRAPH_ERROR_TYPE, true,
@@ -71,8 +71,12 @@ public class StatechartLaunchConfigurationDelegate implements
 				IResource.DEPTH_INFINITE);
 
 		if (sgraphMarkers.length > 0 || stextMarkers.length > 0) {
-			Status status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, STATUS_CODE,
-					"Simulation could not be started because the selected resource contains errors.",null);
+			Status status = new Status(
+					IStatus.ERROR,
+					Activator.PLUGIN_ID,
+					STATUS_CODE,
+					"Simulation could not be started because the selected resource contains errors.",
+					null);
 			IStatusHandler statusHandler = DebugPlugin.getDefault()
 					.getStatusHandler(status);
 			statusHandler.handleStatus(status, this);
@@ -84,9 +88,13 @@ public class StatechartLaunchConfigurationDelegate implements
 		Statechart statechart = (Statechart) EcoreUtil.getObjectByType(
 				resource.getContents(), SGraphPackage.Literals.STATECHART);
 
+		String platformResource = statechart.eResource().getURI()
+				.toPlatformString(true);
+
 		ISGraphExecutionBuilder builder = getBuilder(statechart);
 		ISGraphExecutionFacade executionFacade = builder.build(statechart);
-		IDebugTarget target = new SCTDebugTarget(launch, executionFacade);
+		IDebugTarget target = new SCTDebugTarget(launch, executionFacade,
+				platformResource);
 		launch.addDebugTarget(target);
 
 	}

+ 1 - 1
plugins/org.yakindu.sct.simulation.runtime/.settings/org.eclipse.core.resources.prefs

@@ -1,3 +1,3 @@
-#Thu Jul 28 13:46:50 CEST 2011
+#Sat Sep 10 11:23:39 CEST 2011
 eclipse.preferences.version=1
 encoding/<project>=UTF-8

+ 27 - 0
plugins/org.yakindu.sct.simulation.runtime/src-gen/org/yakindu/sct/simulation/runtime/sgraph/RTEvent.java

@@ -11,4 +11,31 @@ public abstract class RTEvent {
 	public String getId() {
 		return id;
 	}
+
+	@Override
+	public int hashCode() {
+		final int prime = 31;
+		int result = 1;
+		result = prime * result + ((id == null) ? 0 : id.hashCode());
+		return result;
+	}
+
+	@Override
+	public boolean equals(Object obj) {
+		if (this == obj)
+			return true;
+		if (obj == null)
+			return false;
+		if (getClass() != obj.getClass())
+			return false;
+		RTEvent other = (RTEvent) obj;
+		if (id == null) {
+			if (other.id != null)
+				return false;
+		} else if (!id.equals(other.id))
+			return false;
+		return true;
+	}
+	
+	
 }

+ 0 - 1
plugins/org.yakindu.sct.simulation.runtime/src-gen/org/yakindu/sct/simulation/runtime/sgraph/RTPseudostate.java

@@ -17,7 +17,6 @@ public class RTPseudostate extends RTNode {
 	}
 
 	protected void enter() {
-
 		if (kind == PseudostateKind.INITIAL) {
 			// go directly into the next state (special transition needs no
 			// event

+ 4 - 0
plugins/org.yakindu.sct.simulation.runtime/src-gen/org/yakindu/sct/simulation/runtime/sgraph/RTSignalEvent.java

@@ -37,5 +37,9 @@ public class RTSignalEvent extends RTEvent {
 	public Class<?> getType() {
 		return type;
 	}
+	
+	
+	
+	
 
 }

+ 2 - 2
plugins/org.yakindu.sct.simulation.runtime/src/org/yakindu/sct/simulation/runtime/ExecutionScope.java

@@ -11,7 +11,7 @@
 package org.yakindu.sct.simulation.runtime;
 
 import java.util.Collection;
-import java.util.List;
+import java.util.Set;
 
 import org.yakindu.sct.simulation.runtime.sgraph.RTSignalEvent;
 import org.yakindu.sct.simulation.runtime.stext.RTVariable;
@@ -32,6 +32,6 @@ public interface ExecutionScope {
 	
 	Collection<RTVariable> getVariables();
 
-	List<RTSignalEvent> getEvents();
+	Set<RTSignalEvent> getEvents();
 
 }

+ 1 - 1
plugins/org.yakindu.sct.simulation.runtime/src/org/yakindu/sct/simulation/runtime/sgraph/ExecutionScopeAdapter.java

@@ -69,7 +69,7 @@ public class ExecutionScopeAdapter implements ISGraphExecutionScope {
 		}
 		return scopeEvents;
 	}
-
+	
 	
 	private ScopeEvent toScope(RTSignalEvent rtEvent) {
 		return new ScopeEvent(rtEvent.getId(), rtEvent.getType(), rtEvent.getValue());

+ 18 - 8
plugins/org.yakindu.sct.simulation.runtime/src/org/yakindu/sct/simulation/runtime/sgraph/RTStatechart.java

@@ -33,10 +33,10 @@ public class RTStatechart extends AbstractStatechart implements ExecutionScope,
 	protected Map<Object, Object> aliasToElementMap = new HashMap<Object, Object>();
 	protected Map<Object, Object> elementToAliasMap = new HashMap<Object, Object>();
 
-	protected List<RTSignalEvent> events = new ArrayList<RTSignalEvent>();
+	protected Set<RTSignalEvent> events = new HashSet<RTSignalEvent>();
 	protected Map<String, RTSignalEvent> eventMap = new HashMap<String, RTSignalEvent>();
 
-	protected List<RTVariable> variables = new ArrayList<RTVariable>();
+	protected Set<RTVariable> variables = new HashSet<RTVariable>();
 	protected Map<String, RTVariable> variableMap = new HashMap<String, RTVariable>();
 
 	protected Set<RTState> currentStateConfigurartion = new HashSet<RTState>();
@@ -96,8 +96,8 @@ public class RTStatechart extends AbstractStatechart implements ExecutionScope,
 	/**
 	 * @return The list of all defined signal events of this statechart.
 	 */
-	public List<RTSignalEvent> getSignalEvents() {
-		return Collections.unmodifiableList(events);
+	public Set<RTSignalEvent> getSignalEvents() {
+		return Collections.unmodifiableSet(events);
 	}
 
 	public void addVariable(RTVariable var) {
@@ -114,8 +114,8 @@ public class RTStatechart extends AbstractStatechart implements ExecutionScope,
 		return variableMap.get(varName);
 	}
 
-	public List<RTVariable> getVariables() {
-		return Collections.unmodifiableList(variables);
+	public Set<RTVariable> getVariables() {
+		return Collections.unmodifiableSet(variables);
 	}
 
 	protected void stateLeft(RTState state) {
@@ -137,6 +137,7 @@ public class RTStatechart extends AbstractStatechart implements ExecutionScope,
 			listener.transitionFired((Transition) elementToAliasMap.get(trans));
 		}
 	}
+
 	public void setVariableValue(RTVariable variable, Object value) {
 		variable.setValue(value);
 		for (ISGraphExecutionListener listener : listeners) {
@@ -235,7 +236,16 @@ public class RTStatechart extends AbstractStatechart implements ExecutionScope,
 		return new ExecutionScopeAdapter(this);
 	}
 
-	public List<RTSignalEvent> getEvents() {
-		return Collections.unmodifiableList(events);
+	public Set<RTSignalEvent> getEvents() {
+		return Collections.unmodifiableSet(events);
+	}
+
+	public Set<Vertex> getStateConfiguration() {
+		Set<Vertex> result = new HashSet<Vertex>();
+		Set<RTState> currentStateConfiguration = getCurrentStateConfiguration();
+		for (RTState rtState : currentStateConfiguration) {
+			result.add((Vertex) elementToAliasMap.get(rtState));
+		}
+		return result;
 	}
 }

+ 23 - 3
plugins/org.yakindu.sct.simulation.runtime/src/org/yakindu/sct/simulation/runtime/sgraph/builder/SGraphBuilder.java

@@ -193,13 +193,33 @@ public class SGraphBuilder extends Function implements ISGraphExecutionBuilder {
 		RTAction exitAction = buildAction(
 				(RTStatechart) parent.getStatechart(), exitReaction);
 
-		if (state.getSubRegions().size() > 0) {
+		if (state.isSubmachine()) {
+			runtimeState = new RTCompoundState(parent.getId() + "."
+					+ state.getName(), state.getName(), parent, entryAction,
+					exitAction);
+
+			EList<Region> regions = state.getSubstatechart().getRegions();
+			EList<EObject> contents = new BasicEList<EObject>();
+			contents.addAll(regions);
+			build(runtimeState, contents);
+
+			// Build the scopes
+			EList<EObject> scopes = new BasicEList<EObject>();
+			scopes.addAll(state.getSubstatechart().getScopes());
+			build(parent.getStatechart(), scopes);
+			// Build the transitions
+			EList<EObject> transitions = new BasicEList<EObject>(
+					EcoreUtil2.getAllContentsOfType(state.getSubstatechart(),
+							Transition.class));
+			build(parent.getStatechart(), transitions);
+
+		} else if (state.isComposite()) {
 			runtimeState = new RTCompoundState(parent.getId() + "."
 					+ state.getName(), state.getName(), parent, entryAction,
 					exitAction);
 			build(runtimeState, state.eContents());
 
-		} else {
+		} else if (state.isSimple()) {
 			runtimeState = new RTSimpleState(parent.getId() + "."
 					+ state.getName(), state.getName(), parent, entryAction,
 					null, exitAction);
@@ -349,7 +369,7 @@ public class SGraphBuilder extends Function implements ISGraphExecutionBuilder {
 				}
 				if (eventSpec instanceof TimeEventSpec) {
 					TimeUnit unit = ((TimeEventSpec) eventSpec).getUnit();
-					
+
 					final int value = ((TimeEventSpec) eventSpec).getValue();
 					timeTrigger = new RTTimeEvent("id") {
 						@Override

+ 2 - 2
plugins/org.yakindu.sct.simulation.runtime/src/org/yakindu/sct/simulation/runtime/stext/RTScope.java

@@ -12,8 +12,8 @@ package org.yakindu.sct.simulation.runtime.stext;
 
 import java.util.Collection;
 import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import org.yakindu.sct.simulation.runtime.ExecutionScope;
 import org.yakindu.sct.simulation.runtime.sgraph.RTSignalEvent;
@@ -76,7 +76,7 @@ public class RTScope implements ExecutionScope {
 		return variables.values();
 	}
 
-	public List<RTSignalEvent> getEvents() {
+	public Set<RTSignalEvent> getEvents() {
 		// TODO Auto-generated method stub
 		return null;
 	}

+ 30 - 9
plugins/org.yakindu.sct.simulation.runtime/src/org/yakindu/sct/simulation/runtime/stext/RTVariable.java

@@ -12,7 +12,6 @@ package org.yakindu.sct.simulation.runtime.stext;
 
 import org.yakindu.sct.simulation.runtime.EvaluationException;
 
-
 /**
  * 
  * 
@@ -24,7 +23,6 @@ public class RTVariable {
 	protected Object value;
 	protected Class<?> type;
 
-	
 	public RTVariable() {
 		super();
 	}
@@ -48,7 +46,6 @@ public class RTVariable {
 		this.name = name;
 	}
 
-	
 	public Class<?> getType() {
 		return type;
 	}
@@ -57,18 +54,42 @@ public class RTVariable {
 		this.type = type;
 	}
 
-	
 	public Object getValue() {
 		return value;
 	}
 
 	public void setValue(Object value) {
-		if(type != null && (! type.isAssignableFrom(value.getClass()))) {
-			throw new EvaluationException(
-					"Variable <" + name + "> of type " + type 
-					+ " is not assignable from " + value.getClass() + " value.");
+		if (type != null && (!type.isAssignableFrom(value.getClass()))) {
+			throw new EvaluationException("Variable <" + name + "> of type "
+					+ type + " is not assignable from " + value.getClass()
+					+ " value.");
 		}
 		this.value = value;
 	}
-	
+
+	@Override
+	public int hashCode() {
+		final int prime = 31;
+		int result = 1;
+		result = prime * result + ((name == null) ? 0 : name.hashCode());
+		return result;
+	}
+
+	@Override
+	public boolean equals(Object obj) {
+		if (this == obj)
+			return true;
+		if (obj == null)
+			return false;
+		if (getClass() != obj.getClass())
+			return false;
+		RTVariable other = (RTVariable) obj;
+		if (name == null) {
+			if (other.name != null)
+				return false;
+		} else if (!name.equals(other.name))
+			return false;
+		return true;
+	}
+
 }

+ 4 - 1
plugins/org.yakindu.sct.simulation.ui/META-INF/MANIFEST.MF

@@ -16,7 +16,10 @@ Require-Bundle: org.eclipse.ui,
  org.eclipse.jdt.debug.ui;bundle-version="3.6.0";visibility:=reexport,
  org.yakindu.sct.simulation.core;bundle-version="1.0.0",
  org.yakindu.sct.model.sgraph;bundle-version="1.0.0",
- de.itemis.xtext.utils.jface;bundle-version="1.0.0"
+ de.itemis.xtext.utils.jface;bundle-version="1.0.0",
+ org.eclipse.ui.ide;bundle-version="3.7.0",
+ org.yakindu.sct.ui.editor;bundle-version="1.0.0",
+ de.itemis.xtext.utils.gmf;bundle-version="1.0.0"
 Bundle-RequiredExecutionEnvironment: J2SE-1.5
 Bundle-ActivationPolicy: lazy
 Import-Package: org.eclipse.ui.dialogs

+ 26 - 1
plugins/org.yakindu.sct.simulation.ui/plugin.xml

@@ -6,7 +6,7 @@
          point="org.eclipse.core.runtime.adapters">
       <factory
             adaptableType="org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.DiagramDocumentEditor"
-            class="org.yakindu.sct.simulation.ui.editor.IHighlightingSupportAdapterFactory">
+            class="org.yakindu.sct.simulation.ui.model.presenter.IHighlightingSupportAdapterFactory">
          <adapter
                type="de.itemis.gmf.runtime.commons.highlighting.IHighlightingSupport">
          </adapter>
@@ -73,4 +73,29 @@
           plugin="org.yakindu.sct.simulation.core">
     </statusHandler>
  </extension>
+ <!-- Source Display Adapter factory -->
+ <extension
+       point="org.eclipse.core.runtime.adapters">
+    <factory
+          adaptableType="org.yakindu.sct.simulation.core.debugmodel.SCTStackFrame"
+          class="org.yakindu.sct.simulation.ui.model.presenter.SCTSourceDisplayAdapterFactory">
+       <adapter
+             type="org.eclipse.debug.ui.sourcelookup.ISourceDisplay">
+       </adapter>
+    </factory>
+     <factory
+          adaptableType="org.yakindu.sct.simulation.core.debugmodel.SCTDebugThread"
+          class="org.yakindu.sct.simulation.ui.model.presenter.SCTSourceDisplayAdapterFactory">
+       <adapter
+             type="org.eclipse.debug.ui.sourcelookup.ISourceDisplay">
+       </adapter>
+    </factory>
+     <factory
+          adaptableType="org.yakindu.sct.simulation.core.debugmodel.SCTDebugTarget"
+          class="org.yakindu.sct.simulation.ui.model.presenter.SCTSourceDisplayAdapterFactory">
+       <adapter
+             type="org.eclipse.debug.ui.sourcelookup.ISourceDisplay">
+       </adapter>
+    </factory>
+ </extension>
 </plugin>

+ 1 - 6
plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/SimulationActivator.java

@@ -2,24 +2,19 @@ package org.yakindu.sct.simulation.ui;
 
 import org.eclipse.ui.plugin.AbstractUIPlugin;
 import org.osgi.framework.BundleContext;
-import org.yakindu.sct.simulation.core.SGraphSimulationSessionRegistry;
-import org.yakindu.sct.simulation.ui.editor.HighlightingExecutionListener;
 
 public class SimulationActivator extends AbstractUIPlugin {
 
 	public static final String PLUGIN_ID = "org.yakindu.sct.statechart.simulation.ui"; //$NON-NLS-1$
 
 	private static SimulationActivator plugin;
-
+	
 	public SimulationActivator() {
 	}
 
 	public void start(BundleContext context) throws Exception {
 		super.start(context);
 		plugin = this;
-		
-		SGraphSimulationSessionRegistry.INSTANCE.getListeners().add(
-				new HighlightingExecutionListener());
 	}
 
 	public void stop(BundleContext context) throws Exception {

+ 0 - 93
plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/editor/HighlightingExecutionListener.java

@@ -1,93 +0,0 @@
-/**
- * Copyright (c) 2011 committers of YAKINDU and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *     committers of YAKINDU - initial API and implementation
- */
-package org.yakindu.sct.simulation.ui.editor;
-
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IEditorPart;
-import org.yakindu.sct.model.sgraph.Transition;
-import org.yakindu.sct.model.sgraph.Vertex;
-import org.yakindu.sct.simulation.core.ISimulationSessionListener;
-import org.yakindu.sct.simulation.core.ISimulationSessionListener.SimulationSessionListenerAdapter;
-
-import de.itemis.gmf.runtime.commons.highlighting.HighlightingParameters;
-import de.itemis.gmf.runtime.commons.highlighting.IHighlightingSupport;
-import de.itemis.xtext.utils.jface.viewers.util.ActiveEditorResolver;
-
-/**
- * 
- * @author andreas muelder - Initial contribution and API
- * 
- */
-public class HighlightingExecutionListener extends
-		SimulationSessionListenerAdapter implements ISimulationSessionListener {
-
-	private IHighlightingSupport highlightingSupport;
-
-	private HighlightingParameters parameters;
-
-	public HighlightingExecutionListener() {
-		parameters = new HighlightingParameters();
-	}
-
-	protected IHighlightingSupport getSupport() {
-		if (highlightingSupport != null)
-			return highlightingSupport;
-		IEditorPart activeEditor = ActiveEditorResolver.getActiveEditor();
-		if (activeEditor != null) {
-			IHighlightingSupport support = (IHighlightingSupport) activeEditor
-					.getAdapter(IHighlightingSupport.class);
-			if (support != null)
-				return highlightingSupport = support;
-		}
-		return new IHighlightingSupport.HighlightingSupportNullImpl();
-	}
-
-	public void stateEntered(final Vertex vertex) {
-		Display.getDefault().asyncExec(new Runnable() {
-			public void run() {
-				getSupport().fadeIn(vertex, parameters);
-			}
-		});
-	}
-
-	public void stateLeft(final Vertex vertex) {
-		Display.getDefault().asyncExec(new Runnable() {
-			public void run() {
-				getSupport().fadeOut(vertex, parameters);
-			}
-		});
-	}
-
-	public void transitionFired(final Transition transition) {
-		Display.getDefault().asyncExec(new Runnable() {
-			public void run() {
-				getSupport().flash(transition, parameters);
-			}
-		});
-	}
-
-	public void simulationStateChanged(SimulationState oldState,
-			final SimulationState newState) {
-		Display.getDefault().asyncExec(new Runnable() {
-			public void run() {
-				switch (newState) {
-				case STARTED:
-					getSupport().lockEditor();
-					break;
-				case TERMINATED:
-					getSupport().releaseEditor();
-					highlightingSupport = null;
-					break;
-				}
-			}
-		});
-	}
-}

+ 17 - 2
plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/editor/IHighlightingSupportAdapterFactory.java

@@ -8,7 +8,10 @@
  * 	committers of YAKINDU - initial API and implementation
  * 
  */
-package org.yakindu.sct.simulation.ui.editor;
+package org.yakindu.sct.simulation.ui.model.presenter;
+
+import java.util.HashMap;
+import java.util.Map;
 
 import org.eclipse.core.runtime.IAdapterFactory;
 import org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.DiagramDocumentEditor;
@@ -25,11 +28,23 @@ import de.itemis.gmf.runtime.commons.highlighting.IHighlightingSupport;
 @SuppressWarnings({ "rawtypes" })
 public class IHighlightingSupportAdapterFactory implements IAdapterFactory {
 
+	private static Map<DiagramDocumentEditor, IHighlightingSupport> cache;
+	static {
+		cache = new HashMap<DiagramDocumentEditor, IHighlightingSupport>();
+	}
+
 	public Object getAdapter(Object adaptableObject, Class adapterType) {
 		if (adapterType == IHighlightingSupport.class) {
 			if (adaptableObject instanceof DiagramDocumentEditor) {
-				return new HighlightingSupportAdapter(
+				IHighlightingSupport supportFromCache = cache
+						.get((DiagramDocumentEditor) adaptableObject);
+				if (supportFromCache != null)
+					return supportFromCache;
+				supportFromCache = new HighlightingSupportAdapter(
 						(DiagramDocumentEditor) adaptableObject);
+				cache.put((DiagramDocumentEditor) adaptableObject,
+						supportFromCache);
+				return supportFromCache;
 			}
 		}
 		return null;

+ 156 - 0
plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/model/presenter/SCTSourceDisplay.java

@@ -0,0 +1,156 @@
+/**
+ * Copyright (c) 2011 committers of YAKINDU and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * Contributors:
+ * 	committers of YAKINDU - initial API and implementation
+ * 
+ */
+package org.yakindu.sct.simulation.ui.model.presenter;
+
+import java.util.Set;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.debug.ui.sourcelookup.ISourceDisplay;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.part.FileEditorInput;
+import org.yakindu.sct.model.sgraph.Transition;
+import org.yakindu.sct.model.sgraph.Vertex;
+import org.yakindu.sct.simulation.core.ISGraphExecutionFacade;
+import org.yakindu.sct.simulation.core.ISimulationSessionListener;
+import org.yakindu.sct.simulation.core.ISimulationSessionListener.SimulationSessionListenerAdapter;
+import org.yakindu.sct.simulation.core.SGraphSimulationSession;
+import org.yakindu.sct.simulation.core.debugmodel.SCTDebugElement;
+import org.yakindu.sct.simulation.core.debugmodel.SCTStackFrame;
+import org.yakindu.sct.ui.editor.editor.StatechartDiagramEditor;
+
+import de.itemis.gmf.runtime.commons.highlighting.HighlightingParameters;
+import de.itemis.gmf.runtime.commons.highlighting.IHighlightingSupport;
+import de.itemis.gmf.runtime.commons.util.EditPartUtils;
+
+/**
+ * The {@link SCTSourceDisplay} displays the active State of the running debug
+ * session.
+ * 
+ * <pre>
+ *  - highlights the initial active states
+ *  - registers itself as a {@link ISimulationSessionListener} to paint state changes
+ * </pre>
+ * 
+ * @author andreas muelder - Initial contribution and API
+ * 
+ */
+public class SCTSourceDisplay extends SimulationSessionListenerAdapter
+		implements ISimulationSessionListener, ISourceDisplay {
+
+	private IHighlightingSupport support = new IHighlightingSupport.HighlightingSupportNullImpl();
+
+	private SGraphSimulationSession lastActiveSession;
+
+	private HighlightingParameters parameters = new HighlightingParameters();
+
+	public void displaySource(Object element, IWorkbenchPage page,
+			boolean forceSourceLookup) {
+
+		SCTDebugElement debugElement = (SCTDebugElement) element;
+		SGraphSimulationSession session = (SGraphSimulationSession) debugElement
+				.getAdapter(SGraphSimulationSession.class);
+		ISGraphExecutionFacade facade = (ISGraphExecutionFacade) debugElement
+				.getAdapter(ISGraphExecutionFacade.class);
+
+		StatechartDiagramEditor editor = openEditorAndSelectElements(
+				debugElement, page);
+
+		support = (IHighlightingSupport) editor
+				.getAdapter(IHighlightingSupport.class);
+
+		if (support.isLocked())
+			support.releaseEditor();
+
+		// Paint the active states if the session is not terminated
+		if (session.getCurrentState() != SimulationState.TERMINATED) {
+			support.lockEditor();
+			Set<Vertex> stateConfiguration = facade.getStateConfiguration();
+			for (Vertex vertex : stateConfiguration) {
+				support.highlight(vertex, new HighlightingParameters());
+			}
+		}
+
+		// Register me as a Session Listener to control the highlighting
+		if (lastActiveSession != null) {
+			lastActiveSession.getListeners().remove(this);
+		}
+		session.getListeners().add(this);
+		lastActiveSession = session;
+
+	}
+
+	public void stateEntered(final Vertex vertex) {
+		Display.getDefault().asyncExec(new Runnable() {
+			public void run() {
+				getSupport().fadeIn(vertex, parameters);
+			}
+		});
+	}
+
+	public void stateLeft(final Vertex vertex) {
+		Display.getDefault().asyncExec(new Runnable() {
+			public void run() {
+				getSupport().fadeOut(vertex, parameters);
+			}
+		});
+	}
+
+	public void transitionFired(final Transition transition) {
+		Display.getDefault().asyncExec(new Runnable() {
+			public void run() {
+				getSupport().flash(transition, parameters);
+			}
+		});
+	}
+
+	/**
+	 * Opens the editor for this resource and selects the selected Editparts
+	 * 
+	 * @param debugElement
+	 * @param page
+	 * @return
+	 */
+	private StatechartDiagramEditor openEditorAndSelectElements(
+			SCTDebugElement debugElement, IWorkbenchPage page) {
+		String platformString = debugElement.getResourceString();
+		IResource resource = ResourcesPlugin.getWorkspace().getRoot()
+				.findMember(platformString);
+		StatechartDiagramEditor editor = null;
+		try {
+			editor = (StatechartDiagramEditor) page.openEditor(
+					new FileEditorInput(((IFile) resource)),
+					StatechartDiagramEditor.ID);
+
+			if (debugElement instanceof SCTStackFrame) {
+				IGraphicalEditPart editPart = EditPartUtils
+						.findEditPartForSemanticElement(editor
+								.getDiagramGraphicalViewer().getRootEditPart(),
+								((SCTStackFrame) debugElement).getState());
+				if (editPart != null) {
+					editor.getDiagramGraphicalViewer().reveal(editPart);
+					editor.getDiagramGraphicalViewer().select(editPart);
+				}
+			}
+		} catch (PartInitException e) {
+			e.printStackTrace();
+		}
+		return editor;
+	}
+
+	public IHighlightingSupport getSupport() {
+		return support;
+	}
+}

+ 34 - 0
plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/model/presenter/SCTSourceDisplayAdapterFactory.java

@@ -0,0 +1,34 @@
+/**
+ * Copyright (c) 2011 committers of YAKINDU and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * Contributors:
+ * 	committers of YAKINDU - initial API and implementation
+ * 
+ */
+package org.yakindu.sct.simulation.ui.model.presenter;
+
+import org.eclipse.core.runtime.IAdapterFactory;
+
+/**
+ * Returns a singleton instance of the {@link SCTSourceDisplay}
+ * 
+ * @author andreas muelder - Initial contribution and API
+ * 
+ */
+public class SCTSourceDisplayAdapterFactory implements IAdapterFactory {
+
+	private static SCTSourceDisplay display = new SCTSourceDisplay();
+
+	public Object getAdapter(Object adaptableObject,
+			@SuppressWarnings("rawtypes") Class adapterType) {
+		return display;
+	}
+
+	public Class<?>[] getAdapterList() {
+		return new Class[] { SCTSourceDisplay.class };
+	}
+
+}

+ 24 - 0
plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/view/ActiveSessionProvider.java

@@ -0,0 +1,24 @@
+/**
+ * Copyright (c) 2011 committers of YAKINDU and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * Contributors:
+ * 	committers of YAKINDU - initial API and implementation
+ * 
+ */
+package org.yakindu.sct.simulation.ui.view;
+
+import org.yakindu.sct.simulation.core.SGraphSimulationSession;
+
+/**
+ * 
+ * @author andreas muelder - Initial contribution and API
+ * 
+ */
+public interface ActiveSessionProvider {
+
+	SGraphSimulationSession getActiveSession();
+
+}

+ 74 - 36
plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/view/DeclarationView.java

@@ -13,8 +13,13 @@ package org.yakindu.sct.simulation.ui.view;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.eclipse.core.runtime.PlatformObject;
+import org.eclipse.debug.ui.DebugUITools;
+import org.eclipse.debug.ui.contexts.DebugContextEvent;
+import org.eclipse.debug.ui.contexts.IDebugContextListener;
 import org.eclipse.jface.layout.GridDataFactory;
 import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.StructuredSelection;
 import org.eclipse.jface.viewers.TableViewer;
 import org.eclipse.jface.viewers.TableViewerColumn;
 import org.eclipse.swt.SWT;
@@ -27,6 +32,8 @@ import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.ui.IViewSite;
+import org.eclipse.ui.PartInitException;
 import org.eclipse.ui.part.ViewPart;
 import org.yakindu.sct.model.sgraph.Transition;
 import org.yakindu.sct.model.sgraph.Vertex;
@@ -34,7 +41,6 @@ import org.yakindu.sct.simulation.core.ISGraphExecutionScope.ScopeEvent;
 import org.yakindu.sct.simulation.core.ISGraphExecutionScope.ScopeVariable;
 import org.yakindu.sct.simulation.core.ISimulationSessionListener;
 import org.yakindu.sct.simulation.core.SGraphSimulationSession;
-import org.yakindu.sct.simulation.core.SGraphSimulationSessionRegistry;
 import org.yakindu.sct.simulation.ui.view.editing.BooleanEditingSupport;
 import org.yakindu.sct.simulation.ui.view.editing.IntegerEditingSupport;
 import org.yakindu.sct.simulation.ui.view.editing.MultiEditingSupport;
@@ -45,8 +51,8 @@ import org.yakindu.sct.simulation.ui.view.editing.RealEditingSupport;
  * @author andreas muelder - Initial contribution and API
  * 
  */
-public class DeclarationView extends ViewPart implements
-		ISimulationSessionListener {
+public class DeclarationView extends ViewPart implements IDebugContextListener,
+		ISimulationSessionListener, ActiveSessionProvider {
 
 	private TableViewer eventViewer;
 
@@ -54,9 +60,18 @@ public class DeclarationView extends ViewPart implements
 
 	private List<Control> controls;
 
+	private SGraphSimulationSession activeSession;
+
 	public DeclarationView() {
 		controls = new ArrayList<Control>();
-		SGraphSimulationSessionRegistry.INSTANCE.getListeners().add(this);
+	}
+
+	@Override
+	public void init(IViewSite site) throws PartInitException {
+		super.init(site);
+		DebugUITools.getDebugContextManager()
+				.getContextService(site.getWorkbenchWindow())
+				.addDebugContextListener(this);
 	}
 
 	@Override
@@ -106,8 +121,9 @@ public class DeclarationView extends ViewPart implements
 		createColumn(viewer, "type", 80, 1);
 		TableViewerColumn valueColumn = createColumn(viewer, "value", 80, 2);
 		valueColumn.setEditingSupport(new MultiEditingSupport(viewer,
-				new BooleanEditingSupport(viewer), new IntegerEditingSupport(
-						viewer), new RealEditingSupport(viewer)));
+				new BooleanEditingSupport(viewer, this),
+				new IntegerEditingSupport(viewer, this),
+				new RealEditingSupport(viewer, this)));
 	}
 
 	@Override
@@ -116,8 +132,6 @@ public class DeclarationView extends ViewPart implements
 	}
 
 	public void setEventViewerInput() {
-		SGraphSimulationSession activeSession = SGraphSimulationSessionRegistry.INSTANCE
-				.getActiveSession();
 		if (activeSession != null) {
 			List<ScopeEvent> events = activeSession.getExecutionScope()
 					.getEvents();
@@ -140,8 +154,6 @@ public class DeclarationView extends ViewPart implements
 	}
 
 	private void setVariableViewerInput() {
-			SGraphSimulationSession activeSession = SGraphSimulationSessionRegistry.INSTANCE
-					.getActiveSession();
 		if (activeSession != null) {
 			List<ScopeVariable> variables = activeSession.getExecutionScope()
 					.getVariables();
@@ -157,28 +169,6 @@ public class DeclarationView extends ViewPart implements
 		variableViewer.setInput(null);
 	}
 
-	public void simulationStateChanged(SimulationState oldState,
-			SimulationState newState) {
-		switch (newState) {
-		case STARTED:
-			Display.getDefault().asyncExec(new Runnable() {
-				public void run() {
-					setEventViewerInput();
-					setVariableViewerInput();
-				}
-			});
-			break;
-		case TERMINATED:
-			Display.getDefault().asyncExec(new Runnable() {
-				public void run() {
-					clearViewerInput();
-				}
-			});
-			;
-			break;
-		}
-	}
-
 	public void variableValueChanged(String variableName, Object value) {
 		Display.getDefault().asyncExec(new Runnable() {
 			public void run() {
@@ -189,7 +179,6 @@ public class DeclarationView extends ViewPart implements
 
 	@Override
 	public void dispose() {
-		SGraphSimulationSessionRegistry.INSTANCE.getListeners().remove(this);
 		super.dispose();
 	}
 
@@ -213,7 +202,7 @@ public class DeclarationView extends ViewPart implements
 		});
 	}
 
-	private static final class ButtonListener implements SelectionListener {
+	private final class ButtonListener implements SelectionListener {
 
 		private final String eventName;
 
@@ -222,8 +211,6 @@ public class DeclarationView extends ViewPart implements
 		}
 
 		public void widgetSelected(SelectionEvent e) {
-			SGraphSimulationSession activeSession = SGraphSimulationSessionRegistry.INSTANCE
-					.getActiveSession();
 			if (activeSession != null) {
 				activeSession.raiseEvent(new ScopeEvent(eventName));
 			}
@@ -233,4 +220,55 @@ public class DeclarationView extends ViewPart implements
 			// Nothing to do
 		}
 	}
+
+	public void debugContextChanged(DebugContextEvent event) {
+		StructuredSelection strSel = (StructuredSelection) event.getContext();
+		PlatformObject firstElement = (PlatformObject) strSel.getFirstElement();
+		if (firstElement == null) {
+			return;
+		}
+		SGraphSimulationSession selectedSession = (SGraphSimulationSession) firstElement
+				.getAdapter(SGraphSimulationSession.class);
+		if (selectedSession == null
+				|| selectedSession.getCurrentState() == SimulationState.TERMINATED) {
+			activeSession = selectedSession;
+			clearViewerInput();
+		}
+		if (!(selectedSession == activeSession) && selectedSession != null) {
+			if (activeSession != null) {
+				activeSession.getListeners().remove(this);
+			}
+			activeSession = selectedSession;
+			selectedSession.getListeners().add(this);
+			clearViewerInput();
+			setEventViewerInput();
+			setVariableViewerInput();
+		}
+	}
+
+	public SGraphSimulationSession getActiveSession() {
+		return activeSession;
+	}
+
+	public void simulationStateChanged(SimulationState oldState,
+			SimulationState newState) {
+		switch (newState) {
+		case STARTED:
+			Display.getDefault().asyncExec(new Runnable() {
+				public void run() {
+					setEventViewerInput();
+					setVariableViewerInput();
+				}
+			});
+			break;
+		case TERMINATED:
+			Display.getDefault().asyncExec(new Runnable() {
+				public void run() {
+					clearViewerInput();
+				}
+			});
+			;
+			break;
+		}
+	}
 }

+ 3 - 2
plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/view/editing/BooleanEditingSupport.java

@@ -17,6 +17,7 @@ import org.eclipse.swt.SWT;
 import org.eclipse.swt.widgets.Composite;
 import org.yakindu.sct.simulation.core.ISGraphExecutionScope.ScopeSlot;
 import org.yakindu.sct.simulation.core.ISGraphExecutionScope.ScopeVariable;
+import org.yakindu.sct.simulation.ui.view.ActiveSessionProvider;
 
 /**
  * {@link CellEditor} support for Boolean values
@@ -26,8 +27,8 @@ import org.yakindu.sct.simulation.core.ISGraphExecutionScope.ScopeVariable;
  */
 public class BooleanEditingSupport extends ScopeSlotEditingSupport {
 
-	public BooleanEditingSupport(ColumnViewer viewer) {
-		super(viewer);
+	public BooleanEditingSupport(ColumnViewer viewer, ActiveSessionProvider provider) {
+		super(viewer, provider);
 	}
 
 	@Override

+ 3 - 2
plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/view/editing/IntegerEditingSupport.java

@@ -15,6 +15,7 @@ import org.eclipse.jface.viewers.ColumnViewer;
 import org.eclipse.jface.viewers.ICellEditorValidator;
 import org.eclipse.jface.viewers.TextCellEditor;
 import org.eclipse.swt.widgets.Composite;
+import org.yakindu.sct.simulation.ui.view.ActiveSessionProvider;
 
 /**
  * {@link TextCellEditor} support for Integer values
@@ -24,8 +25,8 @@ import org.eclipse.swt.widgets.Composite;
  */
 public class IntegerEditingSupport extends ScopeSlotEditingSupport {
 
-	public IntegerEditingSupport(ColumnViewer viewer) {
-		super(viewer);
+	public IntegerEditingSupport(ColumnViewer viewer,ActiveSessionProvider provider) {
+		super(viewer, provider);
 	}
 
 	@Override

+ 4 - 2
plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/view/editing/RealEditingSupport.java

@@ -15,6 +15,7 @@ import org.eclipse.jface.viewers.ColumnViewer;
 import org.eclipse.jface.viewers.ICellEditorValidator;
 import org.eclipse.jface.viewers.TextCellEditor;
 import org.eclipse.swt.widgets.Composite;
+import org.yakindu.sct.simulation.ui.view.ActiveSessionProvider;
 
 /**
  * {@link TextCellEditor} support for Real values.
@@ -24,8 +25,9 @@ import org.eclipse.swt.widgets.Composite;
  */
 public class RealEditingSupport extends ScopeSlotEditingSupport {
 
-	public RealEditingSupport(ColumnViewer viewer) {
-		super(viewer);
+	public RealEditingSupport(ColumnViewer viewer,
+			ActiveSessionProvider provider) {
+		super(viewer, provider);
 	}
 
 	@Override

+ 9 - 7
plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/view/editing/ScopeSlotEditingSupport.java

@@ -13,8 +13,7 @@ package org.yakindu.sct.simulation.ui.view.editing;
 import org.eclipse.jface.viewers.ColumnViewer;
 import org.yakindu.sct.simulation.core.ISGraphExecutionScope;
 import org.yakindu.sct.simulation.core.ISGraphExecutionScope.ScopeSlot;
-import org.yakindu.sct.simulation.core.SGraphSimulationSessionRegistry;
-
+import org.yakindu.sct.simulation.ui.view.ActiveSessionProvider;
 
 /**
  * 
@@ -23,19 +22,22 @@ import org.yakindu.sct.simulation.core.SGraphSimulationSessionRegistry;
  */
 public abstract class ScopeSlotEditingSupport extends PublicEditingSupport {
 
+	private final ActiveSessionProvider provider;
+
 	protected abstract Class<?> getSupportedType();
 
 	protected abstract Object convertValue(Object value);
 
-	public ScopeSlotEditingSupport(ColumnViewer viewer) {
+	public ScopeSlotEditingSupport(ColumnViewer viewer,
+			ActiveSessionProvider provider) {
 		super(viewer);
+		this.provider = provider;
 	}
 
 	@Override
 	public boolean canEdit(Object element) {
 		if (element instanceof ScopeSlot) {
-			return getSupportedType().equals(
-					((ScopeSlot) element).getType());
+			return getSupportedType().equals(((ScopeSlot) element).getType());
 		}
 		return false;
 	}
@@ -54,8 +56,8 @@ public abstract class ScopeSlotEditingSupport extends PublicEditingSupport {
 		if (value == null)
 			return;
 		if (element instanceof ScopeSlot) {
-			ISGraphExecutionScope scope = SGraphSimulationSessionRegistry.INSTANCE
-					.getActiveSession().getExecutionScope();
+			ISGraphExecutionScope scope = provider.getActiveSession()
+					.getExecutionScope();
 			scope.setSlotValue((ScopeSlot) element, value);
 		}
 	}