Changeset 5088


Ignore:
Timestamp:
2003-08-04T11:45:43+12:00 (21 years ago)
Author:
jmt12
Message:

Ensures that a default search type is provided, and that at least type is selected at all times. Also fixed bug where buttons never became active - ever

File:
1 edited

Legend:

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

    r5037 r5088  
    5252    extends DOMProxyListModel {
    5353
     54    static final public String[] SEARCH_TYPES = {"form", "plain"};
     55
    5456    /** The default size of a label, in an attempt to make labels/fields line up. */
    5557    static final private Dimension LABEL_SIZE = new Dimension(150,25);
    5658
    57     static final private String[] SEARCH_TYPES = {"form", "plain"};
    5859
    5960    /** The controls used to edit the search types. */
     
    125126        title_label.setHorizontalAlignment(JLabel.CENTER);
    126127        instructions_textarea = new JTextArea("CDM.SearchTypeManager.Instructions");
    127         instructions_textarea.setCaretPosition(0);
    128128        instructions_textarea.setEditable(false);
    129129        instructions_textarea.setLineWrap(true);
    130         instructions_textarea.setRows(4);
     130        instructions_textarea.setRows(6);
    131131        instructions_textarea.setWrapStyleWord(true);
    132132
     
    257257   
    258258    public void gainFocus() {
     259        instructions_textarea.setCaretPosition(0);
    259260        validateControls(isMGPPEnabled());
    260261    }
     
    266267    private void validateControls(boolean advanced_search_enabled) {
    267268        // Enable or disable controls based on whether MGPP is enabled
    268         add_button.setEnabled(add_button.isEnabled() && advanced_search_enabled);
     269        // validate add button, which depends on the current combobox selection and the contents of the assigned search types list
     270        Object selected_item = search_type_combobox.getSelectedItem();
     271        add_button.setEnabled(advanced_search_enabled && selected_item != null && !model.contains(selected_item));
     272        // validate other controls.
    269273        current_search_types_list.setEnabled(advanced_search_enabled);
    270274        enable_advanced_searches_checkbox.setSelected(advanced_search_enabled);
    271275        search_type_combobox.setEnabled(advanced_search_enabled);
    272         remove_button.setEnabled(remove_button.isEnabled() && advanced_search_enabled);
     276        remove_button.setEnabled(current_search_types_list.getModel().getSize() > 1 && !current_search_types_list.isSelectionEmpty() && advanced_search_enabled);
    273277    }
    274278
     
    301305        public void valueChanged(ListSelectionEvent event) {
    302306        if(!event.getValueIsAdjusting()) {
    303             remove_button.setEnabled(!current_search_types_list.isSelectionEmpty());
     307            remove_button.setEnabled(current_search_types_list.getModel().getSize() > 1 && !current_search_types_list.isSelectionEmpty());
    304308        }
    305309        }
     
    316320        boolean advanced_search_enabled = enable_advanced_searches_checkbox.isSelected();
    317321        model.root.setAttribute(CollectionConfiguration.ASSIGNED_ATTRIBUTE, (advanced_search_enabled ? CollectionConfiguration.TRUE_STR : CollectionConfiguration.FALSE_STR));
     322        CollectionDesignManager.index_manager.setMGPPEnabled(advanced_search_enabled);
    318323        validateControls(advanced_search_enabled);
    319         CollectionDesignManager.index_manager.setMGPPEnabled(advanced_search_enabled);
    320324        Gatherer.g_man.wait(false);
    321325        }
     
    335339            }
    336340        }
     341        Object selected_object = search_type_combobox.getSelectedItem();
     342        if(selected_object != null) {
     343            add_button.setEnabled(!model.contains(selected_object));
     344        }
     345        else {
     346            add_button.setEnabled(false);
     347        }
    337348        remove_button.setEnabled(false);
    338349        }
     
    373384        Object selected_object = search_type_combobox.getSelectedItem();
    374385        if(selected_object != null) {
    375             add_button.setEnabled(model.contains(selected_object));
     386            add_button.setEnabled(!model.contains(selected_object));
    376387        }
    377388        else {
Note: See TracChangeset for help on using the changeset viewer.