]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Experiments folder is not adaptable to resource anymore (because there is no such...
authorjplaine <jplaine@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Tue, 14 Sep 2010 09:44:58 +0000 (09:44 +0000)
committerjplaine <jplaine@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Tue, 14 Sep 2010 09:44:58 +0000 (09:44 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@17899 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewExperimentNodeHandler.java
org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynModel.java

index 93354fe2725aefc016d738be82d8902a756f4e8e..65b35e4830b44eaadd0ee998116d6d16d435955f 100644 (file)
@@ -12,8 +12,9 @@ import org.simantics.db.common.request.WriteRequest;
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.layer0.utils.direct.GraphUtils;\r
 import org.simantics.simulation.ontology.SimulationResource;\r
+import org.simantics.sysdyn.ui.browser.nodes.ExperimentsFolder;\r
 import org.simantics.ui.SimanticsUI;\r
-import org.simantics.ui.utils.ResourceAdaptionUtils;\r
+import org.simantics.ui.utils.AdaptionUtils;\r
 \r
 public class NewExperimentNodeHandler extends AbstractHandler {\r
 \r
@@ -22,11 +23,12 @@ public class NewExperimentNodeHandler extends AbstractHandler {
         System.out.println("New Experiment");\r
 \r
         ISelection sel = HandlerUtil.getCurrentSelection(event);\r
-        Resource[] resources = ResourceAdaptionUtils.toResources(sel);\r
-        if (resources.length != 1)\r
+        \r
+        ExperimentsFolder node = AdaptionUtils.adaptToSingle(sel, ExperimentsFolder.class);\r
+        if (node == null)\r
             return null;\r
 \r
-        final Resource model = resources[0];\r
+        final Resource model = node.data;\r
 \r
         SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
 \r
index ec01a1c64d0bf6a0080905e712c1157d00616cf8..0866565e32ccc4dbf5902f2a5d62b8fa8890999b 100644 (file)
@@ -59,7 +59,7 @@ import org.simantics.sysdyn.representation.expressions.ParameterExpression;
 \r
 /**\r
  * Maintains a Java representation of system dynamic model.\r
- * @author Hannu Niemistö\r
+ * @author Hannu Niemist\r
  */\r
 public class SysdynModel implements IMappingListener, IModel {\r
 \r
@@ -382,10 +382,12 @@ public class SysdynModel implements IMappingListener, IModel {
                SysdynExperiment exp = new SysdynExperiment(experiment, configurationResource);\r
                try {\r
                        exp.init(g);\r
-                       listener.onExperimentActivated(exp);\r
+                       if(listener != null)\r
+                               listener.onExperimentActivated(exp);\r
                        return exp;\r
                } catch(Exception e) {\r
-                       listener.onFailure(e);\r
+                       if(listener != null)\r
+                               listener.onFailure(e);\r
                        return null;\r
                }\r
        }\r