commit c71170c24333954bc836ef60cdb3b45aef488fd4
Author: Simon Legner <Simon.Legner@gmail.com>
Date: 2020-04-20 23:21:12 +0200
fix #19127 - Jump to Position: jump to place name
diff --git a/src/org/openstreetmap/josm/actions/JumpToAction.java b/src/org/openstreetmap/josm/actions/JumpToAction.java
index 52cbca965..77bccd469 100644
a
|
b
|
|
8 | 8 | import java.awt.GridBagLayout; |
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 | |
13 | 15 | import javax.swing.JLabel; |
… |
… |
|
25 | 27 | import org.openstreetmap.josm.gui.datatransfer.ClipboardUtils; |
26 | 28 | import org.openstreetmap.josm.gui.widgets.JosmTextField; |
27 | 29 | import org.openstreetmap.josm.gui.widgets.SelectAllOnFocusGainedDecorator; |
| 30 | import org.openstreetmap.josm.io.NameFinder; |
28 | 31 | import org.openstreetmap.josm.spi.preferences.Config; |
29 | 32 | import org.openstreetmap.josm.tools.GBC; |
30 | 33 | import org.openstreetmap.josm.tools.ImageProvider; |
… |
… |
|
39 | 42 | public class JumpToAction extends JosmAction { |
40 | 43 | |
41 | 44 | private final JosmTextField url = new JosmTextField(); |
| 45 | private final JosmTextField place = new JosmTextField(); |
42 | 46 | private final JosmTextField lat = new JosmTextField(); |
43 | 47 | private final JosmTextField lon = new JosmTextField(); |
44 | 48 | private final JosmTextField zm = new JosmTextField(); |
… |
… |
public void showJumpToDialog() {
|
131 | 135 | zm.getDocument().addDocumentListener(x); |
132 | 136 | url.getDocument().addDocumentListener(new OsmURLListener()); |
133 | 137 | |
| 138 | SelectAllOnFocusGainedDecorator.decorate(place); |
134 | 139 | SelectAllOnFocusGainedDecorator.decorate(lat); |
135 | 140 | SelectAllOnFocusGainedDecorator.decorate(lon); |
136 | 141 | SelectAllOnFocusGainedDecorator.decorate(zm); |
… |
… |
public void showJumpToDialog() {
|
139 | 144 | JPanel p = new JPanel(new GridBagLayout()); |
140 | 145 | panel.add(p, BorderLayout.NORTH); |
141 | 146 | |
| 147 | p.add(new JLabel(tr("Areas around places")), GBC.eol()); |
| 148 | p.add(place, GBC.eol().fill(GBC.HORIZONTAL)); |
| 149 | |
142 | 150 | p.add(new JLabel(tr("Latitude")), GBC.eol()); |
143 | 151 | p.add(lat, GBC.eol().fill(GBC.HORIZONTAL)); |
144 | 152 | |
… |
… |
public void showJumpToDialog() {
|
158 | 166 | final int option = new JumpToPositionDialog(buttons, panel).showDialog().getValue(); |
159 | 167 | |
160 | 168 | if (option != 1) return; |
| 169 | if (place.hasFocus()) { |
| 170 | try { |
| 171 | List<NameFinder.SearchResult> placeResults = NameFinder.queryNominatim(place.getText()); |
| 172 | mv.zoomTo(placeResults.get(0).getBounds()); |
| 173 | return; |
| 174 | } catch (IOException | RuntimeException ignore) { |
| 175 | Logging.debug(ignore); |
| 176 | } |
| 177 | } |
161 | 178 | try { |
162 | 179 | zoomLvl = Double.parseDouble(zm.getText()); |
163 | 180 | ll = new LatLon(Double.parseDouble(lat.getText()), Double.parseDouble(lon.getText())); |