1 /*******************************************************************************
2 * Copyright (c) 2013 Association for Decentralized Information Management in
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.document.server;
14 import org.simantics.document.server.serverResponse.DelayedResponse;
15 import org.simantics.simulation.experiment.ExperimentState;
16 import org.simantics.simulation.experiment.IExperiment;
17 import org.simantics.simulation.experiment.IExperimentListener;
20 * Listener for listening experiment stopped events. Listener removes itself
21 * when experiment has first been run and then stopped and notifies response.
23 * @author Teemu Lempinen
26 public class ExperimentStoppedListener implements IExperimentListener {
28 private boolean hasRun = false;
29 private DelayedResponse response;
30 private IExperiment experiment;
32 public ExperimentStoppedListener(IExperiment experiment, DelayedResponse response) {
33 this.experiment = experiment;
34 this.response = response;
38 public void stateChanged(ExperimentState state) {
39 if(state.equals(ExperimentState.RUNNING))
42 if(state.equals(ExperimentState.STOPPED) && hasRun) {
44 experiment.removeListener(this);
45 synchronized(response) {