فهرست منبع

Merge pull request #241 from Yakindu/issue_simulation

Issue simulation
Andreas Mülder 9 سال پیش
والد
کامیت
891feb42e9
13فایلهای تغییر یافته به همراه198 افزوده شده و 559 حذف شده
  1. 0 12
      examples/org.yakindu.sct.ui.examples/plugin.xml
  2. 34 1
      plugins/org.yakindu.base.gmf.runtime/src/org/yakindu/base/gmf/runtime/highlighting/HighlightingSupportAdapter.java
  3. 2 2
      plugins/org.yakindu.base.gmf.runtime/src/org/yakindu/base/gmf/runtime/highlighting/IHighlightingSupport.java
  4. 3 66
      plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/debugmodel/SCTDebugTarget.java
  5. 0 168
      plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/debugmodel/SCTDebugThread.java
  6. 0 166
      plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/debugmodel/SCTStackFrame.java
  7. 1 1
      plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/model/presenter/DefaultDynamicNotationHandler.java
  8. 2 2
      plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/model/presenter/ExecutionContextVisualizer.java
  9. 1 1
      plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/model/presenter/SCTSourceDisplay.java
  10. 8 8
      plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/model/presenter/SCTSourceDisplayDispatcher.java
  11. 103 96
      plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/view/AbstractDebugTargetView.java
  12. 42 32
      plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/view/ExecutionContextContentProvider.java
  13. 2 4
      plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/view/ExecutionContextViewerFactory.java

+ 0 - 12
examples/org.yakindu.sct.ui.examples/plugin.xml

@@ -18,23 +18,11 @@
 			<description>YAKINDU Statechart Tools examples</description>
 		</wizard>
 	</extension>
-   <!-- org.yakindu.sct.example.lightswitch -->
 	<extension point="org.eclipse.emf.common.ui.examples">
 	  <example wizardID="org.yakindu.sct.examples" pageImage="icons/logo-16.png">
 		 <projectDescriptor name="org.yakindu.sct.examples.lightswitch" contentURI="contents/org.yakindu.sct.examples.lightswitch.zip" description="Lightswitch example from the tutorial section"/>
-	  </example>
-   </extension>
-	<!-- org.yakindu.sct.example.trafficlight -->
-	<extension point="org.eclipse.emf.common.ui.examples">
-	  <example wizardID="org.yakindu.sct.examples" pageImage="icons/logo-16.png">
 		 <projectDescriptor name="org.yakindu.sct.examples.trafficlight" contentURI="contents/org.yakindu.sct.examples.trafficlight.zip" description="Trafficlight example with java generated source code"/>
-	  </example>
-   </extension>
-   <!-- org.yakindu.sct.example.clock -->
-	<extension point="org.eclipse.emf.common.ui.examples">
-	  <example wizardID="org.yakindu.sct.examples" pageImage="icons/logo-16.png">
 		 <projectDescriptor name="org.yakindu.sct.examples.clock" contentURI="contents/org.yakindu.sct.examples.clock.zip" description="Clock example Model without generated source code"/>
 	  </example>
    </extension>
-   
 </plugin>

+ 34 - 1
plugins/org.yakindu.base.gmf.runtime/src/org/yakindu/base/gmf/runtime/highlighting/HighlightingSupportAdapter.java

@@ -11,6 +11,7 @@
 package org.yakindu.base.gmf.runtime.highlighting;
 
 import java.lang.reflect.Method;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -124,7 +125,17 @@ public class HighlightingSupportAdapter implements IHighlightingSupport {
 		if (locked) {
 			throw new IllegalStateException("Editor already locked!");
 		}
+		List<Action> singletonList = new ArrayList<>();
+		singletonList.add(new Action() {
+			@Override
+			public void execute(IHighlightingSupport hs) {
+				lockEditorInternal();
+			}
+		});
+		executeSync(singletonList);
+	}
 
+	private void lockEditorInternal() {
 		setSanityCheckEnablementState(false);
 		for (Object editPart : diagramWorkbenchPart.getDiagramGraphicalViewer().getEditPartRegistry().values()) {
 			if (editPart instanceof IGraphicalEditPart) {
@@ -151,7 +162,17 @@ public class HighlightingSupportAdapter implements IHighlightingSupport {
 		if (!locked) {
 			throw new IllegalStateException("Editor not locked!");
 		}
+		List<Action> singletonList = new ArrayList<>();
+		singletonList.add(new Action() {
+			@Override
+			public void execute(IHighlightingSupport hs) {
+				releaseInternal();
+			}
+		});
+		executeSync(singletonList);
+	}
 
+	protected void releaseInternal() {
 		// restore all elements still being highlighted
 		for (ColorMemento figureState : figureStates.values()) {
 			figureState.restore();
@@ -201,7 +222,7 @@ public class HighlightingSupportAdapter implements IHighlightingSupport {
 		return locked;
 	}
 
-	public void execute(final List<Action> actions) {
+	public void executeAsync(final List<Action> actions) {
 		if (actions != null) {
 
 			Display.getDefault().asyncExec(new Runnable() {
@@ -213,4 +234,16 @@ public class HighlightingSupportAdapter implements IHighlightingSupport {
 			});
 		}
 	}
+	public void executeSync(final List<Action> actions) {
+		if (actions != null) {
+
+			Display.getDefault().syncExec(new Runnable() {
+				public void run() {
+					for (Action a : actions) {
+						a.execute(HighlightingSupportAdapter.this);
+					}
+				}
+			});
+		}
+	}
 }

+ 2 - 2
plugins/org.yakindu.base.gmf.runtime/src/org/yakindu/base/gmf/runtime/highlighting/IHighlightingSupport.java

@@ -32,7 +32,7 @@ public interface IHighlightingSupport {
 
 	void flash(List<? extends EObject> semanticElemesnt, HighlightingParameters parameters, int highlightTime);
 
-	void execute(List<Action> actions);
+	void executeAsync(List<Action> actions);
 
 	public static interface Action {
 		public void execute(IHighlightingSupport hs);
@@ -97,7 +97,7 @@ public interface IHighlightingSupport {
 		}
 
 		@Override
-		public void execute(List<Action> actions) {
+		public void executeAsync(List<Action> actions) {
 		}
 
 		@Override

+ 3 - 66
plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/debugmodel/SCTDebugTarget.java

@@ -10,10 +10,6 @@
  */
 package org.yakindu.sct.simulation.core.debugmodel;
 
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
 import org.eclipse.core.resources.IMarkerDelta;
 import org.eclipse.core.runtime.Assert;
 import org.eclipse.core.runtime.CoreException;
@@ -27,18 +23,12 @@ import org.eclipse.debug.core.model.IMemoryBlock;
 import org.eclipse.debug.core.model.IProcess;
 import org.eclipse.debug.core.model.IStep;
 import org.eclipse.debug.core.model.IThread;
-import org.eclipse.emf.common.notify.Notification;
 import org.eclipse.emf.common.notify.impl.AdapterImpl;
 import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
 import org.yakindu.base.base.NamedElement;
-import org.yakindu.sct.model.sgraph.Region;
-import org.yakindu.sct.model.sgraph.RegularState;
 import org.yakindu.sct.simulation.core.engine.IExecutionControl;
 import org.yakindu.sct.simulation.core.engine.ISimulationEngine;
 import org.yakindu.sct.simulation.core.sruntime.ExecutionContext;
-import org.yakindu.sct.simulation.core.sruntime.SRuntimePackage;
-import org.yakindu.sct.simulation.core.sruntime.util.CrossDocumentContentAdapter;
 
 /**
  * 
@@ -55,7 +45,6 @@ public class SCTDebugTarget extends SCTDebugElement implements IDebugTarget, ISt
 	private boolean suspended = false;
 
 	private final NamedElement element;
-	protected List<SCTDebugThread> threads;
 
 	protected ISimulationEngine engine;
 
@@ -72,15 +61,9 @@ public class SCTDebugTarget extends SCTDebugElement implements IDebugTarget, ISt
 	}
 
 	public void init() {
-		threads = new ArrayList<SCTDebugThread>();
 		executionControl = engine.getExecutionControl();
 		executionControl.init();
 		DebugPlugin.getDefault().getBreakpointManager().addBreakpointListener(this);
-		engine.getExecutionContext().eAdapters().add(updater = createUpdater());
-	}
-
-	protected AdapterImpl createUpdater() {
-		return new UpdateTreeAdapter();
 	}
 
 	public void start() {
@@ -96,40 +79,12 @@ public class SCTDebugTarget extends SCTDebugElement implements IDebugTarget, ISt
 		engine.getExecutionControl().stepForward();
 	}
 
-	public IThread[] getThreads() throws DebugException {
-		// Collect all active regions
-		List<RegularState> activeLeafStates = engine.getExecutionContext().getActiveStates();
-		List<Region> activeRegions = new ArrayList<Region>();
-		for (RegularState vertex : activeLeafStates) {
-			activeRegions.add(vertex.getParentRegion());
-		}
-		synchronized (threads) {
-			// Remove orphaned debug threads
-			Iterator<SCTDebugThread> iterator = threads.iterator();
-			while (iterator.hasNext()) {
-				SCTDebugThread next = iterator.next();
-				if (!activeRegions.contains(next.getElement())) {
-					iterator.remove();
-				}
-			}
-			// Add new debug threads
-			for (Region region : activeRegions) {
-				boolean found = false;
-				for (SCTDebugThread thread : threads) {
-					if (thread.getElement() == region) {
-						found = true;
-					}
-				}
-				if (!found) {
-					threads.add(new SCTDebugThread(this, engine, getResourceString(), region));
-				}
-			}
-			return threads.toArray(new IThread[] {});
-		}
+	public synchronized IThread[] getThreads() throws DebugException {
+		return new IThread[] {};
 	}
 
 	public boolean hasThreads() throws DebugException {
-		return true;
+		return false;
 	}
 
 	public String getName() throws DebugException {
@@ -246,24 +201,6 @@ public class SCTDebugTarget extends SCTDebugElement implements IDebugTarget, ISt
 		return engine;
 	}
 
-	// Fires fireChangeEvents to refresh the DebugUI TreeViewer with the active
-	// states
-	public class UpdateTreeAdapter extends CrossDocumentContentAdapter {
-
-		@Override
-		protected boolean shouldAdapt(EStructuralFeature feature) {
-			return feature == SRuntimePackage.Literals.EXECUTION_CONTEXT__ACTIVE_STATES;
-		}
-
-		@Override
-		public void notifyChanged(Notification notification) {
-			if (notification.getFeature() == SRuntimePackage.Literals.EXECUTION_CONTEXT__ACTIVE_STATES) {
-				fireChangeEvent(DebugEvent.CONTENT);
-			}
-			super.notifyChanged(notification);
-		}
-	}
-
 	public boolean canStepInto() {
 		// Not used
 		return false;

+ 0 - 168
plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/debugmodel/SCTDebugThread.java

@@ -1,168 +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.debugmodel;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.Assert;
-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.base.base.NamedElement;
-import org.yakindu.sct.model.sgraph.RegularState;
-import org.yakindu.sct.model.sgraph.Vertex;
-import org.yakindu.sct.simulation.core.engine.ISimulationEngine;
-
-/**
- * 
- * @author andreas muelder - Initial contribution and API
- * 
- */
-public class SCTDebugThread extends SCTDebugElement implements IThread {
-
-	private final NamedElement element;
-	protected List<SCTStackFrame> stateStack;
-	private Vertex lastActiveState;
-	private ISimulationEngine container;
-
-	public SCTDebugThread(SCTDebugTarget target, ISimulationEngine container, String resourceString,
-			NamedElement element) {
-		super(target, resourceString);
-		Assert.isNotNull(element);
-		this.container = container;
-		this.element = element;
-		stateStack = new ArrayList<SCTStackFrame>();
-	}
-
-	public int getPriority() throws DebugException {
-		return 0;
-	}
-
-	public IStackFrame[] getStackFrames() throws DebugException {
-		List<RegularState> activeLeafStates = container.getExecutionContext().getActiveStates();
-		Vertex activeState = null;
-		for (Vertex vertex : activeLeafStates) {
-			if (vertex.getParentRegion() == element) {
-				activeState = vertex;
-				break;
-			}
-		}
-		synchronized (stateStack) {
-			if (activeState != null && lastActiveState != activeState) {
-				lastActiveState = activeState;
-				EObject container = activeState;
-				stateStack = new ArrayList<SCTStackFrame>();
-				while (container != null) {
-					if (container instanceof RegularState) {
-						stateStack.add(new SCTStackFrame(this, (RegularState) container, getResourceString()));
-					}
-					container = container.eContainer();
-				}
-			}
-			return stateStack.toArray(new IStackFrame[] {});
-		}
-	}
-
-	public boolean hasStackFrames() throws DebugException {
-		return true;
-	}
-
-	public String getName() throws DebugException {
-		return fullQfn(element);
-	}
-
-	public IBreakpoint[] getBreakpoints() {
-		return new IBreakpoint[0];
-	}
-
-	public boolean canResume() {
-		return getDebugTarget().canResume();
-	}
-
-	public boolean canSuspend() {
-		return getDebugTarget().canSuspend();
-	}
-
-	public boolean isSuspended() {
-		return getDebugTarget().isSuspended();
-	}
-
-	public void resume() throws DebugException {
-		getDebugTarget().resume();
-	}
-
-	public void suspend() throws DebugException {
-		getDebugTarget().suspend();
-	}
-
-	public boolean canStepInto() {
-		return false;
-	}
-
-	public boolean canStepOver() {
-		return getDebugTarget().canStepOver();
-	}
-
-	public boolean canStepReturn() {
-		return false;
-	}
-
-	public boolean isStepping() {
-		return getDebugTarget().isStepping();
-	}
-
-	public void stepInto() throws DebugException {
-	}
-
-	public void stepOver() throws DebugException {
-		getDebugTarget().stepOver();
-	}
-
-	public void stepReturn() throws DebugException {
-	}
-
-	public boolean canTerminate() {
-		return getDebugTarget().canTerminate();
-	}
-
-	public boolean isTerminated() {
-		return getDebugTarget().isTerminated();
-	}
-
-	public void terminate() throws DebugException {
-		getDebugTarget().terminate();
-	}
-
-	public IStackFrame getTopStackFrame() throws DebugException {
-		return null;
-	}
-
-	@SuppressWarnings("unchecked")
-	public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
-		if (adapter == ISimulationEngine.class)
-			return container;
-		if (adapter == EObject.class)
-			return element;
-		return super.getAdapter(adapter);
-	}
-
-	public SCTDebugTarget getDebugTarget() {
-		return (SCTDebugTarget) super.getDebugTarget();
-	}
-
-	public NamedElement getElement() {
-		return element;
-	}
-
-}

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

@@ -1,166 +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.debugmodel;
-
-import org.eclipse.debug.core.DebugEvent;
-import org.eclipse.debug.core.DebugException;
-import org.eclipse.debug.core.ILaunch;
-import org.eclipse.debug.core.model.IRegisterGroup;
-import org.eclipse.debug.core.model.IStackFrame;
-import org.eclipse.debug.core.model.IVariable;
-import org.eclipse.emf.ecore.EObject;
-import org.yakindu.base.base.NamedElement;
-
-/**
- * 
- * @author andreas muelder - Initial contribution and API
- * 
- */
-public class SCTStackFrame extends SCTDebugElement implements IStackFrame {
-
-	private final SCTDebugThread thread;
-	private final NamedElement element;
-
-	public SCTStackFrame(SCTDebugThread thread, NamedElement element, String resourceString) {
-		super(thread.getDebugTarget(), resourceString);
-		this.thread = thread;
-		this.element = element;
-	}
-
-	public String getModelIdentifier() {
-		return IDebugConstants.ID_DEBUG_MODEL;
-	}
-
-	public boolean canStepInto() {
-		return thread.canStepInto();
-	}
-
-	public boolean canStepOver() {
-		return thread.canStepOver();
-	}
-
-	public boolean canStepReturn() {
-		return thread.canStepReturn();
-	}
-
-	public boolean isStepping() {
-		return thread.isStepping();
-	}
-
-	public void stepInto() throws DebugException {
-		thread.stepInto();
-	}
-
-	public void stepOver() throws DebugException {
-		thread.stepOver();
-	}
-
-	public void stepReturn() throws DebugException {
-		thread.stepReturn();
-	}
-
-	public boolean canResume() {
-		return thread.canResume();
-	}
-
-	public boolean canSuspend() {
-		return thread.canSuspend();
-	}
-
-	public boolean isSuspended() {
-		return thread.isSuspended();
-	}
-
-	public void resume() throws DebugException {
-		thread.resume();
-		fireEvent(new DebugEvent(this, DebugEvent.RESUME));
-
-	}
-
-	public void suspend() throws DebugException {
-		thread.suspend();
-		fireEvent(new DebugEvent(this, DebugEvent.SUSPEND));
-	}
-
-	public boolean canTerminate() {
-		return thread.canTerminate();
-	}
-
-	public boolean isTerminated() {
-		return thread.isTerminated();
-	}
-
-	public void terminate() throws DebugException {
-		thread.terminate();
-		fireEvent(new DebugEvent(this, DebugEvent.TERMINATE));
-	}
-
-	public SCTDebugThread getThread() {
-		return thread;
-	}
-
-	public IVariable[] getVariables() throws DebugException {
-		return new IVariable[] {};
-	}
-
-	public boolean hasVariables() throws DebugException {
-		return false;
-	}
-
-	public int getLineNumber() throws DebugException {
-		return -1;
-	}
-
-	public int getCharStart() throws DebugException {
-		return -1;
-	}
-
-	public int getCharEnd() throws DebugException {
-		return -1;
-	}
-
-	public String getName() throws DebugException {
-		return fullQfn(element);
-
-	}
-
-	public IRegisterGroup[] getRegisterGroups() throws DebugException {
-		return new IRegisterGroup[] {};
-	}
-
-	public boolean hasRegisterGroups() throws DebugException {
-		return false;
-	}
-
-	public SCTDebugTarget getDebugTarget() {
-		return (SCTDebugTarget) thread.getDebugTarget();
-	}
-
-	public ILaunch getLaunch() {
-		return thread.getLaunch();
-	}
-
-	public String getResourceString() {
-		return element.eResource().getURI().toPlatformString(true);
-	}
-
-	@SuppressWarnings("unchecked")
-	public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
-		if (adapter == EObject.class)
-			return element;
-		return super.getAdapter(adapter);
-	}
-
-	public NamedElement getElement() {
-		return element;
-	}
-
-}

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

@@ -48,7 +48,7 @@ public class DefaultDynamicNotationHandler extends AbstractDynamicNotationHandle
 		actions.add(new IHighlightingSupport.Flash(context.getExecutedElements(), HighlightingParameters.DEFAULT,
 				FLASHTIME));
 		actions.add(new IHighlightingSupport.Highlight(context.getExecutedElements(), SUSPENDED_PARAMS));
-		getHighlightingSupport().execute(actions);
+		getHighlightingSupport().executeAsync(actions);
 	}
 
 	@Override

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

@@ -90,7 +90,7 @@ public class ExecutionContextVisualizer extends CrossDocumentContentAdapter {
 				}
 			}
 		}
-		getHighlightingSupport().execute(actions);
+		getHighlightingSupport().executeAsync(actions);
 	}
 
 	protected void highlight(final Notification notification, HighlightingParameters params) {
@@ -103,7 +103,7 @@ public class ExecutionContextVisualizer extends CrossDocumentContentAdapter {
 			List<EObject> objects = toList(notification.getOldValue());
 			actions.add(new IHighlightingSupport.Highlight(objects, null));
 		}
-		getHighlightingSupport().execute(actions);
+		getHighlightingSupport().executeAsync(actions);
 	}
 
 	@SuppressWarnings("unchecked")

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

@@ -90,7 +90,7 @@ public class SCTSourceDisplay implements ISourceDisplay {
 		handler.clear();
 	}
 
-	private IEditorPart openEditor(DebugElement debugElement, IWorkbenchPage page) {
+	public IEditorPart openEditor(DebugElement debugElement, IWorkbenchPage page) {
 		EObject semanticObject = (EObject) debugElement.getAdapter(EObject.class);
 		IFile file = (IFile) debugElement.getAdapter(IFile.class);
 		if (file == null)

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

@@ -48,16 +48,16 @@ public class SCTSourceDisplayDispatcher implements ISourceDisplay, IDebugEventSe
 
 	public void displaySource(Object element, IWorkbenchPage page, boolean forceSourceLookup) {
 		SCTDebugTarget newTarget = unwrapTarget(element);
-		if (newTarget == null || activeDebugTarget == newTarget)
+		if (newTarget.getDebugTarget().isTerminated())
 			return;
+		if (newTarget != null && activeDebugTarget != newTarget){
+			if (activeSourceDisplay != null)
+				activeSourceDisplay.terminate();
+			activeSourceDisplay = new SCTSourceDisplay(
+					(ISimulationEngine) newTarget.getAdapter(ISimulationEngine.class));
+		}
+		activeSourceDisplay.displaySource(newTarget, page, forceSourceLookup);
 		activeDebugTarget = newTarget;
-		if (activeDebugTarget.getDebugTarget().isTerminated())
-			return;
-		if (activeSourceDisplay != null)
-			activeSourceDisplay.terminate();
-		activeSourceDisplay = new SCTSourceDisplay(
-				(ISimulationEngine) activeDebugTarget.getAdapter(ISimulationEngine.class));
-		activeSourceDisplay.displaySource(activeDebugTarget, page, forceSourceLookup);
 	}
 
 	protected SCTDebugTarget unwrapTarget(Object element) {

+ 103 - 96
plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/view/AbstractDebugTargetView.java

@@ -1,96 +1,103 @@
-/**
- * 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.eclipse.core.runtime.IAdaptable;
-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.DebugUITools;
-import org.eclipse.debug.ui.contexts.DebugContextEvent;
-import org.eclipse.debug.ui.contexts.IDebugContextListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.part.ViewPart;
-
-/**
- * Base {@link ViewPart} implementation for all views that are related to the
- * current selected debug target.
- * 
- * @author andreas muelder - Initial contribution and API
- * 
- */
-public abstract class AbstractDebugTargetView extends ViewPart implements IDebugContextListener, IDebugEventSetListener {
-
-	protected IDebugTarget debugTarget;
-
-	protected abstract void activeTargetChanged(IDebugTarget target);
-
-	protected abstract void handleDebugEvent(DebugEvent event);
-
-	public AbstractDebugTargetView() {
-		registerListeners();
-	}
-
-	protected void registerListeners() {
-		DebugUITools.getDebugContextManager().addDebugContextListener(this);
-		DebugPlugin.getDefault().addDebugEventListener(this);
-	}
-
-	@Override
-	public void dispose() {
-		DebugUITools.getDebugContextManager().removeDebugContextListener(this);
-		DebugPlugin.getDefault().removeDebugEventListener(this);
-		super.dispose();
-	}
-
-	@Override
-	public void createPartControl(Composite parent) {
-		setActiveSession();
-	}
-
-	protected void setActiveSession() {
-		// if a simulation session is running, we should initialize with its
-		// content
-		IAdaptable debugContext = DebugUITools.getDebugContext();
-		if (debugContext != null) {
-			IDebugTarget debugTarget = (IDebugTarget) debugContext.getAdapter(IDebugTarget.class);
-			if (debugTarget != null) {
-				if (!debugTarget.isTerminated()) {
-					this.debugTarget = (IDebugTarget) debugTarget;
-					activeTargetChanged(this.debugTarget);
-				}
-			}
-		}
-	}
-
-	public void debugContextChanged(DebugContextEvent event) {
-		if ((event.getFlags() & DebugContextEvent.ACTIVATED) > 0) {
-			PlatformObject object = (PlatformObject) ((IStructuredSelection) event.getContext()).getFirstElement();
-			if (object == null)
-				return;
-			IDebugTarget newTarget = (IDebugTarget) object.getAdapter(IDebugTarget.class);
-			if (newTarget != debugTarget && newTarget != null && !newTarget.isTerminated()) {
-				debugTarget = newTarget;
-				activeTargetChanged(newTarget);
-			}
-		}
-
-	}
-
-	public final void handleDebugEvents(DebugEvent[] events) {
-		for (DebugEvent debugEvent : events) {
-			handleDebugEvent(debugEvent);
-		}
-	}
-}
+/**
+ * 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.eclipse.core.runtime.IAdaptable;
+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.Launch;
+import org.eclipse.debug.core.model.IDebugTarget;
+import org.eclipse.debug.ui.DebugUITools;
+import org.eclipse.debug.ui.contexts.DebugContextEvent;
+import org.eclipse.debug.ui.contexts.IDebugContextListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.part.ViewPart;
+
+/**
+ * Base {@link ViewPart} implementation for all views that are related to the
+ * current selected debug target.
+ * 
+ * @author andreas muelder - Initial contribution and API
+ * 
+ */
+public abstract class AbstractDebugTargetView extends ViewPart
+		implements IDebugContextListener, IDebugEventSetListener {
+
+	protected IDebugTarget debugTarget;
+
+	protected abstract void activeTargetChanged(IDebugTarget target);
+
+	protected abstract void handleDebugEvent(DebugEvent event);
+
+	public AbstractDebugTargetView() {
+		registerListeners();
+	}
+
+	protected void registerListeners() {
+		DebugUITools.getDebugContextManager().addDebugContextListener(this);
+		DebugPlugin.getDefault().addDebugEventListener(this);
+	}
+
+	@Override
+	public void dispose() {
+		DebugUITools.getDebugContextManager().removeDebugContextListener(this);
+		DebugPlugin.getDefault().removeDebugEventListener(this);
+		super.dispose();
+	}
+
+	@Override
+	public void createPartControl(Composite parent) {
+		setActiveSession();
+	}
+
+	protected void setActiveSession() {
+		// if a simulation session is running, we should initialize with its
+		// content
+		IAdaptable debugContext = DebugUITools.getDebugContext();
+		if (debugContext != null) {
+			IDebugTarget debugTarget = (IDebugTarget) debugContext.getAdapter(IDebugTarget.class);
+			if (debugTarget != null) {
+				if (!debugTarget.isTerminated()) {
+					this.debugTarget = (IDebugTarget) debugTarget;
+					activeTargetChanged(this.debugTarget);
+				}
+			}
+		}
+	}
+
+	public void debugContextChanged(DebugContextEvent event) {
+		if ((event.getFlags() & DebugContextEvent.ACTIVATED) > 0) {
+			PlatformObject object = (PlatformObject) ((IStructuredSelection) event.getContext()).getFirstElement();
+			if (object == null)
+				return;
+			IDebugTarget newTarget = null;
+			if (object instanceof Launch) {
+				newTarget = ((Launch) object).getDebugTarget();
+			} else {
+				newTarget = (IDebugTarget) object.getAdapter(IDebugTarget.class);
+			}
+			if (newTarget != debugTarget && newTarget != null && !newTarget.isTerminated()) {
+				debugTarget = newTarget;
+				activeTargetChanged(newTarget);
+			}
+		}
+
+	}
+
+	public final void handleDebugEvents(DebugEvent[] events) {
+		for (DebugEvent debugEvent : events) {
+			handleDebugEvent(debugEvent);
+		}
+	}
+}

+ 42 - 32
plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/view/ExecutionContextContentProvider.java

@@ -10,8 +10,6 @@
  */
 package org.yakindu.sct.simulation.ui.view;
 
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.ecore.util.EContentAdapter;
 import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.jface.util.IPropertyChangeListener;
 import org.eclipse.jface.util.PropertyChangeEvent;
@@ -20,7 +18,6 @@ import org.eclipse.jface.viewers.Viewer;
 import org.eclipse.swt.widgets.Display;
 import org.yakindu.sct.simulation.core.sruntime.CompositeSlot;
 import org.yakindu.sct.simulation.core.sruntime.ExecutionContext;
-import org.yakindu.sct.simulation.core.sruntime.SRuntimePackage;
 import org.yakindu.sct.simulation.ui.SimulationActivator;
 import org.yakindu.sct.simulation.ui.view.actions.HideTimeEventsAction;
 
@@ -31,12 +28,48 @@ import org.yakindu.sct.simulation.ui.view.actions.HideTimeEventsAction;
  */
 public class ExecutionContextContentProvider implements ITreeContentProvider, IPropertyChangeListener {
 
+	protected class ViewerRefresher implements Runnable {
+
+		private static final int UPDATE_INTERVAL = 500;
+
+		private boolean cancel = false;
+
+		@Override
+		public void run() {
+			while (!cancel && viewer.getInput() != null) {
+				try {
+					Thread.sleep(UPDATE_INTERVAL);
+					Display.getDefault().asyncExec(new Runnable() {
+						public void run() {
+							if (viewer != null && !viewer.getControl().isDisposed() && shouldUpdate)
+								viewer.refresh();
+						}
+					});
+				} catch (InterruptedException e) {
+					e.printStackTrace();
+				}
+			}
+
+		}
+
+		public boolean isCancel() {
+			return cancel;
+		}
+
+		public void setCancel(boolean cancel) {
+			this.cancel = cancel;
+		}
+
+	}
+
+	private boolean shouldUpdate = true;
+	private ViewerRefresher refresher;
 	private Viewer viewer;
-	protected RefreshAdapter refreshAdapter = new RefreshAdapter();
-	protected boolean shouldUpdate = true;
 
 	public void dispose() {
 		getStore().removePropertyChangeListener(this);
+		if (refresher != null)
+			refresher.cancel = true;
 	}
 
 	public ExecutionContextContentProvider() {
@@ -45,13 +78,11 @@ public class ExecutionContextContentProvider implements ITreeContentProvider, IP
 
 	public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
 		this.viewer = viewer;
-		if (oldInput != null) {
-			ExecutionContext oldContext = (ExecutionContext) oldInput;
-			oldContext.eAdapters().remove(refreshAdapter);
-		}
+		refresher = new ViewerRefresher();
 		if (newInput != null) {
-			ExecutionContext newContext = (ExecutionContext) newInput;
-			newContext.eAdapters().add(refreshAdapter);
+			new Thread(refresher).start();
+		} else {
+			refresher.cancel = true;
 		}
 	}
 
@@ -94,8 +125,6 @@ public class ExecutionContextContentProvider implements ITreeContentProvider, IP
 				viewer.refresh();
 		}
 	}
-	
-	
 
 	public boolean isShouldUpdate() {
 		return shouldUpdate;
@@ -105,23 +134,4 @@ public class ExecutionContextContentProvider implements ITreeContentProvider, IP
 		this.shouldUpdate = shouldUpdate;
 	}
 
-
-
-	protected final class RefreshAdapter extends EContentAdapter {
-		@Override
-		public void notifyChanged(final Notification notification) {
-			if (notification.getFeature() == SRuntimePackage.Literals.EXECUTION_SLOT__VALUE
-					|| notification.getFeature() == SRuntimePackage.Literals.EXECUTION_EVENT__RAISED
-					|| notification.getFeature() == SRuntimePackage.Literals.EXECUTION_EVENT__SCHEDULED
-					|| notification.getFeature() == SRuntimePackage.Literals.COMPOSITE_SLOT__SLOTS)
-				Display.getDefault().asyncExec(new Runnable() {
-					public void run() {
-						if (viewer != null && !viewer.getControl().isDisposed() && shouldUpdate)
-							viewer.refresh();
-					}
-				});
-
-			super.notifyChanged(notification);
-		}
-	}
 }

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

@@ -61,14 +61,12 @@ public class ExecutionContextViewerFactory {
 				.addEditorActivationListener(new ColumnViewerEditorActivationListener() {
 					@Override
 					public void afterEditorDeactivated(ColumnViewerEditorDeactivationEvent event) {
-						contentProvider.shouldUpdate = true;
+						contentProvider.setShouldUpdate(true);
 						viewer.refresh();
-
 					}
-
 					@Override
 					public void afterEditorActivated(ColumnViewerEditorActivationEvent event) {
-						contentProvider.shouldUpdate = false;
+						contentProvider.setShouldUpdate(false);
 
 					}