Changeset 9907


Ignore:
Timestamp:
2005-05-18T17:08:50+12:00 (19 years ago)
Author:
kjdon
Message:

added a build type selection element - mgpp/lucene

File:
1 edited

Legend:

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

    r8243 r9907  
    4545import org.w3c.dom.*;
    4646
    47 /** This class maintains an ordered list of the search types available in the collection (MGPP command available in G2.39 or later). Currently only 'form' and 'plain' are valid.
     47/** This class maintains an ordered list of the search types available in the collection (MGPP/lucene command available in G2.39 or later). Currently only 'form' and 'plain' are valid.
    4848 * @author John Thompson, Greenstone Digital Library, University of Waikato
    4949 * @version 2.4
     
    5151public class SearchTypeManager
    5252    extends DOMProxyListModel {
    53 
    54     static final public String[] SEARCH_TYPES = { "form", "plain" };
    55 
     53   
     54    static final public String[] SEARCH_TYPES = {  "plain" , "form"};
     55    static final public String[] BUILD_TYPES = {  "lucene", "mgpp" };
     56   
     57    /** the buildtype element in the config file  - searchtypemanager looks
     58     * after this now */
     59    public CollectionMeta build_type = null;
    5660    /** The controls used to edit the search types. */
    5761    private Control controls = null;
     
    6367    this.model = this;
    6468    DebugStream.println("SearchTypeManager: parsed " + getSize() + " search types.");
     69    build_type = new CollectionMeta(CollectionDesignManager.collect_config.getBuildType());
     70
    6571    }
    6672
     
    7177    }
    7278    }
    73 
     79   
    7480    public Control getControls() {
    7581    if(controls == null) {
     
    7985    }
    8086
    81     /** Return a list of the currently assigned search types as a comma separated string.
    82     * @return a String
    83     */
    84     public String getSearchTypes() {
    85         StringBuffer search_types = new StringBuffer();
    86         ArrayList types = children();
    87         for (int i = 0; i < types.size(); i++) {
    88             if (i>0) {
    89                 search_types.append(",");
    90             }
    91             search_types.append(((SearchType)types.get(i)).getName());
    92         }
    93         return search_types.toString();
    94     }
    95 
    96     /** Be examining the SearchType 'root' we were created with, determine if mgpp is enabled.
    97     * @return true if MGPP is enabled, false otherwise
    98     */
    99     public boolean isMGPPEnabled() {
    100         return root.getAttribute(CollectionConfiguration.ASSIGNED_ATTRIBUTE).equals(CollectionConfiguration.TRUE_STR);
    101     }
    102 
     87    /** Return a list of the currently assigned search types as a comma separated string.
     88    * @return a String
     89    */
     90    public String getSearchTypes() {
     91    StringBuffer search_types = new StringBuffer();
     92    ArrayList types = children();
     93    for (int i = 0; i < types.size(); i++) {
     94        if (i>0) {
     95        search_types.append(",");
     96        }
     97        search_types.append(((SearchType)types.get(i)).getName());
     98    }
     99    return search_types.toString();
     100    }
     101   
     102    /** By examining the SearchType 'root' we were created with, determine if mgpp is enabled.
     103    * @return true if MGPP is enabled, false otherwise
     104    */
     105    public boolean isMGPPEnabled() {
     106    return root.getAttribute(CollectionConfiguration.ASSIGNED_ATTRIBUTE).equals(CollectionConfiguration.TRUE_STR);
     107    }
     108   
    103109    private void moveSearchType(SearchType search_type, boolean direction) {
    104110    // Try to move the classifier one step in the desired direction.
     
    142148
    143149    private GComboBox search_type_combobox;
     150    private GComboBox build_type_combobox;
    144151
    145152    private JButton add_button;
     
    159166
    160167    public SearchTypeControl() {
     168   
    161169        // Creation
    162170        title_label = new JLabel();
     
    179187        JPanel inner_panel = new JPanel();
    180188
     189        JPanel indexer_type_panel = new JPanel();
     190        JPanel build_type_panel = new JPanel();
     191
    181192        enable_advanced_searches_checkbox = new JCheckBox();
    182193        Dictionary.registerText(enable_advanced_searches_checkbox, "CDM.SearchTypeManager.Enable");
    183194
     195        build_type_combobox = new GComboBox(BUILD_TYPES);
     196        build_type_combobox.setPreferredSize(Utility.LABEL_SIZE);
     197        build_type_combobox.setBackgroundNonSelectionColor(Configuration.getColor("coloring.editable_background", false));
     198        build_type_combobox.setBackgroundSelectionColor(Configuration.getColor("coloring.collection_selection_background", false));
     199        build_type_combobox.setEditable(true);
     200        build_type_combobox.setSelectedIndex(1);// mgpp is at 1
     201        String selected_value = build_type.getValue(CollectionMeta.TEXT);
     202        if (!selected_value.equals("")) {
     203        for (int i=0; i<build_type_combobox.getItemCount();i++) {
     204            String item = (String)build_type_combobox.getItemAt(i);
     205            if (item.equals(selected_value)) {
     206            build_type_combobox.setSelectedIndex(i);
     207            break;
     208            }
     209        }
     210        } else {
     211        build_type.setValue((String)build_type_combobox.getSelectedItem());
     212        build_type.setAssigned(isMGPPEnabled());
     213
     214        }
     215        build_type_combobox.setTextNonSelectionColor(Configuration.getColor("coloring.workspace_tree_foreground", false));
     216        build_type_combobox.setTextSelectionColor(Configuration.getColor("coloring.collection_selection_foreground", false));
     217        Dictionary.registerTooltip(build_type_combobox, "CDM.SearchTypeManager.BuildType_Selection_Tooltip");
     218
     219        JLabel build_type_label = new JLabel();
     220        Dictionary.registerText(build_type_label, "CDM.SearchTypeManager.BuildType_Selection");
    184221        JPanel current_search_types_panel = new JPanel();
    185222        current_search_types_label = new JLabel();
     
    193230        move_up_button.setEnabled(false);
    194231        move_up_button.setMnemonic(KeyEvent.VK_U);
    195         //move_up_button.setPreferredSize(Utility.DOUBLE_IMAGE_BUTTON_SIZE);
     232
    196233        Dictionary.registerBoth(move_up_button, "CDM.Move.Move_Up", "CDM.Move.Move_Up_Tooltip");
    197234
     
    199236        move_down_button.setEnabled(false);
    200237        move_down_button.setMnemonic(KeyEvent.VK_D);
    201         //move_down_button.setPreferredSize(Utility.DOUBLE_IMAGE_BUTTON_SIZE);
     238
    202239        Dictionary.registerBoth(move_down_button, "CDM.Move.Move_Down", "CDM.Move.Move_Down_Tooltip");
    203240
     
    210247        search_type_combobox.setBackgroundSelectionColor(Configuration.getColor("coloring.collection_selection_background", false));
    211248        search_type_combobox.setEditable(true);
    212         search_type_combobox.setSelectedIndex(0);
     249        search_type_combobox.setSelectedIndex(0); 
    213250        search_type_combobox.setTextNonSelectionColor(Configuration.getColor("coloring.workspace_tree_foreground", false));
    214251        search_type_combobox.setTextSelectionColor(Configuration.getColor("coloring.collection_selection_foreground", false));
     
    225262        remove_button.setMnemonic(KeyEvent.VK_R);
    226263        Dictionary.registerBoth(remove_button, "CDM.SearchTypeManager.Remove", "CDM.SearchTypeManager.Remove_Tooltip");
    227 
     264       
     265     
    228266        // Connection
    229267        add_button.addActionListener(new AddActionListener());
     268        build_type_combobox.addActionListener(new BuildTypeActionListener());
    230269        current_search_types_list.addListSelectionListener(new CurrentSearchTypesListSelectionListener());
    231270        enable_advanced_searches_checkbox.addActionListener(new EnableAdvancedSearchesActionListener());
     
    254293        current_search_types_panel.add(movement_panel, BorderLayout.EAST);
    255294
     295        build_type_panel.setLayout(new BorderLayout());
     296        build_type_panel.add(build_type_label, BorderLayout.WEST);
     297        build_type_panel.add(build_type_combobox, BorderLayout.CENTER);
     298
     299        indexer_type_panel.setLayout(new GridLayout(1,2,0,5));
     300        indexer_type_panel.add(enable_advanced_searches_checkbox);
     301        indexer_type_panel.add(build_type_panel);
     302       
    256303        button_panel.setBorder(BorderFactory.createEmptyBorder(2,0,0,0));
    257304        button_panel.setLayout(new GridLayout(1,2,0,5));
     
    265312
    266313        inner_panel.setLayout(new BorderLayout());
    267         inner_panel.add(enable_advanced_searches_checkbox, BorderLayout.NORTH);
     314        inner_panel.add(indexer_type_panel, BorderLayout.NORTH);
    268315        inner_panel.add(current_search_types_panel, BorderLayout.CENTER);
    269316        inner_panel.add(search_type_panel, BorderLayout.SOUTH);
     
    298345        // validate other controls.
    299346        current_search_types_list.setEnabled(advanced_search_enabled);
     347        build_type_combobox.setEnabled(advanced_search_enabled);
    300348        enable_advanced_searches_checkbox.setSelected(advanced_search_enabled);
    301349        search_type_combobox.setEnabled(advanced_search_enabled);
     
    362410        CollectionDesignManager.index_manager.setMGPPEnabled(advanced_search_enabled);
    363411        validateControls(advanced_search_enabled);
     412        build_type.setAssigned(advanced_search_enabled);
    364413        Gatherer.g_man.wait(false);
    365414        }
    366415    }
    367416
     417    private class BuildTypeActionListener
     418        implements  ActionListener {
     419
     420        public void actionPerformed(ActionEvent event) {
     421        build_type.setValue((String)build_type_combobox.getSelectedItem());
     422        }
     423
     424    }
    368425    /** Listenes for actions on the Remove button, and if detected removes the currently selected search types. */
    369426    private class RemoveActionListener
Note: See TracChangeset for help on using the changeset viewer.