Changeset 18126 in josm for trunk/src/org


Ignore:
Timestamp:
2021-08-06T01:22:18+02:00 (3 years ago)
Author:
Don-vip
Message:

fix #21203 - CCE in HistoryComboBox#addCurrentItemToHistory (patch by taylor.smock)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/widgets/HistoryComboBox.java

    r12846 r18126  
    66import javax.swing.text.JTextComponent;
    77
     8import org.openstreetmap.josm.data.tagging.ac.AutoCompletionItem;
    89import org.openstreetmap.josm.gui.tagging.ac.AutoCompletingComboBox;
    910import org.openstreetmap.josm.spi.preferences.Config;
     
    5556     */
    5657    public void addCurrentItemToHistory() {
    57         model.addElement((String) getEditor().getItem());
     58        Object item = getEditor().getItem();
     59        if (item instanceof String) {
     60            model.addElement((String) item);
     61        } else if (item instanceof AutoCompletionItem) {
     62            model.addElement((AutoCompletionItem) item);
     63        } else {
     64            throw new IllegalArgumentException(item.getClass().getSimpleName() + " is not supported in addCurrentItemToHistory");
     65        }
    5866    }
    5967
Note: See TracChangeset for help on using the changeset viewer.