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

Last change on this file since 18611 was 16680, checked in by anna, 16 years ago

Improved customization of metadata sets/elements used in the Depositor. Two aspects involved: the front-end user interface (depositoraction.cpp) and back-end GLI format panel. Associated changes include the depositor's macro file, GLI dictionary and GLI help document

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