Changeset 13047


Ignore:
Timestamp:
2006-10-06T14:58:12+13:00 (18 years ago)
Author:
mdewsnip
Message:

GUI side of the new "indexing options" controls.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/cdm/IndexingManager.java

    r12164 r13047  
    3434import org.greenstone.gatherer.Configuration;
    3535import org.greenstone.gatherer.DebugStream;
     36import org.greenstone.gatherer.Dictionary;
    3637import org.greenstone.gatherer.Gatherer;
    3738import org.greenstone.gatherer.gui.DesignPaneHeader;
     
    4344import org.greenstone.gatherer.util.JarTools;
    4445import org.greenstone.gatherer.util.StaticStrings;
    45 import org.w3c.dom.*;
     46
     47
    4648/** This class is responsible for coordinating the IndexManager and LevelManager and BuildTypeManager into one panel 
    4749 * @author John Thompson, Greenstone Digital Library, University of Waikato
     
    5456    private BuildTypeManager build_type_manager = null;
    5557
     58    private JCheckBox stem_checkbox = new JCheckBox();
     59    private JCheckBox casefold_checkbox = new JCheckBox();
     60    private JCheckBox accent_fold_checkbox = new JCheckBox();
     61
    5662    private String build_type = null;
    5763
    5864    private Control controls = null;
    59     public IndexingManager() {
    60 
     65
     66
     67    public IndexingManager()
     68    {
    6169    build_type_manager = new BuildTypeManager();
    6270    build_type = build_type_manager.getBuildType();
     
    6775        index_manager = new IndexManager(CollectionDesignManager.collect_config.getMGPPIndexes(), build_type);
    6876    }
    69    
    7077    }
    7178
     
    93100    return index_manager.getIndexes();
    94101    }
     102
     103    public String getIndexingOptionsString()
     104    {
     105    if (build_type.equals(BuildTypeManager.BUILD_TYPE_LUCENE)) {
     106        return "";
     107    }
     108
     109    String indexing_options_string = "";
     110    indexing_options_string += (stem_checkbox.isSelected() ? "stem " : "");
     111    indexing_options_string += (casefold_checkbox.isSelected() ? "casefold " : "");
     112    indexing_options_string += (accent_fold_checkbox.isSelected() ? "accentfold " : "");
     113    return indexing_options_string;
     114    }
     115
    95116    public ArrayList getLevels() {
    96117    if (!build_type.equals(BuildTypeManager.BUILD_TYPE_MG)) {
     
    121142    private class IndexingControl
    122143    extends JPanel
    123     implements Control,  BuildTypeManager.BuildTypeListener {
    124 
    125     JPanel build_type_panel = null;
    126     JPanel index_panel = null;
     144    implements Control, BuildTypeManager.BuildTypeListener
     145    {
     146    JPanel index_plus_options_panel = null;
     147    JPanel indexing_options_panel = null;
    127148    JPanel level_panel = null;
    128149    JPanel main_index_pane = null;
     
    134155        JPanel header_pane = new DesignPaneHeader("CDM.GUI.Indexes", "searchindexes");     
    135156       
    136         build_type_panel = (JPanel)build_type_manager.getControls();
    137         index_panel = (JPanel)index_manager.getControls();
     157        JPanel build_type_panel = (JPanel)build_type_manager.getControls();
     158        JPanel index_panel = (JPanel)index_manager.getControls();
    138159        level_panel = (JPanel)level_manager.getControls();
     160
     161        index_plus_options_panel = new JPanel();
     162        index_plus_options_panel.setLayout(new BorderLayout());
     163        index_plus_options_panel.add(index_panel, BorderLayout.CENTER);
     164        indexing_options_panel = new IndexingOptionsControl();
     165        if (!build_type.equals(BuildTypeManager.BUILD_TYPE_LUCENE)) {
     166        index_plus_options_panel.add(indexing_options_panel, BorderLayout.SOUTH);
     167        }
    139168
    140169        main_index_pane = new JPanel();
    141170        main_index_pane.setLayout(new BorderLayout());
    142171        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)) {
     172        main_index_pane.add(index_plus_options_panel, BorderLayout.CENTER);
     173        if (!build_type.equals(BuildTypeManager.BUILD_TYPE_MG)) {
    145174        main_index_pane.add(level_panel, BorderLayout.SOUTH);
    146175        }
     
    160189    public void destroy() {}
    161190
    162     public void buildTypeChanged(String new_build_type) {
     191    public void buildTypeChanged(String new_build_type)
     192    {
    163193        if (build_type.equals(new_build_type)) {
    164         // shouldn't happen
     194        // shouldn't happen
    165195        return;
    166196        }
    167        
     197
     198        // Show/hide the indexing options panel
     199        if (build_type.equals(BuildTypeManager.BUILD_TYPE_LUCENE)) {
     200        // Changing to MG/MGPP
     201        index_plus_options_panel.add(indexing_options_panel, BorderLayout.SOUTH);
     202        }
     203        else if (new_build_type.equals(BuildTypeManager.BUILD_TYPE_LUCENE)) {
     204        // Changing to Lucene
     205        index_plus_options_panel.remove(indexing_options_panel);
     206        }
     207        // Accent-folding is currently not available for MG
     208        accent_fold_checkbox.setEnabled(!new_build_type.equals(BuildTypeManager.BUILD_TYPE_MG));
     209
     210        // Show/hide the levels panel
    168211        if (build_type.equals(BuildTypeManager.BUILD_TYPE_MG)) {
    169         // changing to  mgpp/lucene
     212        // Changing to MGPP/Lucene
    170213        level_panel.setEnabled(true);
    171214        main_index_pane.add(level_panel, BorderLayout.SOUTH);
    172        
    173         } else if (new_build_type.equals(BuildTypeManager.BUILD_TYPE_MG)) {
    174         // changing to mg
     215        }
     216        else if (new_build_type.equals(BuildTypeManager.BUILD_TYPE_MG)) {
     217        // Changing to MG
    175218        level_panel.setEnabled(false);
    176219        main_index_pane.remove(level_panel);
    177220        }
     221
    178222        build_type = new_build_type;
    179223    }
    180     }
    181 
     224
     225
     226    private class IndexingOptionsControl
     227        extends JPanel
     228    {
     229        public IndexingOptionsControl()
     230        {
     231        setLayout(new BorderLayout(10,10));
     232        setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
     233
     234        stem_checkbox.setText(Dictionary.get("CDM.IndexingManager.Stem"));
     235        casefold_checkbox.setText(Dictionary.get("CDM.IndexingManager.Casefold"));
     236        accent_fold_checkbox.setText(Dictionary.get("CDM.IndexingManager.Accent_fold"));
     237
     238        // Accent-folding is currently not available for MG
     239        accent_fold_checkbox.setEnabled(!build_type.equals(BuildTypeManager.BUILD_TYPE_MG));
     240
     241        JPanel checkbox_panel = new JPanel();
     242        checkbox_panel.setLayout(new GridLayout(1, 3));
     243        checkbox_panel.add(stem_checkbox);
     244        checkbox_panel.add(casefold_checkbox);
     245        checkbox_panel.add(accent_fold_checkbox);
     246
     247        add(new JLabel(Dictionary.get("CDM.IndexingManager.Options")), BorderLayout.WEST);
     248        add(checkbox_panel, BorderLayout.CENTER);
     249        }
     250    }
     251    }
    182252}
Note: See TracChangeset for help on using the changeset viewer.