1 | /**
|
---|
2 | *#########################################################################
|
---|
3 | *
|
---|
4 | * A component of the GAI application, part of the Greenstone digital
|
---|
5 | * library suite from the New Zealand Digital Library Project at the
|
---|
6 | * University of Waikato, New Zealand.
|
---|
7 | *
|
---|
8 | * <BR><BR>
|
---|
9 | *
|
---|
10 | *
|
---|
11 | * <BR><BR>
|
---|
12 | *
|
---|
13 | * Copyright (C) 1999 New Zealand Digital Library Project
|
---|
14 | *
|
---|
15 | * <BR><BR>
|
---|
16 | *
|
---|
17 | * This program is free software; you can redistribute it and/or modify
|
---|
18 | * it under the terms of the GNU General Public License as published by
|
---|
19 | * the Free Software Foundation; either version 2 of the License, or
|
---|
20 | * (at your option) any later version.
|
---|
21 | *
|
---|
22 | * <BR><BR>
|
---|
23 | *
|
---|
24 | * This program is distributed in the hope that it will be useful,
|
---|
25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
27 | * GNU General Public License for more details.
|
---|
28 | *
|
---|
29 | * <BR><BR>
|
---|
30 | * Author: Chi-Yu Huang, Greenstone Digital Library, University of Waikato
|
---|
31 | *
|
---|
32 | * You should have received a copy of the GNU General Public License
|
---|
33 | * along with this program; if not, write to the Free Software
|
---|
34 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
35 | *########################################################################
|
---|
36 | */
|
---|
37 | package org.greenstone.admin.gui;
|
---|
38 |
|
---|
39 | import java.awt.*;
|
---|
40 | import java.awt.event.*;
|
---|
41 | import javax.swing.*;
|
---|
42 | import javax.swing.event.*;
|
---|
43 |
|
---|
44 | import org.greenstone.admin.GAI;
|
---|
45 | import org.greenstone.util.Configuration;
|
---|
46 |
|
---|
47 | /** The menu bar for the Administration tools main GUI.
|
---|
48 | * @author Chi-Yu Huang, Greenstone Digital Library, University of Waikato
|
---|
49 | * @version
|
---|
50 | */
|
---|
51 | public class MenuBar
|
---|
52 | extends JMenuBar {
|
---|
53 | /** The icon to be displayed alongside the context choosen help file. */
|
---|
54 | private int current_tab = -1;
|
---|
55 |
|
---|
56 | private JMenu file = null;
|
---|
57 | private JMenu edit = null;
|
---|
58 | public JMenu help = null;
|
---|
59 | // public JMenuItem file_cdimage = null;
|
---|
60 | // public JMenuItem file_close = null;
|
---|
61 | //public JMenuItem file_delete = null;
|
---|
62 | public JMenuItem file_exit = null;
|
---|
63 | public JMenuItem file_save = null;
|
---|
64 | public JMenuItem help_general;
|
---|
65 | public JMenuItem help_conf;
|
---|
66 | public JMenuItem help_ext;
|
---|
67 | public JMenuItem help_monitor;
|
---|
68 | public JMenuItem help_log;
|
---|
69 | public JMenuItem help_about;
|
---|
70 |
|
---|
71 | static public ImageIcon HELP_ICON = null;
|
---|
72 | static public ImageIcon BLANK_ICON = null;
|
---|
73 |
|
---|
74 | // public MenuBar(MenuListener Menu_listener)
|
---|
75 | public MenuBar(MenuListener menu_listener)
|
---|
76 | {
|
---|
77 | HELP_ICON = new ImageIcon(GAI.images_path +"help.gif");
|
---|
78 | BLANK_ICON = new ImageIcon(GAI.images_path+"blank.gif");
|
---|
79 |
|
---|
80 | //file = new JMenu("File");
|
---|
81 | file = new JMenu();
|
---|
82 | file.setMnemonic(KeyEvent.VK_F);
|
---|
83 | file.setText(GAI.dictionary.get("Menu.File"));
|
---|
84 |
|
---|
85 | //file_save = new JMenuItem("Save");
|
---|
86 | file_save = new JMenuItem();
|
---|
87 | file_save.addActionListener(GAI.ga_man);
|
---|
88 | file_save.setMnemonic(KeyEvent.VK_S);
|
---|
89 | file_save.setText(GAI.dictionary.get("Menu.File_Save"));
|
---|
90 |
|
---|
91 | //file_exit = new JMenuItem("Exit");
|
---|
92 | file_exit = new JMenuItem();
|
---|
93 | file_exit.addActionListener(GAI.ga_man);
|
---|
94 | file_exit.setMnemonic(KeyEvent.VK_X);
|
---|
95 | file_exit.setText(GAI.dictionary.get("Menu.File_Exit"));
|
---|
96 |
|
---|
97 | //Layout (File menu)
|
---|
98 | file.add(file_save);
|
---|
99 | file.add(new JSeparator());
|
---|
100 | file.add(file_exit);
|
---|
101 |
|
---|
102 | // Edit menu
|
---|
103 | //edit = new JMenu("Edit");
|
---|
104 | edit = new JMenu();
|
---|
105 | edit.setMnemonic(KeyEvent.VK_E);
|
---|
106 | edit.setText(GAI.dictionary.get("Menu.Edit"));
|
---|
107 |
|
---|
108 | // Help menu
|
---|
109 | //help = new JMenu("Help");
|
---|
110 | help = new JMenu();
|
---|
111 | help.setMnemonic(KeyEvent.VK_H);
|
---|
112 | help.setIcon(HELP_ICON);
|
---|
113 | help.setText(GAI.dictionary.get("Menu.Help"));
|
---|
114 |
|
---|
115 | help_general = new JMenuItem();
|
---|
116 | help_general.addActionListener(GAI.ga_man);
|
---|
117 | help_general.setText(GAI.dictionary.get("Source.General"));
|
---|
118 |
|
---|
119 | help_conf = new JMenuItem();
|
---|
120 | help_conf.addActionListener(GAI.ga_man);
|
---|
121 | help_conf.setText(GAI.dictionary.get("GAI.Configuration"));
|
---|
122 |
|
---|
123 | help_ext = new JMenuItem();
|
---|
124 | help_ext.addActionListener(GAI.ga_man);
|
---|
125 | help_ext.setText(GAI.dictionary.get("GAI.Ext"));
|
---|
126 |
|
---|
127 | help_monitor = new JMenuItem();
|
---|
128 | help_monitor.addActionListener(GAI.ga_man);
|
---|
129 | help_monitor.setText(GAI.dictionary.get("GAI.Monitor"));
|
---|
130 |
|
---|
131 | help_log = new JMenuItem();
|
---|
132 | help_log.addActionListener(GAI.ga_man);
|
---|
133 | help_log.setText(GAI.dictionary.get("GAI.Log"));
|
---|
134 |
|
---|
135 | help_about = new JMenuItem();
|
---|
136 | help_about.addActionListener(GAI.ga_man);
|
---|
137 | help_about.setText(GAI.dictionary.get("Menu.Help_About"));
|
---|
138 |
|
---|
139 |
|
---|
140 | // Layout (help menu)
|
---|
141 | help.add(help_general);
|
---|
142 | help.add(new JSeparator());
|
---|
143 | if (Configuration.get("admin.conf")) {
|
---|
144 | help.add(help_conf);
|
---|
145 | }
|
---|
146 | if (Configuration.get("admin.ext")) {
|
---|
147 | help.add(help_ext);
|
---|
148 | }
|
---|
149 | if (Configuration.get("admin.monitor")) {
|
---|
150 | help.add(help_monitor);
|
---|
151 | }
|
---|
152 | if (Configuration.get("admin.log")) {
|
---|
153 | help.add(help_log);
|
---|
154 | }
|
---|
155 |
|
---|
156 | help.add(new JSeparator());
|
---|
157 | help.add(help_about);
|
---|
158 |
|
---|
159 | // Layout (menu bar)
|
---|
160 | add(file);
|
---|
161 | add(Box.createHorizontalStrut(15));
|
---|
162 | add(edit);
|
---|
163 | add(Box.createHorizontalGlue());
|
---|
164 | add(help);
|
---|
165 | }
|
---|
166 |
|
---|
167 | /** Once a quit has been requested by the user, prevent any further menu selections. */
|
---|
168 | public void exit() {
|
---|
169 | file.setEnabled(false);
|
---|
170 | edit.setEnabled(false);
|
---|
171 | help.setEnabled(false);
|
---|
172 | }
|
---|
173 |
|
---|
174 | /*public void refresh(int refresh_reason, boolean ready)
|
---|
175 | {
|
---|
176 | file_close.setEnabled(ready);
|
---|
177 | file_save.setEnabled(ready);
|
---|
178 | }*/
|
---|
179 |
|
---|
180 |
|
---|
181 | /** In order to provide context aware help advice we keep track of which
|
---|
182 | * tab the user has open, and then highlight that help menu item with
|
---|
183 | * separators.
|
---|
184 | * @param tab_index The index of the selected tab (0-7).
|
---|
185 | */
|
---|
186 | public void tabSelected(int tab_index) {
|
---|
187 | JMenuItem selected;
|
---|
188 | if(current_tab != -1) {
|
---|
189 | // Remove the image
|
---|
190 | selected = help.getItem(current_tab);
|
---|
191 | if(selected != null) {
|
---|
192 | selected.setIcon(BLANK_ICON);
|
---|
193 | }
|
---|
194 | }
|
---|
195 | current_tab = tab_index + 2;
|
---|
196 | selected = help.getItem(current_tab);
|
---|
197 | if(selected != null) {
|
---|
198 | selected.setIcon(HELP_ICON);
|
---|
199 |
|
---|
200 | }
|
---|
201 | selected = null;
|
---|
202 | }
|
---|
203 | }
|
---|