source: branches/ant-install-branch/gsdl3/src/java/org/greenstone/admin/gui/MenuBar.java@ 9972

Last change on this file since 9972 was 9972, checked in by chi, 19 years ago

The initial version of GAI applications.

  • Property svn:keywords set to Author Date Id Revision
File size: 8.9 KB
Line 
1/**
2 *#########################################################################
3 *
4 * A component of the Gatherer 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 */
37package org.greenstone.admin.gui;
38
39import java.awt.*;
40import java.awt.event.*;
41import javax.swing.*;
42import javax.swing.event.*;
43
44import org.greenstone.admin.GAI;
45import org.greenstone.core.util.Utility;
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
52public class MenuBar
53 extends JMenuBar {
54 /** The icon to be displayed alongside the context choosen help file. */
55 private int current_tab = -1;
56
57 private JMenu file = null;
58 private JMenu edit = null;
59 public JMenu help = null;
60 //public JMenuItem file_associations;
61 // public JMenuItem file_cdimage = null;
62 // public JMenuItem file_close = null;
63 //public JMenuItem file_delete = null;
64 public JMenuItem file_exit = null;
65 // public JMenuItem file_exportas = null;
66 // public JMenuItem file_new = null;
67 //public JMenuItem file_open = null;
68 //public JMenuItem file_options = null;
69 // public JMenuItem file_save = null;
70 // public JMenuItem edit_copy;
71 //public JMenuItem edit_cut;
72 // public JMenuItem edit_paste;
73 public JMenuItem help_conf;
74 public JMenuItem help_ext;
75 public JMenuItem help_monitor;
76 public JMenuItem help_log;
77 //public JMenuItem help_gather;
78 //public JMenuItem help_enrich;
79 //public JMenuItem help_design;
80 //public JMenuItem help_create;
81 public JMenuItem help_about;
82
83 //public static String imagePath = "/research/chi/gsdl3/src/java/org/greenstone/admin/images/";
84 public static String imagePath = "/research/chi/gsdl3-test/gsdl3/src/java/org/greenstone/admin/images/";
85
86 static public ImageIcon HELP_ICON = null;
87
88 // public MenuBar(MenuListener Menu_listener)
89 public MenuBar()
90 {
91 HELP_ICON = new ImageIcon("images/help.gif");
92 file = new JMenu("File");
93 file.setMnemonic(KeyEvent.VK_F);
94 //Dictionary.registerText(file, "Menu.File");
95
96 /*file_associations = new JMenuItem();
97 file_associations.addActionListener(Gatherer.g_man);
98 file_associations.setMnemonic(KeyEvent.VK_A);
99 Dictionary.registerText(file_associations, "Menu.File_Associations");
100
101 file_cdimage = new JMenuItem();
102 file_cdimage.addActionListener(Gatherer.g_man);
103 file_cdimage.setMnemonic(KeyEvent.VK_I);
104 Dictionary.registerText(file_cdimage, "Menu.File_CDimage");
105
106 file_close = new JMenuItem();
107 file_close.addActionListener(Gatherer.g_man);
108 file_close.setEnabled(false);
109 file_close.setMnemonic(KeyEvent.VK_C);
110 Dictionary.registerText(file_close, "Menu.File_Close");
111
112 file_delete = new JMenuItem();
113 file_delete.addActionListener(Gatherer.g_man);
114 file_delete.setMnemonic(KeyEvent.VK_D);
115 Dictionary.registerText(file_delete, "Menu.File_Delete");*/
116
117 file_exit = new JMenuItem("Exit");
118 file_exit.addActionListener(GAI.ga_man);
119 file_exit.setMnemonic(KeyEvent.VK_X);
120 //Dictionary.registerText(file_exit, "Menu.File_Exit");
121
122 /*file_exportas = new JMenuItem();
123 file_exportas.addActionListener(Gatherer.g_man);
124 file_exportas.setMnemonic(KeyEvent.VK_E);
125 Dictionary.registerText(file_exportas, "Menu.File_ExportAs");*/
126
127 /*file_new = new JMenuItem();
128 file_new.addActionListener(Gatherer.g_man);
129 file_new.setMnemonic(KeyEvent.VK_N);
130 Dictionary.registerText(file_new, "Menu.File_New");
131
132 file_open = new JMenuItem();
133 file_open.addActionListener(Gatherer.g_man);
134 file_open.setMnemonic(KeyEvent.VK_O);
135 Dictionary.registerText(file_open, "Menu.File_Open");
136
137 file_options = new JMenuItem();
138 file_options.addActionListener(Gatherer.g_man);
139 file_options.setMnemonic(KeyEvent.VK_P);
140 Dictionary.registerText(file_options, "Menu.File_Options");
141
142 file_save = new JMenuItem();
143 file_save.addActionListener(Gatherer.g_man);
144 file_save.setEnabled(false);
145 file_save.setMnemonic(KeyEvent.VK_S);
146 Dictionary.registerText(file_save, "Menu.File_Save");*/
147
148 // Layout (file menu)
149 /*file.add(file_new);
150 file.add(file_open);
151 file.add(file_save);
152 file.add(file_close);*/
153 file.add(new JSeparator());
154 /*file.add(file_delete);
155 file.add(file_exportas);
156 file.add(file_cdimage);
157 file.add(new JSeparator());
158 file.add(file_associations);
159 file.add(file_options);
160 file.add(new JSeparator());*/
161 file.add(file_exit);
162
163 // Edit menu
164 edit = new JMenu("Edit");
165 edit.setMnemonic(KeyEvent.VK_E);
166 //Dictionary.registerText(edit, "Menu.Edit");
167
168 /*edit_cut = new JMenuItem();
169 edit_cut.addActionListener(Gatherer.g_man);
170 edit_cut.setMnemonic(KeyEvent.VK_X);
171 Dictionary.registerText(edit_cut, "Menu.Edit_Cut");
172
173 edit_copy = new JMenuItem();
174 edit_copy.addActionListener(Gatherer.g_man);
175 edit_copy.setMnemonic(KeyEvent.VK_C);
176 Dictionary.registerText(edit_copy, "Menu.Edit_Copy");
177
178 edit_paste = new JMenuItem();
179 edit_paste.addActionListener(Gatherer.g_man);
180 edit_paste.setMnemonic(KeyEvent.VK_V);
181 Dictionary.registerText(edit_paste, "Menu.Edit_Paste");
182
183 // Layout (edit menu)
184 edit.add(edit_cut);
185 edit.add(edit_copy);
186 edit.add(edit_paste);*/
187
188 // Help menu
189 help = new JMenu("Help");
190 help.setMnemonic(KeyEvent.VK_H);
191 help.setIcon(HELP_ICON);
192 //Dictionary.setText(help, "Menu.Help");
193
194 help_conf = new JMenuItem("Configuration");
195 //help_log.addActionListener(Gatherer.g_man);
196 //Dictionary.registerText(help_general, "Source.General");
197
198 help_ext = new JMenuItem("Ext");
199 help_monitor = new JMenuItem("Monitor");
200 help_log = new JMenuItem("Log");
201
202 /*help_gather = new JMenuItem(Utility.BLANK_ICON);
203 help_gather.addActionListener(Gatherer.g_man);
204 Dictionary.registerText(help_gather, "GUI.Gather");
205
206 help_enrich = new JMenuItem(Utility.BLANK_ICON);
207 help_enrich.addActionListener(Gatherer.g_man);
208 Dictionary.registerText(help_enrich, "GUI.Enrich");
209
210 help_design = new JMenuItem(Utility.BLANK_ICON);
211 help_design.addActionListener(Gatherer.g_man);
212 Dictionary.registerText(help_design, "GUI.Design");
213
214 help_create = new JMenuItem(Utility.BLANK_ICON);
215 help_create.addActionListener(Gatherer.g_man);
216 Dictionary.registerText(help_create, "GUI.Create");*/
217
218 help_about = new JMenuItem("About");
219 //help_about.addActionListener(Gatherer.g_man);
220 //Dictionary.registerText(help_about, "Menu.Help_About");
221
222 // Layout (help menu)
223 help.add(help_conf);
224 help.add(help_ext);
225 help.add(help_monitor);
226 help.add(help_log);
227 help.add(new JSeparator());
228
229 /*if (Configuration.get("workflow.download", true)) {
230 help.add(help_download);
231 }
232 if (Configuration.get("workflow.gather", true)) {
233 help.add(help_gather);
234 }
235 if (Configuration.get("workflow.enrich", true)) {
236 help.add(help_enrich);
237 }
238 if (Configuration.get("workflow.design", true)) {
239 help.add(help_design);
240 }
241 if (Configuration.get("workflow.create", true)) {
242 help.add(help_create);
243 }*/
244
245 help.add(new JSeparator());
246 help.add(help_about);
247
248 // Layout (menu bar)
249 add(file);
250 add(Box.createHorizontalStrut(15));
251 add(edit);
252 add(Box.createHorizontalGlue());
253 add(help);
254 }
255
256 /** Once a quit has been requested by the user, prevent any further menu selections. */
257 public void exit() {
258 file.setEnabled(false);
259 edit.setEnabled(false);
260 help.setEnabled(false);
261 }
262
263 /*public void refresh(int refresh_reason, boolean ready)
264 {
265 file_close.setEnabled(ready);
266 file_save.setEnabled(ready);
267 }*/
268
269
270 /** In order to provide context aware help advice we keep track of which
271 * tab the user has open, and then highlight that help menu item with
272 * separators.
273 * @param tab_index The index of the selected tab (0-7).
274 */
275 public void tabSelected(int tab_index) {
276 JMenuItem selected;
277 if(current_tab != -1) {
278 // Remove the image
279 selected = help.getItem(current_tab);
280 if(selected != null) {
281 selected.setIcon(Utility.BLANK_ICON);
282 }
283 }
284 current_tab = tab_index + 2;
285 selected = help.getItem(current_tab);
286 if(selected != null) {
287 //selected.setIcon(Utility.HELP_ICON);
288 //
289 }
290 selected = null;
291 }
292}
Note: See TracBrowser for help on using the repository browser.