source: trunk/gli/src/org/greenstone/gatherer/gui/DesignPane.java@ 10396

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

Fixed a couple of null pointer exceptions thrown when attempting to change modes without a collection open.

  • Property svn:keywords set to Author Date Id Revision
File size: 3.6 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.io.*;
41import java.util.*;
42import javax.swing.*;
43import org.greenstone.gatherer.Gatherer;
44import org.greenstone.gatherer.cdm.CollectionDesignManager;
45/** This serves as the Collection configuration pane and came in two flavors.<BR>
46 * The lower tech version has now been made redundant.<BR>
47 * The higher tech, and finally implemented, version uses a tree to allow a user to navigate through the various regions of the config file and further allows them to interactively design and modify such gsdl elements as classifiers and plugins.
48 * @author John Thompson, Greenstone Digital Library, University of Waikato
49 * @version 2.2
50 */
51public class DesignPane
52 extends JPanel {
53 /** The collection manager is responsible for parsing in, and allowing the editing of, a single collections configuration file. */
54 private CollectionDesignManager cdm = null;
55
56 /** The constructor. */
57 public DesignPane() {
58 }
59
60 /** Called to cause the components to lay themselves out and be displayed.
61 */
62 public void display() {
63 // Layout
64 this.setLayout(new BorderLayout());
65 }
66
67 public void gainFocus() {
68 if (cdm == null && Gatherer.c_man.ready()) {
69 // Retrieve the new config manager.
70 cdm = Gatherer.c_man.getCollection().cdm;
71 // Display it.
72 cdm.display(this);
73 }
74 if (cdm != null) {
75 cdm.gainFocus();
76 }
77 }
78
79 public ArrayList getLanguageCodes() {
80 return cdm.language_manager.getLanguageCodes();
81 }
82
83 public boolean canSave() {
84 return cdm.canSave();
85 }
86
87 public void loseFocus() {
88 if (cdm != null) {
89 cdm.save();
90 }
91 }
92
93 /** Called whenever the detail mode changes to ensure the filters are at an appropriate level (ie only editable by those that understand regular expression matching)
94 * @param mode the mode level as an int
95 */
96 public void modeChanged(int mode) {
97 if (cdm != null) {
98 cdm.modeChanged(mode);
99 }
100 }
101
102 /** This method is called whenever the state of the current collection changes.
103 */
104 public void refresh(int refresh_reason, boolean ready)
105 {
106 if (ready) {
107 // Retrieve the new config manager.
108 cdm = Gatherer.c_man.getCollection().cdm;
109 // Display it.
110 cdm.display(this);
111 }
112 else {
113 if (cdm != null) {
114 cdm.destroy();
115 cdm = null;
116 }
117 }
118 }
119
120 public void saveConfiguration() {
121 if (cdm != null) {
122 cdm.save();
123 }
124 }
125}
Note: See TracBrowser for help on using the repository browser.