]> gerrit.simantics Code Review - simantics/3d.git/blob - org.simantics.proconf.g3d/src/org/simantics/proconf/g3d/animation/ui/AnimationControlCreator.java
Set copyright texts for java files in the latest development branches.
[simantics/3d.git] / org.simantics.proconf.g3d / src / org / simantics / proconf / g3d / animation / ui / AnimationControlCreator.java
1 /*******************************************************************************\r
2  * Copyright (c) 2007- VTT Technical Research Centre of Finland.\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
7  *\r
8  * Contributors:\r
9  *     VTT Technical Research Centre of Finland - initial API and implementation\r
10  *******************************************************************************/\r
11 package org.simantics.proconf.g3d.animation.ui;\r
12 \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
18 \r
19 \r
20 \r
21 public class AnimationControlCreator {\r
22         \r
23         private AnimationSystem animationSystem;\r
24         \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
29         }\r
30         \r
31         public Action createStopAction() {\r
32                 return new StopAction();\r
33         }\r
34         \r
35         public Action createPauseAction() {\r
36                 return new PauseAction();\r
37         }\r
38         \r
39         public Action createPlayAction() {\r
40                 return new PlayAction();\r
41         }\r
42         \r
43         private class StopAction extends Action implements AnimationSystemListener {\r
44                 \r
45                 public StopAction() {\r
46                         super();\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
52                 }\r
53                 \r
54                 public void run() {\r
55                         animationSystem.stop();\r
56                 }\r
57                 \r
58                 public void animationAdded(AnimationSystem animationSystem, AnimationController animationController) {\r
59                         this.setEnabled(true);\r
60                 }\r
61                 \r
62                 public void animationPaused(AnimationSystem animationSystem) {\r
63                         this.setEnabled(true);\r
64                 }\r
65                 \r
66                 public void animationPlay(AnimationSystem animationSystem) {\r
67                         this.setEnabled(true);\r
68                 }\r
69                 \r
70                 public void animationStopped(AnimationSystem animationSystem) {\r
71                         this.setEnabled(false);\r
72                 }\r
73         }\r
74         \r
75         private class PlayAction extends Action implements AnimationSystemListener {\r
76                 \r
77                 public PlayAction() {\r
78                         super();\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
84                 }\r
85                 \r
86                 public void run() {\r
87                         animationSystem.play();\r
88                 }\r
89                 \r
90                 public void animationAdded(AnimationSystem animationSystem, AnimationController animationController) {\r
91                         this.setEnabled(animationSystem.isPause());\r
92                 }\r
93                 \r
94                 public void animationPaused(AnimationSystem animationSystem) {\r
95                         this.setEnabled(true);\r
96                 }\r
97                 \r
98                 public void animationPlay(AnimationSystem animationSystem) {\r
99                         this.setEnabled(false);\r
100                 }\r
101                 \r
102                 public void animationStopped(AnimationSystem animationSystem) {\r
103                         this.setEnabled(false);\r
104                 }\r
105         }\r
106         \r
107         private class PauseAction extends Action implements AnimationSystemListener {\r
108                 \r
109                 public PauseAction() {\r
110                         super();\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
116                 }\r
117                 \r
118                 public void run() {\r
119                         animationSystem.pause();\r
120                 }\r
121                 \r
122                 public void animationAdded(AnimationSystem animationSystem, AnimationController animationController) {\r
123                         this.setEnabled(!animationSystem.isPause());\r
124                 }\r
125                 \r
126                 public void animationPaused(AnimationSystem animationSystem) {\r
127                         this.setEnabled(false);\r
128                 }\r
129                 \r
130                 public void animationPlay(AnimationSystem animationSystem) {\r
131                         this.setEnabled(true);\r
132                 }\r
133                 \r
134                 public void animationStopped(AnimationSystem animationSystem) {\r
135                         this.setEnabled(false);\r
136                 }\r
137         }\r
138 \r
139 }\r