From: jplaine Date: Tue, 14 Sep 2010 09:44:58 +0000 (+0000) Subject: Experiments folder is not adaptable to resource anymore (because there is no such... X-Git-Tag: simantics-1.2.0~50 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=f2a25bd4679d882b62b4b0629fd9893ae1d8ae58;p=simantics%2Fsysdyn.git Experiments folder is not adaptable to resource anymore (because there is no such resource), so the adaption code is changed a bit.. git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@17899 ac1ea38d-2e2b-0410-8846-a27921b304fc --- diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewExperimentNodeHandler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewExperimentNodeHandler.java index 93354fe2..65b35e48 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewExperimentNodeHandler.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewExperimentNodeHandler.java @@ -12,8 +12,9 @@ import org.simantics.db.common.request.WriteRequest; import org.simantics.db.exception.DatabaseException; import org.simantics.layer0.utils.direct.GraphUtils; import org.simantics.simulation.ontology.SimulationResource; +import org.simantics.sysdyn.ui.browser.nodes.ExperimentsFolder; import org.simantics.ui.SimanticsUI; -import org.simantics.ui.utils.ResourceAdaptionUtils; +import org.simantics.ui.utils.AdaptionUtils; public class NewExperimentNodeHandler extends AbstractHandler { @@ -22,11 +23,12 @@ public class NewExperimentNodeHandler extends AbstractHandler { System.out.println("New Experiment"); ISelection sel = HandlerUtil.getCurrentSelection(event); - Resource[] resources = ResourceAdaptionUtils.toResources(sel); - if (resources.length != 1) + + ExperimentsFolder node = AdaptionUtils.adaptToSingle(sel, ExperimentsFolder.class); + if (node == null) return null; - final Resource model = resources[0]; + final Resource model = node.data; SimanticsUI.getSession().asyncRequest(new WriteRequest() { diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynModel.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynModel.java index ec01a1c6..0866565e 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynModel.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynModel.java @@ -59,7 +59,7 @@ import org.simantics.sysdyn.representation.expressions.ParameterExpression; /** * Maintains a Java representation of system dynamic model. - * @author Hannu Niemistö + * @author Hannu Niemist� */ public class SysdynModel implements IMappingListener, IModel { @@ -382,10 +382,12 @@ public class SysdynModel implements IMappingListener, IModel { SysdynExperiment exp = new SysdynExperiment(experiment, configurationResource); try { exp.init(g); - listener.onExperimentActivated(exp); + if(listener != null) + listener.onExperimentActivated(exp); return exp; } catch(Exception e) { - listener.onFailure(e); + if(listener != null) + listener.onFailure(e); return null; } }