[12080] | 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;
|
---|
[13047] | 36 | import org.greenstone.gatherer.Dictionary;
|
---|
[12080] | 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;
|
---|
[13047] | 46 |
|
---|
| 47 |
|
---|
[13058] | 48 | /** This class is responsible for coordinating the IndexManager and IndexOptionManager (controls levels, stem options etc) and BuildTypeManager into one panel
|
---|
[12080] | 49 | * @author John Thompson, Greenstone Digital Library, University of Waikato
|
---|
| 50 | * @version 2.3
|
---|
| 51 | */
|
---|
| 52 | public class IndexingManager {
|
---|
| 53 |
|
---|
[13058] | 54 | private IndexOptionManager option_manager = null;
|
---|
[36153] | 55 | private SearchIndexManager index_manager = null;
|
---|
[12080] | 56 | private BuildTypeManager build_type_manager = null;
|
---|
[36153] | 57 | private SortFieldManager sortfield_manager = null;
|
---|
| 58 | private FacetManager facet_manager = null;
|
---|
[12080] | 59 |
|
---|
| 60 | private String build_type = null;
|
---|
| 61 |
|
---|
| 62 | private Control controls = null;
|
---|
| 63 |
|
---|
[13047] | 64 | public IndexingManager()
|
---|
| 65 | {
|
---|
[12080] | 66 | build_type_manager = new BuildTypeManager();
|
---|
| 67 | build_type = build_type_manager.getBuildType();
|
---|
[13058] | 68 | option_manager = new IndexOptionManager(build_type);
|
---|
[36153] | 69 | if (isMG()) {
|
---|
| 70 | index_manager = new SearchIndexManager(CollectionDesignManager.collect_config.getMGIndexes(), build_type);
|
---|
[12080] | 71 | } else {
|
---|
[36153] | 72 | index_manager = new SearchIndexManager(CollectionDesignManager.collect_config.getMGPPIndexes(), build_type);
|
---|
[12080] | 73 | }
|
---|
[36153] | 74 | // we always create the managers, but only display the controls if we
|
---|
| 75 | // are Lucene/SOLR
|
---|
| 76 | sortfield_manager = new SortFieldManager(CollectionDesignManager.collect_config.getSorts(), build_type);
|
---|
| 77 | facet_manager = new FacetManager(CollectionDesignManager.collect_config.getFacets(), build_type);
|
---|
| 78 |
|
---|
[12080] | 79 | }
|
---|
| 80 | public boolean isMGPP() {
|
---|
| 81 | return build_type_manager.isMGPP();
|
---|
| 82 | }
|
---|
| 83 |
|
---|
| 84 | public boolean isLucene() {
|
---|
| 85 | return build_type_manager.isLucene();
|
---|
| 86 | }
|
---|
| 87 |
|
---|
| 88 | public boolean isMG() {
|
---|
| 89 | return build_type_manager.isMG();
|
---|
| 90 | }
|
---|
| 91 |
|
---|
[36153] | 92 | public boolean isSOLR() {
|
---|
| 93 | return build_type_manager.isSOLR();
|
---|
| 94 | }
|
---|
| 95 |
|
---|
[12080] | 96 | public int getNumLevels() {
|
---|
[13058] | 97 | return option_manager.getNumLevels();
|
---|
[12080] | 98 | }
|
---|
| 99 |
|
---|
| 100 | public int getNumIndexes() {
|
---|
| 101 | return index_manager.getSize();
|
---|
| 102 | }
|
---|
| 103 |
|
---|
| 104 | public ArrayList getIndexes() {
|
---|
| 105 | return index_manager.getIndexes();
|
---|
| 106 | }
|
---|
[13047] | 107 |
|
---|
[12080] | 108 | public ArrayList getLevels() {
|
---|
[18611] | 109 | if (!isMG()) {
|
---|
[13058] | 110 | return option_manager.getLevels();
|
---|
[12080] | 111 | }
|
---|
| 112 | return null;
|
---|
| 113 | }
|
---|
| 114 |
|
---|
[36160] | 115 | public ArrayList getSortFields() {
|
---|
| 116 | if (isLucene() || isSOLR()) {
|
---|
| 117 | return sortfield_manager.getIndexes();
|
---|
| 118 | }
|
---|
| 119 | return null;
|
---|
| 120 | }
|
---|
| 121 | public ArrayList getFacets() {
|
---|
| 122 | if (isSOLR()) {
|
---|
| 123 | return facet_manager.getIndexes();
|
---|
| 124 | }
|
---|
| 125 | return null;
|
---|
| 126 | }
|
---|
| 127 |
|
---|
| 128 |
|
---|
[12080] | 129 | public Control getControls() {
|
---|
| 130 | if (controls == null) {
|
---|
| 131 | controls = new IndexingControl();
|
---|
| 132 | }
|
---|
| 133 | return controls;
|
---|
| 134 | }
|
---|
| 135 |
|
---|
| 136 | public void destroy() {
|
---|
| 137 |
|
---|
| 138 | }
|
---|
| 139 |
|
---|
| 140 | /** Called when the detail mode has changed which in turn may cause several design elements to be available/hidden
|
---|
| 141 | * @param mode the new mode as an int
|
---|
| 142 | */
|
---|
| 143 | public void modeChanged(int mode) {
|
---|
| 144 |
|
---|
| 145 | }
|
---|
| 146 |
|
---|
| 147 |
|
---|
| 148 | private class IndexingControl
|
---|
| 149 | extends JPanel
|
---|
[13047] | 150 | implements Control, BuildTypeManager.BuildTypeListener
|
---|
| 151 | {
|
---|
[12080] | 152 | JPanel main_index_pane = null;
|
---|
[13058] | 153 | JPanel index_options_panel = null;
|
---|
[12080] | 154 |
|
---|
[36153] | 155 | JPanel index_sort_facet_panel = null;
|
---|
| 156 | // these get added/removed depending on indexer in use
|
---|
| 157 | private JPanel sortfield_panel = null;
|
---|
| 158 | private JPanel facet_panel = null;
|
---|
| 159 |
|
---|
[12080] | 160 | public IndexingControl() {
|
---|
| 161 | super();
|
---|
[18412] | 162 | this.setComponentOrientation(Dictionary.getOrientation());
|
---|
[12080] | 163 | // Creation
|
---|
| 164 | JPanel header_pane = new DesignPaneHeader("CDM.GUI.Indexes", "searchindexes");
|
---|
| 165 |
|
---|
[13047] | 166 | JPanel build_type_panel = (JPanel)build_type_manager.getControls();
|
---|
[13058] | 167 | index_options_panel = (JPanel)option_manager.getControls();
|
---|
[36153] | 168 |
|
---|
| 169 | index_sort_facet_panel = new JPanel();
|
---|
| 170 |
|
---|
[36176] | 171 | index_sort_facet_panel.setLayout(new GridLayout(0,1,0,5));
|
---|
[36153] | 172 | JPanel index_panel = (JPanel)index_manager.getControls();
|
---|
| 173 | index_sort_facet_panel.add(index_panel);
|
---|
| 174 | if (isLucene() || isSOLR() ) {
|
---|
| 175 | sortfield_panel = (JPanel)sortfield_manager.getControls();
|
---|
| 176 | index_sort_facet_panel.add(sortfield_panel);
|
---|
| 177 | }
|
---|
| 178 | if (isSOLR()) {
|
---|
| 179 | facet_panel = (JPanel)facet_manager.getControls();
|
---|
| 180 | index_sort_facet_panel.add(facet_panel);
|
---|
| 181 | }
|
---|
[12080] | 182 | main_index_pane = new JPanel();
|
---|
| 183 | main_index_pane.setLayout(new BorderLayout());
|
---|
| 184 | main_index_pane.add(build_type_panel, BorderLayout.NORTH);
|
---|
[36153] | 185 | main_index_pane.add(index_sort_facet_panel, BorderLayout.CENTER);
|
---|
[13058] | 186 | main_index_pane.add(index_options_panel, BorderLayout.SOUTH);
|
---|
[18412] | 187 | main_index_pane.setComponentOrientation(Dictionary.getOrientation());
|
---|
| 188 |
|
---|
[12080] | 189 | setBorder(BorderFactory.createEmptyBorder(0,5,0,0));
|
---|
| 190 | setLayout(new BorderLayout());
|
---|
| 191 | add(header_pane, BorderLayout.NORTH);
|
---|
| 192 | add(main_index_pane, BorderLayout.CENTER);
|
---|
| 193 |
|
---|
| 194 | build_type_manager.addBuildTypeListener(this);
|
---|
| 195 | build_type_manager.addBuildTypeListener(index_manager);
|
---|
[36153] | 196 | build_type_manager.addBuildTypeListener(sortfield_manager);
|
---|
| 197 | build_type_manager.addBuildTypeListener(facet_manager);
|
---|
[13058] | 198 | build_type_manager.addBuildTypeListener(option_manager);
|
---|
[12080] | 199 | }
|
---|
| 200 |
|
---|
| 201 | public void loseFocus() {}
|
---|
| 202 | public void gainFocus() {}
|
---|
| 203 | public void destroy() {}
|
---|
| 204 |
|
---|
[13047] | 205 | public void buildTypeChanged(String new_build_type)
|
---|
| 206 | {
|
---|
[12080] | 207 | if (build_type.equals(new_build_type)) {
|
---|
[13047] | 208 | // shouldn't happen
|
---|
[12080] | 209 | return;
|
---|
| 210 | }
|
---|
[36153] | 211 | if (hasSorts(new_build_type) && !hasSorts(build_type)) {
|
---|
| 212 | sortfield_panel = (JPanel)sortfield_manager.getControls();
|
---|
| 213 | index_sort_facet_panel.add(sortfield_panel);
|
---|
| 214 | // add sort panel
|
---|
| 215 | }
|
---|
| 216 | if (hasSorts(build_type) && ! hasSorts(new_build_type)) {
|
---|
| 217 | // remove sort panel
|
---|
| 218 | index_sort_facet_panel.remove(sortfield_panel);
|
---|
| 219 | }
|
---|
| 220 | if (hasFacets(new_build_type) && ! hasFacets(build_type)) {
|
---|
| 221 | // add facet
|
---|
| 222 | facet_panel = (JPanel)facet_manager.getControls();
|
---|
| 223 | index_sort_facet_panel.add(facet_panel);
|
---|
| 224 | }
|
---|
| 225 | if (hasFacets(build_type) && ! hasFacets(new_build_type)) {
|
---|
| 226 | // remove facet pane
|
---|
| 227 | index_sort_facet_panel.remove(facet_panel);
|
---|
| 228 | }
|
---|
[13058] | 229 | build_type = new_build_type;
|
---|
[12080] | 230 | }
|
---|
[13047] | 231 |
|
---|
[36153] | 232 | private boolean hasSorts(String build_type) {
|
---|
| 233 | return build_type.equals(BuildTypeManager.BUILD_TYPE_LUCENE) || build_type.equals(BuildTypeManager.BUILD_TYPE_SOLR);
|
---|
| 234 | }
|
---|
| 235 | private boolean hasFacets(String build_type) {
|
---|
| 236 | return build_type.equals(BuildTypeManager.BUILD_TYPE_SOLR);
|
---|
| 237 |
|
---|
| 238 | }
|
---|
| 239 |
|
---|
[12080] | 240 | }
|
---|
| 241 | }
|
---|