Changeset 15011 in josm


Ignore:
Timestamp:
2019-04-21T18:06:48+02:00 (8 months ago)
Author:
GerdP
Message:

fix #15558: apply 15558-v3.patch

Location:
trunk/src/org/openstreetmap/josm
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/OpenLocationAction.java

    r14397 r15011  
    1212import java.util.Collection;
    1313import java.util.Collections;
    14 import java.util.LinkedList;
    1514import java.util.List;
    1615import java.util.Objects;
     
    110109     */
    111110    protected void restoreUploadAddressHistory(HistoryComboBox cbHistory) {
    112         List<String> cmtHistory = new LinkedList<>(Config.getPref().getList(getClass().getName() + ".uploadAddressHistory",
    113                 new LinkedList<String>()));
    114         // we have to reverse the history, because ComboBoxHistory will reverse it again in addElement()
    115         //
    116         Collections.reverse(cmtHistory);
    117         cbHistory.setPossibleItems(cmtHistory);
     111        cbHistory.setPossibleItemsTopDown(Config.getPref().getList(getClass().getName() + ".uploadAddressHistory",
     112                Collections.emptyList()));
    118113    }
    119114
  • trunk/src/org/openstreetmap/josm/actions/SearchNotesDownloadAction.java

    r14656 r15011  
    88import java.awt.event.ActionEvent;
    99import java.util.Collections;
    10 import java.util.LinkedList;
    11 import java.util.List;
    1210import java.util.Optional;
    1311
     
    4341    public void actionPerformed(ActionEvent e) {
    4442        HistoryComboBox searchTermBox = new HistoryComboBox();
    45         List<String> searchHistory = new LinkedList<>(Config.getPref().getList(HISTORY_KEY, new LinkedList<String>()));
    46         Collections.reverse(searchHistory);
    47         searchTermBox.setPossibleItems(searchHistory);
     43        searchTermBox.setPossibleItemsTopDown(Config.getPref().getList(HISTORY_KEY, Collections.emptyList()));
    4844
    4945        JPanel contentPanel = new JPanel(new GridBagLayout());
  • trunk/src/org/openstreetmap/josm/gui/dialogs/OsmIdSelectionDialog.java

    r14674 r15011  
    1414import java.util.Collections;
    1515import java.util.EnumSet;
    16 import java.util.LinkedList;
    1716import java.util.List;
    1817import java.util.stream.Collectors;
     
    180179     */
    181180    protected void restorePrimitivesHistory(HistoryComboBox cbHistory) {
    182         List<String> cmtHistory = new LinkedList<>(
    183                 Config.getPref().getList(getClass().getName() + ".primitivesHistory", new LinkedList<String>()));
    184         // we have to reverse the history, because ComboBoxHistory will reverse it again in addElement()
    185         Collections.reverse(cmtHistory);
    186         cbHistory.setPossibleItems(cmtHistory);
     181        cbHistory.setPossibleItemsTopDown(
     182                Config.getPref().getList(getClass().getName() + ".primitivesHistory", Collections.emptyList()));
    187183    }
    188184
  • trunk/src/org/openstreetmap/josm/gui/download/OverpassQueryWizardDialog.java

    r14325 r15011  
    9595            queryWizard.setText(items.get(0));
    9696        }
    97         // HistoryComboBox needs the reversed list
    98         Collections.reverse(items);
    99         queryWizard.setPossibleItems(items);
     97        queryWizard.setPossibleItemsTopDown(items);
    10098
    10199        setCancelButton(CANCEL + 1);
  • trunk/src/org/openstreetmap/josm/gui/download/PlaceSelection.java

    r14273 r15011  
    1818import java.util.ArrayList;
    1919import java.util.Collections;
    20 import java.util.LinkedList;
    2120import java.util.List;
    2221import java.util.StringTokenizer;
     
    115114        cbSearchExpression = new HistoryComboBox();
    116115        cbSearchExpression.setToolTipText(tr("Enter a place name to search for"));
    117         List<String> cmtHistory = new LinkedList<>(Config.getPref().getList(HISTORY_KEY, new LinkedList<String>()));
    118         Collections.reverse(cmtHistory);
    119         cbSearchExpression.setPossibleItems(cmtHistory);
     116        cbSearchExpression.setPossibleItemsTopDown(Config.getPref().getList(HISTORY_KEY, Collections.emptyList()));
    120117        lpanel.add(cbSearchExpression);
    121118
  • trunk/src/org/openstreetmap/josm/gui/io/BasicUploadSettingsPanel.java

    r14977 r15011  
    1414import java.awt.event.KeyEvent;
    1515import java.util.Arrays;
    16 import java.util.Collections;
    1716import java.util.LinkedList;
    1817import java.util.List;
     
    114113
    115114    private static void populateHistoryComboBox(HistoryComboBox hcb, String historyKey, List<String> defaultValues) {
    116         List<String> cmtHistory = new LinkedList<>(Config.getPref().getList(historyKey, defaultValues));
    117         Collections.reverse(cmtHistory); // we have to reverse the history, because ComboBoxHistory will reverse it again in addElement()
    118         hcb.setPossibleItems(cmtHistory);
     115        hcb.setPossibleItemsTopDown(Config.getPref().getList(historyKey, defaultValues));
    119116        hcb.discardAllUndoableEdits();
    120117    }
  • trunk/src/org/openstreetmap/josm/gui/preferences/projection/CustomProjectionChoice.java

    r12859 r15011  
    1111import java.util.Collection;
    1212import java.util.Collections;
    13 import java.util.LinkedList;
    1413import java.util.List;
    1514
     
    7574                    "+proj=lonlat +ellps=WGS84 +datum=WGS84 +bounds=-180,-90,180,90",
    7675                    "+proj=tmerc +lat_0=0 +lon_0=9 +k_0=1 +x_0=3500000 +y_0=0 +ellps=bessel +nadgrids=BETA2007.gsb");
    77             List<String> inputHistory = new LinkedList<>(Config.getPref().getList("projection.custom.value.history", samples));
    78             Collections.reverse(inputHistory);
    79             cbInput.setPossibleItems(inputHistory);
     76            cbInput.setPossibleItemsTopDown(Config.getPref().getList("projection.custom.value.history", samples));
    8077            cbInput.setText(initialText == null ? "" : initialText);
    8178
  • trunk/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletingComboBox.java

    r13573 r15011  
    99import java.awt.im.InputContext;
    1010import java.util.Collection;
     11import java.util.Collections;
     12import java.util.LinkedList;
    1113import java.util.Locale;
    1214
     
    288290
    289291    /**
    290      * Sets the items of the combobox to the given {@code String}s.
     292     * Sets the items of the combobox to the given {@code String}s in reversed order (last element first).
    291293     * @param elems String items
    292294     */
     
    298300            model.addElement(new AutoCompletionItem(elem, AutoCompletionPriority.UNKNOWN));
    299301        }
     302        this.setSelectedItem(null);
    300303        // disable autocomplete to prevent unnecessary actions in AutoCompletingComboBoxDocument#insertString
    301304        autocompleteEnabled = false;
    302         this.getEditor().setItem(oldValue); // Do not use setSelectedItem(oldValue); (fix #8013)
     305        this.setSelectedItem(oldValue);
    303306        autocompleteEnabled = true;
     307    }
     308
     309    /**
     310     * Sets the items of the combobox to the given {@code String}s in top down order.
     311     * @param elems Collection of String items (is not changed)
     312     * @since 15011
     313     */
     314    public void setPossibleItemsTopDown(Collection<String> elems) {
     315        // We have to reverse the history, because ComboBoxHistory will reverse it again in addElement()
     316        LinkedList<String> reversed = new LinkedList<>(elems);
     317        Collections.reverse(reversed);
     318        setPossibleItems(reversed);
    304319    }
    305320
Note: See TracChangeset for help on using the changeset viewer.