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

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

The latest development when Chi leave on 31/10/2005.

  • Property svn:keywords set to Author Date Id Revision
File size: 5.7 KB
Line 
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 */
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.Configuration;
46import org.greenstone.core.Dictionary;
47import org.greenstone.core.util.Utility;
48
49/** The menu bar for the Administration tools main GUI.
50 * @author Chi-Yu Huang, Greenstone Digital Library, University of Waikato
51 * @version
52 */
53public class MenuBar
54 extends JMenuBar {
55 /** The icon to be displayed alongside the context choosen help file. */
56 private int current_tab = -1;
57
58 private JMenu file = null;
59 private JMenu edit = null;
60 public JMenu help = null;
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_save = null;
66 public JMenuItem help_general;
67 public JMenuItem help_conf;
68 public JMenuItem help_ext;
69 public JMenuItem help_monitor;
70 public JMenuItem help_log;
71 public JMenuItem help_about;
72
73 static public ImageIcon HELP_ICON = null;
74
75 // public MenuBar(MenuListener Menu_listener)
76 public MenuBar(MenuListener menu_listener)
77 {
78 HELP_ICON = new ImageIcon(GAI.images_path +"help.gif");
79 //file = new JMenu("File");
80 file = new JMenu();
81 file.setMnemonic(KeyEvent.VK_F);
82 Dictionary.registerText(file, "Menu.File");
83
84 //file_save = new JMenuItem("Save");
85 file_save = new JMenuItem();
86 file_save.addActionListener(GAI.ga_man);
87 file_save.setMnemonic(KeyEvent.VK_S);
88 Dictionary.registerText(file_save, "Menu.File_Save");
89
90 //file_exit = new JMenuItem("Exit");
91 file_exit = new JMenuItem();
92 file_exit.addActionListener(GAI.ga_man);
93 file_exit.setMnemonic(KeyEvent.VK_X);
94 Dictionary.registerText(file_exit, "Menu.File_Exit");
95 //Layout (File menu)
96 file.add(file_save);
97 file.add(new JSeparator());
98 file.add(file_exit);
99
100 // Edit menu
101 //edit = new JMenu("Edit");
102 edit = new JMenu();
103 edit.setMnemonic(KeyEvent.VK_E);
104 Dictionary.registerText(edit, "Menu.Edit");
105
106 // Help menu
107 //help = new JMenu("Help");
108 help = new JMenu();
109 help.setMnemonic(KeyEvent.VK_H);
110 help.setIcon(HELP_ICON);
111 Dictionary.setText(help, "Menu.Help");
112
113 help_general = new JMenuItem();
114 help_general.addActionListener(GAI.ga_man);
115 Dictionary.registerText(help_general,"Source.General");
116
117 help_conf = new JMenuItem();
118 help_conf.addActionListener(GAI.ga_man);
119 Dictionary.registerText(help_conf,"GAI.Configuration");
120
121 help_ext = new JMenuItem();
122 help_ext.addActionListener(GAI.ga_man);
123 Dictionary.registerText(help_ext,"GAI.Ext");
124
125 help_monitor = new JMenuItem();
126 help_monitor.addActionListener(GAI.ga_man);
127 Dictionary.registerText(help_monitor,"GAI.Monitor");
128
129 help_log = new JMenuItem();
130 help_log.addActionListener(GAI.ga_man);
131 Dictionary.registerText(help_log,"GAI.Log");
132
133 help_about = new JMenuItem();
134 help_about.addActionListener(GAI.ga_man);
135 Dictionary.registerText(help_about,"Menu.Help_About");
136
137
138 // Layout (help menu)
139 help.add(help_general);
140 help.add(new JSeparator());
141 if (Configuration.get("admin.conf", true)) {
142 help.add(help_conf);
143 }
144 if (Configuration.get("admin.ext", true)) {
145 help.add(help_ext);
146 }
147 if (Configuration.get("admin.monitor", true)) {
148 help.add(help_monitor);
149 }
150 if (Configuration.get("admin.log", true)) {
151 help.add(help_log);
152 }
153
154 help.add(new JSeparator());
155 help.add(help_about);
156
157 // Layout (menu bar)
158 add(file);
159 add(Box.createHorizontalStrut(15));
160 add(edit);
161 add(Box.createHorizontalGlue());
162 add(help);
163 }
164
165 /** Once a quit has been requested by the user, prevent any further menu selections. */
166 public void exit() {
167 file.setEnabled(false);
168 edit.setEnabled(false);
169 help.setEnabled(false);
170 }
171
172 /*public void refresh(int refresh_reason, boolean ready)
173 {
174 file_close.setEnabled(ready);
175 file_save.setEnabled(ready);
176 }*/
177
178
179 /** In order to provide context aware help advice we keep track of which
180 * tab the user has open, and then highlight that help menu item with
181 * separators.
182 * @param tab_index The index of the selected tab (0-7).
183 */
184 public void tabSelected(int tab_index) {
185 JMenuItem selected;
186 if(current_tab != -1) {
187 // Remove the image
188 selected = help.getItem(current_tab);
189 if(selected != null) {
190 selected.setIcon(Utility.BLANK_ICON);
191 }
192 }
193 current_tab = tab_index + 2;
194 selected = help.getItem(current_tab);
195 if(selected != null) {
196 //selected.setIcon(Utility.HELP_ICON);
197 //
198 }
199 selected = null;
200 }
201}
Note: See TracBrowser for help on using the repository browser.