Changeset 9484 in josm
- Timestamp:
- 2016-01-16T13:32:46+01:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/OverpassDownloadAction.java
r9385 r9484 150 150 overpassWizard = new HistoryComboBox(); 151 151 overpassWizard.setToolTipText(tooltip); 152 overpassWizard.getEditor ().getEditorComponent().addFocusListener(disableActionsFocusListener);152 overpassWizard.getEditorComponent().addFocusListener(disableActionsFocusListener); 153 153 final JButton buildQuery = new JButton(tr("Build query")); 154 154 buildQuery.addActionListener(new AbstractAction() { -
trunk/src/org/openstreetmap/josm/actions/search/SearchAction.java
r9371 r9484 209 209 public void mouseClicked(MouseEvent e) { 210 210 try { 211 JTextComponent tf = (JTextComponent) hcb.getEditor().getEditorComponent();211 JTextComponent tf = hcb.getEditorComponent(); 212 212 tf.getDocument().insertString(tf.getCaretPosition(), ' ' + insertText, null); 213 213 } catch (BadLocationException ex) { … … 283 283 buildHints(right, hcbSearchString); 284 284 285 final JTextComponent editorComponent = (JTextComponent) hcbSearchString.getEditor().getEditorComponent();285 final JTextComponent editorComponent = hcbSearchString.getEditorComponent(); 286 286 editorComponent.getDocument().addDocumentListener(new AbstractTextComponentValidator(editorComponent) { 287 287 -
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/TagEditHelper.java
r9271 r9484 508 508 protected FocusAdapter addFocusAdapter(final AutoCompletionManager autocomplete, final Comparator<AutoCompletionListItem> comparator) { 509 509 // get the combo box' editor component 510 JTextComponent editor = (JTextComponent) values.getEditor().getEditorComponent();510 final JTextComponent editor = values.getEditorComponent(); 511 511 // Refresh the values model when focus is gained 512 512 FocusAdapter focus = new FocusAdapter() { -
trunk/src/org/openstreetmap/josm/gui/download/PlaceSelection.java
r9309 r9484 31 31 import javax.swing.JScrollPane; 32 32 import javax.swing.JTable; 33 import javax.swing.JTextField;34 33 import javax.swing.ListSelectionModel; 35 34 import javax.swing.UIManager; … … 121 120 SearchAction searchAction = new SearchAction(); 122 121 JButton btnSearch = new JButton(searchAction); 123 ((JTextField) cbSearchExpression.getEditor().getEditorComponent()).getDocument().addDocumentListener(searchAction);124 ((JTextField) cbSearchExpression.getEditor().getEditorComponent()).addActionListener(searchAction);122 cbSearchExpression.getEditorComponent().getDocument().addDocumentListener(searchAction); 123 cbSearchExpression.getEditorComponent().addActionListener(searchAction); 125 124 126 125 panel.add(btnSearch, GBC.eol().insets(5, 5, 0, 5)); -
trunk/src/org/openstreetmap/josm/gui/io/BasicUploadSettingsPanel.java
r9198 r9484 65 65 CommentModelListener commentModelListener = new CommentModelListener(hcbUploadComment, changesetCommentModel); 66 66 hcbUploadComment.getEditor().addActionListener(commentModelListener); 67 hcbUploadComment.getEditor ().getEditorComponent().addFocusListener(commentModelListener);67 hcbUploadComment.getEditorComponent().addFocusListener(commentModelListener); 68 68 pnl.add(hcbUploadComment, GBC.eol().fill(GBC.HORIZONTAL)); 69 69 … … 90 90 CommentModelListener sourceModelListener = new CommentModelListener(hcbUploadSource, changesetSourceModel); 91 91 hcbUploadSource.getEditor().addActionListener(sourceModelListener); 92 hcbUploadSource.getEditor ().getEditorComponent().addFocusListener(sourceModelListener);92 hcbUploadSource.getEditorComponent().addFocusListener(sourceModelListener); 93 93 pnl.add(hcbUploadSource, GBC.eol().fill(GBC.HORIZONTAL)); 94 94 return pnl; … … 130 130 public void setHistoryComboBoxDownFocusTraversalHandler(final Action handler, final HistoryComboBox hcb) { 131 131 hcb.getEditor().addActionListener(handler); 132 hcb.getEditor ().getEditorComponent().addKeyListener(132 hcb.getEditorComponent().addKeyListener( 133 133 new KeyListener() { 134 134 @Override … … 166 166 public void startUserInput() { 167 167 hcbUploadComment.requestFocusInWindow(); 168 hcbUploadComment.getEditor ().getEditorComponent().requestFocusInWindow();168 hcbUploadComment.getEditorComponent().requestFocusInWindow(); 169 169 } 170 170 -
trunk/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletingComboBox.java
r8840 r9484 130 130 } 131 131 } 132 JTextComponent editorComponent = (JTextComponent) comboBox.getEditor().getEditorComponent();132 final JTextComponent editorComponent = comboBox.getEditorComponent(); 133 133 // save unix system selection (middle mouse paste) 134 134 Clipboard sysSel = Toolkit.getDefaultToolkit().getSystemSelection(); … … 180 180 super(new AutoCompletionListItem(prototype)); 181 181 setRenderer(new AutoCompleteListCellRenderer()); 182 final JTextComponent editorComponent = (JTextComponent) this.getEditor().getEditorComponent();182 final JTextComponent editorComponent = this.getEditorComponent(); 183 183 editorComponent.setDocument(new AutoCompletingComboBoxDocument(this)); 184 184 editorComponent.addFocusListener( -
trunk/src/org/openstreetmap/josm/gui/widgets/ComboBoxHistory.java
r9078 r9484 10 10 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionListItem; 11 11 12 public class ComboBoxHistory extends DefaultComboBoxModel<AutoCompletionListItem> implements Iterable<AutoCompletionListItem> { 12 /** 13 * A data model for {@link HistoryComboBox} 14 */ 15 class ComboBoxHistory extends DefaultComboBoxModel<AutoCompletionListItem> implements Iterable<AutoCompletionListItem> { 13 16 14 17 private final int maxSize; … … 16 19 private final transient List<HistoryChangedListener> listeners = new ArrayList<>(); 17 20 18 public ComboBoxHistory(int size) { 21 /** 22 * Constructs a {@code ComboBoxHistory} keeping track of {@code maxSize} items 23 * @param size the history size 24 */ 25 ComboBoxHistory(int size) { 19 26 maxSize = size; 20 27 } 21 28 29 /** 30 * Adds or moves an element to the top of the history 31 * @param s the element to add 32 */ 22 33 public void addElement(String s) { 23 34 addElement(new AutoCompletionListItem(s)); … … 26 37 /** 27 38 * Adds or moves an element to the top of the history 39 * @param o the element to add 28 40 */ 29 41 @Override … … 80 92 } 81 93 94 /** 95 * {@link javax.swing.DefaultComboBoxModel#removeAllElements() Removes all items} 96 * and {@link ComboBoxHistory#addElement(String) adds} the given items. 97 * @param items the items to set 98 */ 82 99 public void setItemsAsString(List<String> items) { 83 100 removeAllElements(); 84 101 for (int i = items.size()-1; i >= 0; i--) { 85 addElement( new AutoCompletionListItem(items.get(i)));102 addElement(items.get(i)); 86 103 } 87 104 } 88 105 106 /** 107 * Returns the {@link AutoCompletionListItem} items as strings 108 * @return a list of strings 109 */ 89 110 public List<String> asStringList() { 90 111 List<String> list = new ArrayList<>(maxSize); -
trunk/src/org/openstreetmap/josm/gui/widgets/HistoryComboBox.java
r9078 r9484 9 9 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletingComboBox; 10 10 11 /** 12 * An {@link AutoCompletingComboBox} which keeps a history 13 */ 11 14 public class HistoryComboBox extends AutoCompletingComboBox { 12 15 private final ComboBoxHistory model; … … 23 26 } 24 27 28 /** 29 * Returns the text contained in this component 30 * @return the text 31 * @see JTextComponent#getText() 32 */ 25 33 public String getText() { 26 return ((JTextComponent) getEditor().getEditorComponent()).getText();34 return getEditorComponent().getText(); 27 35 } 28 36 37 /** 38 * Sets the text of this component to the specified text 39 * @param value the text to set 40 * @see JTextComponent#setText(java.lang.String) 41 */ 29 42 public void setText(String value) { 30 43 setAutocompleteEnabled(false); 31 ((JTextComponent) getEditor().getEditorComponent()).setText(value);44 getEditorComponent().setText(value); 32 45 setAutocompleteEnabled(true); 33 46 } 34 47 48 /** 49 * Adds or moves the current element to the top of the history 50 * @see ComboBoxHistory#addElement(java.lang.String) 51 */ 35 52 public void addCurrentItemToHistory() { 36 53 model.addElement((String) getEditor().getItem()); 37 54 } 38 55 56 /** 57 * Sets the elements of the ComboBox to the given items 58 * @param history the items to set 59 * @see ComboBoxHistory#setItemsAsString(java.util.List) 60 */ 39 61 public void setHistory(List<String> history) { 40 62 model.setItemsAsString(history); 41 63 } 42 64 65 /** 66 * Returns the items as strings 67 * @return the items as strings 68 * @see ComboBoxHistory#asStringList() 69 */ 43 70 public List<String> getHistory() { 44 71 return model.asStringList(); -
trunk/src/org/openstreetmap/josm/gui/widgets/JosmComboBox.java
r8777 r9484 15 15 16 16 import javax.accessibility.Accessible; 17 import javax.swing.ComboBoxEditor; 17 18 import javax.swing.ComboBoxModel; 18 19 import javax.swing.DefaultComboBoxModel; 19 20 import javax.swing.JComboBox; 20 21 import javax.swing.JList; 22 import javax.swing.JTextField; 21 23 import javax.swing.plaf.basic.ComboPopup; 22 24 import javax.swing.text.JTextComponent; … … 93 95 super(items); 94 96 init(findPrototypeDisplayValue(Arrays.asList(items))); 97 } 98 99 /** 100 * Returns the editor component 101 * @return the editor component 102 * @see ComboBoxEditor#getEditorComponent() 103 * @since 9484 104 */ 105 public JTextField getEditorComponent() { 106 return (JTextField) getEditor().getEditorComponent(); 95 107 } 96 108
Note:
See TracChangeset
for help on using the changeset viewer.