Changeset 8510 in josm for trunk/src/org/openstreetmap/josm/gui/download
- Timestamp:
- 2015-06-20T23:42:21+02:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/download
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/download/BookmarkList.java
r8509 r8510 45 45 public Bookmark(Collection<String> list) { 46 46 List<String> array = new ArrayList<>(list); 47 if (array.size() < 5)47 if (array.size() < 5) 48 48 throw new IllegalArgumentException(tr("Wrong number of arguments for bookmark")); 49 49 name = array.get(0); … … 155 155 */ 156 156 public final void load() { 157 DefaultListModel<Bookmark> model = (DefaultListModel<Bookmark>) getModel();157 DefaultListModel<Bookmark> model = (DefaultListModel<Bookmark>) getModel(); 158 158 model.removeAllElements(); 159 159 Collection<Collection<String>> args = Main.pref.getArray("bookmarks", null); 160 if (args != null) {160 if (args != null) { 161 161 List<Bookmark> bookmarks = new LinkedList<>(); 162 for (Collection<String> entry : args) {162 for (Collection<String> entry : args) { 163 163 try { 164 164 bookmarks.add(new Bookmark(entry)); … … 179 179 public final void save() { 180 180 List<Collection<String>> coll = new LinkedList<>(); 181 for (Object o : ((DefaultListModel<Bookmark>) getModel()).toArray()) {181 for (Object o : ((DefaultListModel<Bookmark>) getModel()).toArray()) { 182 182 String[] array = new String[5]; 183 183 Bookmark b = (Bookmark) o; -
trunk/src/org/openstreetmap/josm/gui/download/BookmarkSelection.java
r7029 r8510 85 85 GridBagConstraints gc = new GridBagConstraints(); 86 86 gc.anchor = GridBagConstraints.NORTHWEST; 87 gc.insets = new Insets(5, 5,5,5);87 gc.insets = new Insets(5, 5, 5, 5); 88 88 pnl.add(lblCurrentDownloadArea = new JMultilineLabel(""), gc); 89 89 … … 99 99 gc.weightx = 0.0; 100 100 gc.weighty = 0.0; 101 gc.insets = new Insets(5, 5,5,5);101 gc.insets = new Insets(5, 5, 5, 5); 102 102 pnl.add(new JButton(actAdd = new AddAction()), gc); 103 103 return pnl; … … 116 116 Bookmark b = bookmarks.getSelectedValue(); 117 117 if (b != null) { 118 gui.boundingBoxChanged(b.getArea(), BookmarkSelection.this);118 gui.boundingBoxChanged(b.getArea(), BookmarkSelection.this); 119 119 } 120 120 } … … 126 126 gc.weighty = 0.0; 127 127 gc.gridwidth = 2; 128 dlg.add(buildDownloadAreaAddPanel(), gc);128 dlg.add(buildDownloadAreaAddPanel(), gc); 129 129 130 130 gc.gridwidth = 1; … … 134 134 gc.weightx = 0.0; 135 135 gc.weighty = 1.0; 136 dlg.add(buildButtonPanel(), gc);136 dlg.add(buildButtonPanel(), gc); 137 137 138 138 gc.gridwidth = 1; … … 196 196 b.setName( 197 197 JOptionPane.showInputDialog( 198 Main.parent, tr("Please enter a name for the bookmarked download area."),198 Main.parent, tr("Please enter a name for the bookmarked download area."), 199 199 tr("Name of location"), 200 200 JOptionPane.QUESTION_MESSAGE) … … 202 202 b.setArea(currentArea); 203 203 if (b.getName() != null && !b.getName().isEmpty()) { 204 ((DefaultListModel<BookmarkList.Bookmark>) bookmarks.getModel()).addElement(b);204 ((DefaultListModel<BookmarkList.Bookmark>) bookmarks.getModel()).addElement(b); 205 205 bookmarks.save(); 206 206 } … … 209 209 210 210 class RemoveAction extends AbstractAction implements ListSelectionListener{ 211 /** 212 * Constructs a new {@code RemoveAction}. 213 */ 211 214 public RemoveAction() { 212 215 putValue(SMALL_ICON, ImageProvider.get("dialogs", "delete")); … … 221 224 return; 222 225 for (Object sel: sels) { 223 ((DefaultListModel<Bookmark>) bookmarks.getModel()).removeElement(sel);226 ((DefaultListModel<Bookmark>) bookmarks.getModel()).removeElement(sel); 224 227 } 225 228 bookmarks.save(); … … 229 232 setEnabled(bookmarks.getSelectedIndices().length > 0); 230 233 } 234 231 235 @Override 232 236 public void valueChanged(ListSelectionEvent e) { … … 235 239 } 236 240 237 class RenameAction extends AbstractAction implements ListSelectionListener{ 241 class RenameAction extends AbstractAction implements ListSelectionListener { 242 /** 243 * Constructs a new {@code RenameAction}. 244 */ 238 245 public RenameAction() { 239 246 putValue(SMALL_ICON, ImageProvider.get("dialogs", "edit")); … … 250 257 Object value = 251 258 JOptionPane.showInputDialog( 252 Main.parent, tr("Please enter a name for the bookmarked download area."),259 Main.parent, tr("Please enter a name for the bookmarked download area."), 253 260 tr("Name of location"), 254 261 JOptionPane.QUESTION_MESSAGE, -
trunk/src/org/openstreetmap/josm/gui/download/BoundingBoxSelection.java
r8444 r8510 57 57 protected void buildDownloadAreaInputFields() { 58 58 latlon = new JosmTextField[4]; 59 for (int i=0; i< 4; i++) {59 for (int i = 0; i < 4; i++) { 60 60 latlon[i] = new JosmTextField(11); 61 latlon[i].setMinimumSize(new Dimension(100, new JosmTextField().getMinimumSize().height));61 latlon[i].setMinimumSize(new Dimension(100, new JosmTextField().getMinimumSize().height)); 62 62 latlon[i].addFocusListener(new SelectAllOnFocusHandler(latlon[i])); 63 63 } … … 95 95 tfOsmUrl.setBorder(latlon[0].getBorder()); 96 96 97 dlg.add(new JLabel(tr("min lat")), GBC.std().insets(10, 20,5,0));98 dlg.add(latlon[0], GBC.std().insets(0, 20,0,0));99 dlg.add(new JLabel(tr("min lon")), GBC.std().insets(10, 20,5,0));100 dlg.add(latlon[1], GBC.eol().insets(0, 20,0,0));101 dlg.add(new JLabel(tr("max lat")), GBC.std().insets(10, 0,5,0));97 dlg.add(new JLabel(tr("min lat")), GBC.std().insets(10, 20, 5, 0)); 98 dlg.add(latlon[0], GBC.std().insets(0, 20, 0, 0)); 99 dlg.add(new JLabel(tr("min lon")), GBC.std().insets(10, 20, 5, 0)); 100 dlg.add(latlon[1], GBC.eol().insets(0, 20, 0, 0)); 101 dlg.add(new JLabel(tr("max lat")), GBC.std().insets(10, 0, 5, 0)); 102 102 dlg.add(latlon[2], GBC.std()); 103 dlg.add(new JLabel(tr("max lon")), GBC.std().insets(10, 0,5,0));103 dlg.add(new JLabel(tr("max lon")), GBC.std().insets(10, 0, 5, 0)); 104 104 dlg.add(latlon[3], GBC.eol()); 105 105 … … 111 111 } 112 112 }); 113 dlg.add(btnClear, GBC.eol().insets(10,20,0,0)); 114 115 dlg.add(new JLabel(tr("URL from www.openstreetmap.org (you can paste an URL here to download the area)")), GBC.eol().insets(10,5,5,0)); 116 dlg.add(tfOsmUrl, GBC.eop().insets(10,0,5,0).fill()); 117 dlg.add(showUrl, GBC.eop().insets(10,0,5,5)); 113 dlg.add(btnClear, GBC.eol().insets(10, 20, 0, 0)); 114 115 dlg.add(new JLabel(tr("URL from www.openstreetmap.org (you can paste an URL here to download the area)")), 116 GBC.eol().insets(10, 5, 5, 0)); 117 dlg.add(tfOsmUrl, GBC.eop().insets(10, 0, 5, 0).fill()); 118 dlg.add(showUrl, GBC.eop().insets(10, 0, 5, 5)); 118 119 showUrl.setEditable(false); 119 120 showUrl.setBackground(dlg.getBackground()); … … 136 137 public Bounds getDownloadArea() { 137 138 double[] values = new double[4]; 138 for (int i =0; i < 4; i++) {139 for (int i = 0; i < 4; i++) { 139 140 try { 140 141 values[i] = Double.parseDouble(latlon[i].getText()); 141 } catch (NumberFormatException x) {142 } catch (NumberFormatException x) { 142 143 return null; 143 144 } … … 152 153 private boolean parseURL(DownloadDialog gui) { 153 154 Bounds b = OsmUrlToBounds.parse(tfOsmUrl.getText()); 154 if (b == null) return false;155 gui.boundingBoxChanged(b, BoundingBoxSelection.this);155 if (b == null) return false; 156 gui.boundingBoxChanged(b, BoundingBoxSelection.this); 156 157 updateBboxFields(b); 157 158 updateUrl(b); … … 198 199 try { 199 200 value = Double.parseDouble(tfLatValue.getText()); 200 } catch (NumberFormatException ex) {201 setErrorMessage(tfLatValue, tr("The string ''{0}'' is not a valid double value.", tfLatValue.getText()));201 } catch (NumberFormatException ex) { 202 setErrorMessage(tfLatValue, tr("The string ''{0}'' is not a valid double value.", tfLatValue.getText())); 202 203 return; 203 204 } 204 205 if (!LatLon.isValidLat(value)) { 205 setErrorMessage(tfLatValue, tr("Value for latitude in range [-90,90] required.", tfLatValue.getText()));206 setErrorMessage(tfLatValue, tr("Value for latitude in range [-90,90] required.", tfLatValue.getText())); 206 207 return; 207 208 } … … 231 232 try { 232 233 value = Double.parseDouble(tfLonValue.getText()); 233 } catch (NumberFormatException ex) {234 setErrorMessage(tfLonValue, tr("The string ''{0}'' is not a valid double value.", tfLonValue.getText()));234 } catch (NumberFormatException ex) { 235 setErrorMessage(tfLonValue, tr("The string ''{0}'' is not a valid double value.", tfLonValue.getText())); 235 236 return; 236 237 } 237 238 if (!LatLon.isValidLon(value)) { 238 setErrorMessage(tfLonValue, tr("Value for longitude in range [-180,180] required.", tfLonValue.getText()));239 setErrorMessage(tfLonValue, tr("Value for longitude in range [-180,180] required.", tfLonValue.getText())); 239 240 return; 240 241 } … … 255 256 static class SelectAllOnFocusHandler extends FocusAdapter { 256 257 private JTextComponent tfTarget; 258 257 259 public SelectAllOnFocusHandler(JTextComponent tfTarget) { 258 260 this.tfTarget = tfTarget; … … 267 269 class OsmUrlRefresher implements DocumentListener { 268 270 @Override 269 public void changedUpdate(DocumentEvent e) { parseURL(parent); } 270 @Override 271 public void insertUpdate(DocumentEvent e) { parseURL(parent); } 272 @Override 273 public void removeUpdate(DocumentEvent e) { parseURL(parent); } 271 public void changedUpdate(DocumentEvent e) { 272 parseURL(parent); 273 } 274 275 @Override 276 public void insertUpdate(DocumentEvent e) { 277 parseURL(parent); 278 } 279 280 @Override 281 public void removeUpdate(DocumentEvent e) { 282 parseURL(parent); 283 } 274 284 } 275 285 276 286 class BoundingBoxBuilder extends FocusAdapter implements ActionListener { 277 287 protected Bounds build() { 278 double minlon, minlat, maxlon, maxlat;288 double minlon, minlat, maxlon, maxlat; 279 289 try { 280 290 minlat = Double.parseDouble(latlon[0].getText().trim()); … … 282 292 maxlat = Double.parseDouble(latlon[2].getText().trim()); 283 293 maxlon = Double.parseDouble(latlon[3].getText().trim()); 284 } catch (NumberFormatException e) {294 } catch (NumberFormatException e) { 285 295 return null; 286 296 } … … 292 302 if (minlat > maxlat) 293 303 return null; 294 return new Bounds(minlat, minlon,maxlat,maxlon);304 return new Bounds(minlat, minlon, maxlat, maxlon); 295 305 } 296 306 -
trunk/src/org/openstreetmap/josm/gui/download/DownloadDialog.java
r8509 r8510 86 86 87 87 private void makeCheckBoxRespondToEnter(JCheckBox cb) { 88 cb.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "doDownload");88 cb.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "doDownload"); 89 89 cb.getActionMap().put("doDownload", actDownload); 90 90 } … … 103 103 104 104 // adding the download tasks 105 pnl.add(new JLabel(tr("Data Sources and Types:")), GBC.std().insets(5, 5,1,5));105 pnl.add(new JLabel(tr("Data Sources and Types:")), GBC.std().insets(5, 5, 1, 5)); 106 106 cbDownloadOsmData = new JCheckBox(tr("OpenStreetMap data"), true); 107 107 cbDownloadOsmData.setToolTipText(tr("Select to download OSM data in the selected download area.")); … … 156 156 cbStartup = new JCheckBox(tr("Open this dialog on startup")); 157 157 cbStartup.setToolTipText( 158 tr("<html>Autostart ''Download from OSM'' dialog every time JOSM is started.<br>You can open it manually from File menu or toolbar.</html>")); 158 tr("<html>Autostart ''Download from OSM'' dialog every time JOSM is started.<br>" + 159 "You can open it manually from File menu or toolbar.</html>")); 159 160 cbStartup.addActionListener(new ActionListener() { 160 161 @Override … … 163 164 }}); 164 165 165 pnl.add(cbNewLayer, GBC.std().anchor(GBC.WEST).insets(5, 5,5,5));166 pnl.add(cbStartup, GBC.std().anchor(GBC.WEST).insets(15, 5,5,5));167 168 pnl.add(sizeCheck, GBC.eol().anchor(GBC.EAST).insets(5, 5,5,2));166 pnl.add(cbNewLayer, GBC.std().anchor(GBC.WEST).insets(5, 5, 5, 5)); 167 pnl.add(cbStartup, GBC.std().anchor(GBC.WEST).insets(15, 5, 5, 5)); 168 169 pnl.add(sizeCheck, GBC.eol().anchor(GBC.EAST).insets(5, 5, 5, 2)); 169 170 170 171 if (!ExpertToggleAction.isExpert()) { 171 172 JLabel infoLabel = new JLabel( 172 173 tr("Use left click&drag to select area, arrows or right mouse button to scroll map, wheel or +/- to zoom.")); 173 pnl.add(infoLabel, GBC.eol().anchor(GBC.SOUTH).insets(0,0,0,0));174 pnl.add(infoLabel, GBC.eol().anchor(GBC.SOUTH).insets(0, 0, 0, 0)); 174 175 } 175 176 return pnl; … … 203 204 204 205 // -- cancel on ESC 205 getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "cancel");206 getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "cancel"); 206 207 getRootPane().getActionMap().put("cancel", actCancel); 207 208 … … 219 220 */ 220 221 public DownloadDialog(Component parent) { 221 super(JOptionPane.getFrameForComponent(parent), tr("Download"), ModalityType.DOCUMENT_MODAL);222 super(JOptionPane.getFrameForComponent(parent), tr("Download"), ModalityType.DOCUMENT_MODAL); 222 223 getContentPane().setLayout(new BorderLayout()); 223 224 getContentPane().add(buildMainPanel(), BorderLayout.CENTER); … … 382 383 mv.getLatLon(mv.getWidth(), 0) 383 384 ); 384 boundingBoxChanged(currentBounds, null);385 boundingBoxChanged(currentBounds, null); 385 386 } else { 386 387 Bounds bounds = getSavedDownloadBounds(); … … 414 415 */ 415 416 public static boolean isAutorunEnabled() { 416 return Main.pref.getBoolean("download.autorun", false);417 return Main.pref.getBoolean("download.autorun", false); 417 418 } 418 419 … … 438 439 WindowGeometry.centerInWindow( 439 440 getParent(), 440 new Dimension(1000, 600)441 new Dimension(1000, 600) 441 442 ) 442 443 ).applySafe(this); -
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 { -
trunk/src/org/openstreetmap/josm/gui/download/SlippyMapChooser.java
r8342 r8510 52 52 if (evt.getPropertyName().equals(BBoxChooser.BBOX_PROP)) { 53 53 if (iGui != null) { 54 iGui.boundingBoxChanged((Bounds) evt.getNewValue(), this);54 iGui.boundingBoxChanged((Bounds) evt.getNewValue(), this); 55 55 } 56 } else if (evt.getPropertyName().equals(SlippyMapBBoxChooser.RESIZE_PROP)) {56 } else if (evt.getPropertyName().equals(SlippyMapBBoxChooser.RESIZE_PROP)) { 57 57 int w, h; 58 58 -
trunk/src/org/openstreetmap/josm/gui/download/TileSelection.java
r8378 r8510 49 49 public void propertyChange(PropertyChangeEvent evt) { 50 50 if (evt.getPropertyName().equals(BBoxChooser.BBOX_PROP)) { 51 Bounds bbox = (Bounds) evt.getNewValue();51 Bounds bbox = (Bounds) evt.getNewValue(); 52 52 parent.boundingBoxChanged(bbox, this); 53 53 }
Note:
See TracChangeset
for help on using the changeset viewer.