1 package org.simantics.modeling.tests.commands;
3 import org.simantics.Simantics;
4 import org.simantics.db.exception.DatabaseException;
5 import org.simantics.db.testing.base.CommandSequenceTest;
6 import org.simantics.db.testing.common.WriteCommand;
7 import org.simantics.project.IProject;
8 import org.simantics.simulation.experiment.IExperiment;
9 import org.simantics.simulation.project.IExperimentManager;
10 import org.simantics.simulation.project.IExperimentManagerListener;
12 public class WaitActiveExperiment extends WriteCommand<CommandSequenceTest> implements IExperimentManagerListener {
17 public void run(CommandSequenceTest environment) throws DatabaseException {
19 IProject project = Simantics.getProject();
20 final IExperimentManager experimentManager = project.getHint(IExperimentManager.KEY_EXPERIMENT_MANAGER);
21 if (experimentManager != null) {
22 IExperiment experiment = experimentManager.getActiveExperiment();
23 if(experiment == null) {
24 experimentManager.addListener(this);
28 // Cannot because of bean comparison
29 //experimentManager.removeListener(this);
32 } catch (Exception e) {
33 throw new DatabaseException(e);
38 public void activeExperimentLoaded(IExperiment experiment) {
43 public void activeExperimentUnloaded() {
47 public void managerDisposed() {