Pārlūkot izejas kodu

[AERI] Log errors during simulation to error log

Andreas Muelder 9 gadi atpakaļ
vecāks
revīzija
46c81fbe0f

+ 6 - 5
plugins/org.yakindu.sct.simulation.core.sexec/src/org/yakindu/sct/simulation/core/sexec/container/AbstractExecutionFlowSimulationEngine.java

@@ -22,7 +22,7 @@ import org.yakindu.base.types.validation.IValidationIssueAcceptor.ValidationIssu
 import org.yakindu.sct.model.sexec.ExecutionFlow;
 import org.yakindu.sct.model.sexec.transformation.IModelSequencer;
 import org.yakindu.sct.model.sgraph.Statechart;
-import org.yakindu.sct.simulation.core.Activator;
+import org.yakindu.sct.simulation.core.SimulationCoreActivator;
 import org.yakindu.sct.simulation.core.engine.IExecutionControl;
 import org.yakindu.sct.simulation.core.engine.ISimulationEngine;
 import org.yakindu.sct.simulation.core.sexec.interpreter.IExecutionFlowInterpreter;
@@ -69,16 +69,17 @@ public abstract class AbstractExecutionFlowSimulationEngine implements ISimulati
 		}
 	}
 
-	private void handleException(Exception e) {
+	protected void handleException(Exception e) {
 		if (e instanceof WrappedException) {
 			WrappedException e1 = (WrappedException)e;
 			handleException(e1.getCause().getMessage(), e1.getCause());
 		} else handleException(e.getMessage(), e);
 	}
 	
-	private void handleException(String message, Throwable t) {
-		Status errorStatus = new Status(Status.ERROR, Activator.PLUGIN_ID, ERROR_DURING_SIMULATION,
+	protected void handleException(String message, Throwable t) {
+		Status errorStatus = new Status(Status.ERROR, SimulationCoreActivator.PLUGIN_ID, ERROR_DURING_SIMULATION,
 				message, t);
+		SimulationCoreActivator.getDefault().getLog().log(errorStatus);
 		IStatusHandler statusHandler = DebugPlugin.getDefault().getStatusHandler(errorStatus);
 		try {
 			statusHandler.handleStatus(errorStatus, getDebugTarget());
@@ -105,7 +106,7 @@ public abstract class AbstractExecutionFlowSimulationEngine implements ISimulati
 		ListBasedValidationIssueAcceptor acceptor = new ListBasedValidationIssueAcceptor();
 		ExecutionFlow flow = sequencer.transform(statechart, acceptor);
 		if (acceptor.getTraces(Severity.ERROR).size() > 0) {
-			Status errorStatus = new Status(Status.ERROR, Activator.PLUGIN_ID, ERROR_DURING_SIMULATION,
+			Status errorStatus = new Status(Status.ERROR, SimulationCoreActivator.PLUGIN_ID, ERROR_DURING_SIMULATION,
 					acceptor.getTraces(Severity.ERROR).iterator().next().toString(), null);
 			IStatusHandler statusHandler = DebugPlugin.getDefault().getStatusHandler(errorStatus);
 			try {

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

@@ -4,7 +4,7 @@ Bundle-Name: YAKINDU Simulation Core
 Bundle-SymbolicName: org.yakindu.sct.simulation.core;singleton:=true
 Bundle-Version: 2.8.1.qualifier
 Bundle-ClassPath: .
-Bundle-Activator: org.yakindu.sct.simulation.core.Activator
+Bundle-Activator: org.yakindu.sct.simulation.core.SimulationCoreActivator
 Bundle-Vendor: statecharts.org
 Bundle-Localization: plugin
 Require-Bundle: org.eclipse.core.runtime,

+ 13 - 8
plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/Activator.java

@@ -10,28 +10,33 @@
 */
 package org.yakindu.sct.simulation.core;
 
+import org.eclipse.core.runtime.Plugin;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
 import org.yakindu.sct.simulation.core.hmr.SCTHotModelReplacementManager;
 
-public class Activator implements BundleActivator {
-
-	private static BundleContext context;
+public class SimulationCoreActivator extends Plugin implements BundleActivator {
 
 	public static final String PLUGIN_ID = "org.yakindu.sct.simulation.core";
 
-	static BundleContext getContext() {
-		return context;
-	}
+	private static SimulationCoreActivator plugin;
+		
 
 	public void start(BundleContext bundleContext) throws Exception {
-		Activator.context = bundleContext;
+		super.start(bundleContext);
+		plugin = this;
 		SCTHotModelReplacementManager.INSTANCE.startup();
+		
 	}
 
 	public void stop(BundleContext bundleContext) throws Exception {
-		Activator.context = null;
+		super.stop(bundleContext);
+		plugin = this;
 		SCTHotModelReplacementManager.INSTANCE.tearDown();
 	}
+	
+	public static SimulationCoreActivator getDefault() {
+		return plugin;
+	}
 
 }