Ticket #15558: 15558-v3.patch
File 15558-v3.patch, 9.8 KB (added by , 5 years ago) |
---|
-
src/org/openstreetmap/josm/actions/OpenLocationAction.java
11 11 import java.util.ArrayList; 12 12 import java.util.Collection; 13 13 import java.util.Collections; 14 import java.util.LinkedList;15 14 import java.util.List; 16 15 import java.util.Objects; 17 16 import java.util.concurrent.Future; … … 109 108 * @param cbHistory the history combo box 110 109 */ 111 110 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())); 118 113 } 119 114 120 115 /** -
src/org/openstreetmap/josm/actions/SearchNotesDownloadAction.java
7 7 import java.awt.GridBagLayout; 8 8 import java.awt.event.ActionEvent; 9 9 import java.util.Collections; 10 import java.util.LinkedList;11 import java.util.List;12 10 import java.util.Optional; 13 11 14 12 import javax.swing.JLabel; … … 42 40 @Override 43 41 public void actionPerformed(ActionEvent e) { 44 42 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())); 48 44 49 45 JPanel contentPanel = new JPanel(new GridBagLayout()); 50 46 GridBagConstraints gc = new GridBagConstraints(); -
src/org/openstreetmap/josm/gui/dialogs/OsmIdSelectionDialog.java
13 13 import java.util.Collection; 14 14 import java.util.Collections; 15 15 import java.util.EnumSet; 16 import java.util.LinkedList;17 16 import java.util.List; 18 17 import java.util.stream.Collectors; 19 18 … … 179 178 * @param cbHistory the {@link HistoryComboBox} to which the history is restored to 180 179 */ 181 180 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())); 187 183 } 188 184 189 185 /** -
src/org/openstreetmap/josm/gui/download/OverpassQueryWizardDialog.java
94 94 if (!items.isEmpty()) { 95 95 queryWizard.setText(items.get(0)); 96 96 } 97 // HistoryComboBox needs the reversed list 98 Collections.reverse(items); 99 queryWizard.setPossibleItems(items); 97 queryWizard.setPossibleItemsTopDown(items); 100 98 101 99 setCancelButton(CANCEL + 1); 102 100 setDefaultButton(BUILD_AN_EXECUTE_QUERY + 1); -
src/org/openstreetmap/josm/gui/download/PlaceSelection.java
17 17 import java.text.DecimalFormat; 18 18 import java.util.ArrayList; 19 19 import java.util.Collections; 20 import java.util.LinkedList;21 20 import java.util.List; 22 21 import java.util.StringTokenizer; 23 22 … … 114 113 115 114 cbSearchExpression = new HistoryComboBox(); 116 115 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())); 120 117 lpanel.add(cbSearchExpression); 121 118 122 119 panel.add(lpanel, GBC.std().fill(GBC.HORIZONTAL).insets(5, 5, 0, 5)); -
src/org/openstreetmap/josm/gui/io/BasicUploadSettingsPanel.java
13 13 import java.awt.event.KeyAdapter; 14 14 import java.awt.event.KeyEvent; 15 15 import java.util.Arrays; 16 import java.util.Collections;17 16 import java.util.LinkedList; 18 17 import java.util.List; 19 18 import java.util.Objects; … … 113 112 } 114 113 115 114 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)); 119 116 hcb.discardAllUndoableEdits(); 120 117 } 121 118 -
src/org/openstreetmap/josm/gui/preferences/projection/CustomProjectionChoice.java
10 10 import java.util.Arrays; 11 11 import java.util.Collection; 12 12 import java.util.Collections; 13 import java.util.LinkedList;14 13 import java.util.List; 15 14 16 15 import javax.swing.JButton; … … 74 73 List<String> samples = Arrays.asList( 75 74 "+proj=lonlat +ellps=WGS84 +datum=WGS84 +bounds=-180,-90,180,90", 76 75 "+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)); 80 77 cbInput.setText(initialText == null ? "" : initialText); 81 78 82 79 final HtmlPanel errorsPanel = new HtmlPanel(); -
src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletingComboBox.java
8 8 import java.awt.event.FocusListener; 9 9 import java.awt.im.InputContext; 10 10 import java.util.Collection; 11 import java.util.Collections; 12 import java.util.LinkedList; 11 13 import java.util.Locale; 12 14 13 15 import javax.swing.ComboBoxEditor; … … 287 289 } 288 290 289 291 /** 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). 291 293 * @param elems String items 292 294 */ 293 295 public void setPossibleItems(Collection<String> elems) { … … 297 299 for (String elem : elems) { 298 300 model.addElement(new AutoCompletionItem(elem, AutoCompletionPriority.UNKNOWN)); 299 301 } 302 this.setSelectedItem(null); 300 303 // disable autocomplete to prevent unnecessary actions in AutoCompletingComboBoxDocument#insertString 301 304 autocompleteEnabled = false; 302 this. getEditor().setItem(oldValue); // Do not use setSelectedItem(oldValue); (fix #8013)305 this.setSelectedItem(oldValue); 303 306 autocompleteEnabled = true; 304 307 } 305 308 306 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 xxx 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); 319 } 320 321 /** 307 322 * Sets the items of the combobox to the given {@code AutoCompletionItem}s. 308 323 * @param elems AutoCompletionItem items 309 324 * @since 12859