]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.document.server/src/org/simantics/document/server/ExperimentStoppedListener.java
Fixed multiple issues causing dangling references to discarded queries
[simantics/platform.git] / bundles / org.simantics.document.server / src / org / simantics / document / server / ExperimentStoppedListener.java
index c6079e2d51ea6d3c8cc9398cba9ce0f39c6ff667..7337ecc906179370f0dc41f0793cef0fc4ac8f89 100644 (file)
@@ -1,50 +1,50 @@
-/*******************************************************************************\r
- * Copyright (c) 2013 Association for Decentralized Information Management in\r
- * Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *     VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.document.server;\r
-\r
-import org.simantics.document.server.serverResponse.DelayedResponse;\r
-import org.simantics.simulation.experiment.ExperimentState;\r
-import org.simantics.simulation.experiment.IExperiment;\r
-import org.simantics.simulation.experiment.IExperimentListener;\r
-\r
-/**\r
- * Listener for listening experiment stopped events. Listener removes itself \r
- * when experiment has first been run and then stopped and notifies response.\r
- * \r
- * @author Teemu Lempinen\r
- *\r
- */\r
-public class ExperimentStoppedListener implements IExperimentListener {\r
-\r
-    private boolean hasRun = false;\r
-    private DelayedResponse response;\r
-    private IExperiment experiment;\r
-\r
-    public ExperimentStoppedListener(IExperiment experiment, DelayedResponse response) {\r
-        this.experiment = experiment;\r
-        this.response = response;\r
-    }\r
-\r
-    @Override\r
-    public void stateChanged(ExperimentState state) {\r
-        if(state.equals(ExperimentState.RUNNING))\r
-            hasRun = true;\r
-\r
-        if(state.equals(ExperimentState.STOPPED) && hasRun) {\r
-            response.setHasRun();\r
-            experiment.removeListener(this);\r
-            synchronized(response) {\r
-                response.notify();\r
-            }\r
-        }\r
-    }\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2013 Association for Decentralized Information Management in
+ * Industry THTH ry.
+ * 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:
+ *     VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+package org.simantics.document.server;
+
+import org.simantics.document.server.serverResponse.DelayedResponse;
+import org.simantics.simulation.experiment.ExperimentState;
+import org.simantics.simulation.experiment.IExperiment;
+import org.simantics.simulation.experiment.IExperimentListener;
+
+/**
+ * Listener for listening experiment stopped events. Listener removes itself 
+ * when experiment has first been run and then stopped and notifies response.
+ * 
+ * @author Teemu Lempinen
+ *
+ */
+public class ExperimentStoppedListener implements IExperimentListener {
+
+    private boolean hasRun = false;
+    private DelayedResponse response;
+    private IExperiment experiment;
+
+    public ExperimentStoppedListener(IExperiment experiment, DelayedResponse response) {
+        this.experiment = experiment;
+        this.response = response;
+    }
+
+    @Override
+    public void stateChanged(ExperimentState state) {
+        if(state.equals(ExperimentState.RUNNING))
+            hasRun = true;
+
+        if(state.equals(ExperimentState.STOPPED) && hasRun) {
+            response.setHasRun();
+            experiment.removeListener(this);
+            synchronized(response) {
+                response.notify();
+            }
+        }
+    }
+}