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.cleverphl.menu.CleverPHLAction;
27: import jacareto.system.Environment;
28: import jacareto.toolkit.EnhancedHashtable;
29: import jacareto.toolkit.HashtableException;
30:
31: import java.awt.Insets;
32:
33: import javax.swing.JToolBar;
34:
35: /**
36: * A cleverphl tool bar.
37: *
38: * @author <a href="mailto:cspannagel@web.de">Christian Spannagel</a>
39: * @version 1.0
40: */
41: public class CleverPHLToolBar extends JToolBar {
42: /**
43: * Creates a new toolbar.
44: *
45: * @param env the environment
46: * @param orientation the orientation of the toolbar
47: * @param key the customization key
48: * @param menuBar the menu bar which knows the actions
49: */
50: public CleverPHLToolBar(Environment env, int orientation,
51: String key, CleverPHLMenuBar menuBar) {
52: super (orientation);
53: createToolBar(env, key, menuBar);
54: setMargin(new Insets(1, 1, 1, 1));
55: }
56:
57: /**
58: * Creates the toolbar.
59: *
60: * @param env the environment
61: * @param key the customization key
62: * @param menuBar the menu bar which knows the actions
63: */
64: private void createToolBar(Environment env, String key,
65: CleverPHLMenuBar menuBar) {
66: EnhancedHashtable map = env.getCustomization().getMap(
67: key + ".Items", new EnhancedHashtable());
68:
69: for (int i = 0; i < map.size(); i++) {
70: try {
71: CleverPHLAction action = (CleverPHLAction) menuBar
72: .getAction(map.getString("" + i));
73: add(new CleverPHLButton(action));
74: } catch (HashtableException h) {
75: env
76: .getLogger()
77: .debug(
78: env
79: .getLanguage()
80: .getString(
81: "CleverPHL.Frame.Msg.ToolBarCreationProblem")
82: + " " + i);
83: }
84: }
85: }
86: }
|