Changeset 9552


Ignore:
Timestamp:
2005-04-05T11:41:13+12:00 (19 years ago)
Author:
mdewsnip
Message:

Fixed a bug where adding indexes on metadata elements whose name didn't match their display name would be screwed up. This was caused by the combobox being editable and converting the contents into strings rather than keeping them as objects. The combobox has been changed to be non-editable and some extra code has been added to check everything stays frosty.

File:
1 edited

Legend:

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

    r9252 r9552  
    10561056        move_index_up_button.setEnabled(false);
    10571057        move_index_up_button.setMnemonic(KeyEvent.VK_U);
    1058         //move_index_up_button.setPreferredSize(Utility.DOUBLE_IMAGE_BUTTON_SIZE);
    10591058        Dictionary.registerBoth(move_index_up_button, "CDM.Move.Move_Up", "CDM.Move.Move_Up_Tooltip");
    10601059
     
    10621061        move_index_down_button.setEnabled(false);
    10631062        move_index_down_button.setMnemonic(KeyEvent.VK_D);
    1064         //move_index_down_button.setPreferredSize(Utility.DOUBLE_IMAGE_BUTTON_SIZE);
    10651063        Dictionary.registerBoth(move_index_down_button, "CDM.Move.Move_Down", "CDM.Move.Move_Down_Tooltip");
    10661064
     
    10861084        index_combobox.setBackgroundNonSelectionColor(Configuration.getColor("coloring.editable_background", false));
    10871085        index_combobox.setBackgroundSelectionColor(Configuration.getColor("coloring.collection_selection_background", false));
    1088         index_combobox.setEditable(true);
     1086        index_combobox.setEditable(false);  // Warning: setting this to true opens a big can of worms
    10891087        index_combobox.setTextNonSelectionColor(Configuration.getColor("coloring.workspace_tree_foreground", false));
    10901088        index_combobox.setTextSelectionColor(Configuration.getColor("coloring.collection_selection_foreground", false));
     
    13551353        // Retrieve the source
    13561354        Object source = index_combobox.getSelectedItem();
     1355
    13571356        // If this object isn't yet in the combobox add it.
    13581357        if(index_combobox.getSelectedIndex() == -1) {
     
    15131512            // Unfortunately we have to generate a valid id
    15141513            String id = null;
    1515             if (selected_object instanceof MetadataElement) {
     1514            // Special cases
     1515            if (selected_object instanceof String && (selected_object.equals(CollectionConfiguration.ALLFIELDS_STR) || selected_object.equals(CollectionConfiguration.METADATA_STR) || selected_object.equals(CollectionConfiguration.TEXT_STR))) {
     1516            id = (String) selected_object;
     1517            }
     1518            else if (selected_object instanceof MetadataElement) {
    15161519            id = ((MetadataElement) selected_object).getFullName();
    15171520            }
    15181521            else {
    1519             id = selected_object.toString();
     1522            System.err.println("Internal Error: Unexpected selected_object in IndexManager.");
     1523            return;
    15201524            }
    15211525            if(id.startsWith(StaticStrings.EXTRACTED_NAMESPACE)) {
Note: See TracChangeset for help on using the changeset viewer.