- Timestamp:
- 2012-02-15T23:19:43+01:00 (13 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/search/SearchAction.java
r4842 r4948 3 3 4 4 import static org.openstreetmap.josm.gui.help.HelpUtil.ht; 5 import org.openstreetmap.josm.gui.preferences.ToolbarPreferences.ActionParser;6 5 import static org.openstreetmap.josm.tools.I18n.tr; 7 6 import static org.openstreetmap.josm.tools.I18n.trc; … … 35 34 import org.openstreetmap.josm.Main; 36 35 import org.openstreetmap.josm.actions.ActionParameter; 37 import org.openstreetmap.josm.actions.ActionParameter.SearchSettingsActionParameter;38 36 import org.openstreetmap.josm.actions.JosmAction; 39 37 import org.openstreetmap.josm.actions.ParameterizedAction; 38 import org.openstreetmap.josm.actions.ActionParameter.SearchSettingsActionParameter; 40 39 import org.openstreetmap.josm.actions.search.SearchCompiler.ParseError; 41 40 import org.openstreetmap.josm.data.osm.DataSet; … … 44 43 import org.openstreetmap.josm.gui.ExtendedDialog; 45 44 import org.openstreetmap.josm.gui.preferences.ToolbarPreferences; 45 import org.openstreetmap.josm.gui.preferences.ToolbarPreferences.ActionParser; 46 46 import org.openstreetmap.josm.gui.widgets.HistoryComboBox; 47 47 import org.openstreetmap.josm.tools.GBC; … … 211 211 final HistoryComboBox hcbSearchString = new HistoryComboBox(); 212 212 hcbSearchString.setText(initialValues.text); 213 hcbSearchString.getEditor().selectAll();214 hcbSearchString.getEditor().getEditorComponent().requestFocusInWindow();215 213 hcbSearchString.setToolTipText(tr("Enter the search expression")); 216 214 // we have to reverse the history, because ComboBoxHistory will reverse it again … … 251 249 left.add(allElements, GBC.eol()); 252 250 left.add(regexSearch, GBC.eol()); 253 left.add(addOnToolbar, GBC.eol()); 251 left.add(addOnToolbar, GBC.eol()); 254 252 } 255 253 … … 309 307 initialValues.allElements = allElements.isSelected(); 310 308 initialValues.regexSearch = regexSearch.isSelected(); 311 309 312 310 if (addOnToolbar.isSelected()) { 313 ToolbarPreferences.ActionDefinition aDef = 311 ToolbarPreferences.ActionDefinition aDef = 314 312 new ToolbarPreferences.ActionDefinition(Main.main.menu.search); 315 313 aDef.getParameters().put("searchExpression", initialValues); … … 317 315 ActionParser actionParser = new ToolbarPreferences.ActionParser(null); 318 316 String res = actionParser.saveAction(aDef); 319 317 320 318 Collection<String> t = new LinkedList<String>(ToolbarPreferences.getToolString()); 321 319 // add custom search button to toolbar preferences -
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java
r4947 r4948 7 7 import java.awt.BorderLayout; 8 8 import java.awt.Component; 9 import java.awt.Dialog.ModalityType;10 9 import java.awt.Dimension; 11 10 import java.awt.Font; 12 11 import java.awt.GridBagLayout; 13 12 import java.awt.Point; 13 import java.awt.Toolkit; 14 import java.awt.Dialog.ModalityType; 15 import java.awt.datatransfer.Clipboard; 16 import java.awt.datatransfer.Transferable; 14 17 import java.awt.event.ActionEvent; 15 18 import java.awt.event.ActionListener; … … 33 36 import java.util.List; 34 37 import java.util.Map; 35 import java.util.Map.Entry;36 38 import java.util.Set; 37 39 import java.util.TreeMap; 38 40 import java.util.TreeSet; 39 41 import java.util.Vector; 42 import java.util.Map.Entry; 40 43 41 44 import javax.swing.AbstractAction; … … 85 88 import org.openstreetmap.josm.data.osm.event.DataSetListenerAdapter; 86 89 import org.openstreetmap.josm.data.osm.event.DatasetEventManager; 90 import org.openstreetmap.josm.data.osm.event.SelectionEventManager; 87 91 import org.openstreetmap.josm.data.osm.event.DatasetEventManager.FireMode; 88 import org.openstreetmap.josm.data.osm.event.SelectionEventManager;89 92 import org.openstreetmap.josm.gui.DefaultNameFormatter; 90 93 import org.openstreetmap.josm.gui.ExtendedDialog; … … 302 305 final JOptionPane optionPane = new JOptionPane(panel, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION) { 303 306 @Override public void selectInitialValue() { 307 // save unix system selection (middle mouse paste) 308 Clipboard sysSel = Toolkit.getDefaultToolkit().getSystemSelection(); 309 if(sysSel != null) { 310 Transferable old = sysSel.getContents(null); 304 311 values.requestFocusInWindow(); 305 312 values.getEditor().selectAll(); 313 sysSel.setContents(old, null); 314 } else { 315 values.requestFocusInWindow(); 316 values.getEditor().selectAll(); 317 } 306 318 } 307 319 }; … … 498 510 JOptionPane pane = new JOptionPane(p, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION){ 499 511 @Override public void selectInitialValue() { 512 // save unix system selection (middle mouse paste) 513 Clipboard sysSel = Toolkit.getDefaultToolkit().getSystemSelection(); 514 if(sysSel != null) { 515 Transferable old = sysSel.getContents(null); 500 516 keys.requestFocusInWindow(); 501 517 keys.getEditor().selectAll(); 518 sysSel.setContents(old, null); 519 } else { 520 keys.requestFocusInWindow(); 521 keys.getEditor().selectAll(); 522 } 502 523 } 503 524 }; -
trunk/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletingComboBox.java
r4576 r4948 3 3 4 4 import java.awt.Component; 5 import java.awt.Toolkit; 6 import java.awt.datatransfer.Clipboard; 7 import java.awt.datatransfer.Transferable; 5 8 import java.awt.event.FocusEvent; 6 9 import java.awt.event.FocusListener; … … 28 31 29 32 private boolean autocompleteEnabled = true; 30 33 31 34 private int maxTextLength = -1; 32 35 … … 53 56 if (selecting || (offs == 0 && str.equals(getText(0, getLength())))) 54 57 return; 55 if (maxTextLength > -1 && str.length()+getLength() > maxTextLength) { 56 return; 57 } 58 if (maxTextLength > -1 && str.length()+getLength() > maxTextLength) 59 return; 58 60 boolean initial = (offs == 0 && getLength() == 0 && str.length() > 1); 59 61 super.insertString(offs, str, a); … … 110 112 } 111 113 JTextComponent editor = (JTextComponent)comboBox.getEditor().getEditorComponent(); 112 editor.setSelectionStart(start); 113 editor.setSelectionEnd(end); 114 // save unix system selection (middle mouse paste) 115 Clipboard sysSel = Toolkit.getDefaultToolkit().getSystemSelection(); 116 if(sysSel != null) { 117 Transferable old = sysSel.getContents(null); 118 editor.select(start, end); 119 sysSel.setContents(old, null); 120 } else { 121 editor.select(start, end); 122 } 114 123 } 115 124 … … 125 134 for (int i = 0, n = model.getSize(); i < n; i++) { 126 135 AutoCompletionListItem currentItem = (AutoCompletionListItem) model.getElementAt(i); 127 if (currentItem.getValue().equals(pattern)) {136 if (currentItem.getValue().equals(pattern)) 128 137 return currentItem; 129 }130 138 if (!match && currentItem.getValue().startsWith(pattern)) { 131 139 if (bestItem == null || currentItem.getPriority().compareTo(bestItem.getPriority()) > 0) { … … 147 155 } 148 156 public void focusGained(FocusEvent e) { 157 // save unix system selection (middle mouse paste) 158 Clipboard sysSel = Toolkit.getDefaultToolkit().getSystemSelection(); 159 if(sysSel != null) { 160 Transferable old = sysSel.getContents(null); 149 161 editor.selectAll(); 162 sysSel.setContents(old, null); 163 } else { 164 editor.selectAll(); 165 } 150 166 } 151 167 } … … 154 170 setMaximumRowCount(maxsize); 155 171 } 156 172 157 173 public void setMaxTextLength(int length) 158 174 { … … 212 228 model.addElement(new AutoCompletionListItem(elem, AutoCompletionItemPritority.UNKNOWN)); 213 229 } 230 // disable autocomplete to prevent unnecessary actions in 231 // AutoCompletingComboBoxDocument#insertString 232 autocompleteEnabled = false; 214 233 this.getEditor().setItem(oldValue); 234 autocompleteEnabled = true; 215 235 } 216 236
Note:
See TracChangeset
for help on using the changeset viewer.