1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.xnap.gui;
21
22 import java.awt.Component;
23 import java.util.Iterator;
24 import java.util.LinkedList;
25
26 import javax.help.CSH;
27 import javax.swing.JToolBar;
28
29 import org.xnap.gui.action.ActionHelper;
30 import org.xnap.gui.action.PluginDialogAction;
31 import org.xnap.gui.action.PreferencesDialogAction;
32 import org.xnap.gui.action.ShowHotlistAction;
33 import org.xnap.gui.component.XNapToolBarButton;
34 import org.xnap.gui.component.XNapToolBarToggleButton;
35
36 /***
37 * The MainToolBar is shown at the top of the main application window.
38 */
39 public class MainToolBar extends JToolBar
40 {
41
42
43
44
45 /***
46 * A list of components that is added temporarily to this toolbar.
47 */
48 private LinkedList temporaries = new LinkedList();
49
50
51
52 public MainToolBar()
53 {
54 add(new XNapToolBarButton(new PluginDialogAction()));
55 add(new XNapToolBarButton(new PreferencesDialogAction()));
56
57 add(new XNapToolBarButton
58 (ActionHelper.pluginPreferencesDialogAction));
59
60
61
62
63 addSeparator();
64 add(new XNapToolBarToggleButton(new ShowHotlistAction()));
65 addSeparator();
66 add(new XNapToolBarButton(ActionHelper.cutAction));
67 add(new XNapToolBarButton(ActionHelper.copyAction));
68 add(new XNapToolBarButton(ActionHelper.pasteAction));
69 addSeparator();
70
71
72 CSH.setHelpIDString(this, "main-toolbar");
73 }
74
75
76
77 /***
78 * Adds <code>c</code>.
79 *
80 * @see #removeAllTemporaries()
81 */
82 public void addTemporary(Component c)
83 {
84 add(c);
85 temporaries.add(c);
86 }
87
88 /***
89 * Removes all components that were added by
90 * {@link #addTemporary(Component)}.
91 */
92 public void removeAllTemporaries()
93 {
94 for (Iterator i = temporaries.iterator(); i.hasNext();) {
95 remove((Component)i.next());
96 }
97 temporaries.clear();
98 }
99 }