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

Last change on this file since 13591 was 13582, checked in by mdewsnip, 17 years ago

Removed some unnecessary package imports.

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