]> gerrit.simantics Code Review - simantics/sysdyn.git/blob
75cc05acf24ee1f216da76da1015c5866d2950b7
[simantics/sysdyn.git] /
1 package org.simantics.sysdyn.ui.handlers.simulationPlayback;\r
2 \r
3 import org.eclipse.core.commands.AbstractHandler;\r
4 import org.eclipse.core.commands.ExecutionEvent;\r
5 import org.eclipse.core.commands.ExecutionException;\r
6 import org.simantics.simulation.experiment.IExperiment;\r
7 import org.simantics.simulation.project.IExperimentManager;\r
8 import org.simantics.sysdyn.manager.SysdynPlaybackExperiment;\r
9 import org.simantics.sysdyn.ui.utils.HandlerUtils;\r
10 import org.simantics.ui.SimanticsUI;\r
11 \r
12 public class PlaybackReloadHandler extends AbstractHandler {\r
13 \r
14     @Override\r
15     public Object execute(ExecutionEvent event) throws ExecutionException {\r
16         HandlerUtils.saveBeforeExperimentRun(event);\r
17         \r
18         IExperimentManager manager = SimanticsUI.getProject().getHint(IExperimentManager.KEY_EXPERIMENT_MANAGER);\r
19         IExperiment experiment = manager.getActiveExperiment();\r
20         if(experiment == null || !(experiment instanceof SysdynPlaybackExperiment)) \r
21             return null;\r
22         SysdynPlaybackExperiment spe = (SysdynPlaybackExperiment)experiment;\r
23         spe.simulate(true);\r
24         return null;\r
25     }\r
26 \r
27 }\r