Bladeren bron

DebugModel refactoring:
- removed SimulationSession, added dynamicNotationHandler to configure simulation editor highlighting

Andreas Mülder 14 jaren geleden
bovenliggende
commit
48ac596382
29 gewijzigde bestanden met toevoegingen van 827 en 768 verwijderingen
  1. 0 1
      plugins/org.yakindu.sct.simulation.core/META-INF/MANIFEST.MF
  2. 8 0
      plugins/org.yakindu.sct.simulation.core/plugin.properties
  3. 33 106
      plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/debugmodel/SCTDebugTarget.java
  4. 14 8
      plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/debugmodel/SCTDebugThread.java
  5. 3 7
      plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/debugmodel/SCTStackFrame.java
  6. 3 2
      plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/hmr/SCTHotModelReplacementManager.java
  7. 53 0
      plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/runtime/AbstractExecutionFacade.java
  8. 4 0
      plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/runtime/IExecutionContext.java
  9. 7 15
      plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/runtime/IExecutionFacade.java
  10. 1 5
      plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/runtime/IExecutionFacadeFactory.java
  11. 3 10
      plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/runtime/IExecutionFacadeListener.java
  12. 24 6
      plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/runtime/impl/ExecutionContextImpl.java
  13. 0 27
      plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/session/ISimulationSessionListener.java
  14. 0 184
      plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/session/SimulationSession.java
  15. 6 0
      plugins/org.yakindu.sct.simulation.ui/.project
  16. 5 1
      plugins/org.yakindu.sct.simulation.ui/META-INF/MANIFEST.MF
  17. 1 1
      plugins/org.yakindu.sct.simulation.ui/plugin.xml
  18. 34 0
      plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/model/presenter/AbstractDynamicNotationHandler.java
  19. 65 0
      plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/model/presenter/DefaultDynamicNotationHandler.java
  20. 26 0
      plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/model/presenter/IDynamicNotationHandler.java
  21. 71 113
      plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/model/presenter/SCTSourceDisplay.java
  22. 0 24
      plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/view/ActiveSessionProvider.java
  23. 336 238
      plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/view/DeclarationView.java
  24. 74 0
      plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/view/ExecutionContextContentProvider.java
  25. 44 0
      plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/view/ExecutionContextLabelProvider.java
  26. 2 3
      plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/view/editing/BooleanEditingSupport.java
  27. 2 3
      plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/view/editing/IntegerEditingSupport.java
  28. 2 4
      plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/view/editing/RealEditingSupport.java
  29. 6 10
      plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/view/editing/ScopeSlotEditingSupport.java

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

@@ -21,5 +21,4 @@ Export-Package: org.yakindu.sct.simulation.core,
  org.yakindu.sct.simulation.core.launch,
  org.yakindu.sct.simulation.core.runtime,
  org.yakindu.sct.simulation.core.runtime.impl,
- org.yakindu.sct.simulation.core.session,
  org.yakindu.sct.simulation.core.util

+ 8 - 0
plugins/org.yakindu.sct.simulation.core/plugin.properties

@@ -0,0 +1,8 @@
+
+# <copyright>
+# </copyright>
+#
+# $Id$
+
+pluginName = SRuntime Model
+providerName = www.example.org

+ 33 - 106
plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/debugmodel/SCTDebugTarget.java

@@ -11,9 +11,10 @@
 package org.yakindu.sct.simulation.core.debugmodel;
 
 import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
 import java.util.List;
+import java.util.Set;
+import java.util.Timer;
+import java.util.TimerTask;
 
 import org.eclipse.core.resources.IMarkerDelta;
 import org.eclipse.core.runtime.CoreException;
@@ -27,43 +28,33 @@ import org.eclipse.debug.core.model.IMemoryBlock;
 import org.eclipse.debug.core.model.IProcess;
 import org.eclipse.debug.core.model.IThread;
 import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.yakindu.sct.model.sgraph.FinalState;
-import org.yakindu.sct.model.sgraph.Region;
-import org.yakindu.sct.model.sgraph.State;
 import org.yakindu.sct.model.sgraph.Statechart;
-import org.yakindu.sct.model.sgraph.Transition;
 import org.yakindu.sct.model.sgraph.Vertex;
 import org.yakindu.sct.simulation.core.extensions.ExecutionFactoryExtensions;
 import org.yakindu.sct.simulation.core.extensions.ExecutionFactoryExtensions.ExecutionFactoryDescriptor;
 import org.yakindu.sct.simulation.core.runtime.IExecutionFacade;
 import org.yakindu.sct.simulation.core.runtime.IExecutionFacadeFactory;
-import org.yakindu.sct.simulation.core.runtime.IExecutionFacadeListener;
-import org.yakindu.sct.simulation.core.session.SimulationSession;
 
 /**
  * 
  * @author andreas muelder - Initial contribution and API
  * 
  */
-public class SCTDebugTarget extends SCTDebugElement implements IDebugTarget,
-		IExecutionFacadeListener {
+public class SCTDebugTarget extends SCTDebugElement implements IDebugTarget {
 
-	private IProcess process;
+	// TODO: Add to launch tab config
+	private static final int CYCLE_SLEEP_TIME = 100;
 
 	private ILaunch launch;
 
 	private IExecutionFacade facade;
 
-	private SimulationSession session;
+	private Timer timer;
 
 	private boolean stepping = false;
 	private boolean terminated = false;
 	private boolean suspended = false;
 
-	private List<Region> activeRegions = new ArrayList<Region>();
-	private List<Vertex> activeStates = new ArrayList<Vertex>();
-
 	private final Statechart statechart;
 
 	public SCTDebugTarget(ILaunch launch, Statechart statechart)
@@ -71,10 +62,9 @@ public class SCTDebugTarget extends SCTDebugElement implements IDebugTarget,
 		super(null, statechart.eResource().getURI().toPlatformString(true));
 		this.launch = launch;
 		this.statechart = statechart;
-
+		timer = new Timer();
 		DebugPlugin.getDefault().getBreakpointManager()
 				.addBreakpointListener(this);
-
 		createExecutionModel(statechart);
 
 	}
@@ -82,37 +72,45 @@ public class SCTDebugTarget extends SCTDebugElement implements IDebugTarget,
 	private void createExecutionModel(Statechart statechart) {
 		IExecutionFacadeFactory factory = getExecutionFacadeFactory(statechart);
 		facade = factory.createExecutionFacade(statechart);
-		facade.addExecutionListener(this);
-		session = new SimulationSession(facade);
-		new Thread(session).start();
-		session.start();
+		facade.enter();
+		scheduleCycle();
+	}
+
+	protected void scheduleCycle() {
+		if (!terminated && !suspended)
+			timer.schedule(new TimerTask() {
+				public void run() {
+					facade.runCycle();
+					scheduleCycle();
+				}
+			}, CYCLE_SLEEP_TIME);
 	}
 
 	protected IExecutionFacadeFactory getExecutionFacadeFactory(EObject context) {
 		Iterable<ExecutionFactoryDescriptor> executionFactoryDescriptor = ExecutionFactoryExtensions
 				.getExecutionFactoryDescriptor();
-		// 7TODO: Handle more than one registered factory
+		// TODO: Handle more than one registered factory
 		ExecutionFactoryDescriptor next = executionFactoryDescriptor.iterator()
 				.next();
 		return next.createExecutableExtensionFactory();
 	}
 
 	public IProcess getProcess() {
-		return process;
+		return null;
 	}
 
 	public void stepOver() {
 		fireEvent(new DebugEvent(getDebugTarget(), DebugEvent.STEP_OVER));
-		session.singleStep();
 	}
 
 	public IThread[] getThreads() throws DebugException {
 		List<SCTDebugThread> threads = new ArrayList<SCTDebugThread>();
-		for (int i = activeRegions.size() - 1; i >= 0; i--) {
+		Set<Vertex> activeLeafStates = facade.getExecutionContext()
+				.getActiveLeafStates();
+		for (Vertex vertex : activeLeafStates) {
 			threads.add(new SCTDebugThread(this, facade, getResourceString(),
-					activeRegions.get(i)));
+					vertex.getParentRegion()));
 		}
-
 		return threads.toArray(new IThread[] {});
 	}
 
@@ -137,11 +135,11 @@ public class SCTDebugTarget extends SCTDebugElement implements IDebugTarget,
 	}
 
 	public void terminate() throws DebugException {
-		facade.removeExecutionListener(this);
-		// activeStates = Collections.emptyList();
 		fireEvent(new DebugEvent(getDebugTarget(), DebugEvent.TERMINATE));
 		terminated = true;
-		session.terminate();
+		facade.tearDown();
+		timer.cancel();
+		timer.purge();
 	}
 
 	public boolean canResume() {
@@ -159,14 +157,13 @@ public class SCTDebugTarget extends SCTDebugElement implements IDebugTarget,
 	public void resume() throws DebugException {
 		fireEvent(new DebugEvent(this, DebugEvent.RESUME));
 		fireChangeEvent(DebugEvent.CONTENT);
-		session.resume();
 		suspended = false;
+		scheduleCycle();
 	}
 
 	public void suspend() throws DebugException {
 		fireEvent(new DebugEvent(this, DebugEvent.SUSPEND));
 		fireChangeEvent(DebugEvent.CONTENT);
-		session.suspend();
 		suspended = true;
 	}
 
@@ -209,10 +206,11 @@ public class SCTDebugTarget extends SCTDebugElement implements IDebugTarget,
 	}
 
 	public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
-		if (adapter == SimulationSession.class)
-			return session;
 		if (adapter == IExecutionFacade.class)
 			return facade;
+		if (adapter == EObject.class) {
+			return statechart;
+		}
 		return super.getAdapter(adapter);
 	}
 
@@ -220,78 +218,7 @@ public class SCTDebugTarget extends SCTDebugElement implements IDebugTarget,
 		return isSuspended() && !isTerminated();
 	}
 
-	public void stateEntered(Vertex vertex) {
-		if (vertex instanceof State) {
-			if (((State) vertex).isLeaf()) {
-				activeStates.add(vertex);
-				activeRegions.add(vertex.getParentRegion());
-			}
-		} else if (vertex instanceof FinalState) {
-			activeStates.add(vertex);
-			activeRegions.add(vertex.getParentRegion());
-		}
-		fireChangeEvent(DebugEvent.CONTENT);
-	}
-
-	public void stateLeft(Vertex vertex) {
-		if (vertex instanceof State) {
-			activeStates.remove(vertex);
-			if (((State) vertex).isLeaf()) {
-				if (activeRegions.contains(vertex.getParentRegion()))
-					activeRegions.remove(vertex.getParentRegion());
-			}
-		} else if (vertex instanceof FinalState) {
-			if (activeRegions.contains(vertex.getParentRegion()))
-				activeRegions.remove(vertex.getParentRegion());
-		}
-		fireChangeEvent(DebugEvent.CONTENT);
-	}
-
-	public void pseudoStateExecuted(Vertex vertex) {
-	}
-
-	public void transitionFired(Transition transition) {
-	}
-
 	public boolean isStepping() {
 		return stepping;
 	}
-
-	public List<Region> getActiveRegions() {
-		return activeRegions;
-	}
-
-	public List<Vertex> getActiveStates() {
-		return activeStates;
-	}
-
-	public List<Vertex> getActiveStatesForRegion(Region region) {
-		List<Vertex> result = new ArrayList<Vertex>();
-		for (Vertex vertex : activeStates) {
-			if (EcoreUtil.isAncestor(region, vertex)) {
-				result.addAll(getActiveHierachy(vertex));
-			}
-
-			Collections.reverse(result);
-		}
-		return result;
-
-	}
-
-	private Collection<? extends Vertex> getActiveHierachy(Vertex vertex) {
-		List<Vertex> result = new ArrayList<Vertex>();
-		result.add(vertex);
-		EObject container = vertex.eContainer();
-		while (container != null) {
-			if (container instanceof State) {
-				result.add((State) container);
-			}
-			container = container.eContainer();
-		}
-		return result;
-	}
-
-	public Statechart getStatechart() {
-		return statechart;
-	}
 }

+ 14 - 8
plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/debugmodel/SCTDebugThread.java

@@ -12,15 +12,16 @@ package org.yakindu.sct.simulation.core.debugmodel;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Set;
 
 import org.eclipse.debug.core.DebugException;
 import org.eclipse.debug.core.model.IBreakpoint;
 import org.eclipse.debug.core.model.IStackFrame;
 import org.eclipse.debug.core.model.IThread;
+import org.eclipse.emf.ecore.EObject;
 import org.yakindu.sct.model.sgraph.Region;
 import org.yakindu.sct.model.sgraph.Vertex;
 import org.yakindu.sct.simulation.core.runtime.IExecutionFacade;
-import org.yakindu.sct.simulation.core.session.SimulationSession;
 
 /**
  * 
@@ -30,10 +31,12 @@ import org.yakindu.sct.simulation.core.session.SimulationSession;
 public class SCTDebugThread extends SCTDebugElement implements IThread {
 
 	private final Region region;
+	private final IExecutionFacade facade;
 
 	public SCTDebugThread(SCTDebugTarget target, IExecutionFacade facade,
 			String resourceString, Region region) {
 		super(target, resourceString);
+		this.facade = facade;
 		this.region = region;
 	}
 
@@ -42,12 +45,14 @@ public class SCTDebugThread extends SCTDebugElement implements IThread {
 	}
 
 	public IStackFrame[] getStackFrames() throws DebugException {
-		List<Vertex> activeStates = getDebugTarget().getActiveStatesForRegion(
-				region);
 		List<IStackFrame> stackFrames = new ArrayList<IStackFrame>();
-		for (int i = activeStates.size() - 1; i >= 0; i--) {
-			stackFrames.add(new SCTStackFrame(this, activeStates.get(i),
-					getResourceString()));
+		Set<Vertex> activeLeafStates = facade.getExecutionContext()
+				.getActiveLeafStates();
+		for (Vertex vertex : activeLeafStates) {
+			if (vertex.getParentRegion() == region) {
+				stackFrames.add(new SCTStackFrame(this, vertex,
+						getResourceString()));
+			}
 		}
 		return stackFrames.toArray(new IStackFrame[] {});
 	}
@@ -127,10 +132,11 @@ public class SCTDebugThread extends SCTDebugElement implements IThread {
 	}
 
 	public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
-		if (adapter == SimulationSession.class)
-			return getDebugTarget().getAdapter(SimulationSession.class);
 		if (adapter == IExecutionFacade.class)
 			return getDebugTarget().getAdapter(IExecutionFacade.class);
+		if (adapter == EObject.class) {
+			return region;
+		}
 		return super.getAdapter(adapter);
 	}
 

+ 3 - 7
plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/debugmodel/SCTStackFrame.java

@@ -16,9 +16,9 @@ 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.Vertex;
 import org.yakindu.sct.simulation.core.runtime.IExecutionFacade;
-import org.yakindu.sct.simulation.core.session.SimulationSession;
 
 /**
  * 
@@ -151,19 +151,15 @@ public class SCTStackFrame extends SCTDebugElement implements IStackFrame {
 		return thread.getLaunch();
 	}
 
-	public Vertex getState() {
-		return state;
-	}
-
 	public String getResourceString() {
 		return state.eResource().getURI().toPlatformString(true);
 	}
 
 	public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
-		if (adapter == SimulationSession.class)
-			return thread.getAdapter(SimulationSession.class);
 		if (adapter == IExecutionFacade.class)
 			return getDebugTarget().getAdapter(IExecutionFacade.class);
+		if(adapter == EObject.class)
+			return state;
 		return super.getAdapter(adapter);
 	}
 

+ 3 - 2
plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/hmr/SCTHotModelReplacementManager.java

@@ -28,6 +28,7 @@ import org.eclipse.debug.core.IDebugEventSetListener;
 import org.eclipse.debug.core.ILaunch;
 import org.eclipse.debug.core.ILaunchListener;
 import org.eclipse.debug.core.model.IDebugTarget;
+import org.eclipse.emf.ecore.EObject;
 import org.eclipse.emf.ecore.util.EcoreUtil;
 import org.yakindu.sct.model.sgraph.Statechart;
 import org.yakindu.sct.simulation.core.debugmodel.SCTDebugTarget;
@@ -160,8 +161,8 @@ public class SCTHotModelReplacementManager implements IResourceChangeListener,
 			// Reload the Statechart form the changes resource
 			Statechart newStatechart = ResourceUtil
 					.loadStatechart(sctDebugTarget.getResourceString());
-			if (!EcoreUtil
-					.equals(newStatechart, sctDebugTarget.getStatechart())) {
+			if (!EcoreUtil.equals(newStatechart,
+					(EObject) sctDebugTarget.getAdapter(EObject.class))) {
 				// The model semantically changed, we have to create a
 				// notificiation for that....
 				modelReplacementFailedTargets.add(sctDebugTarget);

+ 53 - 0
plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/runtime/AbstractExecutionFacade.java

@@ -0,0 +1,53 @@
+/**
+ * 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.runtime;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.yakindu.sct.model.sexec.Trace;
+
+/**
+ * Adds convenience for {@link IExecutionTraceListener} handling.
+ * 
+ * @author andreas muelder - Initial contribution and API
+ * 
+ */
+public abstract class AbstractExecutionFacade implements IExecutionFacade {
+
+	private List<IExecutionTraceListener> _listeners;
+
+	public AbstractExecutionFacade() {
+		_listeners = new ArrayList<IExecutionTraceListener>();
+	}
+
+	public void addTraceListener(IExecutionTraceListener listener) {
+		synchronized (_listeners) {
+			if (!_listeners.contains(listener)) {
+				_listeners.add(listener);
+			}
+		}
+	}
+
+	public void removeTraceListener(IExecutionTraceListener listener) {
+		synchronized (_listeners) {
+			_listeners.remove(listener);
+		}
+	}
+
+	protected void notifyTraceStepEntered(Trace trace) {
+		synchronized (_listeners) {
+			for (IExecutionTraceListener listener : _listeners) {
+				listener.traceStepExecuted(trace);
+			}
+		}
+	}
+}

+ 4 - 0
plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/runtime/IExecutionContext.java

@@ -83,6 +83,10 @@ public interface IExecutionContext {
 	 * Returns a Set with all currently active states
 	 */
 	public Set<Vertex> getActiveLeafStates();
+	/**
+	 * Returns a set with all active leaf states including parents
+	 */
+	public Set<Vertex> getAllActiveStates();
 	/**
 	 * Returns the active state configuration
 	 */

+ 7 - 15
plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/runtime/IExecutionFacade.java

@@ -10,8 +10,6 @@
  */
 package org.yakindu.sct.simulation.core.runtime;
 
-
-
 /**
  * Facade for executable statechart implementation.
  * 
@@ -19,25 +17,19 @@ package org.yakindu.sct.simulation.core.runtime;
  * 
  */
 public interface IExecutionFacade {
-	/**
-	 * Returns a name for the Execution Facade implementation
-	 */
+
 	public String getName();
-	
+
 	public void tearDown();
-	/**
-	 * Startes the execution
-	 */
+
 	public void enter();
-	/**
-	 * Executes one cycle
-	 */
+
 	public void runCycle();
 
-	public void addExecutionListener(IExecutionFacadeListener listener);
+	public void addTraceListener(IExecutionTraceListener listener);
 
-	public void removeExecutionListener(IExecutionFacadeListener listener);
+	public void removeTraceListener(IExecutionTraceListener listener);
 
 	public IExecutionContext getExecutionContext();
-	
+
 }

+ 1 - 5
plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/runtime/IExecutionFacadeFactory.java

@@ -18,11 +18,7 @@ import org.yakindu.sct.model.sgraph.Statechart;
  * 
  */
 public interface IExecutionFacadeFactory {
-	/**
-	 * 
-	 * @param statechart
-	 * @return
-	 */
+
 	public IExecutionFacade createExecutionFacade(Statechart statechart);
 
 }

+ 3 - 10
plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/runtime/IExecutionFacadeListener.java

@@ -10,22 +10,15 @@
  */
 package org.yakindu.sct.simulation.core.runtime;
 
-import org.yakindu.sct.model.sgraph.Transition;
-import org.yakindu.sct.model.sgraph.Vertex;
+import org.yakindu.sct.model.sexec.Trace;
 
 /**
  * 
  * @author andreas muelder - Initial contribution and API
  * 
  */
-public interface IExecutionFacadeListener {
+public interface IExecutionTraceListener {
 
-	void stateEntered(Vertex vertex);
-
-	void stateLeft(Vertex vertex);
-
-	void pseudoStateExecuted(Vertex vertex);
-
-	void transitionFired(Transition transition);
+	public void traceStepExecuted(Trace trace);
 
 }

+ 24 - 6
plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/runtime/impl/ExecutionContextImpl.java

@@ -11,12 +11,15 @@
 package org.yakindu.sct.simulation.core.runtime.impl;
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
+import org.eclipse.emf.ecore.EObject;
 import org.yakindu.sct.model.sexec.ExecutionState;
+import org.yakindu.sct.model.sgraph.State;
 import org.yakindu.sct.model.sgraph.Vertex;
 import org.yakindu.sct.simulation.core.runtime.ExecutionException;
 import org.yakindu.sct.simulation.core.runtime.IExecutionContext;
@@ -88,19 +91,13 @@ public class ExecutionContextImpl extends AbstractExecutionContext implements
 	}
 
 	public boolean isEventRaised(String eventName) {
-//		System.out.println("IsEvent Raised: " + eventName);
 		synchronized (raisedEvents) {
 			for (ExecutionEvent event : raisedEvents) {
 				if (eventName.equals(event.getName())) {
-//					System.out.println("True");
 					return true;
 				}
 			}
 		}
-//		System.out.println("False");
-		for (ExecutionEvent event : raisedEvents) {
-//			System.out.println(event.getName());
-		}
 		return false;
 	}
 
@@ -153,4 +150,25 @@ public class ExecutionContextImpl extends AbstractExecutionContext implements
 		return vertices;
 	}
 
+	public Set<Vertex> getAllActiveStates() {
+		Set<Vertex> vertices = new HashSet<Vertex>();
+		for (ExecutionState state : activeStateConfig) {
+			vertices.addAll(getActiveHierachy((Vertex) state.getSourceElement()));
+		}
+		return vertices;
+	}
+
+	private Collection<? extends Vertex> getActiveHierachy(Vertex vertex) {
+		List<Vertex> result = new ArrayList<Vertex>();
+		result.add(vertex);
+		EObject container = vertex.eContainer();
+		while (container != null) {
+			if (container instanceof State) {
+				result.add((State) container);
+			}
+			container = container.eContainer();
+		}
+		return result;
+	}
+
 }

+ 0 - 27
plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/session/ISimulationSessionListener.java

@@ -1,27 +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.session;
-
-/**
- * 
- * @author andreas muelder - Initial contribution and API
- * 
- */
-public interface ISimulationSessionListener {
-
-	public static enum SimulationState {
-		STARTED, RUNNING, SINGLESTEP, PAUSED, TERMINATED
-	}
-
-	public void simulationStateChanged(SimulationState oldState,
-			SimulationState newState);
-
-}

+ 0 - 184
plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/session/SimulationSession.java

@@ -1,184 +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.session;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.Timer;
-import java.util.TimerTask;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.LinkedBlockingQueue;
-
-import org.yakindu.sct.model.sgraph.CompositeElement;
-import org.yakindu.sct.model.sgraph.State;
-import org.yakindu.sct.model.sgraph.Vertex;
-import org.yakindu.sct.simulation.core.runtime.IExecutionContext;
-import org.yakindu.sct.simulation.core.runtime.IExecutionFacade;
-import org.yakindu.sct.simulation.core.runtime.impl.ExecutionEvent;
-import org.yakindu.sct.simulation.core.session.ISimulationSessionListener.SimulationState;
-
-/**
- * 
- * @author andreas muelder - Initial contribution and API
- * 
- */
-public class SimulationSession implements Runnable {
-
-	// TODO: Add to launch tab config
-	private static final int CYCLE_SLEEP_TIME = 100;
-
-	private List<ISimulationSessionListener> listeners;
-
-	private BlockingQueue<Runnable> taskQueue;
-
-	private SimulationState currentState;
-
-	private final IExecutionFacade facade;
-
-	private Timer timer;
-
-	public SimulationSession(IExecutionFacade facade) {
-		this.facade = facade;
-		listeners = new ArrayList<ISimulationSessionListener>();
-		taskQueue = new LinkedBlockingQueue<Runnable>();
-		timer = new Timer();
-	}
-
-	public void start() {
-		taskQueue.add(new Runnable() {
-			public void run() {
-				changeSimulationState(SimulationState.STARTED);
-				facade.enter();
-				changeSimulationState(SimulationState.RUNNING);
-				scheduleCycle();
-			}
-		});
-	}
-
-	public void singleStep() {
-		taskQueue.add(new Runnable() {
-			public void run() {
-				changeSimulationState(SimulationState.SINGLESTEP);
-			}
-		});
-	}
-
-	public void resume() {
-		taskQueue.add(new Runnable() {
-			public void run() {
-				changeSimulationState(SimulationState.RUNNING);
-				scheduleCycle();
-			}
-		});
-	}
-
-	public void suspend() {
-		taskQueue.add(new Runnable() {
-			public void run() {
-				changeSimulationState(SimulationState.PAUSED);
-			}
-		});
-	}
-
-	public void terminate() {
-		taskQueue.add(new Runnable() {
-			public void run() {
-				changeSimulationState(SimulationState.TERMINATED);
-			}
-		});
-		facade.tearDown();
-	}
-
-	public void raiseEvent(final ExecutionEvent event) {
-		taskQueue.add(new Runnable() {
-			public void run() {
-				facade.getExecutionContext().raiseEvent(event.getName(),
-						event.getValue());
-			}
-		});
-	}
-
-	protected void scheduleCycle() {
-		if (currentState == SimulationState.RUNNING) {
-			timer.schedule(new TimerTask() {
-				public void run() {
-					taskQueue.add(new Runnable() {
-						public void run() {
-							facade.runCycle();
-						}
-					});
-					scheduleCycle();
-				}
-			}, CYCLE_SLEEP_TIME);
-
-		}
-	}
-
-	public void run() {
-		while (!(currentState == SimulationState.TERMINATED)) {
-			try {
-				Runnable task = taskQueue.take();
-				task.run();
-			} catch (InterruptedException e) {
-				e.printStackTrace();
-			}
-		}
-	}
-
-	protected void changeSimulationState(SimulationState newState) {
-		synchronized (listeners) {
-			for (ISimulationSessionListener listener : listeners) {
-				listener.simulationStateChanged(this.currentState, newState);
-			}
-			this.currentState = newState;
-		}
-	}
-
-	public void addSimulationListener(ISimulationSessionListener listener) {
-		synchronized (listeners) {
-			listeners.add(listener);
-		}
-	}
-
-	public void removeSimulationListener(ISimulationSessionListener listener) {
-		synchronized (listeners) {
-			listeners.remove(listener);
-		}
-	}
-
-	public IExecutionContext getExecutionContext() {
-		return facade.getExecutionContext();
-	}
-
-	public SimulationState getCurrentState() {
-		return currentState;
-	}
-
-	public Set<Vertex> getActiveStates() {
-		Set<Vertex> activeStates = new HashSet<Vertex>();
-		Set<Vertex> leafStates = facade.getExecutionContext()
-				.getActiveLeafStates();
-		activeStates.addAll(leafStates);
-		for (Vertex vertex : leafStates) {
-			CompositeElement composite = vertex.getParentRegion()
-					.getComposite();
-			while (composite instanceof State) {
-				activeStates.add((State) composite);
-				composite = ((State) composite).getParentRegion()
-						.getComposite();
-			}
-		}
-		return activeStates;
-	}
-
-}

+ 6 - 0
plugins/org.yakindu.sct.simulation.ui/.project

@@ -20,9 +20,15 @@
 			<arguments>
 			</arguments>
 		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
 	</buildSpec>
 	<natures>
 		<nature>org.eclipse.pde.PluginNature</nature>
 		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
 	</natures>
 </projectDescription>

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

@@ -20,7 +20,11 @@ Require-Bundle: org.eclipse.ui,
  org.eclipse.ui.ide,
  org.yakindu.sct.ui.editor,
  de.itemis.xtext.utils.gmf,
- org.yakindu.sct.ui;bundle-version="1.0.0"
+ org.yakindu.sct.ui;bundle-version="1.0.0",
+ org.yakindu.sct.model.sexec;bundle-version="1.0.0",
+ com.google.inject;bundle-version="2.0.0",
+ org.eclipse.xtext.xbase.lib;bundle-version="2.0.1",
+ org.eclipse.xtext.xtend2.lib;bundle-version="2.0.1"
 Bundle-RequiredExecutionEnvironment: J2SE-1.5
 Bundle-ActivationPolicy: lazy
 Import-Package: org.eclipse.ui.dialogs

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

@@ -12,7 +12,6 @@
          </adapter>
       </factory>
    </extension>
-	
 	<!-- Launch configuration images -->
    <extension point="org.eclipse.debug.ui.launchConfigurationTypeImages">
     	<launchConfigurationTypeImage
@@ -73,6 +72,7 @@
           plugin="org.yakindu.sct.simulation.core">
     </statusHandler>
  </extension>
+ 
  <!-- Source Display Adapter factory -->
  <extension
        point="org.eclipse.core.runtime.adapters">

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

@@ -0,0 +1,34 @@
+package org.yakindu.sct.simulation.ui.model.presenter;
+
+import org.eclipse.swt.widgets.Display;
+import org.yakindu.sct.model.sexec.Trace;
+
+import de.itemis.gmf.runtime.commons.highlighting.IHighlightingSupport;
+
+/**
+ * @author andreas muelder - Initial contribution and API
+ * 
+ */
+public abstract class AbstractDynamicNotationHandler implements
+		IDynamicNotationHandler {
+
+	protected abstract void visualizeStep(Trace trace);
+
+	private IHighlightingSupport support;
+
+	public IHighlightingSupport getHighlightingSupport() {
+		return support;
+	}
+
+	public void setHighlightingSupport(IHighlightingSupport support) {
+		this.support = support;
+	}
+
+	public final void traceStepExecuted(final Trace trace) {
+		Display.getDefault().asyncExec(new Runnable() {
+			public void run() {
+				visualizeStep(trace);
+			}
+		});
+	}
+}

+ 65 - 0
plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/model/presenter/DefaultDynamicNotationHandler.java

@@ -0,0 +1,65 @@
+package org.yakindu.sct.simulation.ui.model.presenter;
+
+import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.emf.ecore.EObject;
+import org.yakindu.sct.model.sexec.ReactionFired;
+import org.yakindu.sct.model.sexec.Trace;
+import org.yakindu.sct.model.sexec.TraceStateEntered;
+import org.yakindu.sct.model.sexec.TraceStateExited;
+import org.yakindu.sct.model.sgraph.Vertex;
+import org.yakindu.sct.simulation.core.runtime.IExecutionContext;
+
+import de.itemis.gmf.runtime.commons.highlighting.HighlightingParameters;
+
+/**
+ * @author andreas muelder - Initial contribution and API
+ * 
+ */
+public class DefaultDynamicNotationHandler extends AbstractDynamicNotationHandler {
+
+	private static final HighlightingParameters TRANSITION_PARAMS = new HighlightingParameters(
+			0, ColorConstants.darkGreen, ColorConstants.gray, false);
+
+	private EObject lastTakenTransition = null;
+
+	public void restoreNotationState(IExecutionContext context) {
+		for (Vertex vertex : context.getAllActiveStates()) {
+			getHighlightingSupport().fadeIn(vertex,
+					HighlightingParameters.DEFAULT);
+		}
+		getHighlightingSupport().fadeIn(lastTakenTransition, TRANSITION_PARAMS);
+
+	}
+
+	public void visualizeStep(final TraceStateEntered trace) {
+		getHighlightingSupport().fadeIn(
+				((TraceStateEntered) trace).getState().getSourceElement(),
+				HighlightingParameters.DEFAULT);
+	}
+
+	public void visualizeStep(final TraceStateExited trace) {
+		getHighlightingSupport().fadeOut(
+				((TraceStateExited) trace).getState().getSourceElement(),
+				HighlightingParameters.DEFAULT);
+	}
+
+	public void visualizeStep(final ReactionFired trace) {
+		EObject transition = trace.getReaction().getSourceElement();
+		if (lastTakenTransition != null) {
+			getHighlightingSupport().fadeOut(lastTakenTransition,
+					TRANSITION_PARAMS);
+		}
+		getHighlightingSupport().fadeIn(transition, TRANSITION_PARAMS);
+		lastTakenTransition = transition;
+	}
+
+	// dispatch
+	public void visualizeStep(final Trace trace) {
+		if (trace instanceof TraceStateEntered)
+			visualizeStep((TraceStateEntered) trace);
+		if (trace instanceof TraceStateExited)
+			visualizeStep((TraceStateExited) trace);
+		if (trace instanceof ReactionFired)
+			visualizeStep((ReactionFired) trace);
+	}
+}

+ 26 - 0
plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/model/presenter/IDynamicNotationHandler.java

@@ -0,0 +1,26 @@
+package org.yakindu.sct.simulation.ui.model.presenter;
+
+import org.yakindu.sct.model.sexec.Trace;
+import org.yakindu.sct.simulation.core.runtime.IExecutionContext;
+import org.yakindu.sct.simulation.core.runtime.IExecutionTraceListener;
+
+import de.itemis.gmf.runtime.commons.highlighting.IHighlightingSupport;
+
+/**
+ * @author andreas muelder - Initial contribution and API
+ * 
+ */
+public interface IDynamicNotationHandler extends IExecutionTraceListener {
+
+	public void restoreNotationState(IExecutionContext context);
+
+	/**
+	 * {@see IExecutionTraceListener#traceStepExecuted(Trace)}
+	 */
+	public void traceStepExecuted(Trace trace);
+
+	public void setHighlightingSupport(IHighlightingSupport support);
+
+	public IHighlightingSupport getHighlightingSupport();
+
+}

+ 71 - 113
plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/model/presenter/SCTSourceDisplay.java

@@ -10,169 +10,130 @@
  */
 package org.yakindu.sct.simulation.ui.model.presenter;
 
-import java.util.Set;
+import java.util.HashMap;
+import java.util.Map;
 
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IResource;
 import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.debug.core.DebugEvent;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.IDebugEventSetListener;
 import org.eclipse.debug.ui.sourcelookup.ISourceDisplay;
+import org.eclipse.emf.ecore.EObject;
 import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.swt.widgets.Display;
+import org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.DiagramDocumentEditor;
 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.debugmodel.SCTDebugElement;
-import org.yakindu.sct.simulation.core.debugmodel.SCTStackFrame;
+import org.yakindu.sct.simulation.core.debugmodel.SCTDebugTarget;
 import org.yakindu.sct.simulation.core.runtime.IExecutionFacade;
-import org.yakindu.sct.simulation.core.runtime.IExecutionFacadeListener;
-import org.yakindu.sct.simulation.core.session.ISimulationSessionListener;
-import org.yakindu.sct.simulation.core.session.SimulationSession;
 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 implements ISimulationSessionListener,
-		IExecutionFacadeListener, ISourceDisplay {
+public class SCTSourceDisplay implements ISourceDisplay, IDebugEventSetListener {
 
-	private IHighlightingSupport support = new IHighlightingSupport.HighlightingSupportNullImpl();
+	private DiagramDocumentEditor prevEditor;
+	private SCTDebugTarget lastActiveTarget;
+	private Map<IExecutionFacade, IDynamicNotationHandler> _handler;
 
-	private SimulationSession lastActiveSession;
-
-	private HighlightingParameters parameters = new HighlightingParameters();
+	public SCTSourceDisplay() {
+		_handler = new HashMap<IExecutionFacade, IDynamicNotationHandler>();
+		DebugPlugin.getDefault().addDebugEventListener(this);
+	}
 
 	public void displaySource(Object element, IWorkbenchPage page,
 			boolean forceSourceLookup) {
-
 		SCTDebugElement debugElement = (SCTDebugElement) element;
-		SimulationSession session = (SimulationSession) debugElement
-				.getAdapter(SimulationSession.class);
-
-		if(lastActiveSession == session){
+		if (debugElement.getDebugTarget().isTerminated())
+			return;
+		DiagramDocumentEditor editor = openEditorAndSelectElements(
+				debugElement, page);
+		if (debugElement.getDebugTarget() == lastActiveTarget
+				&& prevEditor == editor) {
 			return;
 		}
-		
+		prevEditor = editor;
+		lastActiveTarget = (SCTDebugTarget) debugElement.getDebugTarget();
+
 		IExecutionFacade facade = (IExecutionFacade) debugElement
 				.getAdapter(IExecutionFacade.class);
-		
-		//TODO CHECK FOR MULTI EDITOR SIM
-		facade.addExecutionListener(this);
-
-		StatechartDiagramEditor editor = openEditorAndSelectElements(
-				debugElement, page);
-
-		// Release the old editor
-		if (support.isLocked())
-			support.releaseEditor();
+		IDynamicNotationHandler handler = _handler.get(facade);
+		if (handler == null) {
+			handler = createNotationHandler(facade);
 
-		support = (IHighlightingSupport) editor
+		}
+		IHighlightingSupport support = (IHighlightingSupport) editor
 				.getAdapter(IHighlightingSupport.class);
-
-		// Release the new editor
+		handler.setHighlightingSupport(support);
 		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 = session.getActiveStates();
-			for (Vertex vertex : stateConfiguration) {
-				support.highlight(vertex, parameters);
-			}
-		}
-
-		// Register me as a Session Listener to control the highlighting
-		if (lastActiveSession != null) {
-			lastActiveSession.removeSimulationListener(this);
-		}
-		session.addSimulationListener(this);
-		lastActiveSession = session;
-
+		support.lockEditor();
+		handler.restoreNotationState(facade.getExecutionContext());
 	}
 
-	public void stateEntered(final Vertex vertex) {
-		Display.getDefault().asyncExec(new Runnable() {
-			public void run() {
-				getSupport().fadeIn(vertex, parameters);
-			}
-		});
+	private IDynamicNotationHandler createNotationHandler(
+			IExecutionFacade facade) {
+		IDynamicNotationHandler handler = new DefaultDynamicNotationHandler();
+		facade.addTraceListener(handler);
+		_handler.put(facade, handler);
+		return handler;
 	}
 
-	public void stateLeft(final Vertex vertex) {
-		Display.getDefault().asyncExec(new Runnable() {
-			public void run() {
-				getSupport().fadeOut(vertex, parameters);
-			}
-		});
+	public void handleDebugEvents(DebugEvent[] events) {
+		for (DebugEvent debugEvent : events) {
+			handleDebugEvent(debugEvent);
+		}
 	}
 
-	
-	public void pseudoStateExecuted(final Vertex vertex) {
-		Display.getDefault().asyncExec(new Runnable() {
-			public void run() {
-				getSupport().flash(vertex, parameters);
-			}
-		});		
+	private void handleDebugEvent(DebugEvent debugEvent) {
+		switch (debugEvent.getKind()) {
+		case DebugEvent.TERMINATE:
+			handleDebugTargetTerminated(debugEvent);
+			break;
+		}
 	}
 
-	public void transitionFired(final Transition transition) {
-		Display.getDefault().asyncExec(new Runnable() {
-			public void run() {
-				getSupport().flash(transition, parameters);
+	private void handleDebugTargetTerminated(DebugEvent debugEvent) {
+		Object source = debugEvent.getSource();
+		if (source instanceof SCTDebugTarget) {
+			SCTDebugTarget target = (SCTDebugTarget) source;
+			IExecutionFacade facade = (IExecutionFacade) target
+					.getAdapter(IExecutionFacade.class);
+			if (_handler.containsKey(facade)) {
+				IDynamicNotationHandler handler = _handler.get(facade);
+				handler.getHighlightingSupport().releaseEditor();
+				facade.removeTraceListener(handler);
+				System.out.println("Removing handler");
+				_handler.remove(facade);
 			}
-		});
-	}
-
-	public void simulationStateChanged(SimulationState oldState,
-			SimulationState newState) {
-		if (newState == SimulationState.TERMINATED) {
-			if (support.isLocked())
-				support.releaseEditor();
 		}
 	}
 
-	/**
-	 * Opens the editor for this resource and selects the selected Editparts
-	 * 
-	 * @param debugElement
-	 * @param page
-	 * @return
-	 */
-	private StatechartDiagramEditor openEditorAndSelectElements(
+	private DiagramDocumentEditor openEditorAndSelectElements(
 			SCTDebugElement debugElement, IWorkbenchPage page) {
 		String platformString = debugElement.getResourceString();
 		IResource resource = ResourcesPlugin.getWorkspace().getRoot()
 				.findMember(platformString);
-		StatechartDiagramEditor editor = null;
+		DiagramDocumentEditor editor = null;
 		try {
-			editor = (StatechartDiagramEditor) page.openEditor(
+			editor = (DiagramDocumentEditor) 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);
-				}
+			IGraphicalEditPart editPart = EditPartUtils
+					.findEditPartForSemanticElement(editor
+							.getDiagramGraphicalViewer().getRootEditPart(),
+							(EObject) debugElement.getAdapter(EObject.class));
+			if (editPart != null) {
+				editor.getDiagramGraphicalViewer().select(editPart);
+				editor.getDiagramGraphicalViewer().reveal(editPart);
 			}
 		} catch (PartInitException e) {
 			e.printStackTrace();
@@ -180,7 +141,4 @@ public class SCTSourceDisplay implements ISimulationSessionListener,
 		return editor;
 	}
 
-	public IHighlightingSupport getSupport() {
-		return support;
-	}
 }

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

@@ -1,24 +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.view;
-
-import org.yakindu.sct.simulation.core.session.SimulationSession;
-
-/**
- * 
- * @author andreas muelder - Initial contribution and API
- * 
- */
-public interface ActiveSessionProvider {
-
-	SimulationSession getActiveSession();
-
-}

+ 336 - 238
plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/view/DeclarationView.java

@@ -10,37 +10,28 @@
  */
 package org.yakindu.sct.simulation.ui.view;
 
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
 import org.eclipse.core.runtime.PlatformObject;
+import org.eclipse.debug.core.DebugEvent;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.IDebugEventSetListener;
+import org.eclipse.debug.core.model.IDebugTarget;
+import org.eclipse.debug.ui.AbstractDebugView;
 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.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.TreeViewerColumn;
+import org.eclipse.jface.viewers.Viewer;
 import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.TableEditor;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
 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.simulation.core.runtime.IExecutionContextListener;
-import org.yakindu.sct.simulation.core.runtime.impl.ExecutionEvent;
-import org.yakindu.sct.simulation.core.runtime.impl.ExecutionVariable;
-import org.yakindu.sct.simulation.core.session.ISimulationSessionListener;
-import org.yakindu.sct.simulation.core.session.SimulationSession;
+import org.yakindu.sct.simulation.core.debugmodel.SCTDebugTarget;
+import org.yakindu.sct.simulation.core.runtime.IExecutionContext;
+import org.yakindu.sct.simulation.core.runtime.IExecutionFacade;
+import org.yakindu.sct.simulation.ui.model.presenter.IDynamicNotationHandler;
 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;
@@ -51,257 +42,364 @@ import org.yakindu.sct.simulation.ui.view.editing.RealEditingSupport;
  * @author andreas muelder - Initial contribution and API
  * 
  */
-public class DeclarationView extends ViewPart implements IDebugContextListener,
-		ISimulationSessionListener, IExecutionContextListener,
-		ActiveSessionProvider {
-
-	private TableViewer eventViewer;
-
-	private TableViewer variableViewer;
+public class DeclarationView extends AbstractDebugView implements
+		IDebugContextListener, IDebugEventSetListener {
 
-	private Map<Control, SelectionListener> controls;
-	private Map<Control, TableEditor> tableEditors;
-
-	private SimulationSession activeSession;
+	private TreeViewer viewer;
 
 	public DeclarationView() {
-		controls = new HashMap<Control, SelectionListener>();
-		tableEditors = new HashMap<Control, TableEditor>();
+		DebugUITools.getDebugContextManager().addDebugContextListener(this);
+		DebugPlugin.getDefault().addDebugEventListener(this);
 	}
 
 	@Override
-	public void init(IViewSite site) throws PartInitException {
-		super.init(site);
-		DebugUITools.getDebugContextManager()
-				.getContextService(site.getWorkbenchWindow())
-				.addDebugContextListener(this);
+	public void dispose() {
+		super.dispose();
+		DebugUITools.getDebugContextManager().removeDebugContextListener(this);
+		DebugPlugin.getDefault().removeDebugEventListener(this);
 	}
 
 	@Override
-	public void createPartControl(Composite parent) {
-		parent.setLayout(new GridLayout(1, true));
-		createEventViewer(parent);
-		createVariableViewer(parent);
-	}
-
-	private void createVariableViewer(Composite parent) {
-		variableViewer = createTableViewer(parent);
-		createScopeSlotColumns(variableViewer);
-		setVariableViewerInput();
-	}
-
-	private void createEventViewer(Composite parent) {
-		eventViewer = createTableViewer(parent);
-		createScopeSlotColumns(eventViewer);
-		createColumn(eventViewer, "raise", 50, 3);
-		setEventViewerInput();
-	}
-
-	private TableViewer createTableViewer(Composite parent) {
-		TableViewer viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL
-				| SWT.V_SCROLL | SWT.FULL_SELECTION);
-		viewer.getTable().setLinesVisible(true);
-		viewer.getTable().setHeaderVisible(true);
-		GridDataFactory.fillDefaults().grab(true, true)
-				.applyTo(viewer.getTable());
-		viewer.setContentProvider(new ArrayContentProvider());
-		return viewer;
-	}
-
-	private TableViewerColumn createColumn(TableViewer viewer, String text,
-			int width, int index) {
-		TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);
-		column.getColumn().setText(text);
-		column.getColumn().setWidth(width);
-		column.getColumn().setResizable(true);
+	protected Viewer createViewer(Composite parent) {
+		viewer = new TreeViewer(parent);
+		viewer.getTree().setHeaderVisible(true);
+		viewer.getTree().setLinesVisible(true);
+		TreeViewerColumn column = new TreeViewerColumn(viewer, SWT.DEFAULT);
+		column.getColumn().setText("Name");
 		column.getColumn().setMoveable(true);
-		column.setLabelProvider(new ScopeSlotLabelProvider(index));
-		return column;
-	}
+		column.getColumn().setWidth(200);
+		column.setLabelProvider(new ExecutionContextLabelProvider(0));
 
-	private void createScopeSlotColumns(TableViewer viewer) {
-		createColumn(viewer, "name", 80, 0);
-		createColumn(viewer, "type", 80, 1);
-		TableViewerColumn valueColumn = createColumn(viewer, "value", 80, 2);
+		TreeViewerColumn valueColumn = new TreeViewerColumn(viewer, SWT.DEFAULT);
+		valueColumn.getColumn().setText("Value");
+		valueColumn.getColumn().setMoveable(true);
+		valueColumn.getColumn().setWidth(100);
 		valueColumn.setEditingSupport(new MultiEditingSupport(viewer,
-				new BooleanEditingSupport(viewer, this),
-				new IntegerEditingSupport(viewer, this),
-				new RealEditingSupport(viewer, this)));
-	}
-
-	@Override
-	public void setFocus() {
-		eventViewer.getTable().setFocus();
+				new BooleanEditingSupport(viewer), new IntegerEditingSupport(
+						viewer), new RealEditingSupport(viewer)));
+		valueColumn.setLabelProvider(new ExecutionContextLabelProvider(1));
+
+		TreeViewerColumn raiseEventColumn = new TreeViewerColumn(viewer,
+				SWT.DEFAULT);
+		raiseEventColumn.getColumn().setText("Raise");
+		raiseEventColumn.getColumn().setMoveable(true);
+		raiseEventColumn.getColumn().setWidth(50);
+		raiseEventColumn.setLabelProvider(new ExecutionContextLabelProvider(0));
+
+		viewer.setContentProvider(new ExecutionContextContentProvider());
+		return viewer;
 	}
 
-	public void setEventViewerInput() {
-		if (activeSession != null) {
-			List<ExecutionEvent> events = activeSession.getExecutionContext()
-					.getDeclaredEvents();
-
-			eventViewer.setInput(events);
-
-			TableItem[] items = eventViewer.getTable().getItems();
-			for (TableItem tableItem : items) {
-				final TableEditor tableEditor = new TableEditor(
-						eventViewer.getTable());
-				tableEditor.horizontalAlignment = SWT.LEFT;
-				tableEditor.grabHorizontal = true;
-				tableEditor.grabVertical = true;
-				Button button = new Button(eventViewer.getTable(), SWT.FLAT);
-				button.setText("raise");
-				ButtonListener listener = new ButtonListener(
-						tableItem.getText());
-				button.addSelectionListener(listener);
-				tableEditor.setEditor(button, tableItem, 3);
-				tableEditors.put(button, tableEditor);
-				controls.put(button, listener);
-			}
+	public void debugContextChanged(DebugContextEvent event) {
+		if ((event.getFlags() & DebugContextEvent.ACTIVATED) > 0) {
+			PlatformObject object = (PlatformObject) ((IStructuredSelection) event
+					.getContext()).getFirstElement();
+			SCTDebugTarget debugTarget = (SCTDebugTarget) object
+					.getAdapter(IDebugTarget.class);
+			if (!debugTarget.isTerminated())
+				refreshInput(debugTarget);
 		}
+
 	}
 
-	private void setVariableViewerInput() {
-		if (activeSession != null) {
-			List<ExecutionVariable> variables = activeSession
-					.getExecutionContext().getVariables();
-			variableViewer.setInput(variables);
+	public void handleDebugEvents(DebugEvent[] events) {
+		for (DebugEvent debugEvent : events) {
+			handleDebugEvent(debugEvent);
 		}
 	}
 
-	public void clearViewerInput(boolean disposeControls) {
-		// clear the viewer input. This has to be done before the Buttons are
-		// disposed. Otherwise listeners the TableViewer adds to Buttons can't
-		// be removed from them what leads to a memory leak.
-		eventViewer.setInput(null);
-		eventViewer.refresh();
-		variableViewer.setInput(null);
-		eventViewer.refresh();
-
-		for (Control control : controls.keySet()) {
-			if (control instanceof Button) {
-				// Listeners have to be removed manually otherwise the garbage
-				// collector can't cleanup the button
-				if (controls.get(control) != null) {
-					((Button) control).removeSelectionListener(controls
-							.get(control));
-				}
-				// Same for the tableEditor
-				if (tableEditors.get(control) != null) {
-					tableEditors.get(control).dispose();
+	private void handleDebugEvent(DebugEvent debugEvent) {
+		switch (debugEvent.getKind()) {
+		case DebugEvent.TERMINATE:
+			Display.getDefault().asyncExec(new Runnable() {
+				public void run() {
+					viewer.setInput(null);
 				}
-			}
-			if (disposeControls) {
-				control.dispose();
-			}
+			});
+			break;
 		}
-		// if the controls are disposed they are never used again and should not
-		// use memory anymore.
-		controls.clear();
-		tableEditors.clear();
 	}
 
-	// @Override
-	// public void dispose() {
-	// clearViewerInput(false);
-	// super.dispose();
-	// }
-
-	private final class ButtonListener implements SelectionListener {
-
-		private final String eventName;
-
-		public ButtonListener(String eventName) {
-			this.eventName = eventName;
-		}
+	private void refreshInput(SCTDebugTarget debugTarget) {
+		IExecutionFacade facade = (IExecutionFacade) debugTarget
+				.getAdapter(IExecutionFacade.class);
+		viewer.setInput(facade.getExecutionContext());
 
-		public void widgetSelected(SelectionEvent e) {
-			if (activeSession != null) {
-				activeSession.raiseEvent(new ExecutionEvent(eventName));
-			}
-		}
+	}
 
-		public void widgetDefaultSelected(SelectionEvent e) {
-			// Nothing to do
-		}
+	@Override
+	protected void createActions() {
 
 	}
 
-	public void debugContextChanged(DebugContextEvent event) {
-		StructuredSelection strSel = (StructuredSelection) event.getContext();
-		PlatformObject firstElement = (PlatformObject) strSel.getFirstElement();
-		if (firstElement == null) {
-			return;
-		}
-		SimulationSession selectedSession = (SimulationSession) firstElement
-				.getAdapter(SimulationSession.class);
-		if (selectedSession == null
-				|| selectedSession.getCurrentState() == SimulationState.TERMINATED) {
-			activeSession = selectedSession;
-			clearViewerInput(true);
-		}
-		if (!(selectedSession == activeSession) && selectedSession != null) {
-			if (activeSession != null) {
-				activeSession.removeSimulationListener(this);
-				activeSession.getExecutionContext()
-						.removeExecutionContextListener(this);
-			}
-			activeSession = selectedSession;
-			selectedSession.addSimulationListener(this);
-			selectedSession.getExecutionContext().addExecutionContextListener(
-					this);
-			clearViewerInput(true);
-			setEventViewerInput();
-			setVariableViewerInput();
-		}
+	@Override
+	protected String getHelpContextId() {
+		return null;
 	}
 
-	public SimulationSession getActiveSession() {
-		return activeSession;
-	}
+	@Override
+	protected void fillContextMenu(IMenuManager menu) {
 
-	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(true);
-				}
-			});
-			;
-			break;
-		}
 	}
 
-	public void variableDeclared(ExecutionVariable variable) {
-		// Nothing to do
-	}
+	@Override
+	protected void configureToolBar(IToolBarManager tbm) {
 
-	public void eventDeclared(ExecutionEvent event) {
-		// Nothing to do
 	}
 
-	public void eventRaised(ExecutionEvent event) {
-		Display.getDefault().asyncExec(new Runnable() {
-			public void run() {
-				setEventViewerInput();
-			}
-		});
+	public IExecutionContext getExecutionContext() {
+		// TODO Auto-generated method stub
+		return null;
 	}
 
-	public void variableValueChanged(ExecutionVariable variable) {
-		Display.getDefault().asyncExec(new Runnable() {
-			public void run() {
-				setVariableViewerInput();
-			}
-		});
-	}
+	// private TableViewer eventViewer;
+	//
+	// private TableViewer variableViewer;
+	//
+	// private Map<Control, SelectionListener> controls;
+	// private Map<Control, TableEditor> tableEditors;
+	//
+	// //private SimulationSession activeSession;
+	//
+	// public DeclarationView() {
+	// controls = new HashMap<Control, SelectionListener>();
+	// tableEditors = new HashMap<Control, TableEditor>();
+	// }
+	//
+	// @Override
+	// public void init(IViewSite site) throws PartInitException {
+	// super.init(site);
+	// DebugUITools.getDebugContextManager()
+	// .getContextService(site.getWorkbenchWindow())
+	// .addDebugContextListener(this);
+	// }
+	//
+	// @Override
+	// public void createPartControl(Composite parent) {
+	// parent.setLayout(new GridLayout(1, true));
+	// createEventViewer(parent);
+	// createVariableViewer(parent);
+	// }
+	//
+	// private void createVariableViewer(Composite parent) {
+	// variableViewer = createTableViewer(parent);
+	// createScopeSlotColumns(variableViewer);
+	// setVariableViewerInput();
+	// }
+	//
+	// private void createEventViewer(Composite parent) {
+	// eventViewer = createTableViewer(parent);
+	// createScopeSlotColumns(eventViewer);
+	// createColumn(eventViewer, "raise", 50, 3);
+	// setEventViewerInput();
+	// }
+	//
+	// private TableViewer createTableViewer(Composite parent) {
+	// TableViewer viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL
+	// | SWT.V_SCROLL | SWT.FULL_SELECTION);
+	// viewer.getTable().setLinesVisible(true);
+	// viewer.getTable().setHeaderVisible(true);
+	// GridDataFactory.fillDefaults().grab(true, true)
+	// .applyTo(viewer.getTable());
+	// viewer.setContentProvider(new ArrayContentProvider());
+	// return viewer;
+	// }
+	//
+	// private TableViewerColumn createColumn(TableViewer viewer, String text,
+	// int width, int index) {
+	// TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);
+	// column.getColumn().setText(text);
+	// column.getColumn().setWidth(width);
+	// column.getColumn().setResizable(true);
+	// column.getColumn().setMoveable(true);
+	// column.setLabelProvider(new ScopeSlotLabelProvider(index));
+	// return column;
+	// }
+	//
+	// private void createScopeSlotColumns(TableViewer viewer) {
+	// // createColumn(viewer, "name", 80, 0);
+	// // createColumn(viewer, "type", 80, 1);
+	// // TableViewerColumn valueColumn = createColumn(viewer, "value", 80, 2);
+	// // valueColumn.setEditingSupport(new MultiEditingSupport(viewer,
+	// // new BooleanEditingSupport(viewer, this),
+	// // new IntegerEditingSupport(viewer, this),
+	// // new RealEditingSupport(viewer, this)));
+	// }
+	//
+	// @Override
+	// public void setFocus() {
+	// eventViewer.getTable().setFocus();
+	// }
+	//
+	// public void setEventViewerInput() {
+	// // if (activeSession != null) {
+	// // List<ExecutionEvent> events = activeSession.getExecutionContext()
+	// // .getDeclaredEvents();
+	// //
+	// // eventViewer.setInput(events);
+	// //
+	// // TableItem[] items = eventViewer.getTable().getItems();
+	// // for (TableItem tableItem : items) {
+	// // final TableEditor tableEditor = new TableEditor(
+	// // eventViewer.getTable());
+	// // tableEditor.horizontalAlignment = SWT.LEFT;
+	// // tableEditor.grabHorizontal = true;
+	// // tableEditor.grabVertical = true;
+	// // Button button = new Button(eventViewer.getTable(), SWT.FLAT);
+	// // button.setText("raise");
+	// // ButtonListener listener = new ButtonListener(
+	// // tableItem.getText());
+	// // button.addSelectionListener(listener);
+	// // tableEditor.setEditor(button, tableItem, 3);
+	// // tableEditors.put(button, tableEditor);
+	// // controls.put(button, listener);
+	// // }
+	// // }
+	// }
+	//
+	// private void setVariableViewerInput() {
+	// // if (activeSession != null) {
+	// // List<ExecutionVariable> variables = activeSession
+	// // .getExecutionContext().getVariables();
+	// // variableViewer.setInput(variables);
+	// // }
+	// }
+	//
+	// public void clearViewerInput(boolean disposeControls) {
+	// // clear the viewer input. This has to be done before the Buttons are
+	// // disposed. Otherwise listeners the TableViewer adds to Buttons can't
+	// // be removed from them what leads to a memory leak.
+	// eventViewer.setInput(null);
+	// eventViewer.refresh();
+	// variableViewer.setInput(null);
+	// eventViewer.refresh();
+	//
+	// for (Control control : controls.keySet()) {
+	// if (control instanceof Button) {
+	// // Listeners have to be removed manually otherwise the garbage
+	// // collector can't cleanup the button
+	// if (controls.get(control) != null) {
+	// ((Button) control).removeSelectionListener(controls
+	// .get(control));
+	// }
+	// // Same for the tableEditor
+	// if (tableEditors.get(control) != null) {
+	// tableEditors.get(control).dispose();
+	// }
+	// }
+	// if (disposeControls) {
+	// control.dispose();
+	// }
+	// }
+	// // if the controls are disposed they are never used again and should not
+	// // use memory anymore.
+	// controls.clear();
+	// tableEditors.clear();
+	// }
+	//
+	// // @Override
+	// // public void dispose() {
+	// // clearViewerInput(false);
+	// // super.dispose();
+	// // }
+	//
+	// private final class ButtonListener implements SelectionListener {
+	//
+	// private final String eventName;
+	//
+	// public ButtonListener(String eventName) {
+	// this.eventName = eventName;
+	// }
+	//
+	// public void widgetSelected(SelectionEvent e) {
+	// // if (activeSession != null) {
+	// // activeSession.raiseEvent(new ExecutionEvent(eventName));
+	// // }
+	// }
+	//
+	// public void widgetDefaultSelected(SelectionEvent e) {
+	// // Nothing to do
+	// }
+	//
+	// }
+	//
+	// public void debugContextChanged(DebugContextEvent event) {
+	// // StructuredSelection strSel = (StructuredSelection) event.getContext();
+	// // PlatformObject firstElement = (PlatformObject)
+	// strSel.getFirstElement();
+	// // if (firstElement == null) {
+	// // return;
+	// // }
+	// // SimulationSession selectedSession = (SimulationSession) firstElement
+	// // .getAdapter(SimulationSession.class);
+	// // if (selectedSession == null
+	// // || selectedSession.getCurrentState() == SimulationState.TERMINATED) {
+	// // activeSession = selectedSession;
+	// // clearViewerInput(true);
+	// // }
+	// // if (!(selectedSession == activeSession) && selectedSession != null) {
+	// // if (activeSession != null) {
+	// // activeSession.removeSimulationListener(this);
+	// // activeSession.getExecutionContext()
+	// // .removeExecutionContextListener(this);
+	// // }
+	// // activeSession = selectedSession;
+	// // selectedSession.addSimulationListener(this);
+	// // selectedSession.getExecutionContext().addExecutionContextListener(
+	// // this);
+	// // clearViewerInput(true);
+	// // setEventViewerInput();
+	// // setVariableViewerInput();
+	// // }
+	// }
+	// //
+	// // public SimulationSession 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(true);
+	// // }
+	// // });
+	// // ;
+	// // break;
+	// // }
+	// // }
+	//
+	// public void variableDeclared(ExecutionVariable variable) {
+	// // Nothing to do
+	// }
+	//
+	// public void eventDeclared(ExecutionEvent event) {
+	// // Nothing to do
+	// }
+	//
+	// public void eventRaised(ExecutionEvent event) {
+	// Display.getDefault().asyncExec(new Runnable() {
+	// public void run() {
+	// setEventViewerInput();
+	// }
+	// });
+	// }
+	//
+	// public void variableValueChanged(ExecutionVariable variable) {
+	// Display.getDefault().asyncExec(new Runnable() {
+	// public void run() {
+	// setVariableViewerInput();
+	// }
+	// });
+	// }
 }

+ 74 - 0
plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/view/ExecutionContextContentProvider.java

@@ -0,0 +1,74 @@
+package org.yakindu.sct.simulation.ui.view;
+
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.widgets.Display;
+import org.yakindu.sct.simulation.core.runtime.IExecutionContext;
+import org.yakindu.sct.simulation.core.runtime.IExecutionContextListener;
+import org.yakindu.sct.simulation.core.runtime.impl.AbstractSlot;
+import org.yakindu.sct.simulation.core.runtime.impl.ExecutionEvent;
+import org.yakindu.sct.simulation.core.runtime.impl.ExecutionVariable;
+
+import com.google.common.collect.Iterables;
+
+public class ExecutionContextContentProvider implements ITreeContentProvider,
+		IExecutionContextListener {
+
+	private Viewer viewer;
+
+	public void dispose() {
+
+	}
+
+	public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+		this.viewer = viewer;
+		if (oldInput != null) {
+			IExecutionContext oldContext = (IExecutionContext) oldInput;
+			oldContext.removeExecutionContextListener(this);
+		}
+		if (newInput != null) {
+			IExecutionContext newContext = (IExecutionContext) newInput;
+			newContext.addExecutionContextListener(this);
+		}
+	}
+
+	public Object[] getElements(Object inputElement) {
+		if (inputElement == null) {
+			return new Object[] {};
+		}
+		IExecutionContext context = (IExecutionContext) inputElement;
+		Iterable<AbstractSlot> concat = Iterables.concat(
+				context.getDeclaredEvents(), context.getVariables());
+		return Iterables.toArray(concat, Object.class);
+	}
+
+	public Object[] getChildren(Object parentElement) {
+		return null;
+	}
+
+	public Object getParent(Object element) {
+		return null;
+	}
+
+	public boolean hasChildren(Object element) {
+		return false;
+	}
+
+	public void variableDeclared(ExecutionVariable variable) {
+	}
+
+	public void eventDeclared(ExecutionEvent event) {
+	}
+
+	public void eventRaised(ExecutionEvent event) {
+	}
+
+	public void variableValueChanged(ExecutionVariable variable) {
+		Display.getDefault().asyncExec(new Runnable() {
+			public void run() {
+				viewer.refresh();
+			}
+		});
+	}
+
+}

+ 44 - 0
plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/view/ExecutionContextLabelProvider.java

@@ -0,0 +1,44 @@
+package org.yakindu.sct.simulation.ui.view;
+
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.Image;
+import org.yakindu.sct.simulation.core.runtime.impl.AbstractSlot;
+import org.yakindu.sct.simulation.core.runtime.impl.ExecutionEvent;
+
+public class ExecutionContextLabelProvider extends ColumnLabelProvider {
+
+	private final int index;
+
+	public ExecutionContextLabelProvider(int index) {
+		this.index = index;
+	}
+
+	@Override
+	public String getText(Object element) {
+		AbstractSlot abstractSlot = (AbstractSlot) element;
+		switch (index) {
+		case 0:
+			return abstractSlot.getName();
+		case 1:
+			if (abstractSlot.getValue() != null)
+				return abstractSlot.getValue().toString();
+		default:
+			return "";
+		}
+	}
+
+	@Override
+	public Image getImage(Object element) {
+		return super.getImage(element);
+	}
+	
+	@Override
+	public Font getFont(Object element) {
+		if(element instanceof ExecutionEvent){
+			
+		}
+		return super.getFont(element);
+	}
+
+}

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

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

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

@@ -15,7 +15,6 @@ 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
@@ -25,8 +24,8 @@ import org.yakindu.sct.simulation.ui.view.ActiveSessionProvider;
  */
 public class IntegerEditingSupport extends ScopeSlotEditingSupport {
 
-	public IntegerEditingSupport(ColumnViewer viewer,ActiveSessionProvider provider) {
-		super(viewer, provider);
+	public IntegerEditingSupport(ColumnViewer viewer) {
+		super(viewer);
 	}
 
 	@Override

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

@@ -15,7 +15,6 @@ 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.
@@ -25,9 +24,8 @@ import org.yakindu.sct.simulation.ui.view.ActiveSessionProvider;
  */
 public class RealEditingSupport extends ScopeSlotEditingSupport {
 
-	public RealEditingSupport(ColumnViewer viewer,
-			ActiveSessionProvider provider) {
-		super(viewer, provider);
+	public RealEditingSupport(ColumnViewer viewer) {
+		super(viewer);
 	}
 
 	@Override

+ 6 - 10
plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/view/editing/ScopeSlotEditingSupport.java

@@ -11,9 +11,9 @@
 package org.yakindu.sct.simulation.ui.view.editing;
 
 import org.eclipse.jface.viewers.ColumnViewer;
+import org.yakindu.sct.simulation.core.runtime.IExecutionContext;
 import org.yakindu.sct.simulation.core.runtime.impl.AbstractSlot;
 import org.yakindu.sct.simulation.core.runtime.impl.ExecutionVariable;
-import org.yakindu.sct.simulation.ui.view.ActiveSessionProvider;
 
 /**
  * 
@@ -22,16 +22,12 @@ import org.yakindu.sct.simulation.ui.view.ActiveSessionProvider;
  */
 public abstract class ScopeSlotEditingSupport extends PublicEditingSupport {
 
-	private final ActiveSessionProvider provider;
-
 	protected abstract Class<?> getSupportedType();
 
 	protected abstract Object convertValue(Object value);
 
-	public ScopeSlotEditingSupport(ColumnViewer viewer,
-			ActiveSessionProvider provider) {
+	public ScopeSlotEditingSupport(ColumnViewer viewer) {
 		super(viewer);
-		this.provider = provider;
 	}
 
 	@Override
@@ -57,10 +53,10 @@ public abstract class ScopeSlotEditingSupport extends PublicEditingSupport {
 		if (value == null)
 			return;
 		if (element instanceof ExecutionVariable) {
-			provider.getActiveSession()
-					.getExecutionContext()
-					.setVariableValue(((ExecutionVariable) element).getName(),
-							value);
+			IExecutionContext input = (IExecutionContext) getViewer()
+					.getInput();
+			input.setVariableValue(((ExecutionVariable) element).getName(),
+					value);
 		}
 	}
 }