Browse Source

Refactored Simulation core

Andreas Mülder 12 years ago
parent
commit
3270e25ef0

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

@@ -19,12 +19,14 @@ Require-Bundle: org.eclipse.core.runtime,
 Bundle-RequiredExecutionEnvironment: J2SE-1.5
 Bundle-ActivationPolicy: lazy
 Export-Package: org.yakindu.sct.simulation.core,
+ org.yakindu.sct.simulation.core.debugmodel,
  org.yakindu.sct.simulation.core.engine,
  org.yakindu.sct.simulation.core.hmr,
  org.yakindu.sct.simulation.core.launch,
  org.yakindu.sct.simulation.core.sruntime,
  org.yakindu.sct.simulation.core.sruntime.impl,
- org.yakindu.sct.simulation.core.sruntime.util
+ org.yakindu.sct.simulation.core.sruntime.util,
+ org.yakindu.sct.simulation.core.util
 Import-Package: com.google.inject;version="1.3.0",
  org.eclipse.debug.internal.ui.viewers.model.provisional,
  org.eclipse.emf.edit.ui.provider,

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

@@ -12,52 +12,6 @@
          </adapter>
       </factory>
    </extension>
-	<!-- Launch configuration images -->
-   <extension point="org.eclipse.debug.ui.launchConfigurationTypeImages">
-    	<launchConfigurationTypeImage
-        	icon="icons/Statechart-Launcher-16.png"
-        	configTypeID="org.yakindu.sct.simulation.core.launch.statechart"
-        	id="org.yakindu.sct.core.simulation.launch.statechartTypeImage">
-	    </launchConfigurationTypeImage>
-	</extension>
-	
-	<!-- launch tab group -->
-	<extension point="org.eclipse.debug.ui.launchConfigurationTabGroups">
-  	  <launchConfigurationTabGroup
-    	 type="org.yakindu.sct.simulation.core.launch.statechart"
-  	     class="org.yakindu.sct.simulation.ui.launch.tabs.StatechartLaunchConfigurationTabGroup"
-  	     id="org.yakindu.sct.simulation.ui.launch.tabs.statechart.tabs">
-  	      <launchMode 
-                  mode="debug"
-                  perspective="org.yakindu.sct.ui.SimulationPerspective">
-            </launchMode>
-              <launchMode 
-                  mode="run"
-                  perspective="org.yakindu.sct.ui.SimulationPerspective">
-            </launchMode>
-   	 </launchConfigurationTabGroup>
-	</extension>
-	
-	<!-- launch shortcuts -->
-	<extension point="org.eclipse.debug.ui.launchShortcuts">
-	    <shortcut
-	        id="org.yakindu.sct.core.simulation.launch.shortcut"
-	        class="org.yakindu.sct.simulation.ui.launch.StatechartLaunchShortcut"
-	        label="YAKINDU Statechart"
-	        icon="icons/Statechart-Launcher-16.png"
-	        modes="run, debug">
-	         <contextualLaunch>
-				<enablement>
-					<with variable="selection">
-					<count value="1"/>
-						<iterate>
-							<test property="org.eclipse.debug.ui.matchesPattern" value="*.sct"/>
-						</iterate>
-					</with>
-				</enablement>
-		  	 </contextualLaunch>
-	    </shortcut>
-	</extension>
 	
 <!-- Session Listener -->
  <extension
@@ -130,83 +84,4 @@
           class="org.yakindu.sct.simulation.ui.preferences.PreferenceInitializer">
     </initializer>
  </extension>
- 
- 
- 
- <!-- Toggle breakpoint action -->
-<extension point="org.eclipse.ui.commands">
- 	<command
-       defaultHandler="org.yakindu.sct.simulation.ui.breakpoints.ToggleBreakpointCommand"
-       id="org.yakindu.sct.simulation.ui.breakpoints.ToggleBreakpointCommand"
-       name="Toggle breakpoint">
-	</command>
-</extension>
-
-<extension
-       point="org.eclipse.ui.menus">
-    <menuContribution
-          allPopups="false"
-          locationURI="popup:org.eclipse.gmf.runtime.diagram.ui.DiagramEditorContextMenu">
-          <command
-                commandId="org.yakindu.sct.simulation.ui.breakpoints.ToggleBreakpointCommand"
-                label="Toggle Breakpoint"
-                style="push">
-             <visibleWhen
-                checkEnabled="false">
-             <with
-                   variable="selection">
-                <iterate
-                      ifEmpty="false"
-                      operator="and">
-                      <or>
-                   <!--
-                   <instanceof
-                         value="org.yakindu.sct.ui.editor.editparts.TransitionEditPart">
-                   </instanceof>
-                   -->
-                    <instanceof
-                         value="org.yakindu.sct.ui.editor.editparts.StateEditPart">
-                   </instanceof>
-                   </or>
-                </iterate>
-             </with>
-          </visibleWhen>
-          </command>
-    </menuContribution>
- </extension>
- <!-- Debug Model Presentation -->
-	<extension point = "org.eclipse.debug.ui.debugModelPresentations"> 
-       <debugModelPresentation 
-           class = "org.yakindu.sct.simulation.ui.breakpoints.SCTDebugModelPresentation"
-           id = "org.yakindu.sct.debug.core.breakpoints">
-       </debugModelPresentation> 
-   </extension>  
-  <!-- Breakpoint Decoration Provider -->
-   <extension id="breakpointDecoratorProvider" name="BreakpointDecorations" point="org.eclipse.gmf.runtime.diagram.ui.decoratorProviders">
-      <decoratorProvider class="org.yakindu.sct.simulation.ui.breakpoints.BreakpointDecorationProvider">
-         <Priority name="Medium"/>
-         <object class="org.eclipse.gmf.runtime.diagram.ui.editparts.IPrimaryEditPart(org.eclipse.gmf.runtime.diagram.ui)" id="PRIMARY_VIEW"/>
-         <context decoratorTargets="PRIMARY_VIEW"/>
-      </decoratorProvider>
-   </extension>
-  <!-- Breakpoint Detail Pane factory -->
-  <extension point="org.eclipse.debug.ui.detailPaneFactories">
-       <detailFactories
-             class="org.yakindu.sct.simulation.ui.breakpoints.SCTDetailPaneFactory"
-             id="sctDetailPane">
-             <enablement>
-       		   <with
-                variable="selection">
-             <count
-                   value="1">
-             </count>
-             <iterate>
-                <instanceof
-                      value="org.yakindu.sct.simulation.core.breakpoints.SCTBreakpoint">
-                </instanceof>
-             </iterate>
-          </with>
-       </enablement>
-       </detailFactories>
-</extension>
 </plugin>

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

@@ -0,0 +1,96 @@
+/**
+ * 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);
+		}
+	}
+}

+ 11 - 15
plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/view/ExecutionContextLabelProvider.java

@@ -15,12 +15,11 @@ import org.eclipse.jface.viewers.StyledCellLabelProvider;
 import org.eclipse.jface.viewers.ViewerCell;
 import org.eclipse.swt.custom.StyleRange;
 import org.yakindu.base.types.Enumerator;
-import org.yakindu.sct.simulation.core.runtime.IExecutionContext;
-import org.yakindu.sct.simulation.core.runtime.ISlot;
-import org.yakindu.sct.simulation.core.runtime.impl.ExecutionEvent;
-import org.yakindu.sct.simulation.core.runtime.impl.ExecutionVariable;
+import org.yakindu.sct.simulation.core.sruntime.CompositeSlot;
+import org.yakindu.sct.simulation.core.sruntime.ExecutionEvent;
+import org.yakindu.sct.simulation.core.sruntime.ExecutionSlot;
+import org.yakindu.sct.simulation.core.sruntime.ExecutionVariable;
 import org.yakindu.sct.simulation.ui.SimulationImages;
-import org.yakindu.sct.simulation.ui.view.ExecutionContextContentProvider.Container;
 
 /**
  * 
@@ -49,8 +48,8 @@ public class ExecutionContextLabelProvider extends StyledCellLabelProvider {
 
 	private void updateValueCell(ViewerCell cell) {
 		Object element = cell.getElement();
-		if (element instanceof ISlot) {
-			Object value = ((ISlot) element).getValue();
+		if (element instanceof ExecutionSlot) {
+			Object value = ((ExecutionSlot) element).getValue();
 			if (value != null) {
 				if (value instanceof Enumerator) {
 					cell.setText(((Enumerator) value).getName());
@@ -71,15 +70,12 @@ public class ExecutionContextLabelProvider extends StyledCellLabelProvider {
 			style1.length = event.getName().length();
 			style1.underline = true;
 			style1.foreground = ColorConstants.lightBlue;
-			cell.setText(event.getSimpleName());
+			cell.setText(event.getName());
 			cell.setStyleRanges(new StyleRange[] { style1 });
 			if (event.getName().contains("time_event")) {
 				cell.setImage(SimulationImages.TIMEEVENT.image());
 			} else {
-				IExecutionContext context = (IExecutionContext) getViewer()
-						.getInput();
-				if (context.isEventRaised(event.getName())
-						|| context.isEventScheduled(event.getName())) {
+				if (event.isScheduled()) {
 					cell.setImage(SimulationImages.EVENT_ENABLED.image());
 				} else {
 					cell.setImage(SimulationImages.EVENT_DISABLED.image());
@@ -87,10 +83,10 @@ public class ExecutionContextLabelProvider extends StyledCellLabelProvider {
 			}
 		} else if (element instanceof ExecutionVariable) {
 			ExecutionVariable variable = (ExecutionVariable) element;
-			cell.setText(variable.getSimpleName());
+			cell.setText(variable.getName());
 			cell.setImage(SimulationImages.VARIABLE.image());
-		} else if (element instanceof Container) {
-			cell.setText(((Container) element).name);
+		} else if (element instanceof CompositeSlot) {
+			cell.setText(((CompositeSlot) element).getName());
 			cell.setImage(SimulationImages.SCOPE.image());
 		}
 	}