label="Find"\r
style="push">\r
</command>\r
+ <command\r
+ commandId="org.simantics.sysdyn.ui.activateExperiment"\r
+ icon="platform:/plugin/com.famfamfam.silk/icons/control_play_blue.png"\r
+ id="org.simantics.sysdyn.ui.browser.activateExperiment"\r
+ label="Activate Experiment"\r
+ style="push">\r
+ <visibleWhen\r
+ checkEnabled="true">\r
+ <with\r
+ variable="selection">\r
+ <test\r
+ args="org.simantics.sysdyn.ui.browser.nodes.ExperimentNode"\r
+ property="org.simantics.sysdyn.ui.nodeClass">\r
+ </test>\r
+ </with>\r
+ </visibleWhen>\r
+ </command>\r
</menuContribution>\r
<menuContribution\r
locationURI="popup:#SysdynDiagramPopup?after=wbStart">\r
class="org.simantics.sysdyn.ui.handlers.DiagramToolHandler"\r
commandId="org.simantics.sysdyn.ui.diagramTool">\r
</handler>\r
+ <handler\r
+ class="org.simantics.sysdyn.ui.handlers.SysdynExperimentActivator"\r
+ commandId="org.simantics.sysdyn.ui.activateExperiment">\r
+ <activeWhen>\r
+ <with\r
+ variable="selection">\r
+ <or>\r
+ <test\r
+ args="org.simantics.sysdyn.ui.browser.nodes.ExperimentNode"\r
+ property="org.simantics.sysdyn.ui.nodeClass">\r
+ </test>\r
+ </or>\r
+ </with>\r
+ </activeWhen>\r
+ </handler>\r
</extension>\r
<extension\r
point="org.eclipse.ui.importWizards">\r
\r
import java.util.concurrent.Semaphore;\r
\r
+import org.eclipse.core.commands.AbstractHandler;\r
+import org.eclipse.core.commands.ExecutionEvent;\r
+import org.eclipse.core.commands.ExecutionException;\r
import org.eclipse.core.runtime.IProgressMonitor;\r
import org.eclipse.core.runtime.IStatus;\r
import org.eclipse.core.runtime.Status;\r
import org.eclipse.core.runtime.SubMonitor;\r
import org.eclipse.core.runtime.jobs.Job;\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.eclipse.ui.handlers.HandlerUtil;\r
import org.simantics.db.ReadGraph;\r
import org.simantics.db.RequestProcessor;\r
import org.simantics.db.Resource;\r
import org.simantics.simulation.project.IExperimentActivationListener;\r
import org.simantics.simulation.project.IExperimentManager;\r
import org.simantics.sysdyn.ui.listeners.SysdynExperimentManagerListener;\r
+import org.simantics.ui.SimanticsUI;\r
+import org.simantics.ui.utils.ResourceAdaptionUtils;\r
import org.simantics.utils.DataContainer;\r
import org.simantics.utils.ui.ErrorLogger;\r
import org.simantics.utils.ui.ExceptionUtils;\r
import org.simantics.utils.ui.dialogs.ShowMessage;\r
\r
-public class SysdynExperimentActivator {\r
+public class SysdynExperimentActivator extends AbstractHandler {\r
/**\r
* @param project\r
* @param experimentManager\r
}\r
}\r
\r
+ @Override\r
+ public Object execute(ExecutionEvent event) throws ExecutionException {\r
+ ISelection selection = HandlerUtil.getCurrentSelection(event);\r
+ final Resource experiment = ResourceAdaptionUtils.toSingleResource(selection);\r
+ if (experiment == null)\r
+ return null;\r
+\r
+ final IProject project = SimanticsUI.getProject();\r
+ if (project == null)\r
+ return null;\r
+ \r
+ final IExperimentManager experimentManager = project.getHint(IExperimentManager.KEY_EXPERIMENT_MANAGER);\r
+ if (experimentManager == null) {\r
+ ErrorLogger.defaultLogWarning("Experiment manager not available.", new Exception());\r
+ return null;\r
+ }\r
+ \r
+ SysdynExperimentActivator.scheduleActivation(SimanticsUI.getSession(), project, experimentManager, experiment);\r
+ return null;\r
+ }\r
+\r
}\r