Просмотр исходного кода

Batch execute a List of paint actions to increase performance

Andreas Muelder 10 лет назад
Родитель
Сommit
ad3231a7cf

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

@@ -1,102 +1,109 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.4"?>
-<plugin>
-	<!-- Editor Highlighting Adapter -->
-   <extension
-         point="org.eclipse.core.runtime.adapters">
-      <factory
-            adaptableType="org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.DiagramDocumentEditor"
-            class="org.yakindu.sct.simulation.ui.model.presenter.IHighlightingSupportAdapterFactory">
-         <adapter
-               type="org.yakindu.base.gmf.runtime.highlighting.IHighlightingSupport">
-         </adapter>
-      </factory>
-   </extension>
-	
-<!-- Session Listener -->
- <extension
-       point="org.eclipse.ui.views">
-    <category 
-           id="org.yakindu.sct.category"
-           name="YAKINDU SCT"/>
-    <view
-    	  category="org.yakindu.sct.category"
-          allowMultiple="false"
-          class="org.yakindu.sct.simulation.ui.view.SimulationView"
-          icon="icons/Declarations-View-16.gif"
-          id="org.yakindu.sct.simulation.ui.declarationview"
-          name="Simulation View"
-          restorable="true">
-    </view>
- </extension>
- <extension
-       point="org.eclipse.debug.core.statusHandlers">
-    <statusHandler
-          class="org.yakindu.sct.simulation.ui.handler.GenericStatusHandler"
-          code="200"
-          id="org.yakindu.sct.simulation.ui.statushandler"
-          plugin="org.yakindu.sct.simulation.core">
-    </statusHandler>
- </extension>
-  <extension
-       point="org.eclipse.debug.core.statusHandlers">
-    <statusHandler
-          class="org.yakindu.sct.simulation.ui.handler.TerminateLaunchStatusHandler"
-          code="765"
-          id="org.yakindu.sct.simulation.ui.statushandler"
-          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>
- <extension
-       point="org.eclipse.ui.preferencePages">
-    <page
-          class="org.yakindu.sct.simulation.ui.preferences.SimulationPreferencePage"
-          id="org.yakindu.sct.simulation.ui.preferences.SimulationPreferencePage"
-          name="Simulation"
-          category="org.yakindu.sct.ui.preferences.root">
-    </page>
- </extension>
- <extension
-       point="org.eclipse.core.runtime.preferences">
-    <initializer
-          class="org.yakindu.sct.simulation.ui.preferences.PreferenceInitializer">
-    </initializer>
- </extension>
- <extension
-       point="org.eclipse.ui.startup">
-    <startup
-          class="org.yakindu.sct.simulation.ui.SimulationActivator"></startup>
- </extension>
-    <!-- Decoration Providers -->
-   <extension point="org.eclipse.gmf.runtime.diagram.ui.decoratorProviders"> 
-		<decoratorProvider class="org.yakindu.sct.simulation.ui.view.decorator.HighlightingSubmachineDecorationProvider"> 
-			<Priority name="Medium" />
- 		</decoratorProvider> 
- </extension> 
-</plugin>
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+	<!-- Editor Highlighting Adapter -->
+   <extension
+         point="org.eclipse.core.runtime.adapters">
+      <factory
+            adaptableType="org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.DiagramDocumentEditor"
+            class="org.yakindu.sct.simulation.ui.model.presenter.IHighlightingSupportAdapterFactory">
+         <adapter
+               type="org.yakindu.base.gmf.runtime.highlighting.IHighlightingSupport">
+         </adapter>
+      </factory>
+   </extension>
+	
+<!-- Session Listener -->
+ <extension
+       point="org.eclipse.ui.views">
+    <category 
+           id="org.yakindu.sct.category"
+           name="YAKINDU SCT"/>
+    <view
+    	  category="org.yakindu.sct.category"
+          allowMultiple="false"
+          class="org.yakindu.sct.simulation.ui.view.SimulationView"
+          icon="icons/Declarations-View-16.gif"
+          id="org.yakindu.sct.simulation.ui.declarationview"
+          name="Simulation View"
+          restorable="true">
+    </view>
+ </extension>
+ <extension
+       point="org.eclipse.debug.core.statusHandlers">
+    <statusHandler
+          class="org.yakindu.sct.simulation.ui.handler.GenericStatusHandler"
+          code="200"
+          id="org.yakindu.sct.simulation.ui.statushandler"
+          plugin="org.yakindu.sct.simulation.core">
+    </statusHandler>
+ </extension>
+  <extension
+       point="org.eclipse.debug.core.statusHandlers">
+    <statusHandler
+          class="org.yakindu.sct.simulation.ui.handler.TerminateLaunchStatusHandler"
+          code="765"
+          id="org.yakindu.sct.simulation.ui.statushandler"
+          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>
+     <factory
+          adaptableType="org.eclipse.debug.core.Launch"
+          class="org.yakindu.sct.simulation.ui.model.presenter.SCTSourceDisplayAdapterFactory">
+       <adapter
+             type="org.eclipse.debug.ui.sourcelookup.ISourceDisplay">
+       </adapter>
+    </factory>
+ </extension>
+ <extension
+       point="org.eclipse.ui.preferencePages">
+    <page
+          class="org.yakindu.sct.simulation.ui.preferences.SimulationPreferencePage"
+          id="org.yakindu.sct.simulation.ui.preferences.SimulationPreferencePage"
+          name="Simulation"
+          category="org.yakindu.sct.ui.preferences.root">
+    </page>
+ </extension>
+ <extension
+       point="org.eclipse.core.runtime.preferences">
+    <initializer
+          class="org.yakindu.sct.simulation.ui.preferences.PreferenceInitializer">
+    </initializer>
+ </extension>
+ <extension
+       point="org.eclipse.ui.startup">
+    <startup
+          class="org.yakindu.sct.simulation.ui.SimulationActivator"></startup>
+ </extension>
+    <!-- Decoration Providers -->
+   <extension point="org.eclipse.gmf.runtime.diagram.ui.decoratorProviders"> 
+		<decoratorProvider class="org.yakindu.sct.simulation.ui.view.decorator.HighlightingSubmachineDecorationProvider"> 
+			<Priority name="Medium" />
+ 		</decoratorProvider> 
+ </extension> 
+</plugin>

+ 63 - 17
plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/model/presenter/AbstractDynamicNotationHandler.java

@@ -1,26 +1,83 @@
+/**
+ * Copyright (c) 2012 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 static org.eclipse.draw2d.ColorConstants.darkGreen;
+import static org.eclipse.draw2d.ColorConstants.gray;
+import static org.eclipse.draw2d.ColorConstants.green;
+import static org.yakindu.sct.simulation.ui.preferences.SimulationPreferenceConstants.STATE_BACKGROUND_HIGHLIGHTING_COLOR;
+import static org.yakindu.sct.simulation.ui.preferences.SimulationPreferenceConstants.STATE_FOREGROUND_HIGHLIGHTING_COLOR;
+import static org.yakindu.sct.simulation.ui.preferences.SimulationPreferenceConstants.TRANSITION_HIGHLIGHTING_COLOR;
+import static org.yakindu.sct.simulation.ui.preferences.SimulationPreferenceConstants.VERTEX_BACKGROUND_TRANSIENT_COLOR;
+import static org.yakindu.sct.simulation.ui.preferences.SimulationPreferenceConstants.VERTEX_FOREGROUND_TRANSIENT_COLOR;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceConverter;
 import org.eclipse.jface.util.IPropertyChangeListener;
 import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Display;
+import org.yakindu.base.gmf.runtime.highlighting.HighlightingParameters;
 import org.yakindu.base.gmf.runtime.highlighting.IHighlightingSupport;
 import org.yakindu.sct.simulation.ui.SimulationActivator;
 import org.yakindu.sct.simulation.ui.preferences.SimulationPreferenceConstants;
 
 /**
+ * Color handling from the preference store
+ * 
  * @author andreas muelder - Initial contribution and API
  * 
  */
-public abstract class AbstractDynamicNotationHandler implements
-		IDynamicNotationHandler, IPropertyChangeListener {
+public abstract class AbstractDynamicNotationHandler implements IDynamicNotationHandler, IPropertyChangeListener {
 
-	protected abstract void updatePreferences();
+	public static HighlightingParameters TRANSITION_PARAMS = new HighlightingParameters(darkGreen, gray);
+	public static HighlightingParameters STATE_HIGHLIGHT_PARAMS = HighlightingParameters.DEFAULT;
+	public static HighlightingParameters VERTEX_TRANSIENT_PARAMS = new HighlightingParameters(darkGreen, green);
+	public static HighlightingParameters SUSPENDED_PARAMS = new HighlightingParameters(green,
+			HighlightingParameters.DEFAULT.backgroundFadingColor);
 
+	protected static final IHighlightingSupport NULL_SUPPORT =  new IHighlightingSupport.HighlightingSupportNullImpl();
+	
 	public AbstractDynamicNotationHandler() {
-		SimulationActivator.getDefault().getPreferenceStore()
-				.addPropertyChangeListener(this);
+		SimulationActivator.getDefault().getPreferenceStore().addPropertyChangeListener(this);
+		updatePreferences();
+	}
+
+	private IHighlightingSupport support = new IHighlightingSupport.HighlightingSupportNullImpl();
+
+	public void propertyChange(PropertyChangeEvent event) {
+		if (SimulationPreferenceConstants.STATE_BACKGROUND_HIGHLIGHTING_COLOR.equals(event.getProperty())
+				|| SimulationPreferenceConstants.TRANSITION_HIGHLIGHTING_COLOR.equals(event.getProperty())
+				|| SimulationPreferenceConstants.STATE_FOREGROUND_HIGHLIGHTING_COLOR.equals(event.getProperty())) {
+			updatePreferences();
+		}
 	}
 
-	private IHighlightingSupport support;
+	protected void updatePreferences() {
+		IPreferenceStore store = SimulationActivator.getDefault().getPreferenceStore();
+		// read out the new colors
+		RGB foregroundColor = PreferenceConverter.getColor(store, STATE_FOREGROUND_HIGHLIGHTING_COLOR);
+		RGB backgroundColor = PreferenceConverter.getColor(store, STATE_BACKGROUND_HIGHLIGHTING_COLOR);
+		RGB vertexForegroundColor = PreferenceConverter.getColor(store, VERTEX_FOREGROUND_TRANSIENT_COLOR);
+		RGB vertexBackgroundColor = PreferenceConverter.getColor(store, VERTEX_BACKGROUND_TRANSIENT_COLOR);
+		RGB transitionColor = PreferenceConverter.getColor(store, TRANSITION_HIGHLIGHTING_COLOR);
+
+		// Set the new colors
+		STATE_HIGHLIGHT_PARAMS.foregroundFadingColor = new Color(Display.getDefault(), foregroundColor);
+		STATE_HIGHLIGHT_PARAMS.backgroundFadingColor = new Color(Display.getDefault(), backgroundColor);
+		VERTEX_TRANSIENT_PARAMS.foregroundFadingColor = new Color(Display.getDefault(), vertexForegroundColor);
+		VERTEX_TRANSIENT_PARAMS.backgroundFadingColor = new Color(Display.getDefault(), vertexBackgroundColor);
+		TRANSITION_PARAMS.foregroundFadingColor = new Color(Display.getDefault(), transitionColor);
+	}
 
 	public IHighlightingSupport getHighlightingSupport() {
 		return support;
@@ -29,15 +86,4 @@ public abstract class AbstractDynamicNotationHandler implements
 	public void setHighlightingSupport(IHighlightingSupport support) {
 		this.support = support;
 	}
-
-	public void propertyChange(PropertyChangeEvent event) {
-		if (SimulationPreferenceConstants.STATE_BACKGROUND_HIGHLIGHTING_COLOR
-				.equals(event.getProperty())
-				|| SimulationPreferenceConstants.TRANSITION_HIGHLIGHTING_COLOR
-						.equals(event.getProperty())
-				|| SimulationPreferenceConstants.STATE_FOREGROUND_HIGHLIGHTING_COLOR
-						.equals(event.getProperty())) {
-			updatePreferences();
-		}
-	}
 }

+ 31 - 135
plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/model/presenter/DefaultDynamicNotationHandler.java

@@ -10,37 +10,12 @@
  */
 package org.yakindu.sct.simulation.ui.model.presenter;
 
-import static org.eclipse.emf.common.notify.Notification.ADD;
-import static org.eclipse.emf.common.notify.Notification.ADD_MANY;
-import static org.eclipse.emf.common.notify.Notification.REMOVE;
-import static org.eclipse.emf.common.notify.Notification.REMOVE_MANY;
-import static org.yakindu.sct.simulation.core.sruntime.SRuntimePackage.Literals.EXECUTION_CONTEXT__ACTIVE_STATES;
-import static org.yakindu.sct.simulation.core.sruntime.SRuntimePackage.Literals.EXECUTION_CONTEXT__EXECUTED_ELEMENTS;
-import static org.yakindu.sct.simulation.core.sruntime.SRuntimePackage.Literals.EXECUTION_CONTEXT__SUSPENDED_ELEMENTS;
-import static org.yakindu.sct.simulation.ui.preferences.SimulationPreferenceConstants.STATE_BACKGROUND_HIGHLIGHTING_COLOR;
-import static org.yakindu.sct.simulation.ui.preferences.SimulationPreferenceConstants.STATE_FOREGROUND_HIGHLIGHTING_COLOR;
-import static org.yakindu.sct.simulation.ui.preferences.SimulationPreferenceConstants.TRANSITION_HIGHLIGHTING_COLOR;
-import static org.yakindu.sct.simulation.ui.preferences.SimulationPreferenceConstants.VERTEX_BACKGROUND_TRANSIENT_COLOR;
-import static org.yakindu.sct.simulation.ui.preferences.SimulationPreferenceConstants.VERTEX_FOREGROUND_TRANSIENT_COLOR;
-
+import java.util.ArrayList;
 import java.util.List;
 
-import org.eclipse.draw2d.ColorConstants;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.preference.PreferenceConverter;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.widgets.Display;
 import org.yakindu.base.gmf.runtime.highlighting.HighlightingParameters;
-import org.yakindu.sct.model.sgraph.Vertex;
+import org.yakindu.base.gmf.runtime.highlighting.IHighlightingSupport;
 import org.yakindu.sct.simulation.core.sruntime.ExecutionContext;
-import org.yakindu.sct.simulation.core.sruntime.util.CrossDocumentContentAdapter;
-import org.yakindu.sct.simulation.ui.SimulationActivator;
-
-import com.google.common.collect.Lists;
 
 /**
  * @author andreas muelder - Initial contribution and API
@@ -49,123 +24,44 @@ import com.google.common.collect.Lists;
  */
 public class DefaultDynamicNotationHandler extends AbstractDynamicNotationHandler {
 
-	protected static HighlightingParameters TRANSITION_PARAMS = new HighlightingParameters(0, ColorConstants.darkGreen,
-			ColorConstants.gray, false);
-
-	protected static HighlightingParameters SUSPENDED_PARAMS = new HighlightingParameters(0, ColorConstants.green,
-			HighlightingParameters.DEFAULT.backgroundFadingColor, false);
-
-	ExecutionContextVisualizer visualizer = new ExecutionContextVisualizer();
-
-	protected static HighlightingParameters STATE_HIGHLIGHT_PARAMS = HighlightingParameters.DEFAULT;
+	private static final int FLASHTIME = 500;
 
-	protected static HighlightingParameters VERTEX_TRANSIENT_PARAMS = new HighlightingParameters(0,
-			ColorConstants.darkGreen, ColorConstants.green, false);
+	ExecutionContextVisualizer visualizer = new ExecutionContextVisualizer(NULL_SUPPORT);
 
-	protected ExecutionContext context;
+	protected ExecutionContext currentContext;
 
-	public DefaultDynamicNotationHandler() {
-		updatePreferences();
-	}
-
-	public void updateExecutionContext(ExecutionContext context) {
-		if (this.context != null)
-			this.context.eAdapters().remove(visualizer);
-		this.context = context;
-		restoreNotationState(this.context);
-		this.context.eAdapters().add(visualizer);
+	public void display(ExecutionContext context) {
+		if (this.currentContext != null)
+			this.currentContext.eAdapters().remove(visualizer);
+		this.currentContext = context;
+		restoreNotationState(this.currentContext);
+		this.currentContext.eAdapters().add(visualizer);
 	}
 
+	/**
+	 * highlights the whole execution context, only executed once at the
+	 * beginning.
+	 */
 	protected void restoreNotationState(ExecutionContext context) {
-		for (Vertex vertex : context.getAllActiveStates()) {
-			getHighlightingSupport().fadeIn(vertex, HighlightingParameters.DEFAULT);
-		}
-		List<EObject> executedElements = context.getExecutedElements();
-		for (EObject eObject : executedElements) {
-			getHighlightingSupport().flash(eObject, HighlightingParameters.DEFAULT);
-		}
-
-		List<EObject> suspendedElements = context.getSuspendedElements();
-		for (EObject eObject : suspendedElements) {
-			getHighlightingSupport().fadeIn(eObject, SUSPENDED_PARAMS);
-		}
-
+		List<IHighlightingSupport.Action> actions = new ArrayList<IHighlightingSupport.Action>();
+		actions.add(new IHighlightingSupport.Highlight(context.getAllActiveStates(), HighlightingParameters.DEFAULT));
+		actions.add(new IHighlightingSupport.Flash(context.getExecutedElements(), HighlightingParameters.DEFAULT,
+				FLASHTIME));
+		actions.add(new IHighlightingSupport.Highlight(context.getExecutedElements(), SUSPENDED_PARAMS));
+		getHighlightingSupport().execute(actions);
 	}
 
-	protected class ExecutionContextVisualizer extends CrossDocumentContentAdapter {
-
-		@Override
-		protected boolean shouldAdapt(EStructuralFeature feature) {
-			return feature == EXECUTION_CONTEXT__ACTIVE_STATES || feature == EXECUTION_CONTEXT__EXECUTED_ELEMENTS
-					|| feature == EXECUTION_CONTEXT__SUSPENDED_ELEMENTS;
-		}
-
-		@Override
-		public void notifyChanged(final Notification notification) {
-			super.notifyChanged(notification);
-			Display.getDefault().syncExec(new Runnable() {
-				public void run() {
-					if (notification.getFeature() == EXECUTION_CONTEXT__ACTIVE_STATES) {
-						highlight(notification, HighlightingParameters.DEFAULT);
-					} else if (notification.getFeature() == EXECUTION_CONTEXT__EXECUTED_ELEMENTS) {
-						highlight(notification, TRANSITION_PARAMS);
-					} else if (notification.getFeature() == EXECUTION_CONTEXT__SUSPENDED_ELEMENTS) {
-						highlight(notification, SUSPENDED_PARAMS);
-					}
-				}
-			});
-		}
-
-		protected void highlight(final Notification notification, HighlightingParameters params) {
-			int eventType = notification.getEventType();
-			if (eventType == ADD || eventType == ADD_MANY) {
-				fadeIn(notification.getNewValue(), params);
-			} else if (eventType == REMOVE || eventType == REMOVE_MANY) {
-				fadeOut(notification.getOldValue(), params);
-			}
-		}
-
-		protected void fadeOut(Object value, HighlightingParameters parameters) {
-			List<EObject> objects = toList(value);
-			for (EObject eObject : objects) {
-				getHighlightingSupport().fadeOut(eObject, parameters);
-			}
-		}
-
-		protected void fadeIn(Object value, HighlightingParameters parameters) {
-			List<EObject> objects = toList(value);
-			for (EObject eObject : objects) {
-				getHighlightingSupport().fadeIn(eObject, parameters);
-			}
-		}
-
-		@SuppressWarnings("unchecked")
-		private List<EObject> toList(Object value) {
-			List<EObject> objects = Lists.newArrayList();
-			if (value instanceof EObject) {
-				objects.add((EObject) value);
-			} else if (value instanceof List) {
-				objects.addAll((List<EObject>) value);
-			}
-			return objects;
-		}
-
+	@Override
+	public void terminate() {
+		if (this.currentContext != null)
+			this.currentContext.eAdapters().remove(visualizer);
+		visualizer.setHighlightingSupport(NULL_SUPPORT);
+		setHighlightingSupport(NULL_SUPPORT);
 	}
 
-	protected void updatePreferences() {
-		IPreferenceStore store = SimulationActivator.getDefault().getPreferenceStore();
-		// read out the new colors
-		RGB foregroundColor = PreferenceConverter.getColor(store, STATE_FOREGROUND_HIGHLIGHTING_COLOR);
-		RGB backgroundColor = PreferenceConverter.getColor(store, STATE_BACKGROUND_HIGHLIGHTING_COLOR);
-		RGB vertexForegroundColor = PreferenceConverter.getColor(store, VERTEX_FOREGROUND_TRANSIENT_COLOR);
-		RGB vertexBackgroundColor = PreferenceConverter.getColor(store, VERTEX_BACKGROUND_TRANSIENT_COLOR);
-		RGB transitionColor = PreferenceConverter.getColor(store, TRANSITION_HIGHLIGHTING_COLOR);
-
-		// Set the new colors
-		STATE_HIGHLIGHT_PARAMS.foregroundFadingColor = new Color(Display.getDefault(), foregroundColor);
-		STATE_HIGHLIGHT_PARAMS.backgroundFadingColor = new Color(Display.getDefault(), backgroundColor);
-		VERTEX_TRANSIENT_PARAMS.foregroundFadingColor = new Color(Display.getDefault(), vertexForegroundColor);
-		VERTEX_TRANSIENT_PARAMS.backgroundFadingColor = new Color(Display.getDefault(), vertexBackgroundColor);
-		TRANSITION_PARAMS.foregroundFadingColor = new Color(Display.getDefault(), transitionColor);
+	@Override
+	public void setHighlightingSupport(IHighlightingSupport support) {
+		super.setHighlightingSupport(support);
+		visualizer.setHighlightingSupport(support);
 	}
 }

+ 128 - 0
plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/model/presenter/ExecutionContextVisualizer.java

@@ -0,0 +1,128 @@
+/**
+ * Copyright (c) 2012 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 static org.eclipse.emf.common.notify.Notification.ADD;
+import static org.eclipse.emf.common.notify.Notification.ADD_MANY;
+import static org.eclipse.emf.common.notify.Notification.REMOVE;
+import static org.eclipse.emf.common.notify.Notification.REMOVE_MANY;
+import static org.yakindu.sct.simulation.core.sruntime.SRuntimePackage.Literals.EXECUTION_CONTEXT__ACTIVE_STATES;
+import static org.yakindu.sct.simulation.core.sruntime.SRuntimePackage.Literals.EXECUTION_CONTEXT__EXECUTED_ELEMENTS;
+import static org.yakindu.sct.simulation.core.sruntime.SRuntimePackage.Literals.EXECUTION_CONTEXT__SUSPENDED_ELEMENTS;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.yakindu.base.gmf.runtime.highlighting.HighlightingParameters;
+import org.yakindu.base.gmf.runtime.highlighting.IHighlightingSupport;
+import org.yakindu.sct.model.sgraph.RegularState;
+import org.yakindu.sct.model.sgraph.State;
+import org.yakindu.sct.simulation.core.sruntime.ExecutionContext;
+import org.yakindu.sct.simulation.core.sruntime.util.CrossDocumentContentAdapter;
+
+import com.google.common.collect.Lists;
+
+/**
+ * Observes the {@link ExecutionContext} for semantic changes and visualizes
+ * them using {@link IHighlightingSupport}
+ * 
+ * @author andreas muelder - Initial contribution and API
+ * 
+ */
+public class ExecutionContextVisualizer extends CrossDocumentContentAdapter {
+
+	private IHighlightingSupport highlightingSupport;
+
+	public ExecutionContextVisualizer(IHighlightingSupport support) {
+		highlightingSupport = support;
+	}
+
+	@Override
+	protected boolean shouldAdapt(EStructuralFeature feature) {
+		return feature == EXECUTION_CONTEXT__ACTIVE_STATES || feature == EXECUTION_CONTEXT__EXECUTED_ELEMENTS
+				|| feature == EXECUTION_CONTEXT__SUSPENDED_ELEMENTS;
+	}
+
+	@Override
+	public void notifyChanged(final Notification notification) {
+		super.notifyChanged(notification);
+		if (notification.getFeature() == EXECUTION_CONTEXT__ACTIVE_STATES) {
+			highlightStates(notification, HighlightingParameters.DEFAULT);
+		} else if (notification.getFeature() == EXECUTION_CONTEXT__EXECUTED_ELEMENTS) {
+			highlight(notification, DefaultDynamicNotationHandler.TRANSITION_PARAMS);
+		} else if (notification.getFeature() == EXECUTION_CONTEXT__SUSPENDED_ELEMENTS) {
+			highlight(notification, DefaultDynamicNotationHandler.SUSPENDED_PARAMS);
+		}
+	}
+
+	protected void highlightStates(Notification notification, HighlightingParameters params) {
+		int eventType = notification.getEventType();
+		List<EObject> objects = null;
+		if (eventType == ADD || eventType == ADD_MANY) {
+			objects = toList(notification.getNewValue());
+		} else if (eventType == REMOVE || eventType == REMOVE_MANY) {
+			objects = toList(notification.getOldValue());
+		}
+		List<IHighlightingSupport.Action> actions = new ArrayList<IHighlightingSupport.Action>();
+		for (EObject eObject : objects) {
+			if (eObject instanceof State) {
+				EObject container = eObject;
+				while (container != null) {
+					if (container instanceof RegularState) {
+						if (eventType == ADD || eventType == ADD_MANY) {
+							actions.add(new IHighlightingSupport.Highlight(container, params));
+						} else if (eventType == REMOVE || eventType == REMOVE_MANY) {
+							actions.add(new IHighlightingSupport.Highlight(container, null));
+						}
+					}
+					container = container.eContainer();
+				}
+			}
+		}
+		getHighlightingSupport().execute(actions);
+	}
+
+	protected void highlight(final Notification notification, HighlightingParameters params) {
+		List<IHighlightingSupport.Action> actions = new ArrayList<IHighlightingSupport.Action>();
+		int eventType = notification.getEventType();
+		if (eventType == ADD || eventType == ADD_MANY) {
+			List<EObject> objects = toList(notification.getNewValue());
+			actions.add(new IHighlightingSupport.Highlight(objects, params));
+		} else if (eventType == REMOVE || eventType == REMOVE_MANY) {
+			List<EObject> objects = toList(notification.getOldValue());
+			actions.add(new IHighlightingSupport.Highlight(objects, null));
+		}
+		getHighlightingSupport().execute(actions);
+	}
+
+	@SuppressWarnings("unchecked")
+	private List<EObject> toList(Object value) {
+		List<EObject> objects = Lists.newArrayList();
+		if (value instanceof EObject) {
+			objects.add((EObject) value);
+		} else if (value instanceof List) {
+			objects.addAll((List<EObject>) value);
+		}
+		return objects;
+	}
+
+	public IHighlightingSupport getHighlightingSupport() {
+		return highlightingSupport;
+	}
+
+	public void setHighlightingSupport(IHighlightingSupport highlightingSupport) {
+		this.highlightingSupport = highlightingSupport;
+	}
+
+}

+ 0 - 107
plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/model/presenter/ExecutionPathDynamicNotationHandler.java

@@ -1,107 +0,0 @@
-
-package org.yakindu.sct.simulation.ui.model.presenter;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EObject;
-import org.yakindu.base.gmf.runtime.highlighting.IHighlightingSupport;
-import org.yakindu.base.gmf.runtime.highlighting.IHighlightingSupport.Action;
-import org.yakindu.sct.model.sgraph.RegularState;
-import org.yakindu.sct.simulation.core.sruntime.ExecutionContext;
-
-/**
- * This dynamic notation handler highlight the current states, the previous
- * active states and the execution paths that are the transitions and pseudo
- * states that were taken in the last run to completion step (runCycle).
- * 
- * @author terfloth
- */
-public class ExecutionPathDynamicNotationHandler extends
-		DefaultDynamicNotationHandler {
-
-	/** stores the highlighting actions for the last execution cycle */
-	protected List<Action> cycleUpdates = new ArrayList<Action>();
-
-	protected List<RegularState> active = new ArrayList<RegularState>();
-	protected List<RegularState> previousActive = new ArrayList<RegularState>();
-	protected List<EObject> executionPathElements = new ArrayList<EObject>();
-
-	public void restoreNotationState(ExecutionContext context) {
-		List<Action> actionList = new ArrayList<Action>();
-
-		for (RegularState state : context.getAllActiveStates()) {
-			active.add(state);
-			actionList.add(new IHighlightingSupport.Highlight(state,
-					STATE_HIGHLIGHT_PARAMS));
-		}
-
-		getHighlightingSupport().executeBatch(actionList);
-
-	}
-
-//	public void visualizeStep(final TraceBeginRunCycle trace) {
-//
-//		cycleUpdates.clear();
-//
-//		for (EObject obj : previousActive) {
-//			// remove highlighting of previously active state only if it is not
-//			// currently active (which is the case for self-transitions)
-//			if (!active.contains(obj)) {
-//				cycleUpdates.add(new IHighlightingSupport.Highlight(obj, null));
-//			}
-//		}
-//
-//		previousActive.clear();
-//
-//		for (EObject obj : executionPathElements) {
-//			cycleUpdates.add(new IHighlightingSupport.Highlight(obj, null));
-//		}
-//		executionPathElements.clear();
-//
-//	}
-//
-//	public void visualizeStep(final TraceEndRunCycle trace) {
-//
-//		List<Action> actions = new ArrayList<Action>(cycleUpdates);
-//		getHighlightingSupport().executeBatch(actions);
-//
-//	}
-//
-//	public void visualizeStep(final TraceStateEntered trace) {
-//
-//		active.add((RegularState) trace.getState().getSourceElement());
-//		cycleUpdates.add(new IHighlightingSupport.Highlight(trace.getState()
-//				.getSourceElement(), HighlightingParameters.DEFAULT));
-//
-//	}
-//
-//	public void visualizeStep(final TraceStateExited trace) {
-//
-//		RegularState state = (RegularState) trace.getState().getSourceElement();
-//
-//		active.remove(state);
-//		previousActive.add(state);
-//
-//		cycleUpdates.add(new IHighlightingSupport.Highlight(trace.getState()
-//				.getSourceElement(), VERTEX_TRANSIENT_PARAMS));
-//
-//	}
-//
-//	public void visualizeStep(final ReactionFired trace) {
-//
-//		executionPathElements.add(trace.getReaction().getSourceElement());
-//		cycleUpdates.add(new IHighlightingSupport.Highlight(trace.getReaction()
-//				.getSourceElement(), TRANSITION_PARAMS));
-//
-//	}
-//
-//	public void visualizeStep(final TraceNodeExecuted trace) {
-//
-//		executionPathElements.add(trace.getNode().getSourceElement());
-//		cycleUpdates.add(new IHighlightingSupport.Highlight(trace.getNode()
-//				.getSourceElement(), VERTEX_TRANSIENT_PARAMS));
-//
-//	}
-
-}

+ 40 - 18
plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/model/presenter/IDynamicNotationHandler.java

@@ -1,18 +1,40 @@
-package org.yakindu.sct.simulation.ui.model.presenter;
-
-import org.yakindu.base.gmf.runtime.highlighting.IHighlightingSupport;
-import org.yakindu.sct.simulation.core.sruntime.ExecutionContext;
-
-/**
- * @author andreas muelder - Initial contribution and API
- * 
- */
-public interface IDynamicNotationHandler {
-
-	public void updateExecutionContext(ExecutionContext context);
-
-	public void setHighlightingSupport(IHighlightingSupport support);
-
-	public IHighlightingSupport getHighlightingSupport();
-
-}
+/**
+ * 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.yakindu.base.gmf.runtime.highlighting.IHighlightingSupport;
+import org.yakindu.sct.simulation.core.sruntime.ExecutionContext;
+
+/**
+ * An IDynamicNotationHandler displays highlights the semantic elements using an
+ * {@link IHighlightingSupport}s
+ * 
+ * @author andreas muelder - Initial contribution and API
+ * 
+ */
+public interface IDynamicNotationHandler {
+	/**
+	 * This is called whenever the {@link ExecutionContext} changes, not
+	 * everytime an element from the context changes. Implementations have to
+	 * handle executionContext observing for value changes
+	 */
+	public void display(ExecutionContext context);
+
+	/**
+	 * Called when the simulation terminates, can be used for clean up
+	 */
+	public void terminate();
+
+	public void setHighlightingSupport(IHighlightingSupport support);
+
+	public IHighlightingSupport getHighlightingSupport();
+
+}

+ 56 - 56
plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/model/presenter/IHighlightingSupportAdapterFactory.java

@@ -1,56 +1,56 @@
-/**
- * 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.HashMap;
-import java.util.Map;
-
-import org.eclipse.core.runtime.IAdapterFactory;
-import org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.DiagramDocumentEditor;
-import org.yakindu.base.gmf.runtime.highlighting.HighlightingSupportAdapter;
-import org.yakindu.base.gmf.runtime.highlighting.IHighlightingSupport;
-
-/**
- * Adapts GMF Editors to a {@link IHighlightingSupport}
- * 
- * @author andreas muelder - Initial contribution and API
- * 
- */
-@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) {
-				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;
-	}
-
-	public Class[] getAdapterList() {
-		return new Class[] { IHighlightingSupport.class };
-	}
-
-}
+/**
+ * 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.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.DiagramDocumentEditor;
+import org.yakindu.base.gmf.runtime.highlighting.HighlightingSupportAdapter;
+import org.yakindu.base.gmf.runtime.highlighting.IHighlightingSupport;
+
+/**
+ * Adapts GMF Editors to a {@link IHighlightingSupport}
+ * 
+ * @author andreas muelder - Initial contribution and API
+ * 
+ */
+@SuppressWarnings({ "rawtypes" })
+public class IHighlightingSupportAdapterFactory implements IAdapterFactory {
+
+	private static Map<DiagramDocumentEditor, IHighlightingSupport> cache;
+
+	static {
+		cache = new HashMap<DiagramDocumentEditor, IHighlightingSupport>();
+	}
+
+	@SuppressWarnings("unchecked")
+	public Object getAdapter(Object adaptableObject, Class adapterType) {
+		if (adapterType == IHighlightingSupport.class) {
+			if (adaptableObject instanceof DiagramDocumentEditor) {
+				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;
+	}
+
+	@SuppressWarnings("unchecked")
+	public Class[] getAdapterList() {
+		return new Class[] { IHighlightingSupport.class };
+	}
+
+}

+ 3 - 1
plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/model/presenter/SCTSourceDisplay.java

@@ -75,7 +75,7 @@ public class SCTSourceDisplay implements ISourceDisplay {
 			notationHandler.getHighlightingSupport().releaseEditor();
 		}
 		notationHandler.getHighlightingSupport().lockEditor();
-		notationHandler.updateExecutionContext(container.getExecutionContext());
+		notationHandler.display(container.getExecutionContext());
 	}
 
 	public void terminate() {
@@ -85,6 +85,7 @@ public class SCTSourceDisplay implements ISourceDisplay {
 		for (IDynamicNotationHandler notationHandler : values) {
 			if (notationHandler.getHighlightingSupport().isLocked())
 				notationHandler.getHighlightingSupport().releaseEditor();
+			notationHandler.terminate();
 		}
 		handler.clear();
 	}
@@ -136,4 +137,5 @@ public class SCTSourceDisplay implements ISourceDisplay {
 		// No editor found
 		throw new RuntimeException("No editor found for semantic element " + semanticObject);
 	}
+
 }

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

@@ -22,6 +22,7 @@ public class SCTSourceDisplayAdapterFactory implements IAdapterFactory {
 
 	private static SCTSourceDisplayDispatcher display = new SCTSourceDisplayDispatcher();
 
+	@SuppressWarnings("unchecked")
 	public Object getAdapter(Object adaptableObject, @SuppressWarnings("rawtypes") Class adapterType) {
 		return display;
 	}

+ 27 - 19
plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/model/presenter/SCTSourceDisplayDispatcher.java

@@ -10,13 +10,10 @@
  */
 package org.yakindu.sct.simulation.ui.model.presenter;
 
-import java.util.HashMap;
-import java.util.Map;
-
 import org.eclipse.debug.core.DebugEvent;
 import org.eclipse.debug.core.DebugPlugin;
 import org.eclipse.debug.core.IDebugEventSetListener;
-import org.eclipse.debug.core.model.DebugElement;
+import org.eclipse.debug.core.Launch;
 import org.eclipse.debug.core.model.IDebugTarget;
 import org.eclipse.debug.ui.sourcelookup.ISourceDisplay;
 import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor;
@@ -26,6 +23,8 @@ import org.eclipse.ui.IPartListener;
 import org.eclipse.ui.IWorkbenchPage;
 import org.eclipse.ui.IWorkbenchPart;
 import org.eclipse.ui.PlatformUI;
+import org.yakindu.sct.simulation.core.debugmodel.SCTDebugElement;
+import org.yakindu.sct.simulation.core.debugmodel.SCTDebugTarget;
 import org.yakindu.sct.simulation.core.engine.ISimulationEngine;
 import org.yakindu.sct.ui.editor.partitioning.DiagramEditorInput;
 
@@ -39,29 +38,40 @@ import org.yakindu.sct.ui.editor.partitioning.DiagramEditorInput;
  */
 public class SCTSourceDisplayDispatcher implements ISourceDisplay, IDebugEventSetListener, IPartListener {
 
-	private Map<IDebugTarget, SCTSourceDisplay> target2Display;
 	private SCTSourceDisplay activeSourceDisplay;
-	private DebugElement activeDebugTarget;
+	private SCTDebugTarget activeDebugTarget;
 
 	public SCTSourceDisplayDispatcher() {
-		target2Display = new HashMap<IDebugTarget, SCTSourceDisplay>();
 		DebugPlugin.getDefault().addDebugEventListener(this);
 		PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().addPartListener(this);
 	}
 
 	public void displaySource(Object element, IWorkbenchPage page, boolean forceSourceLookup) {
-		activeDebugTarget = (DebugElement) element;
+		SCTDebugTarget newTarget = unwrapTarget(element);
+		if (newTarget == null || activeDebugTarget == newTarget)
+			return;
+		activeDebugTarget = newTarget;
 		if (activeDebugTarget.getDebugTarget().isTerminated())
 			return;
-		activeSourceDisplay = target2Display.get(activeDebugTarget.getDebugTarget());
-		if (activeSourceDisplay == null) {
-			activeSourceDisplay = new SCTSourceDisplay(
-					(ISimulationEngine) activeDebugTarget.getAdapter(ISimulationEngine.class));
-			target2Display.put(activeDebugTarget.getDebugTarget(), activeSourceDisplay);
-		}
+		if (activeSourceDisplay != null)
+			activeSourceDisplay.terminate();
+		activeSourceDisplay = new SCTSourceDisplay(
+				(ISimulationEngine) activeDebugTarget.getAdapter(ISimulationEngine.class));
 		activeSourceDisplay.displaySource(activeDebugTarget, page, forceSourceLookup);
 	}
 
+	protected SCTDebugTarget unwrapTarget(Object element) {
+		if (element instanceof Launch) {
+			IDebugTarget debugTarget = ((Launch) element).getDebugTarget();
+			if (debugTarget instanceof SCTDebugTarget)
+				return (SCTDebugTarget) debugTarget;
+		} else if (element instanceof SCTDebugElement) {
+			return (SCTDebugTarget) ((SCTDebugElement) element).getDebugTarget();
+		}
+		return null;
+
+	}
+
 	public void handleDebugEvents(DebugEvent[] events) {
 		for (DebugEvent debugEvent : events) {
 			handleDebugEvent(debugEvent);
@@ -80,10 +90,8 @@ public class SCTSourceDisplayDispatcher implements ISourceDisplay, IDebugEventSe
 		Object source = debugEvent.getSource();
 		if (source instanceof IDebugTarget) {
 			IDebugTarget target = (IDebugTarget) source;
-			SCTSourceDisplay sourceDisplay = target2Display.get(target);
-			if (sourceDisplay != null) {
-				sourceDisplay.terminate();
-				target2Display.remove(sourceDisplay);
+			if (target == activeDebugTarget) {
+				activeSourceDisplay.terminate();
 			}
 		}
 	}
@@ -121,7 +129,7 @@ public class SCTSourceDisplayDispatcher implements ISourceDisplay, IDebugEventSe
 
 	@Override
 	public void partDeactivated(IWorkbenchPart part) {
-		//Nothing to do
+		// Nothing to do
 	}
 
 }