Changeset 7863 in josm


Ignore:
Timestamp:
2014-12-20T22:08:29+01:00 (10 years ago)
Author:
Don-vip
Message:

fix #10470 - fix invalid recognition of items in AutoCompletionComboBox

Location:
trunk/src/org/openstreetmap/josm/gui
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletingComboBox.java

    r7632 r7863  
    247247            }
    248248            super.setSelectedItem(new AutoCompletionListItem(s, AutoCompletionItemPriority.UNKNOWN));
    249         } else
    250             throw new IllegalArgumentException();
     249        } else {
     250            throw new IllegalArgumentException("Unsupported item: "+item);
     251        }
    251252    }
    252253
  • trunk/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletionListItem.java

    r6437 r7863  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.gui.tagging.ac;
     3
     4import org.openstreetmap.josm.tools.CheckParameterUtil;
    35
    46/**
     
    7981     */
    8082    public void setValue(String value) {
    81         if (value == null)
    82             throw new IllegalArgumentException("argument 'value' must not be null");
     83        CheckParameterUtil.ensureParameterNotNull(value, "value");
    8384        this.value = value;
    8485    }
     
    108109        if (obj == null)
    109110            return false;
     111        if (obj instanceof String)
     112            return obj.equals(value);
    110113        if (getClass() != obj.getClass())
    111114            return false;
  • trunk/src/org/openstreetmap/josm/gui/widgets/JosmComboBox.java

    r7015 r7863  
    160160            JList<E> list = getList();
    161161            if (list != null) {
    162                 if (list.getPrototypeCellValue() != prototype) {
     162                if (!prototype.equals(list.getPrototypeCellValue())) {
    163163                    list.setPrototypeCellValue(prototype);
    164164                }
     
    197197
    198198        private void enableMenu() {
    199             if (launcher == null) {
    200                 if (editor != null) {
    201                     Component editorComponent = editor.getEditorComponent();
    202                     if (editorComponent instanceof JTextComponent) {
    203                         component = (JTextComponent) editorComponent;
    204                         component.addMouseListener(this);
    205                         launcher = TextContextualPopupMenu.enableMenuFor(component);
    206                     }
     199            if (launcher == null && editor != null) {
     200                Component editorComponent = editor.getEditorComponent();
     201                if (editorComponent instanceof JTextComponent) {
     202                    component = (JTextComponent) editorComponent;
     203                    component.addMouseListener(this);
     204                    launcher = TextContextualPopupMenu.enableMenuFor(component);
    207205                }
    208206            }
     
    229227
    230228        private void processEvent(MouseEvent e) {
    231             if (launcher != null && !e.isPopupTrigger()) {
    232                 if (launcher.getMenu().isShowing()) {
    233                     launcher.getMenu().setVisible(false);
    234                 }
     229            if (launcher != null && !e.isPopupTrigger() && launcher.getMenu().isShowing()) {
     230                launcher.getMenu().setVisible(false);
    235231            }
    236232        }
Note: See TracChangeset for help on using the changeset viewer.