Changeset 5772


Ignore:
Timestamp:
2003-11-03T14:23:28+13:00 (20 years ago)
Author:
mdewsnip
Message:

Fixed bug 229: the same file tree filter can be added multiple times to the drop-down list.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/gui/Filter.java

    r5593 r5772  
    129129    }
    130130
    131     /** Change the background color of the filter.
    132      * @param color The new background <strong>Color</strong>.
    133      */
    134     public void setBackground(Color color) {
    135     super.setBackground(color);
    136     }
    137 
    138131    /** Used to restore the filter state to enabled, the normal state during collection editing.
    139132     * @param state The new state for the filter. <i>true</i> for enabled, <i>false</i> otherwise.
     
    237230            String temp_str = (String) temp;
    238231            ///ystem.err.println("Filter = " + temp_str);
    239             // Ignore any string which matches a predefined filter, starting with All Files.
     232
     233            // Ignore any string which matches a predefined filter
    240234            if(temp_str.equals(Dictionary.get("Filter.All_Files"))) {
    241235            }
     
    253247            }
    254248            else {
    255             ///ystem.err.println("Temporary Custom Filter");
    256             entry = new Entry((String)temp, Pattern.compile(encode((String)temp)));
    257             combobox.removeItem(temp);
    258             int position = combobox.getItemCount();
    259             combobox.insertItemAt(entry, position);
    260                 combobox.setSelectedIndex(position);
    261             ///ystem.err.println("Inserting permanent custom filter.");
     249            // Make sure the filter isn't already in the list
     250            boolean already_exists = false;
     251            for (int i = 0; i < combobox.getItemCount(); i++) {
     252                if (temp_str.equals(combobox.getItemAt(i).toString())) {
     253                already_exists = true;
     254                entry = (Entry) combobox.getItemAt(i);
     255                break;
     256                }
     257            }
     258
     259            if (already_exists == false) {
     260                entry = new Entry(temp_str, Pattern.compile(encode(temp_str)));
     261                int position = combobox.getItemCount();
     262                combobox.insertItemAt(entry, position);
     263                combobox.setSelectedIndex(position);
     264            }
    262265            }
    263266        }
Note: See TracChangeset for help on using the changeset viewer.