- Timestamp:
- 2009-10-31T18:40:46+01:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/download/PlaceSelection.java
r2361 r2362 18 18 import java.net.URL; 19 19 import java.util.ArrayList; 20 import java.util.Collections; 20 21 import java.util.LinkedList; 21 22 import java.util.List; … … 49 50 import org.openstreetmap.josm.gui.ExceptionDialogUtil; 50 51 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 52 import org.openstreetmap.josm.gui.widgets.HistoryComboBox; 51 53 import org.openstreetmap.josm.io.OsmTransferException; 52 54 import org.openstreetmap.josm.tools.ImageProvider; … … 57 59 58 60 public class PlaceSelection implements DownloadSelection { 59 60 private JTextField tfSearchExpression; 61 private static final String HISTORY_KEY = "download.places.history"; 62 63 private HistoryComboBox cbSearchExpression; 61 64 private JButton btnSearch; 62 65 private NamedResultTableModel model; … … 79 82 // the search expression field 80 83 // 81 tfSearchExpression = new JTextField(); 82 tfSearchExpression.setToolTipText(tr("Enter a place name to search for")); 84 cbSearchExpression = new HistoryComboBox(); 85 cbSearchExpression.setToolTipText(tr("Enter a place name to search for")); 86 List<String> cmtHistory = new LinkedList<String>(Main.pref.getCollection(HISTORY_KEY, new LinkedList<String>())); 87 Collections.reverse(cmtHistory); 88 cbSearchExpression.setPossibleItems(cmtHistory); 83 89 gc.gridx = 0; 84 90 gc.gridy = 1; 85 91 gc.gridwidth = 1; 86 panel.add( tfSearchExpression, gc);92 panel.add(cbSearchExpression, gc); 87 93 88 94 // the search button … … 90 96 SearchAction searchAction = new SearchAction(); 91 97 btnSearch = new JButton(searchAction); 92 tfSearchExpression.getDocument().addDocumentListener(searchAction);93 tfSearchExpression.addActionListener(searchAction);98 ((JTextField)cbSearchExpression.getEditor().getEditorComponent()).getDocument().addDocumentListener(searchAction); 99 ((JTextField)cbSearchExpression.getEditor().getEditorComponent()).addActionListener(searchAction); 94 100 95 101 gc.gridx = 1; … … 120 126 panel.add(scrollPane, BorderLayout.CENTER); 121 127 122 gui.addDownloadAreaSelector(panel, tr("Areas around Places"));128 gui.addDownloadAreaSelector(panel, tr("Areas around places")); 123 129 124 130 scrollPane.setPreferredSize(scrollPane.getPreferredSize()); … … 255 261 256 262 public void actionPerformed(ActionEvent e) { 257 if (!isEnabled() || tfSearchExpression.getText().trim().length() == 0)263 if (!isEnabled() || cbSearchExpression.getText().trim().length() == 0) 258 264 return; 259 NameQueryTask task = new NameQueryTask(tfSearchExpression.getText()); 265 cbSearchExpression.addCurrentItemToHistory(); 266 Main.pref.putCollection(HISTORY_KEY, cbSearchExpression.getHistory()); 267 NameQueryTask task = new NameQueryTask(cbSearchExpression.getText()); 260 268 Main.worker.submit(task); 261 269 } 262 270 263 271 protected void updateEnabledState() { 264 setEnabled( tfSearchExpression.getText().trim().length() > 0);272 setEnabled(cbSearchExpression.getText().trim().length() > 0); 265 273 } 266 274 … … 439 447 440 448 class NamedResultCellRenderer extends JLabel implements TableCellRenderer { 449 441 450 public NamedResultCellRenderer() { 442 451 setOpaque(true); … … 506 515 } 507 516 } 517 508 518 }
Note:
See TracChangeset
for help on using the changeset viewer.