- Timestamp:
- 2021-08-10T23:33:40+02:00 (3 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/widgets
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/widgets/ComboBoxHistory.java
r12859 r18131 42 42 String newEntry = o.getValue(); 43 43 44 boolean alreadyAdded = false; 44 45 // if history contains this object already, delete it, 45 46 // so that it looks like a move to the top … … 47 48 String oldEntry = getElementAt(i).getValue(); 48 49 if (oldEntry.equals(newEntry)) { 49 removeElementAt(i); 50 if (i == 0) { 51 alreadyAdded = true; 52 break; 53 } else { 54 removeElementAt(i); 55 } 50 56 } 51 57 } 52 58 53 // insert element at the top 54 insertElementAt(o, 0); 59 if (!alreadyAdded) { 60 // insert element at the top 61 insertElementAt(o, 0); 62 } 55 63 56 64 // remove an element, if the history gets too large -
trunk/src/org/openstreetmap/josm/gui/widgets/HistoryComboBox.java
r18128 r18131 6 6 import javax.swing.text.JTextComponent; 7 7 8 import org.openstreetmap.josm.data.tagging.ac.AutoCompletionItem; 8 9 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletingComboBox; 9 10 import org.openstreetmap.josm.spi.preferences.Config; … … 55 56 */ 56 57 public void addCurrentItemToHistory() { 57 model.addElement(getEditor().getItem().toString()); 58 Object item = getEditor().getItem(); 59 // This avoids instantiating multiple AutoCompletionItems 60 if (item instanceof AutoCompletionItem) { 61 model.addElement((AutoCompletionItem) item); 62 } else { 63 model.addElement(item.toString()); 64 } 58 65 } 59 66
Note:
See TracChangeset
for help on using the changeset viewer.