Changeset 4109 in josm for trunk


Ignore:
Timestamp:
2011-06-01T20:57:34+02:00 (14 years ago)
Author:
stoecker
Message:

see 6378 - patch by akks (reworked) - prefill key addition dialog with last values

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java

    r4107 r4109  
    364364    }
    365365
     366    private static String lastAddKey = null;
     367    private static String lastAddValue = null;
    366368    /**
    367369     * Open the add selection dialog and add a new key/value to the table (and
     
    380382        List<AutoCompletionListItem> keyList = autocomplete.getKeys();
    381383
     384        AutoCompletionListItem itemToSelect = null;
    382385        // remove the object's tag keys from the list
    383386        Iterator<AutoCompletionListItem> iter = keyList.iterator();
    384387        while (iter.hasNext()) {
    385388            AutoCompletionListItem item = iter.next();
     389            if (item.getValue().equals(lastAddKey)) {
     390                itemToSelect = item;
     391            }
    386392            for (int i = 0; i < propertyData.getRowCount(); ++i) {
    387393                if (item.getValue().equals(propertyData.getValueAt(i, 0))) {
     394                    if (itemToSelect == item)
     395                        itemToSelect = null;
    388396                    iter.remove();
    389397                    break;
     
    404412        values.setEditable(true);
    405413        p2.add(values, BorderLayout.CENTER);
     414        if (itemToSelect != null) {
     415            keys.setSelectedItem(itemToSelect);
     416            values.setSelectedItem(lastAddValue);
     417        }
    406418
    407419        FocusAdapter focus = addFocusAdapter(-1, keys, values, autocomplete);
     
    425437        if (value.equals(""))
    426438            return;
     439        lastAddKey = key;
     440        lastAddValue = value;
    427441        Main.main.undoRedo.add(new ChangePropertyCommand(sel, key, value));
    428442        btnAdd.requestFocusInWindow();
Note: See TracChangeset for help on using the changeset viewer.