Changeset 5301 for trunk/gli/src/org/greenstone/gatherer/gui/Filter.java
- Timestamp:
- 2003-08-27T15:12:03+12:00 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/gui/Filter.java
r5239 r5301 109 109 label.setPreferredSize(SIZE); 110 110 // Add listeners. 111 combobox.add ItemListener(new ComboBoxListener());111 combobox.addActionListener(new ComboBoxListener()); 112 112 // Layout. 113 113 label.setBorder(BorderFactory.createEmptyBorder(0,0,0,5)); … … 233 233 /** Listens for changes in the combobox as when one is detected attempts to compile a regular expression from whatever text was entered. If successful, or if the item chosen was a predefined filter, it then applies the filter to the target tree. */ 234 234 private class ComboBoxListener 235 implements ItemListener {236 237 * @param event An <strong> ItemEvent</strong> containing more information about the change performed.235 implements ActionListener { 236 /** Called when a new item is selected from the filter combobox, we treat the new entry as a pseudo-regular expression, compile it and then apply it to the tree. 237 * @param event An <strong>ActionEvent</strong> containing more information about the change performed. 238 238 * @see org.greenstone.gatherer.gui.Filter.Entry 239 239 */ 240 public void itemStateChanged(ItemEvent event) { 241 if(!ignore) { 242 ignore = true; 243 if(event.getStateChange() == ItemEvent.SELECTED) { 244 try { 245 Object temp = combobox.getSelectedItem(); 246 Entry entry = null; 247 if(temp instanceof String) { 248 String temp_str = (String) temp; 249 ///ystem.err.println("Filter = " + temp_str); 250 // Ignore any string which matches a predefined filter, starting with All Files. 251 if(temp_str.equals(get("All_Files"))) { 252 } 253 // HTM & HTML 254 else if(temp_str.equals(get("0"))) { 255 } 256 // XML 257 else if(temp_str.equals(get("1"))) { 258 } 259 // Text files 260 else if(temp_str.equals(get("2"))) { 261 } 262 // Images 263 else if(temp_str.equals(get("3"))) { 264 } 265 else { 266 entry = new Entry((String)temp, Pattern.compile(encode((String)temp))); 267 //combobox.removeItem(temp); 268 //int position = combobox.add(entry); 269 //combobox.setSelectedIndex(position); 270 } 271 } 272 else { 273 entry = (Entry) temp; 274 } 275 if(entry != null) { 276 setFilter(entry.getPattern()); 277 // Synchronize other controls. 278 /* 279 for(int i = 0; i < others.size(); i++) { 280 Filter sibling = (Filter) others.get(i); 281 if(sibling != this_filter) { 282 sibling.setComboBoxSelection((Entry)entry); 283 } 284 } 285 */ 286 } 287 // Else we ignore this event as being one of the painfully erroneous events we receive because we've been silly enough to have an editable combobox. 288 } 289 catch (PatternSyntaxException error) { 290 if(first) { 291 JOptionPane.showMessageDialog(Gatherer.g_man, get("Invalid_Pattern"), get("General.Error"), JOptionPane.ERROR_MESSAGE); 292 } 240 public void actionPerformed(ActionEvent event) { 241 try { 242 Object temp = combobox.getSelectedItem(); 243 Entry entry = null; 244 if(temp instanceof String) { 245 String temp_str = (String) temp; 246 ///ystem.err.println("Filter = " + temp_str); 247 // Ignore any string which matches a predefined filter, starting with All Files. 248 if(temp_str.equals(get("All_Files"))) { 249 } 250 // HTM & HTML 251 else if(temp_str.equals(get("0"))) { 252 } 253 // XML 254 else if(temp_str.equals(get("1"))) { 255 } 256 // Text files 257 else if(temp_str.equals(get("2"))) { 258 } 259 // Images 260 else if(temp_str.equals(get("3"))) { 261 } 262 else { 263 ///ystem.err.println("Temporary Custom Filter"); 264 entry = new Entry((String)temp, Pattern.compile(encode((String)temp))); 265 combobox.removeItem(temp); 266 int position = combobox.getItemCount(); 267 combobox.insertItemAt(entry, position); 268 combobox.setSelectedIndex(position); 269 ///ystem.err.println("Inserting permanent custom filter."); 293 270 } 294 271 } 295 ignore = false; 272 else { 273 ///ystem.err.println("Custom Filter"); 274 entry = (Entry) temp; 275 } 276 if(entry != null) { 277 setFilter(entry.getPattern()); 278 } 279 // Else we ignore this event as being one of the painfully erroneous events we receive because we've been silly enough to have an editable combobox. 280 } 281 catch (PatternSyntaxException error) { 282 if(first) { 283 JOptionPane.showMessageDialog(Gatherer.g_man, get("Invalid_Pattern"), get("General.Error"), JOptionPane.ERROR_MESSAGE); 284 } 296 285 } 297 286 }
Note:
See TracChangeset
for help on using the changeset viewer.