Changeset 8510 in josm for trunk/src/org/openstreetmap/josm/gui/download/PlaceSelection.java
- Timestamp:
- 2015-06-20T23:42:21+02:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/download/PlaceSelection.java
r8464 r8510 75 75 private DownloadDialog parent; 76 76 private static final Server[] SERVERS = new Server[] { 77 new Server("Nominatim", "https://nominatim.openstreetmap.org/search?format=xml&q=",tr("Class Type"),tr("Bounds"))77 new Server("Nominatim", "https://nominatim.openstreetmap.org/search?format=xml&q=", tr("Class Type"), tr("Bounds")) 78 78 }; 79 79 private final JosmComboBox<Server> server = new JosmComboBox<>(SERVERS); 80 80 81 81 private static class Server { 82 public String name; 83 public String url; 84 public String thirdcol; 85 public String fourthcol; 86 @Override 87 public String toString() { 88 return name; 89 } 82 public final String name; 83 public final String url; 84 public final String thirdcol; 85 public final String fourthcol; 86 90 87 public Server(String n, String u, String t, String f) { 91 88 name = n; … … 94 91 fourthcol = f; 95 92 } 93 94 @Override 95 public String toString() { 96 return name; 97 } 96 98 } 97 99 98 100 protected JPanel buildSearchPanel() { 99 101 JPanel lpanel = new JPanel(); 100 lpanel.setLayout(new GridLayout(2, 2));102 lpanel.setLayout(new GridLayout(2, 2)); 101 103 JPanel panel = new JPanel(); 102 104 panel.setLayout(new GridBagLayout()); … … 122 124 SearchAction searchAction = new SearchAction(); 123 125 JButton btnSearch = new JButton(searchAction); 124 ((JTextField) cbSearchExpression.getEditor().getEditorComponent()).getDocument().addDocumentListener(searchAction);125 ((JTextField) cbSearchExpression.getEditor().getEditorComponent()).addActionListener(searchAction);126 ((JTextField) cbSearchExpression.getEditor().getEditorComponent()).getDocument().addDocumentListener(searchAction); 127 ((JTextField) cbSearchExpression.getEditor().getEditorComponent()).addActionListener(searchAction); 126 128 127 129 panel.add(btnSearch, GBC.eol().insets(5, 5, 0, 5)); … … 147 149 tblSearchResults.setSelectionModel(selectionModel); 148 150 JScrollPane scrollPane = new JScrollPane(tblSearchResults); 149 scrollPane.setPreferredSize(new Dimension(200, 200));151 scrollPane.setPreferredSize(new Dimension(200, 200)); 150 152 panel.add(scrollPane, BorderLayout.CENTER); 151 153 … … 216 218 currentResult.name = atts.getValue("name"); 217 219 currentResult.info = atts.getValue("info"); 218 if (currentResult.info != null) {220 if (currentResult.info != null) { 219 221 currentResult.info = tr(currentResult.info); 220 222 } … … 288 290 public SearchAction() { 289 291 putValue(NAME, tr("Search ...")); 290 putValue(SMALL_ICON, ImageProvider.get("dialogs", "search"));292 putValue(SMALL_ICON, ImageProvider.get("dialogs", "search")); 291 293 putValue(SHORT_DESCRIPTION, tr("Click to start searching for places")); 292 294 updateEnabledState(); … … 333 335 334 336 public NameQueryTask(String searchExpression) { 335 super(tr("Querying name server"), false /* don't ignore exceptions */);337 super(tr("Querying name server"), false /* don't ignore exceptions */); 336 338 this.searchExpression = searchExpression; 337 useserver = (Server) server.getSelectedItem();339 useserver = (Server) server.getSelectedItem(); 338 340 Main.pref.put("namefinder.server", useserver.name); 339 341 } … … 368 370 getProgressMonitor().indeterminateSubTask(tr("Querying name server ...")); 369 371 URL url = new URL(urlString); 370 synchronized (this) {372 synchronized (this) { 371 373 connection = Utils.openHttpConnection(url); 372 374 } 373 connection.setConnectTimeout(Main.pref.getInteger("socket.timeout.connect", 15)*1000);375 connection.setConnectTimeout(Main.pref.getInteger("socket.timeout.connect", 15)*1000); 374 376 try ( 375 377 InputStream inputStream = connection.getInputStream(); … … 415 417 this.selectionModel = selectionModel; 416 418 } 419 417 420 @Override 418 421 public int getRowCount() { … … 435 438 fireTableDataChanged(); 436 439 } 440 437 441 @Override 438 442 public boolean isCellEditable(int row, int column) { … … 486 490 addColumn(col4); 487 491 } 492 488 493 public void setHeadlines(String third, String fourth) { 489 494 col3.setHeaderValue(third); … … 509 514 static class NamedResultCellRenderer extends JLabel implements TableCellRenderer { 510 515 516 /** 517 * Constructs a new {@code NamedResultCellRenderer}. 518 */ 511 519 public NamedResultCellRenderer() { 512 520 setOpaque(true); 513 setBorder(BorderFactory.createEmptyBorder(2, 2,2,2));521 setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); 514 522 } 515 523 … … 533 541 StringBuilder line = new StringBuilder(); 534 542 StringTokenizer tok = new StringTokenizer(description, " "); 535 while (tok.hasMoreElements()) {543 while (tok.hasMoreElements()) { 536 544 String t = tok.nextToken(); 537 545 if (line.length() == 0) { … … 570 578 break; 571 579 case 3: 572 if (sr.bounds != null) {580 if (sr.bounds != null) { 573 581 setText(sr.bounds.toShortString(new DecimalFormat("0.000"))); 574 582 } else {
Note:
See TracChangeset
for help on using the changeset viewer.