X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.document.server%2Fsrc%2Forg%2Fsimantics%2Fdocument%2Fserver%2FExperimentStoppedListener.java;h=7337ecc906179370f0dc41f0793cef0fc4ac8f89;hp=c6079e2d51ea6d3c8cc9398cba9ce0f39c6ff667;hb=ae2e31aa5eb35410e5b2ce222d42421154f3fecc;hpb=969bd23cab98a79ca9101af33334000879fb60c5 diff --git a/bundles/org.simantics.document.server/src/org/simantics/document/server/ExperimentStoppedListener.java b/bundles/org.simantics.document.server/src/org/simantics/document/server/ExperimentStoppedListener.java index c6079e2d5..7337ecc90 100644 --- a/bundles/org.simantics.document.server/src/org/simantics/document/server/ExperimentStoppedListener.java +++ b/bundles/org.simantics.document.server/src/org/simantics/document/server/ExperimentStoppedListener.java @@ -1,50 +1,50 @@ -/******************************************************************************* - * 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(); - } - } - } -} +/******************************************************************************* + * 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(); + } + } + } +}