- Timestamp:
- 2011-12-21T10:18:40+01:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java
r4663 r4680 270 270 values.setEditable(true); 271 271 272 final Map<String, Integer> m = (Map<String, Integer>) propertyData.getValueAt(row, 1); 273 274 Comparator<AutoCompletionListItem> usedValuesAwareComparator = new Comparator<AutoCompletionListItem>() { 275 276 @Override 277 public int compare(AutoCompletionListItem o1, AutoCompletionListItem o2) { 278 boolean c1 = m.containsKey(o1.getValue()); 279 boolean c2 = m.containsKey(o2.getValue()); 280 if (c1 == c2) { 281 return String.CASE_INSENSITIVE_ORDER.compare(o1.getValue(), o2.getValue()); 282 } else if (c1) { 283 return -1; 284 } else { 285 return +1; 286 } 287 } 288 }; 289 272 290 List<AutoCompletionListItem> valueList = autocomplete.getValues(getAutocompletionKeys(key)); 273 Collections.sort(valueList, defaultACItemComparator);291 Collections.sort(valueList, usedValuesAwareComparator); 274 292 275 293 values.setPossibleACItems(valueList); 276 Map<String, Integer> m=(Map<String, Integer>)propertyData.getValueAt(row, 1);277 294 final String selection= m.size()!=1?tr("<different>"):m.entrySet().iterator().next().getKey(); 278 295 values.setSelectedItem(selection); … … 281 298 p.add(Box.createHorizontalStrut(10), GBC.std()); 282 299 p.add(values, GBC.eol().fill(GBC.HORIZONTAL)); 283 addFocusAdapter(row, keys, values, autocomplete );300 addFocusAdapter(row, keys, values, autocomplete, usedValuesAwareComparator); 284 301 285 302 final JOptionPane optionPane = new JOptionPane(panel, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION) { … … 475 492 } 476 493 477 FocusAdapter focus = addFocusAdapter(-1, keys, values, autocomplete );494 FocusAdapter focus = addFocusAdapter(-1, keys, values, autocomplete, defaultACItemComparator); 478 495 // fire focus event in advance or otherwise the popup list will be too small at first 479 496 focus.focusGained(null); … … 506 523 * @param values 507 524 */ 508 private FocusAdapter addFocusAdapter(final int row, final AutoCompletingComboBox keys, final AutoCompletingComboBox values, final AutoCompletionManager autocomplete) { 525 private FocusAdapter addFocusAdapter(final int row, 526 final AutoCompletingComboBox keys, final AutoCompletingComboBox values, 527 final AutoCompletionManager autocomplete, final Comparator<AutoCompletionListItem> comparator) { 509 528 // get the combo box' editor component 510 529 JTextComponent editor = (JTextComponent)values.getEditor() … … 516 535 517 536 List<AutoCompletionListItem> valueList = autocomplete.getValues(getAutocompletionKeys(key)); 518 Collections.sort(valueList, defaultACItemComparator);537 Collections.sort(valueList, comparator); 519 538 520 539 values.setPossibleACItems(valueList);
Note:
See TracChangeset
for help on using the changeset viewer.