1 /*******************************************************************************
\r
2 * Copyright (c) 2007, 2011 Association for Decentralized Information Management in
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.sysdyn.ui.handlers.simulationPlayback;
\r
14 import org.eclipse.core.commands.AbstractHandler;
\r
15 import org.eclipse.ui.PlatformUI;
\r
16 import org.eclipse.ui.commands.ICommandService;
\r
17 import org.simantics.simulation.experiment.IExperiment;
\r
18 import org.simantics.simulation.project.IExperimentManager;
\r
19 import org.simantics.sysdyn.manager.SysdynPlaybackExperiment;
\r
20 import org.simantics.ui.SimanticsUI;
\r
22 abstract class SpeedHandler extends AbstractHandler {
\r
24 protected void setPlaybackSpeed(long duration) {
\r
27 IExperimentManager manager = SimanticsUI.getProject().getHint(IExperimentManager.KEY_EXPERIMENT_MANAGER);
\r
28 IExperiment experiment = manager.getActiveExperiment();
\r
29 if(experiment == null || !(experiment instanceof SysdynPlaybackExperiment))
\r
31 final SysdynPlaybackExperiment spe = (SysdynPlaybackExperiment)experiment;
\r
33 if(spe.getPlaybackDuration() == duration)
\r
37 spe.setPlaybackDuration(duration);
\r
39 PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
\r
43 ICommandService commandService =
\r
44 (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
\r
45 commandService.refreshElements(PlaybackExperimentHandler.COMMAND, null);
\r