Changeset 3215 in josm


Ignore:
Timestamp:
03.05.2010 10:52:48 (22 months ago)
Author:
bastiK
Message:

fixed #4979 Exception when opening the download window; fixed #2221 - Unexcepted Exception when typing into "Change values?" box with an input method on Mac OS X

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

Legend:

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

    r3214 r3215  
    1818import javax.swing.text.JTextComponent; 
    1919import javax.swing.text.PlainDocument; 
     20import javax.swing.text.StyleConstants; 
    2021 
    2122/** 
     
    5758                return; 
    5859            if (!autocompleteEnabled) 
     60                return; 
     61            // input method for non-latin characters (e.g. scim) 
     62            if (a != null && a.isDefined(StyleConstants.ComposedTextAttribute)) 
    5963                return; 
    6064 
  • trunk/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletingTextField.java

    r3210 r3215  
    1919import javax.swing.text.Document; 
    2020import javax.swing.text.PlainDocument; 
     21import javax.swing.text.StyleConstants; 
    2122 
    2223import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionList; 
     
    5253            } 
    5354 
     55            // input method for non-latin characters (e.g. scim) 
     56            if (a != null && a.isDefined(StyleConstants.ComposedTextAttribute)) { 
     57                super.insertString(offs, str, a); 
     58                return; 
     59            } 
     60 
    5461            // if the current offset isn't at the end of the document we don't autocomplete. 
    5562            // If a highlighted autocompleted suffix was present and we get here Swing has 
  • trunk/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletionListItem.java

    r3214 r3215  
    2525     * constructor 
    2626     */ 
     27    public AutoCompletionListItem(String value, AutoCompletionItemPritority priority) { 
     28        this.value = value; 
     29        this.priority = priority; 
     30    } 
     31 
     32    public AutoCompletionListItem(String value) { 
     33        this.value = value; 
     34        priority = AutoCompletionItemPritority.UNKNOWN; 
     35    } 
     36 
    2737    public AutoCompletionListItem() { 
    2838        value = ""; 
     
    3040    } 
    3141 
    32     public AutoCompletionListItem(String value, AutoCompletionItemPritority priority) { 
    33         this.value = value; 
    34         this.priority = priority; 
    35     } 
    3642 
    3743    /** 
  • trunk/src/org/openstreetmap/josm/gui/widgets/ComboBoxHistory.java

    r3083 r3215  
    3535import javax.swing.DefaultComboBoxModel; 
    3636 
    37 public class ComboBoxHistory extends DefaultComboBoxModel implements Iterable<String> { 
     37import org.openstreetmap.josm.gui.tagging.ac.*; 
     38 
     39public class ComboBoxHistory extends DefaultComboBoxModel implements Iterable<AutoCompletionListItem> { 
    3840 
    3941    private int maxSize = 10; 
     
    5052    @Override 
    5153    public void addElement(Object o) { 
    52         String newEntry = (String)o; 
     54        if (o instanceof String) { 
     55            o = new AutoCompletionListItem((String) o); 
     56        } 
     57 
     58        String newEntry = ((AutoCompletionListItem)o).getValue(); 
    5359 
    5460        // if history contains this object already, delete it, 
    5561        // so that it looks like a move to the top 
    5662        for (int i = 0; i < getSize(); i++) { 
    57             String oldEntry = (String) getElementAt(i); 
     63            String oldEntry = ((AutoCompletionListItem) getElementAt(i)).getValue(); 
    5864            if(oldEntry.equals(newEntry)) { 
    5965                removeElementAt(i); 
     
    7581    } 
    7682 
    77     public Iterator<String> iterator() { 
    78         return new Iterator<String>() { 
     83    public Iterator<AutoCompletionListItem> iterator() { 
     84        return new Iterator<AutoCompletionListItem>() { 
    7985 
    8086            private int position = -1; 
     
    9096            } 
    9197 
    92             public String next() { 
     98            public AutoCompletionListItem next() { 
    9399                position++; 
    94                 return getElementAt(position).toString(); 
     100                return (AutoCompletionListItem)getElementAt(position); 
    95101            } 
    96102 
     
    98104    } 
    99105 
    100     public void setItems(List<String> items) { 
     106    public void setItemsAsString(List<String> items) { 
    101107        removeAllElements(); 
    102         Collections.reverse(items); 
    103         for (String item : items) { 
    104             addElement(item); 
     108        for (int i = items.size()-1; i>=0; i--) { 
     109            addElement(new AutoCompletionListItem(items.get(i))); 
    105110        } 
    106         Collections.reverse(items); 
    107111    } 
    108112 
    109     public List<String> asList() { 
     113    public List<String> asStringList() { 
    110114        List<String> list = new ArrayList<String>(maxSize); 
    111         for (String item : this) { 
    112             list.add(item); 
     115        for (AutoCompletionListItem item : this) { 
     116            list.add(item.getValue()); 
    113117        } 
    114118        return list; 
     
    125129    private void fireHistoryChanged() { 
    126130        for (HistoryChangedListener l : listeners) { 
    127             l.historyChanged(asList()); 
     131            l.historyChanged(asStringList()); 
    128132        } 
    129133    } 
  • trunk/src/org/openstreetmap/josm/gui/widgets/HistoryComboBox.java

    r3210 r3215  
    3232 
    3333    public void setHistory(List<String> history) { 
    34         model.setItems(history); 
     34        model.setItemsAsString(history); 
    3535    } 
    3636 
    3737    public List<String> getHistory() { 
    38         return model.asList(); 
     38        return model.asStringList(); 
    3939    } 
    4040} 
Note: See TracChangeset for help on using the changeset viewer.