Преглед изворни кода

Reference slot are referencing execution slots and not only composite slots.

Thomas Kutz пре 9 година
родитељ
комит
5066b578bb

+ 1 - 0
plugins/org.yakindu.sct.simulation.core.sexec/src/org/yakindu/sct/simulation/core/sexec/container/AbstractExecutionFlowSimulationEngine.java

@@ -64,6 +64,7 @@ public abstract class AbstractExecutionFlowSimulationEngine implements ISimulati
 		try {
 			interpreter.runCycle();
 		} catch (Exception e) {
+			e.printStackTrace();
 			handleException(e);
 		}
 	}

+ 1 - 1
plugins/org.yakindu.sct.simulation.core/model/sruntime.ecore

@@ -50,6 +50,6 @@
   </eClassifiers>
   <eClassifiers xsi:type="ecore:EDataType" name="JavaObject" instanceClassName="java.lang.Object"/>
   <eClassifiers xsi:type="ecore:EClass" name="ReferenceSlot" eSuperTypes="#//CompositeSlot">
-    <eStructuralFeatures xsi:type="ecore:EReference" name="reference" eType="#//CompositeSlot"/>
+    <eStructuralFeatures xsi:type="ecore:EReference" name="reference" eType="#//ExecutionSlot"/>
   </eClassifiers>
 </ecore:EPackage>

+ 4 - 4
plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/sruntime/ReferenceSlot.java

@@ -18,10 +18,10 @@ package org.yakindu.sct.simulation.core.sruntime;
  *
  * <p>
  * The following features are supported:
+ * </p>
  * <ul>
  *   <li>{@link org.yakindu.sct.simulation.core.sruntime.ReferenceSlot#getReference <em>Reference</em>}</li>
  * </ul>
- * </p>
  *
  * @see org.yakindu.sct.simulation.core.sruntime.SRuntimePackage#getReferenceSlot()
  * @model
@@ -37,12 +37,12 @@ public interface ReferenceSlot extends CompositeSlot {
 	 * </p>
 	 * <!-- end-user-doc -->
 	 * @return the value of the '<em>Reference</em>' reference.
-	 * @see #setReference(CompositeSlot)
+	 * @see #setReference(ExecutionSlot)
 	 * @see org.yakindu.sct.simulation.core.sruntime.SRuntimePackage#getReferenceSlot_Reference()
 	 * @model
 	 * @generated
 	 */
-	CompositeSlot getReference();
+	ExecutionSlot getReference();
 
 	/**
 	 * Sets the value of the '{@link org.yakindu.sct.simulation.core.sruntime.ReferenceSlot#getReference <em>Reference</em>}' reference.
@@ -52,6 +52,6 @@ public interface ReferenceSlot extends CompositeSlot {
 	 * @see #getReference()
 	 * @generated
 	 */
-	void setReference(CompositeSlot value);
+	void setReference(ExecutionSlot value);
 
 } // ReferenceSlot

+ 22 - 11
plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/sruntime/impl/ReferenceSlotImpl.java

@@ -27,10 +27,10 @@ import org.yakindu.sct.simulation.core.sruntime.SRuntimePackage;
  * <!-- end-user-doc -->
  * <p>
  * The following features are implemented:
+ * </p>
  * <ul>
  *   <li>{@link org.yakindu.sct.simulation.core.sruntime.impl.ReferenceSlotImpl#getReference <em>Reference</em>}</li>
  * </ul>
- * </p>
  *
  * @generated
  */
@@ -43,7 +43,7 @@ public class ReferenceSlotImpl extends CompositeSlotImpl implements ReferenceSlo
 	 * @generated
 	 * @ordered
 	 */
-	protected CompositeSlot reference;
+	protected ExecutionSlot reference;
 
 	/**
 	 * <!-- begin-user-doc -->
@@ -69,10 +69,10 @@ public class ReferenceSlotImpl extends CompositeSlotImpl implements ReferenceSlo
 	 * <!-- end-user-doc -->
 	 * @generated
 	 */
-	public CompositeSlot getReference() {
+	public ExecutionSlot getReference() {
 		if (reference != null && reference.eIsProxy()) {
 			InternalEObject oldReference = (InternalEObject)reference;
-			reference = (CompositeSlot)eResolveProxy(oldReference);
+			reference = (ExecutionSlot)eResolveProxy(oldReference);
 			if (reference != oldReference) {
 				if (eNotificationRequired())
 					eNotify(new ENotificationImpl(this, Notification.RESOLVE, SRuntimePackage.REFERENCE_SLOT__REFERENCE, oldReference, reference));
@@ -86,7 +86,7 @@ public class ReferenceSlotImpl extends CompositeSlotImpl implements ReferenceSlo
 	 * <!-- end-user-doc -->
 	 * @generated
 	 */
-	public CompositeSlot basicGetReference() {
+	public ExecutionSlot basicGetReference() {
 		return reference;
 	}
 
@@ -95,8 +95,8 @@ public class ReferenceSlotImpl extends CompositeSlotImpl implements ReferenceSlo
 	 * <!-- end-user-doc -->
 	 * @generated
 	 */
-	public void setReference(CompositeSlot newReference) {
-		CompositeSlot oldReference = reference;
+	public void setReference(ExecutionSlot newReference) {
+		ExecutionSlot oldReference = reference;
 		reference = newReference;
 		if (eNotificationRequired())
 			eNotify(new ENotificationImpl(this, Notification.SET, SRuntimePackage.REFERENCE_SLOT__REFERENCE, oldReference, reference));
@@ -126,7 +126,7 @@ public class ReferenceSlotImpl extends CompositeSlotImpl implements ReferenceSlo
 	public void eSet(int featureID, Object newValue) {
 		switch (featureID) {
 			case SRuntimePackage.REFERENCE_SLOT__REFERENCE:
-				setReference((CompositeSlot)newValue);
+				setReference((ExecutionSlot)newValue);
 				return;
 		}
 		super.eSet(featureID, newValue);
@@ -141,7 +141,7 @@ public class ReferenceSlotImpl extends CompositeSlotImpl implements ReferenceSlo
 	public void eUnset(int featureID) {
 		switch (featureID) {
 			case SRuntimePackage.REFERENCE_SLOT__REFERENCE:
-				setReference((CompositeSlot)null);
+				setReference((ExecutionSlot)null);
 				return;
 		}
 		super.eUnset(featureID);
@@ -166,10 +166,21 @@ public class ReferenceSlotImpl extends CompositeSlotImpl implements ReferenceSlo
 	 */
 	@Override
 	public List<ExecutionSlot> getSlots() {
-		if (getReference() != null) {
-			return getReference().getSlots();
+		if (getReference() != null && getReference() instanceof CompositeSlot) {
+			return ((CompositeSlot)getReference()).getSlots();
 		}
 		return super.getSlots();
 	}
+	
+	/**
+	 * @generated NOT
+	 */
+	@Override
+	public Object getValue() {
+		if (getReference() != null) {
+			return getReference().getValue();
+		}
+		return super.getValue();
+	}
 
 } //ReferenceSlotImpl

+ 3 - 3
plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/sruntime/impl/SRuntimePackageImpl.java

@@ -19,6 +19,7 @@ import org.eclipse.emf.ecore.EPackage;
 import org.eclipse.emf.ecore.EReference;
 import org.eclipse.emf.ecore.impl.EPackageImpl;
 import org.yakindu.base.base.BasePackage;
+import org.yakindu.base.types.TypesPackage;
 import org.yakindu.sct.model.sgraph.SGraphPackage;
 import org.yakindu.sct.simulation.core.sruntime.CompositeSlot;
 import org.yakindu.sct.simulation.core.sruntime.EventDirection;
@@ -141,7 +142,6 @@ public class SRuntimePackageImpl extends EPackageImpl implements SRuntimePackage
 
 		// Initialize simple dependencies
 		SGraphPackage.eINSTANCE.eClass();
-		org.yakindu.base.types.TypesPackage.eINSTANCE.eClass();
 
 		// Create package meta-data objects
 		theSRuntimePackage.createPackageContents();
@@ -433,7 +433,7 @@ public class SRuntimePackageImpl extends EPackageImpl implements SRuntimePackage
 		// Obtain other dependent packages
 		BasePackage theBasePackage = (BasePackage)EPackage.Registry.INSTANCE.getEPackage(BasePackage.eNS_URI);
 		SGraphPackage theSGraphPackage = (SGraphPackage)EPackage.Registry.INSTANCE.getEPackage(SGraphPackage.eNS_URI);
-		org.yakindu.base.types.TypesPackage theTypesPackage = (org.yakindu.base.types.TypesPackage)EPackage.Registry.INSTANCE.getEPackage(org.yakindu.base.types.TypesPackage.eNS_URI);
+		TypesPackage theTypesPackage = (TypesPackage)EPackage.Registry.INSTANCE.getEPackage(TypesPackage.eNS_URI);
 
 		// Create type parameters
 
@@ -493,7 +493,7 @@ public class SRuntimePackageImpl extends EPackageImpl implements SRuntimePackage
 		initEReference(getCompositeSlot_Slots(), this.getExecutionSlot(), null, "slots", null, 0, -1, CompositeSlot.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
 
 		initEClass(referenceSlotEClass, ReferenceSlot.class, "ReferenceSlot", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
-		initEReference(getReferenceSlot_Reference(), this.getCompositeSlot(), null, "reference", null, 0, 1, ReferenceSlot.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+		initEReference(getReferenceSlot_Reference(), this.getExecutionSlot(), null, "reference", null, 0, 1, ReferenceSlot.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
 
 		// Initialize enums and add enum literals
 		initEEnum(eventDirectionEEnum, EventDirection.class, "EventDirection");

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

@@ -19,6 +19,7 @@ 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.core.sruntime.ReferenceSlot;
 import org.yakindu.sct.simulation.ui.SimulationImages;
 
 /**
@@ -48,7 +49,16 @@ public class ExecutionContextLabelProvider extends StyledCellLabelProvider {
 
 	private void updateValueCell(ViewerCell cell) {
 		Object element = cell.getElement();
-		if (element instanceof ExecutionSlot) {
+		if (element instanceof ReferenceSlot) {
+			ReferenceSlot refSlot = (ReferenceSlot) element;
+			String label = "";
+			if (refSlot.getReference() != null) {
+				String refFqn = refSlot.getReference().getFqName();
+				Object refValue = refSlot.getReference().getValue();
+				label = refValue != null ? refFqn + " = " + refValue : refFqn;
+			}
+			cell.setText(label);
+		} else if (element instanceof ExecutionSlot) {
 			Object value = ((ExecutionSlot) element).getValue();
 			if (value != null) {
 				if (((ExecutionSlot) element).getType().getOriginType() instanceof EnumerationType) {

+ 5 - 1
plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/view/editing/EnumerationEditingSupport.java

@@ -73,7 +73,11 @@ public class EnumerationEditingSupport extends ScopeSlotEditingSupport {
 		if (element instanceof ExecutionSlot) {
 			if (!((ExecutionSlot) element).isWritable())
 				return false;
-			Type type = ((ExecutionSlot) element).getType().getOriginType();
+			
+			Type type = ((ExecutionSlot) element).getType();
+			if (type != null) {
+				type = type.getOriginType();
+			}
 			return type instanceof EnumerationType;
 		}
 		return false;