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

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

removed import Dictionary line cos its not used

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