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

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

Major changes to CDM - MGPP extension.

  • Property svn:keywords set to Author Date Id Revision
File size: 10.0 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 /** The manager in charge of all aspects of searchtypes. We also ask this manager whether we are MG or MGPP enabled. */
70 static public SearchTypeManager searchtype_manager;
71 /** Contains: A list of subcollections, (defined on metadatadata), a list of which subcollection indexes to build and the default subcollection index. */
72 static public SubcollectionManager subcollection_manager;
73
74 static public SubcollectionIndexManager subcollectionindex_manager;
75 /** 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. */
76 static public SuperCollectionManager supercollection_manager; // Just cause I could ;p
77 /** The text translation manager. */
78 static public TranslationView translation_view;
79 /** 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.
80 * @param collect_config_file the File representing a collection configuration file either in its text (G2) or xml (G3) form
81 */
82 public CollectionDesignManager(File collect_config_file) {
83 Gatherer.println("Initializaing CollectionDesignModule.");
84 change_listener = new CDMChangeListener();
85 // Parse the collection configuration
86 collect_config = new CollectionConfiguration(collect_config_file);
87 if(Gatherer.debug != null) {
88 collect_config.display();
89 }
90 // Create the command information managers, registering the config file with each as necessary
91 language_manager = new LanguageManager(collect_config.getLanguages());
92 collectionmeta_manager = new CollectionMetaManager();
93 classifier_manager = new ClassifierManager();
94 general_manager = new GeneralManager();
95
96 searchtype_manager = new SearchTypeManager(collect_config.getSearchType());
97 if(searchtype_manager.isMGPPEnabled()) {
98 index_manager = new IndexManager(collect_config.getMGPPIndexes());
99 }
100 else {
101 index_manager = new IndexManager(collect_config.getMGIndexes());
102 }
103
104 metadataset_view = new MetadataSetView();
105 plugin_manager = new PlugInManager();
106 plugin_manager.placeSeparator();
107 subcollection_manager = new SubcollectionManager();
108 subcollectionindex_manager = new SubcollectionIndexManager(collect_config.getSubIndexes());
109 supercollection_manager = new SuperCollectionManager(collect_config.getSuperCollection());
110 translation_view = new TranslationView();
111 format_manager = new FormatManager(); // Parse formats at the very end, given that they depend upon several other managers to appear properly.
112 Gatherer.println("CollectionDesignModule loaded.");
113 }
114 /** This method deconstructs each of the managers, causing them to dispose of their controls.
115 */
116 public void destroy() {
117 // Remove visual the component from its parent.
118 if(general_manager.getParent() != null) {
119 general_manager.getParent().remove(general_manager);
120 }
121 // Remove references from persistant listeners.
122 classifier_manager.destroy();
123 classifier_manager = null;
124 format_manager.destroy();
125 format_manager = null;
126 general_manager.destroy();
127 general_manager = null;
128 index_manager.destroy();
129 index_manager = null;
130 language_manager.destroy();
131 language_manager = null;
132 metadataset_view.destroy();
133 metadataset_view = null;
134 plugin_manager.destroy();
135 plugin_manager = null;
136 subcollection_manager.destroy();
137 subcollection_manager = null;
138 supercollection_manager.destroy();
139 supercollection_manager = null;
140 translation_view.destroy();
141 translation_view = null;
142 }
143
144 /** Display the GUI interface for the CollectionDesignManager in the centre of the indicated panel.
145 * @param target the JPanel you wish to display the gui on
146 */
147 public void display(JPanel target) {
148 target.add(general_manager, BorderLayout.CENTER);
149 }
150 /** 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.
151 */
152 public void gainFocus() {
153 general_manager.gainFocus();
154 }
155 /** Retrieve the name of the collection configuration file which is being used as the source of the information in this object.
156 * @return The files absolute path as a <strong>String</strong>.
157 */
158 public String getFilename() {
159 return collect_config.getFile().getAbsolutePath();
160 }
161
162 /** Cause the current collection configuration to be written out to disk.
163 * @see org.greenstone.gatherer.cdm.ClassifierManager
164 * @see org.greenstone.gatherer.cdm.CollectionMetaManager
165 * @see org.greenstone.gatherer.cdm.FormatManager
166 * @see org.greenstone.gatherer.cdm.IndexManager
167 * @see org.greenstone.gatherer.cdm.LanguageManager
168 * @see org.greenstone.gatherer.cdm.MetadataSetManager
169 * @see org.greenstone.gatherer.cdm.PlugInManager
170 * @see org.greenstone.gatherer.cdm.SubcollectionManager
171 * @see org.greenstone.gatherer.util.EmailAddress
172 */
173 public void save() {
174 general_manager.loseFocus();
175 collect_config.save();
176 }
177 /** 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).
178 * @param element The name of the desired element as a <strong>String</strong>.
179 * @see org.greenstone.gatherer.cdm.GUI
180 * @see org.greenstone.gatherer.cdm.MetadataSetManager
181 */
182 public Rectangle setSelectedElement(String element) {
183 // First ensure that the metadata set controls are visible.
184 general_manager.setSelectedView("CDM.GUI.MetadataSets");
185 // Then tell them to select the given element.
186 return metadataset_view.setSelectedElement(element);
187 }
188
189 private class CDMChangeListener
190 implements ActionListener, DocumentListener {
191
192 public void actionPerformed(ActionEvent event) {
193 Gatherer.c_man.getCollection().setSaved(false);
194 }
195
196 /** Gives notification that an attribute or set of attributes changed. */
197 public void changedUpdate(DocumentEvent e) {
198 Gatherer.c_man.getCollection().setSaved(false);
199 }
200
201 /** Gives notification that there was an insert into the document. */
202 public void insertUpdate(DocumentEvent e) {
203 Gatherer.c_man.getCollection().setSaved(false);
204 }
205
206 /** Gives notification that a portion of the document has been removed. */
207 public void removeUpdate(DocumentEvent e) {
208 Gatherer.c_man.getCollection().setSaved(false);
209 }
210 }
211}
Note: See TracBrowser for help on using the repository browser.