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

Last change on this file since 14680 was 14680, checked in by oranfry, 17 years ago

a few better icons for gli

  • Property svn:keywords set to Author Date Id Revision
File size: 8.0 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.png");
57
58 /** The icon to be displayed alongside the context choosen help file. */
59 private int current_tab = -1;
60
61 public JMenu file = null;
62 public 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_format;
84 public JMenuItem help_about;
85
86
87 public MenuBar(MenuListener menu_listener)
88 {
89 file = new JMenu();
90 file.setEnabled(false);
91 file.setText(Dictionary.get("Menu.File"));
92
93 file_associations = new JMenuItem(Dictionary.get("Menu.File_Associations"));
94 file_associations.addActionListener(Gatherer.g_man);
95
96 file_cdimage = new JMenuItem(Dictionary.get("Menu.File_CDimage"));
97 file_cdimage.addActionListener(Gatherer.g_man);
98 file_cdimage.setEnabled(!Gatherer.isGsdlRemote);
99
100 file_close = new JMenuItem(Dictionary.get("Menu.File_Close"));
101 file_close.addActionListener(Gatherer.g_man);
102 file_close.setEnabled(false);
103
104 file_delete = new JMenuItem(Dictionary.get("Menu.File_Delete"));
105 file_delete.addActionListener(Gatherer.g_man);
106
107 file_exit = new JMenuItem(Dictionary.get("Menu.File_Exit"));
108 file_exit.addActionListener(Gatherer.g_man);
109
110 file_exportas = new JMenuItem(Dictionary.get("Menu.File_ExportAs"));
111 file_exportas.addActionListener(Gatherer.g_man);
112 file_exportas.setEnabled((!Gatherer.isGsdlRemote && !Gatherer.GS3));
113
114 file_new = new JMenuItem(Dictionary.get("Menu.File_New"));
115 file_new.addActionListener(Gatherer.g_man);
116
117 file_open = new JMenuItem(Dictionary.get("Menu.File_Open"));
118 file_open.addActionListener(Gatherer.g_man);
119
120 file_options = new JMenuItem(Dictionary.get("Menu.File_Options"));
121 file_options.addActionListener(Gatherer.g_man);
122
123 file_save = new JMenuItem(Dictionary.get("Menu.File_Save"));
124 file_save.addActionListener(Gatherer.g_man);
125 file_save.setEnabled(false);
126
127 // Layout (file menu)
128 file.add(file_new);
129 file.add(file_open);
130 file.add(file_save);
131 file.add(file_close);
132 file.add(new JSeparator());
133 file.add(file_delete);
134 file.add(file_exportas);
135 file.add(file_cdimage);
136 file.add(new JSeparator());
137 file.add(file_associations);
138 file.add(file_options);
139 file.add(new JSeparator());
140 file.add(file_exit);
141
142 // Edit menu
143 edit = new JMenu();
144 edit.setEnabled(false);
145 edit.setText(Dictionary.get("Menu.Edit"));
146
147 edit_cut = new JMenuItem(Dictionary.get("Menu.Edit_Cut"));
148 edit_cut.addActionListener(Gatherer.g_man);
149
150 edit_copy = new JMenuItem(Dictionary.get("Menu.Edit_Copy"));
151 edit_copy.addActionListener(Gatherer.g_man);
152
153 edit_paste = new JMenuItem(Dictionary.get("Menu.Edit_Paste"));
154 edit_paste.addActionListener(Gatherer.g_man);
155
156 // Layout (edit menu)
157 edit.add(edit_cut);
158 edit.add(edit_copy);
159 edit.add(edit_paste);
160
161 // Help menu
162 help = new JMenu();
163 help.setIcon(HELP_ICON);
164 help.setText(Dictionary.get("Menu.Help"));
165
166 help_general = new JMenuItem(Dictionary.get("Source.General"));
167 help_general.addActionListener(Gatherer.g_man);
168
169 help_download = new JMenuItem(Dictionary.get("GUI.Download"), BLANK_ICON);
170 help_download.addActionListener(Gatherer.g_man);
171
172 help_gather = new JMenuItem(Dictionary.get("GUI.Gather"), BLANK_ICON);
173 help_gather.addActionListener(Gatherer.g_man);
174
175 help_enrich = new JMenuItem(Dictionary.get("GUI.Enrich"), BLANK_ICON);
176 help_enrich.addActionListener(Gatherer.g_man);
177
178 help_design = new JMenuItem(Dictionary.get("GUI.Design"), BLANK_ICON);
179 help_design.addActionListener(Gatherer.g_man);
180
181 help_create = new JMenuItem(Dictionary.get("GUI.Create"), BLANK_ICON);
182 help_create.addActionListener(Gatherer.g_man);
183
184 help_format = new JMenuItem(Dictionary.get("GUI.Format"), BLANK_ICON);
185 help_format.addActionListener(Gatherer.g_man);
186
187 help_about = new JMenuItem(Dictionary.get("Menu.Help_About"));
188 help_about.addActionListener(Gatherer.g_man);
189
190 // Layout (help menu)
191 help.add(help_general);
192 help.add(new JSeparator());
193 if (Configuration.get("workflow.download", true)) {
194 help.add(help_download);
195 }
196 if (Configuration.get("workflow.gather", true)) {
197 help.add(help_gather);
198 }
199 if (Configuration.get("workflow.enrich", true)) {
200 help.add(help_enrich);
201 }
202 if (Configuration.get("workflow.design", true)) {
203 help.add(help_design);
204 }
205 if (Configuration.get("workflow.create", true)) {
206 help.add(help_create);
207 }
208 if (Configuration.get("workflow.format", true)) {
209 help.add(help_format);
210 }
211 help.add(new JSeparator());
212 help.add(help_about);
213
214 // Layout (menu bar)
215 this.add(file);
216 this.add(Box.createHorizontalStrut(15));
217 this.add(edit);
218 this.add(Box.createHorizontalGlue());
219 this.add(help);
220 }
221
222 /** Once a quit has been requested by the user, prevent any further menu selections. */
223 public void exit() {
224 file.setEnabled(false);
225 edit.setEnabled(false);
226 help.setEnabled(false);
227 }
228
229 public void refresh(int refresh_reason, boolean ready)
230 {
231 file_close.setEnabled(ready);
232 file_save.setEnabled(ready);
233 }
234
235
236 /** In order to provide context aware help advice we keep track of which
237 * tab the user has open, and then highlight that help menu item with
238 * separators.
239 * @param tab_index The index of the selected tab (0-7).
240 */
241 public void tabSelected(int tab_index) {
242 JMenuItem selected;
243 if(current_tab != -1) {
244 // Remove the image
245 selected = help.getItem(current_tab);
246 if(selected != null) {
247 selected.setIcon(BLANK_ICON);
248 }
249 }
250 current_tab = tab_index + 2;
251 selected = help.getItem(current_tab);
252 if(selected != null) {
253 selected.setIcon(HELP_ICON);
254 }
255 selected = null;
256 }
257}
Note: See TracBrowser for help on using the repository browser.