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

Last change on this file since 13326 was 13326, checked in by mdewsnip, 18 years ago

Removed some unnecessary importing of the util.ZipTools class.

  • Property svn:keywords set to Author Date Id Revision
File size: 10.2 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;
28
29import java.awt.*;
30import java.awt.event.*;
31import java.io.*;
32import javax.swing.*;
33import javax.swing.event.*;
34import org.apache.xerces.parsers.*;
35import org.greenstone.gatherer.Configuration;
36import org.greenstone.gatherer.DebugStream;
37import org.greenstone.gatherer.Gatherer;
38import org.greenstone.gatherer.LocalLibraryServer;
39import org.greenstone.gatherer.remote.RemoteGreenstoneServer;
40import org.greenstone.gatherer.util.Utility;
41import org.w3c.dom.*;
42import org.xml.sax.*;
43
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 /** These listeners listen to changes in the Design mode so as to allow minimal rebuilding */
52 static public DesignChangeListener all_change_listener;
53 static public DesignChangeListener buildcol_change_listener;
54 /** A list of classifiers to use at build time. */
55 static public ClassifierManager classifier_manager;
56 /** The CollectionConfiguration object on which this CDM will be based. */
57 static public CollectionConfiguration collect_config;
58 /** A manager of collection level metadata. */
59 static public CollectionMetaManager collectionmeta_manager;
60 /** A list of formating strings to use at build time. */
61 static public FormatManager format_manager;
62 /** A manager of general options */
63 static public GeneralManager general_manager;
64 /** List of indexes to be built, and the default index.
65 also handles build type and levels */
66 static public IndexingManager index_manager;
67 /** Contains instructions dealing with the collection language. */
68 static public LanguageManager language_manager;
69 /** Handling writing extra.dm file */
70 static public MacrosManager macros_manager;
71 /** A list of plugins to use at build time. */
72 static public PluginManager plugin_manager;
73 /** a manager of searching metadata such as index names*/
74 static public SearchMetadataManager searchmetadata_manager;
75 /** Contains: A list of subcollections, (defined on metadatadata), a list of which subcollection indexes to build and the default subcollection index. */
76 static public SubcollectionManager subcollection_manager;
77
78 static public SubcollectionIndexManager subcollectionindex_manager;
79 /** 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. */
80 static public SuperCollectionManager supercollection_manager; // Just cause I could ;p
81 /** The text translation manager. */
82 static public TranslationView translation_manager;
83 /** These mark what needs to happen when building a collection where ONLY design options have been changed.
84 The build requirements of the higher numbers must include doing everything from the lower numbers. */
85 static final public int ALL = 3;
86 static final public int BUILDCOL = 2;
87 static final public int NOTHING = 0;
88 static private int rebuildTypeRequired = NOTHING; //Rebuild type required if only design options have changed
89
90 /** 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.
91 * @param collect_config_file the File representing a collection configuration file either in its text (G2) or xml (G3) form
92 */
93 public CollectionDesignManager(File collect_config_file) {
94 DebugStream.println("Initializaing CollectionDesignModule.");
95 change_listener = new CDMChangeListener();
96 all_change_listener = new DesignChangeListener(ALL);
97 buildcol_change_listener = new DesignChangeListener(BUILDCOL);
98 // Parse the collection configuration
99 collect_config = new CollectionConfiguration(collect_config_file);
100 if (DebugStream.isDebuggingEnabled()) {
101 collect_config.display();
102 }
103 loadDesignDetails();
104 DebugStream.println("CollectionDesignModule loaded.");
105 }
106
107 /** Reloads the various managers to ensure they have built themselves from the latest details available in the collection configuration class
108 * @see org.greenstone.gatherer.cdm.ClassifierManager
109 * @see org.greenstone.gatherer.cdm.CollectionMetaManager
110 * @see org.greenstone.gatherer.cdm.FormatManager
111 * @see org.greenstone.gatherer.cdm.GeneralManager
112 * @see org.greenstone.gatherer.cdm.IndexManager
113 * @see org.greenstone.gatherer.cdm.LanguageManager
114 * @see org.greenstone.gatherer.cdm.PluginManager
115 * @see org.greenstone.gatherer.cdm.SubcollectionIndexManager
116 * @see org.greenstone.gatherer.cdm.SubcollectionManager
117 * @see org.greenstone.gatherer.cdm.SuperCollectionManager
118 * @see org.greenstone.gatherer.cdm.TranslationView
119 */
120 private void loadDesignDetails() {
121 // Create the command information managers, registering the config file with each as necessary
122 language_manager = new LanguageManager(collect_config.getLanguages());
123 collectionmeta_manager = new CollectionMetaManager();
124 classifier_manager = new ClassifierManager();
125 general_manager = new GeneralManager();
126 macros_manager = new MacrosManager();
127 index_manager = new IndexingManager();
128 plugin_manager = new PluginManager();
129 subcollection_manager = new SubcollectionManager();
130 subcollectionindex_manager = new SubcollectionIndexManager(collect_config.getSubIndexes());
131 supercollection_manager = new SuperCollectionManager(collect_config.getSuperCollection());
132 searchmetadata_manager = new SearchMetadataManager();
133 translation_manager = new TranslationView();
134 format_manager = new FormatManager(); // Parse formats at the very end, given that they depend upon several other managers to appear properly.
135 }
136
137 /** This method deconstructs each of the managers, causing them to dispose of their controls.
138 */
139 public void destroy() {
140 // Remove references from persistant listeners.
141 classifier_manager.destroy();
142 classifier_manager = null;
143 searchmetadata_manager.destroy();
144 searchmetadata_manager = null;
145 format_manager.destroy();
146 format_manager = null;
147 general_manager.destroy();
148 general_manager = null;
149 index_manager.destroy();
150 index_manager = null;
151 language_manager.destroy();
152 language_manager = null;
153 plugin_manager.destroy();
154 plugin_manager = null;
155 subcollection_manager.destroy();
156 subcollection_manager = null;
157 supercollection_manager.destroy();
158 supercollection_manager = null;
159 translation_manager.destroy();
160 translation_manager = null;
161 }
162
163 /** Called when the detail mode has changed which in turn may cause several design elements to be available/hidden
164 * @param mode the new mode as an int
165 */
166 public void modeChanged(int mode) {
167 plugin_manager.modeChanged(mode);
168 classifier_manager.modeChanged(mode);
169 subcollection_manager.modeChanged(mode);
170 supercollection_manager.modeChanged(mode);
171 format_manager.modeChanged(mode);
172 index_manager.modeChanged(mode);
173 translation_manager.modeChanged(mode);
174 general_manager.modeChanged(mode);
175 language_manager.modeChanged(mode);
176 searchmetadata_manager.modeChanged(mode);
177 }
178
179 /** The cdm is considered to be ready if the collect.cfg file was found and parsed and the collection title is not error.
180 * @return true if the collection is ready, false otherwise
181 */
182 public boolean ready() {
183 return collect_config.ready();
184 }
185
186
187 /** Cause the current collection configuration to be written out to disk.
188 */
189 public void save()
190 {
191 collect_config.saveIfNecessary();
192 }
193
194
195 public static int getRebuildTypeRequired() {
196 return rebuildTypeRequired;
197 }
198 public static void resetRebuildTypeRequired() {
199 setRebuildTypeRequired(NOTHING);
200 }
201 public static void setRebuildTypeRequired(int number) {
202 rebuildTypeRequired = number;
203 }
204
205 /**
206 * What exactly does this do?
207 */
208 private class CDMChangeListener
209 implements ActionListener, DocumentListener {
210
211 /** Gives notification that an event has happened */
212 public void actionPerformed(ActionEvent event) {
213 Gatherer.c_man.getCollection().setSaved(false);
214 }
215
216 /** Gives notification that an attribute or set of attributes changed. */
217 public void changedUpdate(DocumentEvent e) {
218 Gatherer.c_man.getCollection().setSaved(false);
219 }
220
221 /** Gives notification that there was an insert into the document. */
222 public void insertUpdate(DocumentEvent e) {
223 Gatherer.c_man.getCollection().setSaved(false);
224 }
225
226 /** Gives notification that a portion of the document has been removed. */
227 public void removeUpdate(DocumentEvent e) {
228 Gatherer.c_man.getCollection().setSaved(false);
229 }
230 }
231}
Note: See TracBrowser for help on using the repository browser.