diff --git a/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java b/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java
index fe00fb8..996d001 100644
a
|
b
|
public class PropertiesDialog extends ToggleDialog implements SelectionChangedLi
|
269 | 269 | }); |
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); |
279 | 296 | values.getEditor().setItem(selection); |
280 | 297 | p.add(new JLabel(tr("Value")), GBC.std()); |
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) { |
286 | 303 | @Override public void selectInitialValue() { |
… |
… |
public class PropertiesDialog extends ToggleDialog implements SelectionChangedLi
|
474 | 491 | } |
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); |
480 | 497 | |
… |
… |
public class PropertiesDialog extends ToggleDialog implements SelectionChangedLi
|
505 | 522 | * @param keys |
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() |
511 | 530 | .getEditorComponent(); |
… |
… |
public class PropertiesDialog extends ToggleDialog implements SelectionChangedLi
|
515 | 534 | String key = keys.getEditor().getItem().toString(); |
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); |
521 | 540 | objKey=key; |