source: trunk/gli/src/org/greenstone/gatherer/cdm/IndexingManager.java@ 12080

Last change on this file since 12080 was 12080, checked in by kjdon, 18 years ago

a new manager which coordinates indexmanager, buildtypemanager, and levelmanager. this is the manager which cdm keeps a reference to.

  • Property svn:keywords set to Author Date Id Revision
File size: 5.7 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.util.*;
32import javax.swing.*;
33import javax.swing.event.*;
34import org.greenstone.gatherer.Configuration;
35import org.greenstone.gatherer.DebugStream;
36import org.greenstone.gatherer.Dictionary;
37import org.greenstone.gatherer.Gatherer;
38import org.greenstone.gatherer.gui.DesignPaneHeader;
39import org.greenstone.gatherer.gui.GComboBox;
40import org.greenstone.gatherer.gui.GLIButton;
41import org.greenstone.gatherer.metadata.MetadataElement;
42import org.greenstone.gatherer.metadata.MetadataSetManager;
43import org.greenstone.gatherer.util.CheckList;
44import org.greenstone.gatherer.util.JarTools;
45import org.greenstone.gatherer.util.StaticStrings;
46import org.w3c.dom.*;
47/** This class is responsible for coordinating the IndexManager and LevelManager and BuildTypeManager into one panel
48 * @author John Thompson, Greenstone Digital Library, University of Waikato
49 * @version 2.3
50 */
51public class IndexingManager {
52
53 private LevelManager level_manager = null;
54 private IndexManager index_manager = null;
55 private BuildTypeManager build_type_manager = null;
56
57 private String build_type = null;
58
59 private Control controls = null;
60 public IndexingManager() {
61
62 build_type_manager = new BuildTypeManager();
63 level_manager = new LevelManager(CollectionDesignManager.collect_config.getLevels());
64 build_type = build_type_manager.getBuildType();
65 if (build_type.equals(BuildTypeManager.BUILD_TYPE_MG)) {
66 index_manager = new IndexManager(CollectionDesignManager.collect_config.getMGIndexes(), build_type);
67 } else {
68 index_manager = new IndexManager(CollectionDesignManager.collect_config.getMGPPIndexes(), build_type);
69 }
70
71 }
72
73 public boolean isMGPP() {
74 return build_type_manager.isMGPP();
75 }
76
77 public boolean isLucene() {
78 return build_type_manager.isLucene();
79 }
80
81 public boolean isMG() {
82 return build_type_manager.isMG();
83 }
84
85 public int getNumLevels() {
86 return level_manager.getSize();
87 }
88
89 public int getNumIndexes() {
90 return index_manager.getSize();
91 }
92
93 public ArrayList getIndexes() {
94 return index_manager.getIndexes();
95 }
96 public ArrayList getLevels() {
97 if (!build_type.equals(BuildTypeManager.BUILD_TYPE_MG)) {
98 return level_manager.getLevels();
99 }
100 return null;
101 }
102
103 public Control getControls() {
104 if (controls == null) {
105 controls = new IndexingControl();
106 }
107 return controls;
108 }
109
110 public void destroy() {
111
112 }
113
114 /** Called when the detail mode has changed which in turn may cause several design elements to be available/hidden
115 * @param mode the new mode as an int
116 */
117 public void modeChanged(int mode) {
118
119 }
120
121
122 private class IndexingControl
123 extends JPanel
124 implements Control, BuildTypeManager.BuildTypeListener {
125
126 JPanel build_type_panel = null;
127 JPanel index_panel = null;
128 JPanel level_panel = null;
129 JPanel main_index_pane = null;
130
131 public IndexingControl() {
132 super();
133
134 // Creation
135 JPanel header_pane = new DesignPaneHeader("CDM.GUI.Indexes", "searchindexes");
136
137 build_type_panel = (JPanel)build_type_manager.getControls();
138 index_panel = (JPanel)index_manager.getControls();
139 level_panel = (JPanel)level_manager.getControls();
140
141 main_index_pane = new JPanel();
142 main_index_pane.setLayout(new BorderLayout());
143 main_index_pane.add(build_type_panel, BorderLayout.NORTH);
144 main_index_pane.add(index_panel, BorderLayout.CENTER);
145 if (!build_type.equals(BuildTypeManager.BUILD_TYPE_MG)) {
146 main_index_pane.add(level_panel, BorderLayout.SOUTH);
147 }
148
149 setBorder(BorderFactory.createEmptyBorder(0,5,0,0));
150 setLayout(new BorderLayout());
151 add(header_pane, BorderLayout.NORTH);
152 add(main_index_pane, BorderLayout.CENTER);
153
154 build_type_manager.addBuildTypeListener(this);
155 build_type_manager.addBuildTypeListener(index_manager);
156 build_type_manager.addBuildTypeListener(level_manager);
157 }
158
159 public void loseFocus() {}
160 public void gainFocus() {}
161 public void destroy() {}
162
163 public void buildTypeChanged(String new_build_type) {
164 if (build_type.equals(new_build_type)) {
165 // shouldn't happen
166 return;
167 }
168
169 if (build_type.equals(BuildTypeManager.BUILD_TYPE_MG)) {
170 // changing to mgpp/lucene
171 level_panel.setEnabled(true);
172 main_index_pane.add(level_panel, BorderLayout.SOUTH);
173
174 } else if (new_build_type.equals(BuildTypeManager.BUILD_TYPE_MG)) {
175 // changing to mg
176 level_panel.setEnabled(false);
177 main_index_pane.remove(level_panel);
178 }
179 build_type = new_build_type;
180 }
181 }
182
183}
Note: See TracBrowser for help on using the repository browser.