source: trunk/gli/src/org/greenstone/gatherer/cdm/GUI.java@ 4364

Last change on this file since 4364 was 4293, checked in by jmt12, 21 years ago

Initial revision

  • Property svn:keywords set to Author Date Id Revision
File size: 26.8 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 */
37
38
39
40
41
42
43package org.greenstone.gatherer.cdm;
44/**************************************************************************************
45 * Title: Gatherer
46 * Description: The Gatherer: a tool for gathering and enriching a digital collection.
47 * Copyright: Copyright (c) 2001
48 * Company: The University of Waikato
49 * Written: 03/05/02
50 * Revised: 28/05/02
51 **************************************************************************************/
52import java.awt.AWTEvent;
53import java.awt.BorderLayout;
54import java.awt.Color;
55import java.awt.Dimension;
56import java.awt.FlowLayout;
57import java.awt.GridLayout;
58import java.awt.event.ActionEvent;
59import java.awt.event.ActionListener;
60import java.awt.event.KeyAdapter;
61import java.awt.event.KeyEvent;
62import java.awt.event.WindowEvent;
63import javax.swing.BorderFactory;
64import javax.swing.JCheckBox;
65import javax.swing.JFrame;
66import javax.swing.JLabel;
67import javax.swing.JPanel;
68import javax.swing.JScrollPane;
69import javax.swing.JTextArea;
70import javax.swing.JTextField;
71import javax.swing.JTree;
72import javax.swing.event.TreeSelectionEvent;
73import javax.swing.event.TreeSelectionListener;
74import javax.swing.text.JTextComponent;
75import javax.swing.tree.DefaultMutableTreeNode;
76import javax.swing.tree.DefaultTreeModel;
77import javax.swing.tree.TreePath;
78import org.greenstone.gatherer.Gatherer;
79import org.greenstone.gatherer.cdm.CollectionDesignManager;
80import org.greenstone.gatherer.cdm.CollectionMeta;
81import org.greenstone.gatherer.util.EmailAddress;
82import org.greenstone.gatherer.util.Utility;
83/** This class is responsible for generating the necessary GUI components. It does this by calling the getEditControls() method of the appropriate class (i.e. IndexManager for index related edits). It also is in charge of correctly adding (and removing) listeners, using phrases from the <strong>Dictionary</strong> rather than the text keys inserted in the component classes, and several other aspects of the design page, including the config file section tree.
84* @author John Thompson, Greenstone Digital Library, University of Waikato
85* @version 2.3
86*/
87public class GUI
88 extends JPanel {
89 /** A reference to the collection manager, as it is here that all of the other data members and managers reside. */
90 private CollectionDesignManager manager = null;
91 /** The controls used to modify the general options. */
92 private Control controls = null;
93 /** A tree to serve as a 'table of contents' for this design tool. We decided on a tree rather than a list, as it allows us to break sections into subsections if they become to complicated. */
94 private DesignTree tree = null;
95 /** A reference to the Gatherer. */
96 private Gatherer gatherer = null;
97 /** The title located just above the content tree. */
98 private JLabel title = null;
99 /** The panel containing both the title and the tree. */
100 private JPanel tree_pane = null;
101 /** The panel apon which is rendered the currently selected section screen. */
102 private JPanel view = null;
103 /** The available subscreens. */
104 static final public String CONTENTS[] = {"General", "Indexes", "Subcollections", "Languages", "Plugins", "Classifiers", "Formats", "MetadataSets"};
105 /** The preferred size of the collection design module screen real-estate. */
106 static final private Dimension SIZE = new Dimension(760, 500);
107 /** Constructor.
108 * @see DesignTree
109 * @see org.greenstone.gatherer.cdm.CollectionDesignManager
110 */
111 public GUI(Gatherer gatherer, CollectionDesignManager manager) {
112 super();
113 // Assignments
114 this.gatherer = gatherer;
115 this.manager = manager;
116 // Creation
117 this.title = new JLabel(get("Design_Topics"));
118 this.tree = new DesignTree();
119 this.tree_pane = new JPanel();
120 this.view = getControls();
121 // Connect
122 tree.addTreeSelectionListener(new TreeListener());
123 tree_pane.setLayout(new BorderLayout());
124 tree_pane.add(title, BorderLayout.NORTH);
125 tree_pane.add(new JScrollPane(tree), BorderLayout.CENTER);
126 // Layout
127 setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
128 setLayout(new BorderLayout());
129 add(tree_pane, BorderLayout.WEST);
130 add(view, BorderLayout.CENTER);
131 }
132 /** Mark the current set of controls as invalid. If they are needed again in the future new controls will be generate.
133 * @see org.greenstone.gatherer.cdm.GUI.Control
134 */
135 public void invalidateControls() {
136 if(controls != null) {
137 controls.destroy();
138 }
139 controls = null;
140 }
141 /** Force the display to show a certain pane of controls.
142 * @param type A <strong>String</strong> giving the name of the submanager view we wish to display.
143 */
144 public void setSelectedView(String type) {
145 tree.setSelectedView(type);
146 }
147 /** Overrides the normal updateUI to ensure that the current view also recieves an update message.
148 */
149 public void updateUI() {
150 if(view != null) {
151 view.updateUI();
152 }
153 super.updateUI();
154 }
155 /**Overridden so we can exit when window is closed
156 * @param event A <strong>WindowsEvent</strong> that encapsulates all the information gathered about the event that called this method.
157 * @see org.greenstone.gatherer.cdm.CollectionDesignManager
158 */
159 protected void processWindowEvent(WindowEvent event) {
160 if(event.getID() == WindowEvent.WINDOW_CLOSING) {
161 manager.save();
162 System.exit(0);
163 }
164 }
165 /** Overloaded to call get with both a key and an empty argument array.
166 * @param key A <strong>String</strong> which is mapped to a initial String within the ResourceBundle.
167 * @return A <strong>String</strong> which has been referenced by the key String and that either contains no argument fields, or has had the argument fields automatiically populated with formatting Strings of with argument String provided in the get call.
168 */
169 private String get(String key) {
170 return get(key, null);
171 }
172 /** Used to retrieve a property value from the Locale specific ResourceBundle, based upon the key and arguments supplied. If the key cannot be found or if some other part of the call fails a default (English) error message is returned. <BR>
173 * Here the get recieves a second argument which is an array of Strings used to populate argument fields, denoted {<I>n</I>}, within the value String returned. Note that argument numbers greater than or equal to 32 are automatically mapped to the formatting String named Farg<I>n</I>.
174 * @param key A <strong>String</strong> which is mapped to a initial String within the ResourceBundle.
175 * @param args A <strong>String[]</strong> used to populate argument fields within the complete String.
176 * @return A <strong>String</strong> which has been referenced by the key String and that either contains no argument fields, or has had the argument fields automatiically populated with formatting Strings of with argument String provided in the get call.
177 * @see org.greenstone.gatherer.Gatherer
178 * @see org.greenstone.gatherer.Dictionary
179 */
180 private String get(String key, String args[]) {
181 if(key.indexOf('.') == -1) {
182 key = "CDM.GUI." + key;
183 }
184 return gatherer.dictionary.get(key, args);
185 }
186 /** Because the CollectionDesignManager has enough to do, this class is resposible for generating the controls for the general options, all of which are stored in the aforementioned manager.
187 * @return A <strong>JPanel</strong> containing controls for editing the general options.
188 */
189 private JPanel getControls() {
190 if(controls == null) {
191 controls = new Control();
192 }
193 return controls;
194 }
195 /** This class represents the visual component of the general options stored in the CollectionDesignManager. */
196 private class Control
197 extends JPanel {
198 /** The collection metadata representing the extra or description of the collection. */
199 private CollectionMeta collection_extra_data = null;
200 /** The collection metadata representing the name of the collection. */
201 private CollectionMeta collection_name_data = null;
202 /** The collection metadata representing the icon file location of the collection. */
203 private CollectionMeta icon_collection_data = null;
204 /** The default size of label on this control. */
205 private Dimension LABEL_SIZE = new Dimension(200,25);
206 /** The checkbox controlling public access to the collection. */
207 private JCheckBox access = null;
208 /** The checkbox controlling the state of the collection. */
209 private JCheckBox beta = null;
210 /** The label denoting the collection extra area. */
211 private JLabel collection_extra_label = null;
212 /** The label denoting the collection extra language (Default). */
213 private JLabel collection_extra_language = null;
214 /** The label denoting the collection name area. */
215 private JLabel collection_name_label = null;
216 /** The label denoting the name language (Default). */
217 private JLabel collection_name_language = null;
218 /** The label denoting the collection icon area. */
219 private JLabel icon_collection_label = null;
220 /** The label denoting the icon language (Default). */
221 private JLabel icon_collection_language = null;
222 /** The label which serves as the title of this view. */
223 private JLabel title = null;
224 /** The panel containing the access controls. */
225 private JPanel access_pane = null;
226 /** The panel containing the state controls. */
227 private JPanel beta_pane = null;
228 /** The central pane that will contain the view. */
229 private JPanel central_pane = null;
230 /** A panel used to affect internal layout of the collection extra area. */
231 private JPanel collection_extra_inner_pane = null;
232 /** The panel containing the collection extra area. */
233 private JPanel collection_extra_pane = null;
234 /** A panel used to affect internal layout of the collection name area. */
235 private JPanel collection_name_inner_pane = null;
236 /** The panel containing the collection name area. */
237 private JPanel collection_name_pane = null;
238 /** A panel used to affect internal layout of the collection icon area. */
239 private JPanel icon_collection_inner_pane = null;
240 /** The panel containing the icon area. */
241 private JPanel icon_collection_pane = null;
242 /** A text area used to display the inline help for this manager. */
243 private JTextArea instructions = null;
244 /** The text field used to edit the collections title. */
245 private JTextField collection_name = null;
246 /** The text field used to edit the file name of the collections icon. */
247 private JTextField icon_collection = null;
248 /** A text area used to modify the collection description. */
249 private JTextArea collection_extra = null;
250 /** Constructor.
251 * @see org.greenstone.gatherer.cdm.CollectionDesignManager
252 * @see org.greenstone.gatherer.cdm.CollectionMeta
253 * @see org.greenstone.gatherer.cdm.CollectionMetaManager
254 * @see org.greenstone.gatherer.cdm.Language
255 * @see org.greenstone.gatherer.cdm.LanguageManager
256 */
257 public Control() {
258 super();
259 collection_extra_data = manager.collectionmetadatum.getCollectionExtra();
260 collection_name_data = manager.collectionmetadatum.getCollectionName();
261 icon_collection_data = manager.collectionmetadatum.getIconCollection();
262 // Creation.
263 access = new JCheckBox(get("CDM.General.Access"));
264 access.setSelected(manager.public_col);
265 access_pane = new JPanel();
266 beta = new JCheckBox(get("CDM.General.Beta"));
267 beta.setSelected(manager.beta);
268 beta_pane = new JPanel();
269 central_pane = new JPanel();
270 collection_extra = new JTextArea();
271 collection_extra_inner_pane = new JPanel();
272 collection_extra_label = new JLabel(get("CDM.General.Collection_Extra"));
273 collection_extra_label.setHorizontalAlignment(JLabel.CENTER);
274 collection_extra_language = new JLabel();
275 collection_extra_pane = new JPanel();
276 if(collection_extra_data != null) {
277 collection_extra.setText(collection_extra_data.getValue());
278 Language language = null;
279 if((language = collection_extra_data.getLanguage()) != null) {
280 collection_extra_language.setText(language.toString());
281 }
282 else {
283 collection_extra_language.setText(manager.languages.getDefaultLanguage().toString());
284 }
285 }
286 collection_name = new JTextField();
287 collection_name_inner_pane = new JPanel();
288 collection_name_label = new JLabel(get("CDM.General.Collection_Name"));
289 collection_name_label.setPreferredSize(LABEL_SIZE);
290 collection_name_language = new JLabel();
291 collection_name_pane = new JPanel();
292 if(collection_name_data != null) {
293 collection_name.setText(collection_name_data.getValue());
294 Language language = null;
295 if((language = collection_name_data.getLanguage()) != null) {
296 collection_name_language.setText(language.toString());
297 }
298 else {
299 collection_name_language.setText(manager.languages.getDefaultLanguage().toString());
300 }
301 }
302 icon_collection = new JTextField();
303 icon_collection_inner_pane = new JPanel();
304 icon_collection_label = new JLabel(get("CDM.General.Icon_Collection"));
305 icon_collection_label.setPreferredSize(LABEL_SIZE);
306 icon_collection_language = new JLabel();
307 icon_collection_pane = new JPanel();
308 if(icon_collection_data != null) {
309 icon_collection.setText(icon_collection_data.getValue());
310 Language language = null;
311 if((language = icon_collection_data.getLanguage()) != null) {
312 icon_collection_language.setText(language.toString());
313 }
314 else {
315 icon_collection_language.setText(manager.languages.getDefaultLanguage().toString());
316 }
317 }
318 instructions = new JTextArea(get("CDM.General.Instructions"));
319 instructions.setBackground(Gatherer.config.getColor("coloring.collection_tree_background", false));
320 instructions.setEditable(false);
321 instructions.setLineWrap(true);
322 instructions.setRows(4);
323 instructions.setWrapStyleWord(true);
324 JPanel lower = new JPanel();
325 title = new JLabel(get("CDM.General.Title"));
326 title.setHorizontalAlignment(JLabel.CENTER);
327 title.setOpaque(true);
328 JPanel upper = new JPanel();
329 // Add listeners.
330 access.addActionListener(new AccessListener());
331 beta.addActionListener(new BetaListener());
332 collection_extra.addKeyListener(new ChangeListener(collection_extra_data, collection_extra, "collectionextra"));
333 collection_name.addKeyListener(new ChangeListener(collection_name_data, collection_name, "collectionname"));
334 collection_name.addKeyListener(new CollectionTitleListener());
335 icon_collection.addKeyListener(new ChangeListener(icon_collection_data, icon_collection, "iconcollection"));
336 // Layout
337 instructions.setBorder(BorderFactory.createEmptyBorder(2,5,2,5));
338
339 upper.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
340 upper.setLayout(new BorderLayout());
341 upper.add(title, BorderLayout.NORTH);
342 upper.add(new JScrollPane(instructions), BorderLayout.CENTER);
343
344 collection_name_label.setBorder(BorderFactory.createEmptyBorder(0,0,0,5));
345 collection_name_language.setBorder(BorderFactory.createEmptyBorder(0,5,0,0));
346
347 collection_name_inner_pane.setBorder(BorderFactory.createEmptyBorder(5,0,5,0));
348 collection_name_inner_pane.setLayout(new BorderLayout());
349 collection_name_inner_pane.add(collection_name);
350
351 collection_name_pane.setLayout(new BorderLayout());
352 collection_name_pane.add(collection_name_label, BorderLayout.WEST);
353 collection_name_pane.add(collection_name_inner_pane, BorderLayout.CENTER);
354 collection_name_pane.add(collection_name_language, BorderLayout.EAST);
355
356 icon_collection_label.setBorder(BorderFactory.createEmptyBorder(0,0,0,5));
357 icon_collection_language.setBorder(BorderFactory.createEmptyBorder(0,5,0,0));
358
359 icon_collection_inner_pane.setBorder(BorderFactory.createEmptyBorder(5,0,5,0));
360 icon_collection_inner_pane.setLayout(new BorderLayout());
361 icon_collection_inner_pane.add(icon_collection, BorderLayout.CENTER);
362
363 icon_collection_pane.setLayout(new BorderLayout());
364 icon_collection_pane.add(icon_collection_label, BorderLayout.WEST);
365 icon_collection_pane.add(icon_collection_inner_pane, BorderLayout.CENTER);
366 icon_collection_pane.add(icon_collection_language, BorderLayout.EAST);
367
368 access_pane.add(access);
369
370 beta_pane.add(beta);
371
372 lower.setBorder(BorderFactory.createEmptyBorder(0,5,5,5));
373 lower.setLayout(new GridLayout(6,1));
374 lower.add(manager.creator.getControls());
375 lower.add(manager.maintainer.getControls());
376 lower.add(access_pane);
377 lower.add(beta_pane);
378 lower.add(collection_name_pane);
379 lower.add(icon_collection_pane);
380
381 collection_extra_inner_pane.setLayout(new BorderLayout());
382 collection_extra_inner_pane.add(collection_extra_label, BorderLayout.WEST);
383 collection_extra_inner_pane.add(collection_extra_language, BorderLayout.EAST);
384
385 collection_extra.setBorder(BorderFactory.createEmptyBorder(2,5,2,5));
386
387 collection_extra_pane.setBorder(BorderFactory.createEmptyBorder(0,5,5,5));
388 collection_extra_pane.setLayout(new BorderLayout());
389 collection_extra_pane.add(collection_extra_inner_pane, BorderLayout.NORTH);
390 collection_extra_pane.add(new JScrollPane(collection_extra), BorderLayout.CENTER);
391
392 central_pane.setLayout(new BorderLayout());
393 central_pane.add(lower, BorderLayout.NORTH);
394 central_pane.add(collection_extra_pane, BorderLayout.CENTER);
395
396 setLayout(new BorderLayout());
397 add(upper, BorderLayout.NORTH);
398 add(central_pane, BorderLayout.CENTER);
399 }
400 /** Destructor.
401 */
402 public void destroy() {
403 }
404 /** We override the updateUI method so that we can ensure we are scrolled to the top of the instructions box first.
405 */
406 public void updateUI() {
407 if(instructions != null) {
408 instructions.setCaretPosition(0);
409 }
410 if(collection_extra != null) {
411 collection_extra.setCaretPosition(0);
412 }
413 super.updateUI();
414 }
415 /** Detect when the collection access changes, and update the configuration as necessary.
416 * @see org.greenstone.gatherer.cdm.CollectionDesignManager
417 */
418 private class AccessListener
419 implements ActionListener {
420 public void actionPerformed(ActionEvent event) {
421 manager.public_col = access.isSelected();
422 }
423 }
424 /** Detect when the collection state changes and update the configuration as necessary.
425 * @see org.greenstone.gatherer.cdm.CollectionDesignManager
426 */
427 private class BetaListener
428 implements ActionListener {
429 public void actionPerformed(ActionEvent event) {
430 manager.beta = beta.isSelected();
431 }
432 }
433 /** This class listens for any changes its registered controls, including enter actions and keys typed, and updates the fields stored in CollectionDesignManager as necessary. */
434 private class ChangeListener
435 extends KeyAdapter {
436 /** The collection metadata to alter. */
437 private CollectionMeta metadata = null;
438 /** The control we are watching for changes. */
439 private JTextComponent component = null;
440 /** The name of the metadata to monitor. */
441 private String name = null;
442 /** Construstor.
443 * @param metadata The <strong>CollectionMeta</strong> to alter.
444 * @param component The <strong>JTextComponent</strong> we are monitoring for changes.
445 * @param name The name of the metadata as a <strong>String</strong>.
446 */
447 public ChangeListener(CollectionMeta metadata, JTextComponent component, String name) {
448 this.component = component;
449 this.metadata = metadata;
450 if(metadata != null) {
451 this.name = metadata.getName().toString();
452 }
453 else {
454 this.name = name;
455 }
456 }
457 /** Any extension of a KeyAdapter may override this method so we can be informed when a key has been released (ie after the character etc has been added). In this case we want to update the appropriate metadata, however there are three distinct cases to consider:<br>&nbsp;1. A simple update of the value field is all that is necessary,<br>&nbsp;2. The metadata exists but it currently has no language, so we must set the language to default and update the value, or<br>&nbsp;3. The metadata doesn't exist so we'll create a new one with the specified name, default language and new value.<br>This final case is highly unlikely but still possible.
458 * @param event An <strong>Event</strong> containing information about the key release.
459 * @see org.greenstone.gatherer.Gatherer
460 * @see org.greenstone.gatherer.cdm.CollectionDesignManager
461 * @see org.greenstone.gatherer.cdm.CollectionMeta
462 * @see org.greenstone.gatherer.cdm.CollectionMetaManager
463 * @see org.greenstone.gatherer.cdm.Language
464 * @see org.greenstone.gatherer.cdm.LanguageManager
465 * @see org.greenstone.gatherer.collection.CollectionManager
466 */
467 public void keyReleased(KeyEvent event) {
468 if(metadata != null) {
469 Language language = metadata.getLanguage();
470 if(language == null) {
471 metadata.update(metadata.getName(), manager.languages.getDefaultLanguage(), component.getText());
472 }
473 else {
474 metadata.update(metadata.getName(), metadata.getLanguage(), component.getText());
475 }
476 }
477 else {
478 metadata = new CollectionMeta(manager, name, manager.languages.getDefaultLanguage(), component.getText());
479 manager.collectionmetadatum.addMetadata(metadata);
480 }
481 gatherer.c_man.configurationChanged();
482 }
483 }
484 /** Listens for changes to the collection name and updates the windows title bar appropriately and collection file. */
485 private class CollectionTitleListener
486 extends KeyAdapter {
487 /** Any extension of a KeyAdapter may override this method so we can be informed when a key has been released (ie after the character etc has been added). When such a change occurs update the main guis title bar to reflect the change and fix the collection name.
488 * @param event An <strong>Event</strong> containing information about the key release.
489 */
490 public void keyReleased(KeyEvent event) {
491 String name = collection_name.getText();
492 if(name != null && name.length() > 0) {
493 gatherer.g_man.setTitle(Utility.PROGRAM_NAME + ":\"" + name + "\"");
494 gatherer.c_man.getCollection().setTitle(name);
495 }
496 }
497 }
498 }
499 /** This tree provides a 'table of contents' for the various components of the design process (collection configuration in more technical terms). */
500 private class DesignTree
501 extends JTree {
502 private DesignNode root = null;
503 /** Constructor. Automatically generates all of the nodes, in the order of CONTENTS.
504 */
505 public DesignTree() {
506 super();
507 root = new DesignNode("Root");
508 this.setModel(new DefaultTreeModel(root));
509 // Now add the design categories.
510 for(int i = 0; i < CONTENTS.length; i++) {
511 root.add(new DesignNode(CONTENTS[i]));
512 }
513 expandRow(0);
514 setRootVisible(false);
515 setSelectionRow(0);
516 }
517 /** Set the current view to the one specified.
518 * @param type The name of the desired view as a <strong>String</strong>.
519 * @see org.greenstone.gatherer.Gatherer
520 * @see org.greenstone.gatherer.cdm.GUI.DesignNode
521 */
522 public void setSelectedView(String type) {
523 type = gatherer.get(type);
524 for(int i = 0; i < root.getChildCount(); i++) {
525 DesignNode child = (DesignNode) root.getChildAt(i);
526 if(child.toString().equals(type)) {
527 TreePath path = new TreePath(child.getPath());
528 setSelectionPath(path);
529 }
530 }
531 }
532 }
533 /** A tree node that retains a reference to one of the possible design sub-views relating to the different sub-managers. */
534 private class DesignNode
535 extends DefaultMutableTreeNode {
536 /** Constructor.
537 * @param object The <strong>Object</strong> assigned to this node.
538 */
539 public DesignNode(String object) {
540 super(object);
541 }
542 /** Retrieve a textual representation of the object.
543 * @return A <strong>String</strong>.
544 */
545 public String toString() {
546 return get((String)getUserObject());
547 }
548 }
549 /** Listens for selection changes in the 'contents' tree, and switches to the appropriate view. */
550 private class TreeListener
551 implements TreeSelectionListener {
552 /** Called whenever the selection changes, we must update the view so it matches the node selected.
553 * @param event A <strong>TreeSelectionEvent</strong> containing more information about the tree selection.
554 * @see org.greenstone.gatherer.cdm.ClassifierManager
555 * @see org.greenstone.gatherer.cdm.CollectionDesignManager
556 * @see org.greenstone.gatherer.cdm.CollectionMetaManager
557 * @see org.greenstone.gatherer.cdm.FormatManager
558 * @see org.greenstone.gatherer.cdm.LanguageManager
559 * @see org.greenstone.gatherer.cdm.MetadataSetManager
560 * @see org.greenstone.gatherer.cdm.SubcollectionManager
561 * @see org.greenstone.gatherer.cdm.PlugInManager
562 */
563 public void valueChanged(TreeSelectionEvent event) {
564 if(!tree.isSelectionEmpty()) {
565 TreePath path = tree.getSelectionPath();
566 DesignNode node = (DesignNode)path.getLastPathComponent();
567 String type = (String)node.getUserObject();
568 // Assure user
569 // Build and change panes.
570 remove(view);
571 view.hasFocus(); // Trigger pending information update events.
572 if(type.equals("General")) {
573 view = getControls();
574 }
575 else if(type.equals("Indexes")) {
576 view = manager.indexes.getControls();
577 }
578 else if(type.equals("Subcollections")) {
579 view = manager.subcollections.getControls();
580 }
581 else if(type.equals("Languages")) {
582 view = manager.languages.getControls();
583 }
584 else if(type.equals("Plugins")) {
585 view = manager.plugins.getControls();
586 }
587 else if(type.equals("Classifiers")) {
588 view = manager.classifiers.getControls();
589 }
590 else if(type.equals("Formats")) {
591 view = manager.formats.getControls();
592 }
593 else if(type.equals("MetadataSets")) {
594 view = manager.metadatasets.getControls();
595 }
596 add(view, BorderLayout.CENTER);
597 view.updateUI();
598 // Ready
599 }
600 }
601 }
602}
Note: See TracBrowser for help on using the repository browser.