Changeset 16402 in josm for trunk/src/org
- Timestamp:
- 2020-05-10T15:58:34+02:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/JumpToAction.java
r14742 r16402 9 9 import java.awt.event.ActionEvent; 10 10 import java.awt.event.KeyEvent; 11 import java.io.IOException; 12 import java.util.List; 11 13 import java.util.Optional; 12 14 15 import javax.swing.BorderFactory; 13 16 import javax.swing.JLabel; 14 17 import javax.swing.JOptionPane; 15 18 import javax.swing.JPanel; 19 import javax.swing.JSeparator; 16 20 import javax.swing.event.DocumentEvent; 17 21 import javax.swing.event.DocumentListener; … … 23 27 import org.openstreetmap.josm.gui.MainApplication; 24 28 import org.openstreetmap.josm.gui.MapView; 29 import org.openstreetmap.josm.gui.Notification; 25 30 import org.openstreetmap.josm.gui.datatransfer.ClipboardUtils; 26 31 import org.openstreetmap.josm.gui.widgets.JosmTextField; 27 32 import org.openstreetmap.josm.gui.widgets.SelectAllOnFocusGainedDecorator; 33 import org.openstreetmap.josm.io.NameFinder; 28 34 import org.openstreetmap.josm.spi.preferences.Config; 29 35 import org.openstreetmap.josm.tools.GBC; … … 40 46 41 47 private final JosmTextField url = new JosmTextField(); 48 private final JosmTextField place = new JosmTextField(); 42 49 private final JosmTextField lat = new JosmTextField(); 43 50 private final JosmTextField lon = new JosmTextField(); … … 112 119 if (boundsFromClipboard.isPresent() && Config.getPref().getBoolean("jumpto.use.clipboard", true)) { 113 120 setBounds(boundsFromClipboard.get()); 121 place.setText(""); 114 122 } else { 115 123 setBounds(mv.getState().getViewArea().getCornerBounds()); … … 132 140 url.getDocument().addDocumentListener(new OsmURLListener()); 133 141 142 SelectAllOnFocusGainedDecorator.decorate(place); 134 143 SelectAllOnFocusGainedDecorator.decorate(lat); 135 144 SelectAllOnFocusGainedDecorator.decorate(lon); … … 140 149 panel.add(p, BorderLayout.NORTH); 141 150 151 p.add(new JLabel(tr("Enter a place name to search for")), GBC.eol()); 152 p.add(place, GBC.eol().fill(GBC.HORIZONTAL)); 153 p.add(new JSeparator(), GBC.eol().fill(GBC.HORIZONTAL).insets(3, 5, 3, 5)); 154 142 155 p.add(new JLabel(tr("Latitude")), GBC.eol()); 143 156 p.add(lat, GBC.eol().fill(GBC.HORIZONTAL)); … … 148 161 p.add(new JLabel(tr("Zoom (in metres)")), GBC.eol()); 149 162 p.add(zm, GBC.eol().fill(GBC.HORIZONTAL)); 163 p.add(new JSeparator(), GBC.eol().fill(GBC.HORIZONTAL).insets(3, 5, 3, 5)); 150 164 151 165 p.add(new JLabel(tr("URL")), GBC.eol()); … … 159 173 160 174 if (option != 1) return; 175 if (place.hasFocus() && !place.getText().trim().isEmpty()) { 176 try { 177 List<NameFinder.SearchResult> searchResults = NameFinder.queryNominatim(place.getText()); 178 if (!searchResults.isEmpty()) { 179 NameFinder.SearchResult searchResult = searchResults.get(0); 180 new Notification(tr("Jumping to: {0}", searchResult.getName())) 181 .setIcon(JOptionPane.INFORMATION_MESSAGE) 182 .show(); 183 mv.zoomTo(searchResult.getBounds()); 184 } 185 return; 186 } catch (IOException | RuntimeException ex) { 187 Logging.warn(ex); 188 } 189 } 161 190 try { 162 191 zoomLvl = Double.parseDouble(zm.getText());
Note:
See TracChangeset
for help on using the changeset viewer.