[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 | */
|
---|
| 27 | package org.greenstone.gatherer.cdm;
|
---|
[5590] | 28 |
|
---|
[4932] | 29 | import java.awt.event.*;
|
---|
| 30 | import java.io.*;
|
---|
| 31 | import javax.swing.event.*;
|
---|
[8236] | 32 | import org.greenstone.gatherer.DebugStream;
|
---|
[4932] | 33 | import org.greenstone.gatherer.Gatherer;
|
---|
[14038] | 34 | import org.greenstone.gatherer.collection.CollectionManager;
|
---|
| 35 | import org.w3c.dom.*;
|
---|
[5590] | 36 |
|
---|
[14038] | 37 | //save()
|
---|
| 38 | import org.greenstone.gatherer.util.XMLTools;
|
---|
| 39 | import 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 | */
|
---|
| 45 | public 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;
|
---|
[22970] | 51 | static public DesignChangeListener databasecol_change_listener;
|
---|
[4932] | 52 | /** A list of classifiers to use at build time. */
|
---|
| 53 | static public ClassifierManager classifier_manager;
|
---|
| 54 | /** The CollectionConfiguration object on which this CDM will be based. */
|
---|
| 55 | static public CollectionConfiguration collect_config;
|
---|
| 56 | /** A manager of collection level metadata. */
|
---|
| 57 | static public CollectionMetaManager collectionmeta_manager;
|
---|
| 58 | /** A list of formating strings to use at build time. */
|
---|
[14038] | 59 | static public SharedByTwoFormatManager format_manager;
|
---|
[12095] | 60 | /** A manager of general options */
|
---|
[4932] | 61 | static public GeneralManager general_manager;
|
---|
[12095] | 62 | /** List of indexes to be built, and the default index.
|
---|
| 63 | also handles build type and levels */
|
---|
| 64 | static public IndexingManager index_manager;
|
---|
[4932] | 65 | /** Contains instructions dealing with the collection language. */
|
---|
| 66 | static public LanguageManager language_manager;
|
---|
[12095] | 67 | /** Handling writing extra.dm file */
|
---|
| 68 | static public MacrosManager macros_manager;
|
---|
[4932] | 69 | /** A list of plugins to use at build time. */
|
---|
[8601] | 70 | static public PluginManager plugin_manager;
|
---|
[12095] | 71 | /** a manager of searching metadata such as index names*/
|
---|
| 72 | static public SearchMetadataManager searchmetadata_manager;
|
---|
[4932] | 73 | /** Contains: A list of subcollections, (defined on metadatadata), a list of which subcollection indexes to build and the default subcollection index. */
|
---|
| 74 | static public SubcollectionManager subcollection_manager;
|
---|
| 75 |
|
---|
| 76 | static public SubcollectionIndexManager subcollectionindex_manager;
|
---|
| 77 | /** 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. */
|
---|
| 78 | static public SuperCollectionManager supercollection_manager; // Just cause I could ;p
|
---|
| 79 | /** The text translation manager. */
|
---|
[12095] | 80 | static public TranslationView translation_manager;
|
---|
[16680] | 81 | /** A manager of configuring depositor metadata */
|
---|
| 82 | static public DepositorMetadataManager depositormetadata_manager;
|
---|
[19404] | 83 |
|
---|
[10237] | 84 | /** These mark what needs to happen when building a collection where ONLY design options have been changed.
|
---|
| 85 | The build requirements of the higher numbers must include doing everything from the lower numbers. */
|
---|
| 86 | static final public int ALL = 3;
|
---|
| 87 | static final public int BUILDCOL = 2;
|
---|
| 88 | static final public int NOTHING = 0;
|
---|
| 89 | static private int rebuildTypeRequired = NOTHING; //Rebuild type required if only design options have changed
|
---|
| 90 |
|
---|
[19404] | 91 | /** This indicates whether a minimal or complete build is required.
|
---|
[19781] | 92 | Minimal means do an incremental rebuild. Complete means do a full rebuild
|
---|
[19430] | 93 | Note: This stores preceisely whether the user selected the minimal or full build radio button.
|
---|
| 94 | Its value does not indicate anything about what gli eventually chose as a result of that "suggestion" */
|
---|
[19404] | 95 | static private boolean isCompleteBuild = false;
|
---|
| 96 |
|
---|
[19430] | 97 | /** These remember which scripts were run for the last build.
|
---|
| 98 | true indicated 'full-' prefix, false indicates 'incremental-' prefix to the given perl script (import.pl or buildcol.pl)
|
---|
| 99 | Note: This stores what gli did, regardless of whether minimal or full was requested by the user */
|
---|
| 100 | static private boolean importWasFull = false;
|
---|
| 101 | static private boolean buildcolWasFull = false;
|
---|
[19404] | 102 |
|
---|
[4932] | 103 | /** 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.
|
---|
| 104 | * @param collect_config_file the File representing a collection configuration file either in its text (G2) or xml (G3) form
|
---|
| 105 | */
|
---|
| 106 | public CollectionDesignManager(File collect_config_file) {
|
---|
[8236] | 107 | DebugStream.println("Initializaing CollectionDesignModule.");
|
---|
[4932] | 108 | change_listener = new CDMChangeListener();
|
---|
[10237] | 109 | all_change_listener = new DesignChangeListener(ALL);
|
---|
| 110 | buildcol_change_listener = new DesignChangeListener(BUILDCOL);
|
---|
[22970] | 111 | databasecol_change_listener = new DesignChangeListener(BUILDCOL);
|
---|
| 112 |
|
---|
[4932] | 113 | // Parse the collection configuration
|
---|
| 114 | collect_config = new CollectionConfiguration(collect_config_file);
|
---|
[8236] | 115 | if (DebugStream.isDebuggingEnabled()) {
|
---|
[4932] | 116 | collect_config.display();
|
---|
| 117 | }
|
---|
[6389] | 118 | loadDesignDetails();
|
---|
[8236] | 119 | DebugStream.println("CollectionDesignModule loaded.");
|
---|
[6389] | 120 | }
|
---|
| 121 |
|
---|
| 122 | /** Reloads the various managers to ensure they have built themselves from the latest details available in the collection configuration class
|
---|
| 123 | * @see org.greenstone.gatherer.cdm.ClassifierManager
|
---|
| 124 | * @see org.greenstone.gatherer.cdm.CollectionMetaManager
|
---|
| 125 | * @see org.greenstone.gatherer.cdm.FormatManager
|
---|
| 126 | * @see org.greenstone.gatherer.cdm.GeneralManager
|
---|
| 127 | * @see org.greenstone.gatherer.cdm.IndexManager
|
---|
| 128 | * @see org.greenstone.gatherer.cdm.LanguageManager
|
---|
[8601] | 129 | * @see org.greenstone.gatherer.cdm.PluginManager
|
---|
[6389] | 130 | * @see org.greenstone.gatherer.cdm.SubcollectionIndexManager
|
---|
| 131 | * @see org.greenstone.gatherer.cdm.SubcollectionManager
|
---|
| 132 | * @see org.greenstone.gatherer.cdm.SuperCollectionManager
|
---|
| 133 | * @see org.greenstone.gatherer.cdm.TranslationView
|
---|
| 134 | */
|
---|
[8002] | 135 | private void loadDesignDetails() {
|
---|
[4932] | 136 | // Create the command information managers, registering the config file with each as necessary
|
---|
| 137 | language_manager = new LanguageManager(collect_config.getLanguages());
|
---|
| 138 | collectionmeta_manager = new CollectionMetaManager();
|
---|
| 139 | classifier_manager = new ClassifierManager();
|
---|
| 140 | general_manager = new GeneralManager();
|
---|
[12095] | 141 | macros_manager = new MacrosManager();
|
---|
| 142 | index_manager = new IndexingManager();
|
---|
[8601] | 143 | plugin_manager = new PluginManager();
|
---|
[4932] | 144 | subcollection_manager = new SubcollectionManager();
|
---|
| 145 | subcollectionindex_manager = new SubcollectionIndexManager(collect_config.getSubIndexes());
|
---|
| 146 | supercollection_manager = new SuperCollectionManager(collect_config.getSuperCollection());
|
---|
[12095] | 147 | searchmetadata_manager = new SearchMetadataManager();
|
---|
[16680] | 148 | depositormetadata_manager = new DepositorMetadataManager();
|
---|
[12095] | 149 | translation_manager = new TranslationView();
|
---|
[14038] | 150 | if (Gatherer.GS3) {
|
---|
| 151 | format_manager = new Format4gs3Manager();
|
---|
| 152 | } else {
|
---|
| 153 | format_manager = new FormatManager(); // Parse formats at the very end, given that they depend upon several other managers to appear properly.
|
---|
[4932] | 154 | }
|
---|
[14038] | 155 | }
|
---|
[6389] | 156 |
|
---|
[4932] | 157 | /** This method deconstructs each of the managers, causing them to dispose of their controls.
|
---|
| 158 | */
|
---|
| 159 | public void destroy() {
|
---|
| 160 | // Remove references from persistant listeners.
|
---|
| 161 | classifier_manager.destroy();
|
---|
| 162 | classifier_manager = null;
|
---|
[12095] | 163 | searchmetadata_manager.destroy();
|
---|
| 164 | searchmetadata_manager = null;
|
---|
[4932] | 165 | format_manager.destroy();
|
---|
| 166 | format_manager = null;
|
---|
[14038] | 167 | // format_4gs3_manager.destroy();
|
---|
| 168 | // format_4gs3_manager = null;
|
---|
[4932] | 169 | general_manager.destroy();
|
---|
| 170 | general_manager = null;
|
---|
| 171 | index_manager.destroy();
|
---|
| 172 | index_manager = null;
|
---|
| 173 | language_manager.destroy();
|
---|
| 174 | language_manager = null;
|
---|
| 175 | plugin_manager.destroy();
|
---|
| 176 | plugin_manager = null;
|
---|
| 177 | subcollection_manager.destroy();
|
---|
| 178 | subcollection_manager = null;
|
---|
| 179 | supercollection_manager.destroy();
|
---|
| 180 | supercollection_manager = null;
|
---|
[16680] | 181 | depositormetadata_manager.destroy();
|
---|
| 182 | depositormetadata_manager = null;
|
---|
[12095] | 183 | translation_manager.destroy();
|
---|
| 184 | translation_manager = null;
|
---|
[4932] | 185 | }
|
---|
| 186 |
|
---|
[6389] | 187 | /** Called when the detail mode has changed which in turn may cause several design elements to be available/hidden
|
---|
| 188 | * @param mode the new mode as an int
|
---|
[4932] | 189 | */
|
---|
[6389] | 190 | public void modeChanged(int mode) {
|
---|
| 191 | plugin_manager.modeChanged(mode);
|
---|
[12095] | 192 | classifier_manager.modeChanged(mode);
|
---|
[6389] | 193 | subcollection_manager.modeChanged(mode);
|
---|
[12095] | 194 | supercollection_manager.modeChanged(mode);
|
---|
[14038] | 195 | //format_manager.modeChanged(mode);
|
---|
[12095] | 196 | index_manager.modeChanged(mode);
|
---|
| 197 | translation_manager.modeChanged(mode);
|
---|
| 198 | general_manager.modeChanged(mode);
|
---|
| 199 | language_manager.modeChanged(mode);
|
---|
| 200 | searchmetadata_manager.modeChanged(mode);
|
---|
[16680] | 201 | depositormetadata_manager.modeChanged(mode);
|
---|
[6389] | 202 | }
|
---|
[4932] | 203 |
|
---|
[5995] | 204 | /** The cdm is considered to be ready if the collect.cfg file was found and parsed and the collection title is not error.
|
---|
| 205 | * @return true if the collection is ready, false otherwise
|
---|
| 206 | */
|
---|
| 207 | public boolean ready() {
|
---|
| 208 | return collect_config.ready();
|
---|
| 209 | }
|
---|
| 210 |
|
---|
[12803] | 211 |
|
---|
[4932] | 212 | /** Cause the current collection configuration to be written out to disk.
|
---|
| 213 | */
|
---|
[14679] | 214 | public void save() {
|
---|
[14237] | 215 | collect_config.saveIfNecessary();
|
---|
[8597] | 216 | }
|
---|
[7739] | 217 |
|
---|
[6051] | 218 |
|
---|
[10237] | 219 | public static int getRebuildTypeRequired() {
|
---|
[19404] | 220 | return rebuildTypeRequired;
|
---|
[10237] | 221 | }
|
---|
[19404] | 222 |
|
---|
[10237] | 223 | public static void resetRebuildTypeRequired() {
|
---|
[19404] | 224 | setRebuildTypeRequired(NOTHING);
|
---|
[10237] | 225 | }
|
---|
| 226 | public static void setRebuildTypeRequired(int number) {
|
---|
[19404] | 227 | rebuildTypeRequired = number;
|
---|
[10237] | 228 | }
|
---|
[8249] | 229 |
|
---|
[19404] | 230 | public static boolean isCompleteBuild() {
|
---|
| 231 | return isCompleteBuild;
|
---|
| 232 | }
|
---|
| 233 | public static void setCompleteBuild(boolean icb) {
|
---|
| 234 | isCompleteBuild = icb;
|
---|
| 235 | }
|
---|
| 236 |
|
---|
[19430] | 237 | public static void setImportWasFull( boolean wasFull ) {
|
---|
| 238 | importWasFull = wasFull;
|
---|
| 239 | }
|
---|
| 240 | public static boolean importWasFull() {
|
---|
| 241 | return importWasFull;
|
---|
| 242 | }
|
---|
| 243 | public static void setBuildcolWasFull( boolean wasFull ) {
|
---|
| 244 | buildcolWasFull = wasFull;
|
---|
| 245 | }
|
---|
| 246 | public static boolean buildcolWasFull() {
|
---|
| 247 | return buildcolWasFull;
|
---|
| 248 | }
|
---|
| 249 |
|
---|
[10237] | 250 | /**
|
---|
| 251 | * What exactly does this do?
|
---|
| 252 | */
|
---|
[4932] | 253 | private class CDMChangeListener
|
---|
| 254 | implements ActionListener, DocumentListener {
|
---|
[6051] | 255 |
|
---|
[10237] | 256 | /** Gives notification that an event has happened */
|
---|
[4932] | 257 | public void actionPerformed(ActionEvent event) {
|
---|
| 258 | Gatherer.c_man.getCollection().setSaved(false);
|
---|
| 259 | }
|
---|
| 260 |
|
---|
| 261 | /** Gives notification that an attribute or set of attributes changed. */
|
---|
| 262 | public void changedUpdate(DocumentEvent e) {
|
---|
| 263 | Gatherer.c_man.getCollection().setSaved(false);
|
---|
| 264 | }
|
---|
[6051] | 265 |
|
---|
[4932] | 266 | /** Gives notification that there was an insert into the document. */
|
---|
| 267 | public void insertUpdate(DocumentEvent e) {
|
---|
| 268 | Gatherer.c_man.getCollection().setSaved(false);
|
---|
| 269 | }
|
---|
[6051] | 270 |
|
---|
[4932] | 271 | /** Gives notification that a portion of the document has been removed. */
|
---|
| 272 | public void removeUpdate(DocumentEvent e) {
|
---|
| 273 | Gatherer.c_man.getCollection().setSaved(false);
|
---|
| 274 | }
|
---|
| 275 | }
|
---|
| 276 | }
|
---|