--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.simulation.ui.handlers;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.project.IProject;\r
+import org.simantics.simulation.ontology.SimulationResource;\r
+import org.simantics.simulation.project.IExperimentManager;\r
+import org.simantics.ui.DoubleClickEvent;\r
+import org.simantics.ui.IDoubleClickAction;\r
+import org.simantics.ui.SimanticsUI;\r
+import org.simantics.ui.utils.ResourceAdaptionUtils;\r
+import org.simantics.utils.ui.action.PriorityAction;\r
+\r
+/**\r
+ * A double click action handler for the graph explorer browser. Intended for\r
+ * invocation when an experiment resource is double clicked, which is controlled\r
+ * from outside of this class.\r
+ * \r
+ * @author Tuukka Lehtonen\r
+ * \r
+ * @see ExperimentActivator\r
+ */\r
+public class ActivateExperimentAction implements IDoubleClickAction {\r
+\r
+ @Override\r
+ public void doubleClickEvent(DoubleClickEvent e) throws DatabaseException {\r
+ ReadGraph g = e.getGraph();\r
+ final Resource experiment = ResourceAdaptionUtils.toSingleResource(e.getResource());\r
+ if (experiment == null)\r
+ return;\r
+\r
+ if (g.isInstanceOf(experiment, SimulationResource.getInstance(g).Experiment)) {\r
+ final IProject project = SimanticsUI.getProject();\r
+ if (project == null)\r
+ return;\r
+\r
+ final IExperimentManager experimentManager = project.getHint(IExperimentManager.KEY_EXPERIMENT_MANAGER);\r
+ if (experimentManager != null) {\r
+ e.add(new PriorityAction(PriorityAction.HIGH+10) {\r
+ @Override\r
+ public void run() {\r
+ ExperimentActivator.scheduleActivation(project.getSession(), project, experimentManager, experiment);\r
+ }\r
+ });\r
+ e.consume();\r
+ return;\r
+ } /*else {\r
+ ExperimentUtil.activateExperiment(g, experiment);\r
+ }*/\r
+\r
+ }\r
+ }\r
+\r
+}\r