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
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
\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
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