[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;
|
---|
[12080] | 55 | private IndexManager index_manager = null;
|
---|
| 56 | private BuildTypeManager build_type_manager = null;
|
---|
| 57 |
|
---|
[13047] | 58 |
|
---|
[12080] | 59 | private String build_type = null;
|
---|
| 60 |
|
---|
| 61 | private Control controls = null;
|
---|
| 62 |
|
---|
[13047] | 63 |
|
---|
| 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);
|
---|
[12080] | 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() {
|
---|
[13058] | 89 | return option_manager.getNumLevels();
|
---|
[12080] | 90 | }
|
---|
| 91 |
|
---|
| 92 | public int getNumIndexes() {
|
---|
| 93 | return index_manager.getSize();
|
---|
| 94 | }
|
---|
| 95 |
|
---|
| 96 | public ArrayList getIndexes() {
|
---|
| 97 | return index_manager.getIndexes();
|
---|
| 98 | }
|
---|
[13047] | 99 |
|
---|
[12080] | 100 | public ArrayList getLevels() {
|
---|
[18611] | 101 | if (!isMG()) {
|
---|
[13058] | 102 | return option_manager.getLevels();
|
---|
[12080] | 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
|
---|
[13047] | 128 | implements Control, BuildTypeManager.BuildTypeListener
|
---|
| 129 | {
|
---|
[12080] | 130 | JPanel main_index_pane = null;
|
---|
[13058] | 131 | JPanel index_options_panel = null;
|
---|
[12080] | 132 |
|
---|
| 133 | public IndexingControl() {
|
---|
| 134 | super();
|
---|
[18412] | 135 | this.setComponentOrientation(Dictionary.getOrientation());
|
---|
[12080] | 136 | // Creation
|
---|
| 137 | JPanel header_pane = new DesignPaneHeader("CDM.GUI.Indexes", "searchindexes");
|
---|
| 138 |
|
---|
[13047] | 139 | JPanel build_type_panel = (JPanel)build_type_manager.getControls();
|
---|
| 140 | JPanel index_panel = (JPanel)index_manager.getControls();
|
---|
[13058] | 141 | index_options_panel = (JPanel)option_manager.getControls();
|
---|
[18412] | 142 |
|
---|
| 143 |
|
---|
[12080] | 144 | main_index_pane = new JPanel();
|
---|
| 145 | main_index_pane.setLayout(new BorderLayout());
|
---|
| 146 | main_index_pane.add(build_type_panel, BorderLayout.NORTH);
|
---|
[13058] | 147 | main_index_pane.add(index_panel, BorderLayout.CENTER);
|
---|
| 148 | main_index_pane.add(index_options_panel, BorderLayout.SOUTH);
|
---|
[18412] | 149 | main_index_pane.setComponentOrientation(Dictionary.getOrientation());
|
---|
| 150 |
|
---|
[12080] | 151 | setBorder(BorderFactory.createEmptyBorder(0,5,0,0));
|
---|
| 152 | setLayout(new BorderLayout());
|
---|
| 153 | add(header_pane, BorderLayout.NORTH);
|
---|
| 154 | add(main_index_pane, BorderLayout.CENTER);
|
---|
| 155 |
|
---|
| 156 | build_type_manager.addBuildTypeListener(this);
|
---|
| 157 | build_type_manager.addBuildTypeListener(index_manager);
|
---|
[13058] | 158 | build_type_manager.addBuildTypeListener(option_manager);
|
---|
[12080] | 159 | }
|
---|
| 160 |
|
---|
| 161 | public void loseFocus() {}
|
---|
| 162 | public void gainFocus() {}
|
---|
| 163 | public void destroy() {}
|
---|
| 164 |
|
---|
[13047] | 165 | public void buildTypeChanged(String new_build_type)
|
---|
| 166 | {
|
---|
[12080] | 167 | if (build_type.equals(new_build_type)) {
|
---|
[13047] | 168 | // shouldn't happen
|
---|
[12080] | 169 | return;
|
---|
| 170 | }
|
---|
[13058] | 171 | build_type = new_build_type;
|
---|
[12080] | 172 | }
|
---|
[13047] | 173 |
|
---|
[12080] | 174 | }
|
---|
| 175 | }
|
---|