source: trunk/gli/src/org/greenstone/gatherer/cdm/CollectionDesignManager.java@ 4932

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

Major CDM rewrite so it uses DOM.

  • Property svn:keywords set to Author Date Id Revision
File size: 9.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 * Author: John Thompson, Greenstone Digital Library, University of Waikato
9 *
10 * Copyright (C) 1999 New Zealand Digital Library Project
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 *########################################################################
26 */
27package org.greenstone.gatherer.cdm;
28import java.awt.*;
29import java.awt.event.*;
30import java.io.*;
31import javax.swing.*;
32import javax.swing.event.*;
33import org.greenstone.gatherer.Gatherer;
34import org.greenstone.gatherer.cdm.ClassifierManager;
35import org.greenstone.gatherer.cdm.CollectionConfiguration;
36import org.greenstone.gatherer.cdm.CollectionMetaManager;
37import org.greenstone.gatherer.cdm.FormatManager;
38import org.greenstone.gatherer.cdm.GeneralManager;
39import org.greenstone.gatherer.cdm.IndexManager;
40import org.greenstone.gatherer.cdm.MetadataSetView;
41import org.greenstone.gatherer.cdm.PlugInManager;
42import org.greenstone.gatherer.cdm.SubcollectionManager;
43import org.greenstone.gatherer.cdm.TranslationView;
44/** This manager provides access to submanagers, which in turn provide tools for the designing of Greenstone collections via the information stored in etc/collect.cfg. This class acts as a hub for the managers that handle specific parts of the configuration such as classifiers, format strings and language settings.
45 * @author John Thompson, Greenstone Digital Library, University of Waikato
46 * @version 2.3d
47 */
48public class CollectionDesignManager {
49 /** This listener listens for any event on any of the components in any of the sub-views, and marks the collection as needing saving if any change occurs. */
50 static public CDMChangeListener change_listener;
51 /** A list of classifiers to use at build time. */
52 static public ClassifierManager classifier_manager;
53 /** The CollectionConfiguration object on which this CDM will be based. */
54 static public CollectionConfiguration collect_config;
55 /** A manager of collection level metadata. */
56 static public CollectionMetaManager collectionmeta_manager;
57 /** A list of formating strings to use at build time. */
58 static public FormatManager format_manager;
59 /** The manager in charge of displaying this manager and the controls for other managers. */
60 static public GeneralManager general_manager;
61 /** List of indexes to be built, and the default index. */
62 static public IndexManager index_manager;
63 /** Contains instructions dealing with the collection language. */
64 static public LanguageManager language_manager;
65 /** A simple manager for the visual review of metadata sets. */
66 static public MetadataSetView metadataset_view;
67 /** A list of plugins to use at build time. */
68 static public PlugInManager plugin_manager;
69 /** Contains: A list of subcollections, (defined on metadatadata), a list of which subcollection indexes to build and the default subcollection index. */
70 static public SubcollectionManager subcollection_manager;
71
72 static public SubcollectionIndexManager subcollectionindex_manager;
73 /** A supercollection command allows a single search to be conducted across several collections. It is a very basic command and so avoids all the crazy model stuff that exists in most of the design managers. */
74 static public SuperCollectionManager supercollection_manager; // Just cause I could ;p
75 /** The text translation manager. */
76 static public TranslationView translation_view;
77 /** Constructor. Loads a certain collection configuration file, which is parsed into a DOM. This model is then registered with the command information managers, each of whom knows how to, and provides controls to, alter certain commands.
78 * @param collect_config_file the File representing a collection configuration file either in its text (G2) or xml (G3) form
79 */
80 public CollectionDesignManager(File collect_config_file) {
81 Gatherer.println("Initializaing CollectionDesignModule.");
82 change_listener = new CDMChangeListener();
83 // Parse the collection configuration
84 collect_config = new CollectionConfiguration(collect_config_file);
85 if(Gatherer.debug != null) {
86 collect_config.display();
87 }
88 // Create the command information managers, registering the config file with each as necessary
89 language_manager = new LanguageManager(collect_config.getLanguages());
90 collectionmeta_manager = new CollectionMetaManager();
91 classifier_manager = new ClassifierManager();
92 general_manager = new GeneralManager();
93 index_manager = new IndexManager(collect_config.getIndexes());
94 metadataset_view = new MetadataSetView();
95 plugin_manager = new PlugInManager();
96 plugin_manager.placeSeparator();
97 subcollection_manager = new SubcollectionManager();
98 subcollectionindex_manager = new SubcollectionIndexManager(collect_config.getSubIndexes());
99 supercollection_manager = new SuperCollectionManager(collect_config.getSuperCollection());
100 translation_view = new TranslationView();
101 format_manager = new FormatManager(); // Parse formats at the very end, given that they depend upon several other managers to appear properly.
102 Gatherer.println("CollectionDesignModule loaded.");
103 }
104 /** This method deconstructs each of the managers, causing them to dispose of their controls.
105 */
106 public void destroy() {
107 // Remove visual the component from its parent.
108 if(general_manager.getParent() != null) {
109 general_manager.getParent().remove(general_manager);
110 }
111 // Remove references from persistant listeners.
112 classifier_manager.destroy();
113 classifier_manager = null;
114 format_manager.destroy();
115 format_manager = null;
116 general_manager.destroy();
117 general_manager = null;
118 index_manager.destroy();
119 index_manager = null;
120 language_manager.destroy();
121 language_manager = null;
122 metadataset_view.destroy();
123 metadataset_view = null;
124 plugin_manager.destroy();
125 plugin_manager = null;
126 subcollection_manager.destroy();
127 subcollection_manager = null;
128 supercollection_manager.destroy();
129 supercollection_manager = null;
130 translation_view.destroy();
131 translation_view = null;
132 }
133
134 /** Display the GUI interface for the CollectionDesignManager in the centre of the indicated panel.
135 * @param target the JPanel you wish to display the gui on
136 */
137 public void display(JPanel target) {
138 target.add(general_manager, BorderLayout.CENTER);
139 }
140 /** When the tab on the JTabbedPane that contains the GUI is selected, this method is called to ensure that the controls are all up to date, in terms of references to metadata etc.
141 */
142 public void gainFocus() {
143 general_manager.gainFocus();
144 }
145 /** Retrieve the name of the collection configuration file which is being used as the source of the information in this object.
146 * @return The files absolute path as a <strong>String</strong>.
147 */
148 public String getFilename() {
149 return collect_config.getFile().getAbsolutePath();
150 }
151
152 /** Cause the current collection configuration to be written out to disk.
153 * @see org.greenstone.gatherer.cdm.ClassifierManager
154 * @see org.greenstone.gatherer.cdm.CollectionMetaManager
155 * @see org.greenstone.gatherer.cdm.FormatManager
156 * @see org.greenstone.gatherer.cdm.IndexManager
157 * @see org.greenstone.gatherer.cdm.LanguageManager
158 * @see org.greenstone.gatherer.cdm.MetadataSetManager
159 * @see org.greenstone.gatherer.cdm.PlugInManager
160 * @see org.greenstone.gatherer.cdm.SubcollectionManager
161 * @see org.greenstone.gatherer.util.EmailAddress
162 */
163 public void save() {
164 general_manager.loseFocus();
165 collect_config.save();
166 }
167 /** Method used during a global search and replace to highlight the appropriate record within the Collection Design Managers version of the Metadata Set Manager (view only).
168 * @param element The name of the desired element as a <strong>String</strong>.
169 * @see org.greenstone.gatherer.cdm.GUI
170 * @see org.greenstone.gatherer.cdm.MetadataSetManager
171 */
172 public Rectangle setSelectedElement(String element) {
173 // First ensure that the metadata set controls are visible.
174 general_manager.setSelectedView("CDM.GUI.MetadataSets");
175 // Then tell them to select the given element.
176 return metadataset_view.setSelectedElement(element);
177 }
178
179 private class CDMChangeListener
180 implements ActionListener, DocumentListener {
181
182 public void actionPerformed(ActionEvent event) {
183 Gatherer.c_man.getCollection().setSaved(false);
184 }
185
186 /** Gives notification that an attribute or set of attributes changed. */
187 public void changedUpdate(DocumentEvent e) {
188 Gatherer.c_man.getCollection().setSaved(false);
189 }
190
191 /** Gives notification that there was an insert into the document. */
192 public void insertUpdate(DocumentEvent e) {
193 Gatherer.c_man.getCollection().setSaved(false);
194 }
195
196 /** Gives notification that a portion of the document has been removed. */
197 public void removeUpdate(DocumentEvent e) {
198 Gatherer.c_man.getCollection().setSaved(false);
199 }
200 }
201}
Note: See TracBrowser for help on using the repository browser.