source: trunk/gli/src/org/greenstone/gatherer/gui/MenuBar.java@ 10726

Last change on this file since 10726 was 10726, checked in by mdewsnip, 19 years ago

(MAJOR CHANGE) This is the remote Greenstone building functionality implemented for the West Yorkshire Fire and Rescue Service. It allows collections to be built without having a local version of Greenstone, using either a stand-alone version of the GLI or the applet.

The collections are stored on the server (allowing people to collaborate on collections -- but not at the same time), and only what is necessary to let the user edit the collection is downloaded. Any changes to the collection are uploaded to the server.

An access restriction mechanism is implemented which uses the standard Greenstone user database to control who has access to collections.

  • Property svn:keywords set to Author Date Id Revision
File size: 8.7 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 * Author: John Thompson, Greenstone Digital Library, University of Waikato
11 *
12 * <BR><BR>
13 *
14 * Copyright (C) 1999 New Zealand Digital Library Project
15 *
16 * <BR><BR>
17 *
18 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation; either version 2 of the License, or
21 * (at your option) any later version.
22 *
23 * <BR><BR>
24 *
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
29 *
30 * <BR><BR>
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.gatherer.gui;
38
39import java.awt.*;
40import java.awt.event.*;
41import javax.swing.*;
42import javax.swing.event.*;
43import org.greenstone.gatherer.Configuration;
44import org.greenstone.gatherer.Dictionary;
45import org.greenstone.gatherer.Gatherer;
46import org.greenstone.gatherer.util.JarTools;
47
48/** The menu bar for the Gatherer main GUI.
49 * @author John Thompson, Greenstone Digital Library, University of Waikato
50 * @version 2.2
51 */
52public class MenuBar
53 extends JMenuBar
54{
55 static public ImageIcon BLANK_ICON = JarTools.getImage("blank.gif");
56 static public ImageIcon HELP_ICON = JarTools.getImage("help.gif");
57
58 /** The icon to be displayed alongside the context choosen help file. */
59 private int current_tab = -1;
60
61 private JMenu file = null;
62 private JMenu edit = null;
63 public JMenu help = null;
64 public JMenuItem file_associations;
65 public JMenuItem file_cdimage = null;
66 public JMenuItem file_close = null;
67 public JMenuItem file_delete = null;
68 public JMenuItem file_exit = null;
69 public JMenuItem file_exportas = null;
70 public JMenuItem file_new = null;
71 public JMenuItem file_open = null;
72 public JMenuItem file_options = null;
73 public JMenuItem file_save = null;
74 public JMenuItem edit_copy;
75 public JMenuItem edit_cut;
76 public JMenuItem edit_paste;
77 public JMenuItem help_general;
78 public JMenuItem help_download;
79 public JMenuItem help_gather;
80 public JMenuItem help_enrich;
81 public JMenuItem help_design;
82 public JMenuItem help_create;
83 public JMenuItem help_about;
84
85
86 public MenuBar(MenuListener menu_listener)
87 {
88 file = new JMenu();
89 file.setMnemonic(KeyEvent.VK_F);
90 Dictionary.registerText(file, "Menu.File");
91
92 file_associations = new JMenuItem();
93 file_associations.addActionListener(Gatherer.g_man);
94 file_associations.setMnemonic(KeyEvent.VK_A);
95 Dictionary.registerText(file_associations, "Menu.File_Associations");
96
97 file_cdimage = new JMenuItem();
98 file_cdimage.addActionListener(Gatherer.g_man);
99 file_cdimage.setEnabled(!Gatherer.isGsdlRemote);
100 file_cdimage.setMnemonic(KeyEvent.VK_I);
101 Dictionary.registerText(file_cdimage, "Menu.File_CDimage");
102
103 file_close = new JMenuItem();
104 file_close.addActionListener(Gatherer.g_man);
105 file_close.setEnabled(false);
106 file_close.setMnemonic(KeyEvent.VK_C);
107 Dictionary.registerText(file_close, "Menu.File_Close");
108
109 file_delete = new JMenuItem();
110 file_delete.addActionListener(Gatherer.g_man);
111 file_delete.setMnemonic(KeyEvent.VK_D);
112 Dictionary.registerText(file_delete, "Menu.File_Delete");
113
114 file_exit = new JMenuItem();
115 file_exit.addActionListener(Gatherer.g_man);
116 file_exit.setMnemonic(KeyEvent.VK_X);
117 Dictionary.registerText(file_exit, "Menu.File_Exit");
118
119 file_exportas = new JMenuItem();
120 file_exportas.addActionListener(Gatherer.g_man);
121 file_exportas.setEnabled(!Gatherer.isGsdlRemote);
122 file_exportas.setMnemonic(KeyEvent.VK_E);
123 Dictionary.registerText(file_exportas, "Menu.File_ExportAs");
124
125 file_new = new JMenuItem();
126 file_new.addActionListener(Gatherer.g_man);
127 file_new.setMnemonic(KeyEvent.VK_N);
128 Dictionary.registerText(file_new, "Menu.File_New");
129
130 file_open = new JMenuItem();
131 file_open.addActionListener(Gatherer.g_man);
132 file_open.setMnemonic(KeyEvent.VK_O);
133 Dictionary.registerText(file_open, "Menu.File_Open");
134
135 file_options = new JMenuItem();
136 file_options.addActionListener(Gatherer.g_man);
137 file_options.setMnemonic(KeyEvent.VK_P);
138 Dictionary.registerText(file_options, "Menu.File_Options");
139
140 file_save = new JMenuItem();
141 file_save.addActionListener(Gatherer.g_man);
142 file_save.setEnabled(false);
143 file_save.setMnemonic(KeyEvent.VK_S);
144 Dictionary.registerText(file_save, "Menu.File_Save");
145
146 // Layout (file menu)
147 file.add(file_new);
148 file.add(file_open);
149 file.add(file_save);
150 file.add(file_close);
151 file.add(new JSeparator());
152 file.add(file_delete);
153 file.add(file_exportas);
154 file.add(file_cdimage);
155 file.add(new JSeparator());
156 file.add(file_associations);
157 file.add(file_options);
158 file.add(new JSeparator());
159 file.add(file_exit);
160
161 // Edit menu
162 edit = new JMenu();
163 edit.setMnemonic(KeyEvent.VK_E);
164 Dictionary.registerText(edit, "Menu.Edit");
165
166 edit_cut = new JMenuItem();
167 edit_cut.addActionListener(Gatherer.g_man);
168 edit_cut.setMnemonic(KeyEvent.VK_X);
169 Dictionary.registerText(edit_cut, "Menu.Edit_Cut");
170
171 edit_copy = new JMenuItem();
172 edit_copy.addActionListener(Gatherer.g_man);
173 edit_copy.setMnemonic(KeyEvent.VK_C);
174 Dictionary.registerText(edit_copy, "Menu.Edit_Copy");
175
176 edit_paste = new JMenuItem();
177 edit_paste.addActionListener(Gatherer.g_man);
178 edit_paste.setMnemonic(KeyEvent.VK_V);
179 Dictionary.registerText(edit_paste, "Menu.Edit_Paste");
180
181 // Layout (edit menu)
182 edit.add(edit_cut);
183 edit.add(edit_copy);
184 edit.add(edit_paste);
185
186 // Help menu
187 help = new JMenu();
188 help.setIcon(HELP_ICON);
189 Dictionary.setText(help, "Menu.Help");
190
191 help_general = new JMenuItem();
192 help_general.addActionListener(Gatherer.g_man);
193 Dictionary.registerText(help_general, "Source.General");
194
195 help_download = new JMenuItem(BLANK_ICON);
196 help_download.addActionListener(Gatherer.g_man);
197 Dictionary.registerText(help_download, "GUI.Download");
198
199 help_gather = new JMenuItem(BLANK_ICON);
200 help_gather.addActionListener(Gatherer.g_man);
201 Dictionary.registerText(help_gather, "GUI.Gather");
202
203 help_enrich = new JMenuItem(BLANK_ICON);
204 help_enrich.addActionListener(Gatherer.g_man);
205 Dictionary.registerText(help_enrich, "GUI.Enrich");
206
207 help_design = new JMenuItem(BLANK_ICON);
208 help_design.addActionListener(Gatherer.g_man);
209 Dictionary.registerText(help_design, "GUI.Design");
210
211 help_create = new JMenuItem(BLANK_ICON);
212 help_create.addActionListener(Gatherer.g_man);
213 Dictionary.registerText(help_create, "GUI.Create");
214
215 help_about = new JMenuItem();
216 help_about.addActionListener(Gatherer.g_man);
217 Dictionary.registerText(help_about, "Menu.Help_About");
218
219 // Layout (help menu)
220 help.add(help_general);
221 help.add(new JSeparator());
222 if (Configuration.get("workflow.download", true)) {
223 help.add(help_download);
224 }
225 if (Configuration.get("workflow.gather", true)) {
226 help.add(help_gather);
227 }
228 if (Configuration.get("workflow.enrich", true)) {
229 help.add(help_enrich);
230 }
231 if (Configuration.get("workflow.design", true)) {
232 help.add(help_design);
233 }
234 if (Configuration.get("workflow.create", true)) {
235 help.add(help_create);
236 }
237 help.add(new JSeparator());
238 help.add(help_about);
239
240 // Layout (menu bar)
241 this.add(file);
242 this.add(Box.createHorizontalStrut(15));
243 this.add(edit);
244 this.add(Box.createHorizontalGlue());
245 this.add(help);
246 }
247
248 /** Once a quit has been requested by the user, prevent any further menu selections. */
249 public void exit() {
250 file.setEnabled(false);
251 edit.setEnabled(false);
252 help.setEnabled(false);
253 }
254
255 public void refresh(int refresh_reason, boolean ready)
256 {
257 file_close.setEnabled(ready);
258 file_save.setEnabled(ready);
259 }
260
261
262 /** In order to provide context aware help advice we keep track of which
263 * tab the user has open, and then highlight that help menu item with
264 * separators.
265 * @param tab_index The index of the selected tab (0-7).
266 */
267 public void tabSelected(int tab_index) {
268 JMenuItem selected;
269 if(current_tab != -1) {
270 // Remove the image
271 selected = help.getItem(current_tab);
272 if(selected != null) {
273 selected.setIcon(BLANK_ICON);
274 }
275 }
276 current_tab = tab_index + 2;
277 selected = help.getItem(current_tab);
278 if(selected != null) {
279 selected.setIcon(HELP_ICON);
280 }
281 selected = null;
282 }
283}
Note: See TracBrowser for help on using the repository browser.