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;
|
---|
28 |
|
---|
29 | import java.awt.*;
|
---|
30 | import java.awt.event.*;
|
---|
31 | import java.util.*;
|
---|
32 | import javax.swing.*;
|
---|
33 | import javax.swing.event.*;
|
---|
34 | import org.greenstone.gatherer.Configuration;
|
---|
35 | import org.greenstone.gatherer.DebugStream;
|
---|
36 | import org.greenstone.gatherer.Dictionary;
|
---|
37 | import org.greenstone.gatherer.Gatherer;
|
---|
38 | import org.greenstone.gatherer.gui.DesignPaneHeader;
|
---|
39 | import org.greenstone.gatherer.gui.GComboBox;
|
---|
40 | import org.greenstone.gatherer.gui.GLIButton;
|
---|
41 | import org.greenstone.gatherer.metadata.MetadataElement;
|
---|
42 | import org.greenstone.gatherer.metadata.MetadataSetManager;
|
---|
43 | import org.greenstone.gatherer.util.CheckList;
|
---|
44 | import org.greenstone.gatherer.util.JarTools;
|
---|
45 | import org.greenstone.gatherer.util.StaticStrings;
|
---|
46 |
|
---|
47 |
|
---|
48 | /** This class is responsible for coordinating the IndexManager and IndexOptionManager (controls levels, stem options etc) and BuildTypeManager into one panel
|
---|
49 | * @author John Thompson, Greenstone Digital Library, University of Waikato
|
---|
50 | * @version 2.3
|
---|
51 | */
|
---|
52 | public class IndexingManager {
|
---|
53 |
|
---|
54 | private IndexOptionManager option_manager = null;
|
---|
55 | private IndexManager index_manager = null;
|
---|
56 | private BuildTypeManager build_type_manager = null;
|
---|
57 |
|
---|
58 |
|
---|
59 | private String build_type = null;
|
---|
60 |
|
---|
61 | private Control controls = null;
|
---|
62 |
|
---|
63 |
|
---|
64 | public IndexingManager()
|
---|
65 | {
|
---|
66 | build_type_manager = new BuildTypeManager();
|
---|
67 | build_type = build_type_manager.getBuildType();
|
---|
68 | option_manager = new IndexOptionManager(build_type);
|
---|
69 | if (build_type.equals(BuildTypeManager.BUILD_TYPE_MG)) {
|
---|
70 | index_manager = new IndexManager(CollectionDesignManager.collect_config.getMGIndexes(), build_type);
|
---|
71 | } else {
|
---|
72 | index_manager = new IndexManager(CollectionDesignManager.collect_config.getMGPPIndexes(), build_type);
|
---|
73 | }
|
---|
74 | }
|
---|
75 |
|
---|
76 | public boolean isMGPP() {
|
---|
77 | return build_type_manager.isMGPP();
|
---|
78 | }
|
---|
79 |
|
---|
80 | public boolean isLucene() {
|
---|
81 | return build_type_manager.isLucene();
|
---|
82 | }
|
---|
83 |
|
---|
84 | public boolean isMG() {
|
---|
85 | return build_type_manager.isMG();
|
---|
86 | }
|
---|
87 |
|
---|
88 | public int getNumLevels() {
|
---|
89 | return option_manager.getNumLevels();
|
---|
90 | }
|
---|
91 |
|
---|
92 | public int getNumIndexes() {
|
---|
93 | return index_manager.getSize();
|
---|
94 | }
|
---|
95 |
|
---|
96 | public ArrayList getIndexes() {
|
---|
97 | return index_manager.getIndexes();
|
---|
98 | }
|
---|
99 |
|
---|
100 | public ArrayList getLevels() {
|
---|
101 | if (!build_type.equals(BuildTypeManager.BUILD_TYPE_MG)) {
|
---|
102 | return option_manager.getLevels();
|
---|
103 | }
|
---|
104 | return null;
|
---|
105 | }
|
---|
106 |
|
---|
107 | public Control getControls() {
|
---|
108 | if (controls == null) {
|
---|
109 | controls = new IndexingControl();
|
---|
110 | }
|
---|
111 | return controls;
|
---|
112 | }
|
---|
113 |
|
---|
114 | public void destroy() {
|
---|
115 |
|
---|
116 | }
|
---|
117 |
|
---|
118 | /** Called when the detail mode has changed which in turn may cause several design elements to be available/hidden
|
---|
119 | * @param mode the new mode as an int
|
---|
120 | */
|
---|
121 | public void modeChanged(int mode) {
|
---|
122 |
|
---|
123 | }
|
---|
124 |
|
---|
125 |
|
---|
126 | private class IndexingControl
|
---|
127 | extends JPanel
|
---|
128 | implements Control, BuildTypeManager.BuildTypeListener
|
---|
129 | {
|
---|
130 | JPanel main_index_pane = null;
|
---|
131 | JPanel index_options_panel = null;
|
---|
132 |
|
---|
133 | public IndexingControl() {
|
---|
134 | super();
|
---|
135 |
|
---|
136 | // Creation
|
---|
137 | JPanel header_pane = new DesignPaneHeader("CDM.GUI.Indexes", "searchindexes");
|
---|
138 |
|
---|
139 | JPanel build_type_panel = (JPanel)build_type_manager.getControls();
|
---|
140 | JPanel index_panel = (JPanel)index_manager.getControls();
|
---|
141 | index_options_panel = (JPanel)option_manager.getControls();
|
---|
142 |
|
---|
143 | main_index_pane = new JPanel();
|
---|
144 | main_index_pane.setLayout(new BorderLayout());
|
---|
145 | main_index_pane.add(build_type_panel, BorderLayout.NORTH);
|
---|
146 | main_index_pane.add(index_panel, BorderLayout.CENTER);
|
---|
147 | main_index_pane.add(index_options_panel, BorderLayout.SOUTH);
|
---|
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(option_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 | {
|
---|
165 | if (build_type.equals(new_build_type)) {
|
---|
166 | // shouldn't happen
|
---|
167 | return;
|
---|
168 | }
|
---|
169 | build_type = new_build_type;
|
---|
170 | }
|
---|
171 |
|
---|
172 | }
|
---|
173 | }
|
---|