[4675] | 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 | */
|
---|
[5564] | 37 | package org.greenstone.gatherer.gui;
|
---|
| 38 |
|
---|
[4675] | 39 | import java.awt.*;
|
---|
| 40 | import java.awt.event.*;
|
---|
| 41 | import javax.swing.*;
|
---|
| 42 | import javax.swing.event.*;
|
---|
[5564] | 43 | import org.greenstone.gatherer.Dictionary;
|
---|
[4675] | 44 | import org.greenstone.gatherer.Gatherer;
|
---|
| 45 | import org.greenstone.gatherer.util.Utility;
|
---|
[5564] | 46 |
|
---|
[4675] | 47 | /** The menu bar for the Gatherer main GUI.
|
---|
| 48 | * @author John Thompson, Greenstone Digital Library, University of Waikato
|
---|
| 49 | * @version 2.2
|
---|
| 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;
|
---|
[5564] | 55 |
|
---|
[4675] | 56 | private JMenu file = null;
|
---|
| 57 | private JMenu edit = null;
|
---|
| 58 | private JMenu metadata = null;
|
---|
| 59 | private JMenu tools = null;
|
---|
| 60 | public JMenu help = null;
|
---|
| 61 | public JMenuItem file_associations;
|
---|
| 62 | public JMenuItem file_close = null;
|
---|
| 63 | public JMenuItem file_delete = null;
|
---|
| 64 | public JMenuItem file_exit = null;
|
---|
[5841] | 65 | public JMenuItem file_export = null;
|
---|
[4675] | 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 file_save_as;
|
---|
| 71 | public JMenuItem edit_copy;
|
---|
| 72 | public JMenuItem edit_cut;
|
---|
| 73 | public JMenuItem edit_paste;
|
---|
| 74 | public JMenuItem edit_undo = null;
|
---|
| 75 | public JMenuItem edit_redo = null;
|
---|
| 76 | public JMenuItem edit_replace = null;
|
---|
| 77 | public JMenuItem edit_search = null;
|
---|
[5564] | 78 | public JMenuItem metadata_import = null;
|
---|
[4675] | 79 | public JMenuItem metadata_edit = null;
|
---|
| 80 | public JMenuItem metadata_export = null;
|
---|
| 81 | public JMenuItem tools_log = null;
|
---|
| 82 | public JMenuItem tools_size = null;
|
---|
| 83 | public JMenuItem help_about;
|
---|
| 84 | public JMenuItem help_browse;
|
---|
| 85 | public JMenuItem help_build;
|
---|
| 86 | public JMenuItem help_collect;
|
---|
| 87 | public JMenuItem help_design;
|
---|
| 88 | public JMenuItem help_export;
|
---|
| 89 | public JMenuItem help_general;
|
---|
| 90 | public JMenuItem help_metaedit;
|
---|
| 91 | public JMenuItem help_mirror ;
|
---|
| 92 | public JMenuItem help_preview;
|
---|
| 93 | public MagicMenuItem metadata_view = null;
|
---|
| 94 |
|
---|
[5564] | 95 | public MenuBar(MenuListener menu_listener)
|
---|
| 96 | {
|
---|
| 97 | file = new JMenu();
|
---|
[4675] | 98 | file.setMnemonic(KeyEvent.VK_F);
|
---|
[5564] | 99 | Dictionary.registerText(file, "Menu.File");
|
---|
[4675] | 100 |
|
---|
[5564] | 101 | file_associations = new JMenuItem();
|
---|
[4675] | 102 | file_associations.addActionListener(Gatherer.g_man);
|
---|
[5564] | 103 | file_associations.setMnemonic(KeyEvent.VK_A);
|
---|
| 104 | Dictionary.registerText(file_associations, "Menu.File_Associations");
|
---|
[4675] | 105 |
|
---|
[5564] | 106 | file_close = new JMenuItem();
|
---|
[4675] | 107 | file_close.addActionListener(Gatherer.g_man);
|
---|
| 108 | file_close.setEnabled(false);
|
---|
[5564] | 109 | file_close.setMnemonic(KeyEvent.VK_C);
|
---|
| 110 | Dictionary.registerText(file_close, "Menu.File_Close");
|
---|
[4675] | 111 |
|
---|
[5564] | 112 | file_delete = new JMenuItem();
|
---|
[4675] | 113 | file_delete.addActionListener(Gatherer.g_man);
|
---|
[5564] | 114 | file_delete.setMnemonic(KeyEvent.VK_D);
|
---|
| 115 | Dictionary.registerText(file_delete, "Menu.File_Delete");
|
---|
[4675] | 116 |
|
---|
[5564] | 117 | file_exit = new JMenuItem();
|
---|
[4675] | 118 | file_exit.addActionListener(Gatherer.g_man);
|
---|
[5564] | 119 | file_exit.setMnemonic(KeyEvent.VK_X);
|
---|
| 120 | Dictionary.registerText(file_exit, "Menu.File_Exit");
|
---|
[4675] | 121 |
|
---|
[5841] | 122 | file_export = new JMenuItem();
|
---|
| 123 | file_export.addActionListener(Gatherer.g_man);
|
---|
| 124 | file_export.setMnemonic(KeyEvent.VK_E);
|
---|
| 125 | Dictionary.registerText(file_export, "Menu.File_Export");
|
---|
| 126 |
|
---|
[5564] | 127 | file_new = new JMenuItem();
|
---|
[4675] | 128 | file_new.addActionListener(Gatherer.g_man);
|
---|
[5564] | 129 | file_new.setMnemonic(KeyEvent.VK_N);
|
---|
| 130 | Dictionary.registerText(file_new, "Menu.File_New");
|
---|
[4675] | 131 |
|
---|
[5564] | 132 | file_open = new JMenuItem();
|
---|
[4675] | 133 | file_open.addActionListener(Gatherer.g_man);
|
---|
[5564] | 134 | file_open.setMnemonic(KeyEvent.VK_O);
|
---|
| 135 | Dictionary.registerText(file_open, "Menu.File_Open");
|
---|
[4675] | 136 |
|
---|
[5564] | 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");
|
---|
[4675] | 141 |
|
---|
[5564] | 142 | file_save = new JMenuItem();
|
---|
[4675] | 143 | file_save.addActionListener(Gatherer.g_man);
|
---|
| 144 | file_save.setEnabled(false);
|
---|
[5564] | 145 | file_save.setMnemonic(KeyEvent.VK_S);
|
---|
| 146 | Dictionary.registerText(file_save, "Menu.File_Save");
|
---|
[4675] | 147 |
|
---|
[5564] | 148 | // file_save_as = new JMenuItem();
|
---|
| 149 | // file_save_as.addActionListener(Gatherer.g_man);
|
---|
| 150 | // file_save_as.setEnabled(false);
|
---|
| 151 | // file_save_as.setMnemonic(KeyEvent.VK_A);
|
---|
| 152 | // Dictionary.registerText(file_save_as, "Menu.File_Save_As");
|
---|
[4675] | 153 |
|
---|
[5564] | 154 | // Layout (file menu)
|
---|
[4675] | 155 | file.add(file_new);
|
---|
| 156 | file.add(file_open);
|
---|
| 157 | file.add(file_save);
|
---|
[5564] | 158 | // file.add(file_save_as);
|
---|
[4675] | 159 | file.add(file_close);
|
---|
[5851] | 160 | file.add(new JSeparator());
|
---|
[4675] | 161 | file.add(file_delete);
|
---|
[5841] | 162 | file.add(file_export);
|
---|
[4675] | 163 | file.add(new JSeparator());
|
---|
| 164 | file.add(file_associations);
|
---|
| 165 | file.add(file_options);
|
---|
| 166 | file.add(new JSeparator());
|
---|
| 167 | file.add(file_exit);
|
---|
| 168 |
|
---|
| 169 | // Edit menu
|
---|
[5564] | 170 | edit = new JMenu();
|
---|
[4675] | 171 | edit.setMnemonic(KeyEvent.VK_E);
|
---|
[5564] | 172 | Dictionary.registerText(edit, "Menu.Edit");
|
---|
[4675] | 173 |
|
---|
[5564] | 174 | edit_cut = new JMenuItem();
|
---|
[4675] | 175 | edit_cut.addActionListener(Gatherer.g_man);
|
---|
[5564] | 176 | edit_cut.setMnemonic(KeyEvent.VK_X);
|
---|
| 177 | Dictionary.registerText(edit_cut, "Menu.Edit_Cut");
|
---|
[4675] | 178 |
|
---|
[5564] | 179 | edit_copy = new JMenuItem();
|
---|
[4675] | 180 | edit_copy.addActionListener(Gatherer.g_man);
|
---|
[5564] | 181 | edit_copy.setMnemonic(KeyEvent.VK_C);
|
---|
| 182 | Dictionary.registerText(edit_copy, "Menu.Edit_Copy");
|
---|
[4675] | 183 |
|
---|
[5564] | 184 | edit_paste = new JMenuItem();
|
---|
[4675] | 185 | edit_paste.addActionListener(Gatherer.g_man);
|
---|
[5564] | 186 | edit_paste.setMnemonic(KeyEvent.VK_V);
|
---|
| 187 | Dictionary.registerText(edit_paste, "Menu.Edit_Paste");
|
---|
[4675] | 188 |
|
---|
[5564] | 189 | // edit_undo = new JMenuItem();
|
---|
| 190 | // edit_undo.setEnabled(false);
|
---|
| 191 | // edit_undo.setMnemonic(KeyEvent.VK_U);
|
---|
| 192 | // Dictionary.registerText(edit_undo, "Menu.Edit_Undo");
|
---|
[4675] | 193 |
|
---|
[5564] | 194 | // edit_redo = new JMenuItem();
|
---|
| 195 | // edit_redo.setEnabled(false);
|
---|
| 196 | // edit_redo.setMnemonic(KeyEvent.VK_D);
|
---|
| 197 | // Dictionary.registerText(edit_redo, "Menu.Edit_Redo");
|
---|
[4675] | 198 |
|
---|
[5564] | 199 | // edit_search = new JMenuItem();
|
---|
| 200 | // edit_search.addActionListener(Gatherer.g_man);
|
---|
| 201 | // edit_search.setMnemonic(KeyEvent.VK_S);
|
---|
| 202 | // Dictionary.registerText(edit_search, "Menu.Edit_Search");
|
---|
[4675] | 203 |
|
---|
[5564] | 204 | // edit_replace = new JMenuItem();
|
---|
| 205 | // edit_replace.addActionListener(Gatherer.g_man);
|
---|
| 206 | // edit_replace.setMnemonic(KeyEvent.VK_R);
|
---|
| 207 | // Dictionary.registerText(edit_replace, "Menu.Edit_Replace");
|
---|
[4675] | 208 |
|
---|
[5564] | 209 | // Layout (edit menu)
|
---|
[4675] | 210 | edit.add(edit_cut);
|
---|
| 211 | edit.add(edit_copy);
|
---|
| 212 | edit.add(edit_paste);
|
---|
[5564] | 213 | // edit.add(new JSeparator());
|
---|
| 214 | // edit.add(edit_undo);
|
---|
| 215 | // edit.add(edit_redo);
|
---|
| 216 | // edit.add(new JSeparator());
|
---|
| 217 | // edit.add(edit_search);
|
---|
| 218 | // edit.add(edit_replace);
|
---|
[4675] | 219 |
|
---|
| 220 | // Metadata menu
|
---|
[5564] | 221 | metadata = new JMenu();
|
---|
[4675] | 222 | metadata.setEnabled(false);
|
---|
| 223 | metadata.setMnemonic(KeyEvent.VK_M);
|
---|
[5564] | 224 | Dictionary.registerText(metadata, "Menu.Metadata");
|
---|
[4675] | 225 |
|
---|
[5564] | 226 | metadata_import = new JMenuItem();
|
---|
| 227 | metadata_import.addActionListener(Gatherer.g_man);
|
---|
| 228 | metadata_import.setMnemonic(KeyEvent.VK_I);
|
---|
| 229 | Dictionary.registerText(metadata_import, "Menu.Metadata_Import");
|
---|
[4675] | 230 |
|
---|
[5564] | 231 | metadata_edit = new JMenuItem();
|
---|
[4675] | 232 | metadata_edit.addActionListener(Gatherer.g_man);
|
---|
[5564] | 233 | metadata_edit.setMnemonic(KeyEvent.VK_E);
|
---|
| 234 | Dictionary.registerText(metadata_edit, "Menu.Metadata_Edit");
|
---|
[4675] | 235 |
|
---|
[5564] | 236 | metadata_export = new JMenuItem();
|
---|
[4675] | 237 | metadata_export.addActionListener(Gatherer.g_man);
|
---|
[5564] | 238 | metadata_export.setMnemonic(KeyEvent.VK_X);
|
---|
| 239 | Dictionary.registerText(metadata_export, "Menu.Metadata_Export");
|
---|
[4675] | 240 |
|
---|
[5593] | 241 | metadata_view = new MagicMenuItem(Dictionary.get("Menu.Metadata_View") + " " + Dictionary.get("FileActions.No_Selection"), KeyEvent.VK_A);
|
---|
[4675] | 242 | metadata_view.addActionListener(Gatherer.g_man);
|
---|
| 243 |
|
---|
[5564] | 244 | // Layout (metadata sets menu)
|
---|
| 245 | metadata.add(metadata_import);
|
---|
[4675] | 246 | metadata.add(metadata_edit);
|
---|
| 247 | metadata.add(metadata_export);
|
---|
| 248 | metadata.add(metadata_view);
|
---|
| 249 |
|
---|
| 250 | // Tools menu
|
---|
[5564] | 251 | // tools = new JMenu();
|
---|
| 252 | // tools.setEnabled(false);
|
---|
| 253 | // tools.setMnemonic(KeyEvent.VK_T);
|
---|
| 254 | // Dictionary.registerText(tools, "Menu.Tools");
|
---|
[4675] | 255 |
|
---|
[5564] | 256 | // tools_log = new JMenuItem();
|
---|
| 257 | // tools_log.addActionListener(Gatherer.g_man);
|
---|
| 258 | // tools_log.setMnemonic(KeyEvent.VK_L);
|
---|
| 259 | // Dictionary.registerText(tools_log, "Menu.Tools_Log");
|
---|
[4675] | 260 |
|
---|
[5564] | 261 | // tools_size = new JMenuItem();
|
---|
| 262 | // tools_size.addActionListener(Gatherer.g_man);
|
---|
| 263 | // tools_size.setMnemonic(KeyEvent.VK_C);
|
---|
| 264 | // Dictionary.registerText(tools_size, "Menu.Tools_Calculate_Record_Size");
|
---|
[4675] | 265 |
|
---|
[5564] | 266 | // Layout (tools menu)
|
---|
| 267 | // tools.add(tools_log);
|
---|
| 268 | // tools.add(tools_size);
|
---|
[4675] | 269 |
|
---|
| 270 | // Help menu
|
---|
[5564] | 271 | help = new JMenu();
|
---|
[4675] | 272 | help.setIcon(Utility.HELP_ICON);
|
---|
[5564] | 273 | Dictionary.setText(help, "Menu.Help");
|
---|
[4675] | 274 |
|
---|
[5564] | 275 | help_about = new JMenuItem();
|
---|
[4675] | 276 | help_about.addActionListener(Gatherer.g_man);
|
---|
[5564] | 277 | Dictionary.registerText(help_about, "Menu.Help_About");
|
---|
[4675] | 278 |
|
---|
[5564] | 279 | help_browse = new JMenuItem(Utility.BLANK_ICON);
|
---|
[4675] | 280 | help_browse.addActionListener(Gatherer.g_man);
|
---|
[5564] | 281 | Dictionary.registerText(help_browse, "GUI.Hunt");
|
---|
[4675] | 282 |
|
---|
[5564] | 283 | help_build = new JMenuItem(Utility.BLANK_ICON);
|
---|
[4675] | 284 | help_build.addActionListener(Gatherer.g_man);
|
---|
[5564] | 285 | Dictionary.registerText(help_build, "GUI.Create");
|
---|
[4675] | 286 |
|
---|
[5564] | 287 | help_collect = new JMenuItem(Utility.BLANK_ICON);
|
---|
[4675] | 288 | help_collect.addActionListener(Gatherer.g_man);
|
---|
[5564] | 289 | Dictionary.registerText(help_collect, "GUI.Gather");
|
---|
[4675] | 290 |
|
---|
[5564] | 291 | help_design = new JMenuItem(Utility.BLANK_ICON);
|
---|
[4675] | 292 | help_design.addActionListener(Gatherer.g_man);
|
---|
[5564] | 293 | Dictionary.registerText(help_design, "GUI.Design");
|
---|
[4675] | 294 |
|
---|
[5564] | 295 | help_export = new JMenuItem(Utility.BLANK_ICON);
|
---|
[4675] | 296 | help_export.addActionListener(Gatherer.g_man);
|
---|
[5564] | 297 | Dictionary.registerText(help_export, "GUI.Export");
|
---|
[4675] | 298 |
|
---|
[5564] | 299 | help_general = new JMenuItem();
|
---|
[4675] | 300 | help_general.addActionListener(Gatherer.g_man);
|
---|
[5564] | 301 | Dictionary.registerText(help_general, "Source.General");
|
---|
[4675] | 302 |
|
---|
[5564] | 303 | help_metaedit = new JMenuItem(Utility.BLANK_ICON);
|
---|
[4675] | 304 | help_metaedit.addActionListener(Gatherer.g_man);
|
---|
[5564] | 305 | Dictionary.registerText(help_metaedit, "GUI.Enrich");
|
---|
[4675] | 306 |
|
---|
[5564] | 307 | help_mirror = new JMenuItem(Utility.BLANK_ICON);
|
---|
[4675] | 308 | help_mirror.addActionListener(Gatherer.g_man);
|
---|
[5564] | 309 | Dictionary.registerText(help_mirror, "GUI.Mirror");
|
---|
[4675] | 310 |
|
---|
[5564] | 311 | help_preview = new JMenuItem(Utility.BLANK_ICON);
|
---|
[4675] | 312 | help_preview.addActionListener(Gatherer.g_man);
|
---|
[5564] | 313 | Dictionary.registerText(help_preview, "GUI.Preview");
|
---|
[4675] | 314 |
|
---|
[5564] | 315 | // Layout (help menu)
|
---|
[4675] | 316 | help.add(help_general);
|
---|
| 317 | help.add(new JSeparator());
|
---|
[5564] | 318 | if (Gatherer.config.get("workflow.browse", true)) {
|
---|
[4675] | 319 | help.add(help_browse);
|
---|
| 320 | }
|
---|
[5564] | 321 | if (Gatherer.config.get("workflow.mirror", true)) {
|
---|
[4675] | 322 | help.add(help_mirror);
|
---|
| 323 | }
|
---|
[5564] | 324 | if (Gatherer.config.get("workflow.gather", true)) {
|
---|
[4675] | 325 | help.add(help_collect);
|
---|
| 326 | }
|
---|
[5564] | 327 | if (Gatherer.config.get("workflow.enrich", true)) {
|
---|
[4675] | 328 | help.add(help_metaedit);
|
---|
| 329 | }
|
---|
[5564] | 330 | if (Gatherer.config.get("workflow.design", true)) {
|
---|
[4675] | 331 | help.add(help_design);
|
---|
| 332 | }
|
---|
[5564] | 333 | if (Gatherer.config.get("workflow.export", true)) {
|
---|
[4675] | 334 | help.add(help_export);
|
---|
| 335 | }
|
---|
[5564] | 336 | if (Gatherer.config.get("workflow.create", true)) {
|
---|
[4675] | 337 | help.add(help_build);
|
---|
| 338 | }
|
---|
[5564] | 339 | if (Gatherer.config.get("workflow.preview", true)) {
|
---|
[4675] | 340 | help.add(help_preview);
|
---|
| 341 | }
|
---|
| 342 | help.add(new JSeparator());
|
---|
| 343 | help.add(help_about);
|
---|
[5564] | 344 |
|
---|
| 345 | // Layout (menu bar)
|
---|
| 346 | this.add(file);
|
---|
| 347 | this.add(Box.createHorizontalStrut(15));
|
---|
| 348 | this.add(edit);
|
---|
| 349 | this.add(Box.createHorizontalStrut(15));
|
---|
| 350 | this.add(metadata);
|
---|
| 351 | // this.add(Box.createHorizontalStrut(15));
|
---|
| 352 | // this.add(tools);
|
---|
[4675] | 353 | this.add(Box.createHorizontalGlue());
|
---|
| 354 | this.add(help);
|
---|
| 355 | }
|
---|
| 356 |
|
---|
| 357 | public void collectionChanged(boolean ready) {
|
---|
| 358 | file_close.setEnabled(ready);
|
---|
| 359 | file_save.setEnabled(ready);
|
---|
[5564] | 360 | // file_save_as.setEnabled(ready);
|
---|
[4675] | 361 | metadata.setEnabled(ready);
|
---|
[5564] | 362 | // tools.setEnabled(ready);
|
---|
| 363 | if (ready) {
|
---|
| 364 | // Gatherer.c_man.undo.registerRedoSource(edit_redo);
|
---|
| 365 | // Gatherer.c_man.undo.registerUndoSource(edit_undo);
|
---|
[4675] | 366 | }
|
---|
| 367 | }
|
---|
| 368 |
|
---|
| 369 | /** Once a quit has been requested by the user, prevent any further menu selections. */
|
---|
| 370 | public void exit() {
|
---|
[5564] | 371 | file.setEnabled(false);
|
---|
[4675] | 372 | edit.setEnabled(false);
|
---|
[5564] | 373 | metadata.setEnabled(false);
|
---|
| 374 | // tools.setEnabled(false);
|
---|
[4675] | 375 | help.setEnabled(false);
|
---|
| 376 | }
|
---|
| 377 |
|
---|
| 378 | public void setMetaAuditSuffix(String metaaudit_suffix) {
|
---|
| 379 | ///ystem.err.println("**** Set suffix: " + metaaudit_suffix);
|
---|
| 380 | if(metaaudit_suffix == null) {
|
---|
[5593] | 381 | metadata_view.setText(Dictionary.get("Menu.Metadata_View") + " " + Dictionary.get("FileActions.No_Selection"));
|
---|
[4675] | 382 | metadata_view.setEnabled(false);
|
---|
| 383 | }
|
---|
| 384 | else {
|
---|
| 385 | ///ystem.err.println("Set metadata view suffix: " + metaaudit_suffix);
|
---|
[5593] | 386 | metadata_view.setText(Dictionary.get("Menu.Metadata_View") + " " + metaaudit_suffix);
|
---|
[4675] | 387 | metadata_view.setEnabled(true);
|
---|
| 388 | }
|
---|
| 389 | }
|
---|
| 390 |
|
---|
| 391 | /** Set the enabled state of one of the help menu items, based on its 'tabs' current state. Note that this method should only be called from the AWTEvent thread. */
|
---|
[5785] | 392 | /* private void tabEnabled(int tab_index, boolean state) {
|
---|
[4675] | 393 | JMenuItem selected = help.getItem(tab_index + 2); // Remember general and separator items
|
---|
| 394 | selected.setEnabled(state);
|
---|
[5785] | 395 | } */
|
---|
[4675] | 396 |
|
---|
| 397 | /** In order to provide context aware help advice we keep track of which
|
---|
[5527] | 398 | * tab the user has open, and then highlight that help menu item with
|
---|
| 399 | * separators.
|
---|
| 400 | * @param tab_index The index of the selected tab (0-7).
|
---|
| 401 | */
|
---|
[4675] | 402 | public void tabSelected(int tab_index) {
|
---|
| 403 | JMenuItem selected;
|
---|
| 404 | if(current_tab != -1) {
|
---|
[5564] | 405 | // Remove the image
|
---|
[4675] | 406 | selected = help.getItem(current_tab);
|
---|
| 407 | if(selected != null) {
|
---|
| 408 | selected.setIcon(Utility.BLANK_ICON);
|
---|
| 409 | }
|
---|
| 410 | }
|
---|
| 411 | current_tab = tab_index + 2;
|
---|
| 412 | selected = help.getItem(current_tab);
|
---|
| 413 | if(selected != null) {
|
---|
| 414 | selected.setIcon(Utility.HELP_ICON);
|
---|
| 415 | }
|
---|
| 416 | selected = null;
|
---|
| 417 | }
|
---|
| 418 |
|
---|
| 419 |
|
---|
| 420 | public class MagicMenuItem
|
---|
| 421 | extends JMenuItem {
|
---|
[5564] | 422 |
|
---|
[4675] | 423 | private boolean can_enable;
|
---|
| 424 | private boolean should_enable;
|
---|
| 425 |
|
---|
| 426 | public MagicMenuItem(String title, int key_event) {
|
---|
| 427 | super(title, key_event);
|
---|
| 428 | super.setEnabled(false);
|
---|
| 429 | can_enable = false;
|
---|
| 430 | should_enable = false;
|
---|
| 431 | }
|
---|
| 432 |
|
---|
| 433 | public void setCanEnable(boolean can_enable) {
|
---|
| 434 | this.can_enable = can_enable;
|
---|
| 435 | if (can_enable) {
|
---|
| 436 | super.setEnabled(should_enable);
|
---|
| 437 | }
|
---|
| 438 | else {
|
---|
| 439 | super.setEnabled(false);
|
---|
| 440 | }
|
---|
| 441 | }
|
---|
| 442 |
|
---|
| 443 | public void setEnabled(boolean should_enable) {
|
---|
| 444 | this.should_enable = should_enable;
|
---|
[5564] | 445 | if (can_enable) {
|
---|
[4675] | 446 | super.setEnabled(should_enable);
|
---|
| 447 | }
|
---|
| 448 | }
|
---|
| 449 | }
|
---|
| 450 | }
|
---|