Changeset 3215 in josm
- Timestamp:
- 2010-05-03T10:52:48+02:00 (15 years ago)
- 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 18 18 import javax.swing.text.JTextComponent; 19 19 import javax.swing.text.PlainDocument; 20 import javax.swing.text.StyleConstants; 20 21 21 22 /** … … 57 58 return; 58 59 if (!autocompleteEnabled) 60 return; 61 // input method for non-latin characters (e.g. scim) 62 if (a != null && a.isDefined(StyleConstants.ComposedTextAttribute)) 59 63 return; 60 64 -
trunk/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletingTextField.java
r3210 r3215 19 19 import javax.swing.text.Document; 20 20 import javax.swing.text.PlainDocument; 21 import javax.swing.text.StyleConstants; 21 22 22 23 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionList; … … 52 53 } 53 54 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 54 61 // if the current offset isn't at the end of the document we don't autocomplete. 55 62 // 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 25 25 * constructor 26 26 */ 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 27 37 public AutoCompletionListItem() { 28 38 value = ""; … … 30 40 } 31 41 32 public AutoCompletionListItem(String value, AutoCompletionItemPritority priority) {33 this.value = value;34 this.priority = priority;35 }36 42 37 43 /** -
trunk/src/org/openstreetmap/josm/gui/widgets/ComboBoxHistory.java
r3083 r3215 35 35 import javax.swing.DefaultComboBoxModel; 36 36 37 public class ComboBoxHistory extends DefaultComboBoxModel implements Iterable<String> { 37 import org.openstreetmap.josm.gui.tagging.ac.*; 38 39 public class ComboBoxHistory extends DefaultComboBoxModel implements Iterable<AutoCompletionListItem> { 38 40 39 41 private int maxSize = 10; … … 50 52 @Override 51 53 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(); 53 59 54 60 // if history contains this object already, delete it, 55 61 // so that it looks like a move to the top 56 62 for (int i = 0; i < getSize(); i++) { 57 String oldEntry = ( String) getElementAt(i);63 String oldEntry = ((AutoCompletionListItem) getElementAt(i)).getValue(); 58 64 if(oldEntry.equals(newEntry)) { 59 65 removeElementAt(i); … … 75 81 } 76 82 77 public Iterator< String> iterator() {78 return new Iterator< String>() {83 public Iterator<AutoCompletionListItem> iterator() { 84 return new Iterator<AutoCompletionListItem>() { 79 85 80 86 private int position = -1; … … 90 96 } 91 97 92 public Stringnext() {98 public AutoCompletionListItem next() { 93 99 position++; 94 return getElementAt(position).toString();100 return (AutoCompletionListItem)getElementAt(position); 95 101 } 96 102 … … 98 104 } 99 105 100 public void setItems (List<String> items) {106 public void setItemsAsString(List<String> items) { 101 107 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))); 105 110 } 106 Collections.reverse(items);107 111 } 108 112 109 public List<String> as List() {113 public List<String> asStringList() { 110 114 List<String> list = new ArrayList<String>(maxSize); 111 for ( Stringitem : this) {112 list.add(item );115 for (AutoCompletionListItem item : this) { 116 list.add(item.getValue()); 113 117 } 114 118 return list; … … 125 129 private void fireHistoryChanged() { 126 130 for (HistoryChangedListener l : listeners) { 127 l.historyChanged(as List());131 l.historyChanged(asStringList()); 128 132 } 129 133 } -
trunk/src/org/openstreetmap/josm/gui/widgets/HistoryComboBox.java
r3210 r3215 32 32 33 33 public void setHistory(List<String> history) { 34 model.setItems (history);34 model.setItemsAsString(history); 35 35 } 36 36 37 37 public List<String> getHistory() { 38 return model.as List();38 return model.asStringList(); 39 39 } 40 40 }
Note:
See TracChangeset
for help on using the changeset viewer.