1 /*******************************************************************************
\r
2 * Copyright (c) 2007 VTT Technical Research Centre of Finland and others.
\r
3 * All rights reserved. This program and the accompanying materials
\r
4 * are made available under the terms of the Eclipse Public License v1.0
\r
5 * which accompanies this distribution, and is available at
\r
6 * http://www.eclipse.org/legal/epl-v10.html
\r
9 * VTT Technical Research Centre of Finland - initial API and implementation
\r
10 *******************************************************************************/
\r
11 package org.simantics.proconf.g3d.animation.ui;
\r
13 import org.eclipse.jface.action.Action;
\r
14 import org.simantics.proconf.g3d.Activator;
\r
15 import org.simantics.proconf.g3d.animation.AnimationController;
\r
16 import org.simantics.proconf.g3d.animation.AnimationSystem;
\r
17 import org.simantics.proconf.g3d.animation.AnimationSystemListener;
\r
21 public class AnimationControlCreator {
\r
23 private AnimationSystem animationSystem;
\r
25 public AnimationControlCreator(AnimationSystem animationSystem) {
\r
26 if (animationSystem == null)
\r
27 throw new IllegalArgumentException("AnimationSystem must not be null");
\r
28 this.animationSystem = animationSystem;
\r
31 public Action createStopAction() {
\r
32 return new StopAction();
\r
35 public Action createPauseAction() {
\r
36 return new PauseAction();
\r
39 public Action createPlayAction() {
\r
40 return new PlayAction();
\r
43 private class StopAction extends Action implements AnimationSystemListener {
\r
45 public StopAction() {
\r
47 this.setImageDescriptor(Activator.imageDescriptorFromPlugin(Activator.PLUGIN_ID, "icons/silk/control_stop_blue.png"));
\r
48 this.setDisabledImageDescriptor(Activator.imageDescriptorFromPlugin(Activator.PLUGIN_ID, "icons/silk/control_stop.png"));
\r
49 animationSystem.addListener(this);
\r
50 if (!animationSystem.isRunning())
\r
51 this.setEnabled(false);
\r
55 animationSystem.stop();
\r
58 public void animationAdded(AnimationSystem animationSystem, AnimationController animationController) {
\r
59 this.setEnabled(true);
\r
62 public void animationPaused(AnimationSystem animationSystem) {
\r
63 this.setEnabled(true);
\r
66 public void animationPlay(AnimationSystem animationSystem) {
\r
67 this.setEnabled(true);
\r
70 public void animationStopped(AnimationSystem animationSystem) {
\r
71 this.setEnabled(false);
\r
75 private class PlayAction extends Action implements AnimationSystemListener {
\r
77 public PlayAction() {
\r
79 this.setImageDescriptor(Activator.imageDescriptorFromPlugin(Activator.PLUGIN_ID, "icons/silk/control_play_blue.png"));
\r
80 this.setDisabledImageDescriptor(Activator.imageDescriptorFromPlugin(Activator.PLUGIN_ID, "icons/silk/control_play.png"));
\r
81 animationSystem.addListener(this);
\r
82 if (!animationSystem.isPause() || !animationSystem.isRunning())
\r
83 this.setEnabled(false);
\r
87 animationSystem.play();
\r
90 public void animationAdded(AnimationSystem animationSystem, AnimationController animationController) {
\r
91 this.setEnabled(animationSystem.isPause());
\r
94 public void animationPaused(AnimationSystem animationSystem) {
\r
95 this.setEnabled(true);
\r
98 public void animationPlay(AnimationSystem animationSystem) {
\r
99 this.setEnabled(false);
\r
102 public void animationStopped(AnimationSystem animationSystem) {
\r
103 this.setEnabled(false);
\r
107 private class PauseAction extends Action implements AnimationSystemListener {
\r
109 public PauseAction() {
\r
111 this.setImageDescriptor(Activator.imageDescriptorFromPlugin(Activator.PLUGIN_ID, "icons/silk/control_pause_blue.png"));
\r
112 this.setDisabledImageDescriptor(Activator.imageDescriptorFromPlugin(Activator.PLUGIN_ID, "icons/silk/control_pause.png"));
\r
113 animationSystem.addListener(this);
\r
114 if (animationSystem.isPause() || !animationSystem.isRunning())
\r
115 this.setEnabled(false);
\r
118 public void run() {
\r
119 animationSystem.pause();
\r
122 public void animationAdded(AnimationSystem animationSystem, AnimationController animationController) {
\r
123 this.setEnabled(!animationSystem.isPause());
\r
126 public void animationPaused(AnimationSystem animationSystem) {
\r
127 this.setEnabled(false);
\r
130 public void animationPlay(AnimationSystem animationSystem) {
\r
131 this.setEnabled(true);
\r
134 public void animationStopped(AnimationSystem animationSystem) {
\r
135 this.setEnabled(false);
\r