01: /*
02: * Jacareto Copyright (c) 2002-2005
03: * Applied Computer Science Research Group, Darmstadt University of
04: * Technology, Institute of Mathematics & Computer Science,
05: * Ludwigsburg University of Education, and Computer Based
06: * Learning Research Group, Aachen University. All rights reserved.
07: *
08: * Jacareto is free software; you can redistribute it and/or
09: * modify it under the terms of the GNU General Public
10: * License as published by the Free Software Foundation; either
11: * version 2 of the License, or (at your option) any later version.
12: *
13: * Jacareto is distributed in the hope that it will be useful,
14: * but WITHOUT ANY WARRANTY; without even the implied warranty of
15: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16: * General Public License for more details.
17: *
18: * You should have received a copy of the GNU General Public
19: * License along with Jacareto; if not, write to the Free
20: * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21: *
22: */
23:
24: package jacareto.cleverphl.gui;
25:
26: import jacareto.comp.manipulation.ManipulationManagement;
27: import jacareto.comp.manipulation.ManipulationManagementEvent;
28: import jacareto.comp.manipulation.ManipulationManagementListener;
29: import jacareto.system.Environment;
30:
31: /**
32: * A cleverphl tool bar.
33: *
34: * @author <a href="mailto:cspannagel@web.de">Christian Spannagel</a>
35: * @version 1.0
36: */
37: public class ManipulationToolBar extends CleverPHLToolBar implements
38: ManipulationManagementListener {
39: /** The manipulation management. */
40: private ManipulationManagement manipulationManagement;
41:
42: /**
43: * Creates a new manipulation toolbar.
44: *
45: * @param env the environment
46: * @param orientation the orientation of the toolbar
47: * @param menuBar the menu bar which knows the actions
48: */
49: public ManipulationToolBar(Environment env, int orientation,
50: CleverPHLMenuBar menuBar) {
51: super (env, orientation, "CleverPHL.SideBar.MainFrame", menuBar);
52: }
53:
54: /**
55: * Sets the manipulation management.
56: *
57: * @param manipulationManagement the new management
58: */
59: public void setManipulationManagement(
60: ManipulationManagement manipulationManagement) {
61: if (this .manipulationManagement != null) {
62: this .manipulationManagement
63: .removeManipulationManagementListener(this );
64: }
65:
66: this .manipulationManagement = manipulationManagement;
67: this .manipulationManagement
68: .addManipulationManagementListener(this );
69: applyToManipulationMode();
70: }
71:
72: /**
73: * Returns the manipulation management.
74: *
75: * @return the actual manipulation management.
76: */
77: public ManipulationManagement getManipulationManagement() {
78: return manipulationManagement;
79: }
80:
81: /**
82: * Called when the state of the manipulation management has changed
83: *
84: * @param event the event
85: */
86: public void manipulationManagementChanged(
87: ManipulationManagementEvent event) {
88: applyToManipulationMode();
89: }
90:
91: private void applyToManipulationMode() {
92: int mode = manipulationManagement.getMode();
93:
94: for (int i = 0; i < 3; i++) {
95: ((CleverPHLButton) getComponentAtIndex(i))
96: .setSelected(i == mode);
97: }
98: }
99: }
|