From 029a1d47fda616411966a9297207860bdd059dda Mon Sep 17 00:00:00 2001 From: lempinen Date: Wed, 13 Nov 2013 13:27:46 +0000 Subject: [PATCH] Improved experiment handling. Now activating a workbench experiment does not destroy simupedia UI completely. It only destroys the experiment. refs #3511 git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@28252 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../ui/handlers/SysdynExperimentActivator.java | 10 ++++++---- .../sysdyn/utils/imports/ImportUtils.java | 18 ++++++++++++------ 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/SysdynExperimentActivator.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/SysdynExperimentActivator.java index 8fa80b3b..f4a52dfb 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/SysdynExperimentActivator.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/SysdynExperimentActivator.java @@ -26,6 +26,7 @@ import org.simantics.db.exception.DatabaseException; import org.simantics.db.request.Read; import org.simantics.message.MessageService; import org.simantics.project.IProject; +import org.simantics.simulation.experiment.ExperimentState; import org.simantics.simulation.experiment.IExperiment; import org.simantics.simulation.model.ExperimentLoadingFailed; import org.simantics.simulation.project.IExperimentActivationListener; @@ -97,10 +98,11 @@ public class SysdynExperimentActivator { monitor.beginTask("Activating experiment", IProgressMonitor.UNKNOWN); try { SysdynExperimentManagerListener.listenManager(manager); - IExperiment experiment = manager.getActiveExperiment(); - if(experiment != null) { - experiment.shutdown(); - } + IExperiment[] experiments = manager.getExperiments(); + for(IExperiment e : experiments) + if(e.getState() != ExperimentState.DISPOSED) + e.shutdown(); + final Semaphore activated = new Semaphore(0); final DataContainer problem = new DataContainer(); manager.startExperiment(experimentResource, new IExperimentActivationListener() { diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/utils/imports/ImportUtils.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/utils/imports/ImportUtils.java index 773e450c..75a83b4b 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/utils/imports/ImportUtils.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/utils/imports/ImportUtils.java @@ -325,9 +325,9 @@ public class ImportUtils { links.add(graph.getURI(link)); if(!links.contains("http://www.semantum.fi/Simupedia-1.0")) { - Resource documentation = graph.getPossibleResource("http://www.semantum.fi/Simupedia-1.0"); - if(documentation != null) - graph.claim(modelRoot, L0.IsLinkedTo, documentation); + Resource simupedia = graph.getPossibleResource("http://www.semantum.fi/Simupedia-1.0"); + if(simupedia != null) + graph.claim(modelRoot, L0.IsLinkedTo, simupedia); } if(!links.contains("http://www.simantics.org/SelectionView-1.2")) { @@ -337,9 +337,15 @@ public class ImportUtils { } if(!links.contains("http://www.semantum.fi/SimupediaWorkbench-1.0")) { - Resource documentWb = graph.getPossibleResource("http://www.semantum.fi/SimupediaWorkbench-1.0"); - if(documentWb != null) - graph.claim(modelRoot, L0.IsLinkedTo, documentWb); + Resource simupediaWb = graph.getPossibleResource("http://www.semantum.fi/SimupediaWorkbench-1.0"); + if(simupediaWb != null) + graph.claim(modelRoot, L0.IsLinkedTo, simupediaWb); + } + + if(!links.contains("http://www.simantics.org/Documentation-1.2")) { + Resource documentation = graph.getPossibleResource("http://www.simantics.org/Documentation-1.2"); + if(documentation != null) + graph.claim(modelRoot, L0.IsLinkedTo, documentation); } } -- 2.47.1