Changeset 33539 in osm for applications/editors/josm/plugins/waydownloader/src/org
- Timestamp:
- 2017-08-26T02:45:24+02:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/waydownloader/src/org/openstreetmap/josm/plugins/waydownloader/WayDownloaderPlugin.java
r33167 r33539 23 23 import org.openstreetmap.josm.data.coor.LatLon; 24 24 import org.openstreetmap.josm.data.osm.DataSet; 25 import org.openstreetmap.josm.data.osm.DefaultNameFormatter; 25 26 import org.openstreetmap.josm.data.osm.Node; 26 27 import org.openstreetmap.josm.data.osm.OsmPrimitive; 27 28 import org.openstreetmap.josm.data.osm.Way; 28 import org.openstreetmap.josm.gui. DefaultNameFormatter;29 import org.openstreetmap.josm.gui.MainApplication; 29 30 import org.openstreetmap.josm.gui.MainMenu; 30 31 import org.openstreetmap.josm.gui.Notification; … … 33 34 import org.openstreetmap.josm.plugins.Plugin; 34 35 import org.openstreetmap.josm.plugins.PluginInformation; 36 import org.openstreetmap.josm.tools.Logging; 35 37 import org.openstreetmap.josm.tools.Shortcut; 36 38 … … 49 51 super(info); 50 52 //add WayDownloadAction to tools menu 51 MainMenu.add(Main .main.menu.moreToolsMenu, new WayDownloadAction());53 MainMenu.add(MainApplication.getMenu().moreToolsMenu, new WayDownloadAction()); 52 54 } 53 55 … … 67 69 public void actionPerformed(ActionEvent e) { 68 70 selectedNode = null; 69 DataSet ds = Main.getLayerManager().getEditDataSet(); 71 DataSet ds = MainApplication.getLayerManager().getEditDataSet(); 70 72 Collection<Node> selection = ds.getSelectedNodes(); 71 73 if (selection.isEmpty()) { … … 84 86 85 87 selectedNode = (Node) selection.iterator().next(); 86 Main .map.mapView.zoomTo(selectedNode.getEastNorth());88 MainApplication.getMap().mapView.zoomTo(selectedNode.getEastNorth()); 87 89 88 90 //Before downloading. Figure a few things out. … … 116 118 // schedule closing of the progress monitor after the download 117 119 // job has finished 118 Main.worker.submit( 119 new Runnable() { 120 @Override 121 public void run() { 122 try { 123 future.get(); 124 } catch(Exception e) { 125 Main.error(e); 126 return; 127 } 128 monitor.close(); 129 } 130 } 120 MainApplication.worker.submit( 121 () -> { 122 try { 123 future.get(); 124 } catch(Exception e1) { 125 Logging.error(e1); 126 return; 127 } 128 monitor.close(); 129 } 131 130 ); 132 131 //The download is scheduled to be executed. 133 132 //Now schedule the run() method (below) to be executed once that's completed. 134 Main.worker.execute(this); 133 MainApplication.worker.execute(this); 135 134 } 136 135 … … 177 176 return; 178 177 Command cmd = MergeNodesAction.mergeNodes( 179 Main.getLayerManager().getEditLayer(),178 MainApplication.getLayerManager().getEditLayer(), 180 179 Collections.singletonList(dupeNode), 181 180 selectedNode 182 181 ); 183 182 if (cmd != null) { 184 Main.main.undoRedo.add(cmd);185 Main.getLayerManager().getEditLayer().data.setSelected(selectedNode); 183 MainApplication.undoRedo.add(cmd); 184 MainApplication.getLayerManager().getEditLayer().data.setSelected(selectedNode); 186 185 } 187 186 connectedWays = findConnectedWays(selectedNode); … … 214 213 215 214 //Select the next node 216 Main.getLayerManager().getEditDataSet().setSelected(nextNode); 217 Main .map.mapView.zoomTo(nextNode.getEastNorth());215 MainApplication.getLayerManager().getEditDataSet().setSelected(nextNode); 216 MainApplication.getMap().mapView.zoomTo(nextNode.getEastNorth()); 218 217 } 219 218 } … … 237 236 */ 238 237 private Node findDuplicateNode(Node referenceNode) { 239 DataSet ds = Main.getLayerManager().getEditDataSet(); 238 DataSet ds = MainApplication.getLayerManager().getEditDataSet(); 240 239 List<Node> candidates = ds.searchNodes(new Bounds(referenceNode.getCoor(), 0.0003, 0.0005).toBBox()); 241 240 for (Node candidate: candidates) { … … 290 289 if (isDownloaded(selectedNode)) return false; 291 290 } 292 Main.getLayerManager().getEditDataSet().setSelected(selectedNode); 291 MainApplication.getLayerManager().getEditDataSet().setSelected(selectedNode); 293 292 return true; 294 293 } 295 294 296 295 private boolean isDownloaded(Node node) { 297 for (DataSource datasource : Main.getLayerManager().getEditDataSet().getDataSources()) { 296 for (DataSource datasource : MainApplication.getLayerManager().getEditDataSet().getDataSources()) { 298 297 Bounds bounds = datasource.bounds; 299 298 if (bounds != null && bounds.contains(node.getCoor())) return true; … … 304 303 private static void showWarningMessage(final String msg) { 305 304 if (msg != null) { 306 Main.warn(msg.replace("<html>", "").replace("</html>", ""));305 Logging.warn(msg.replace("<html>", "").replace("</html>", "")); 307 306 GuiHelper.runInEDT(new Runnable() { 308 307 @Override … … 318 317 private static void showErrorMessage(final String msg) { 319 318 if (msg != null) { 320 Main.error(msg.replace("<html>", "").replace("</html>", ""));319 Logging.error(msg.replace("<html>", "").replace("</html>", "")); 321 320 GuiHelper.runInEDT(new Runnable() { 322 321 @Override … … 332 331 private static void showInfoMessage(final String msg) { 333 332 if (msg != null) { 334 Main.info(msg.replace("<html>", "").replace("</html>", ""));333 Logging.info(msg.replace("<html>", "").replace("</html>", "")); 335 334 GuiHelper.runInEDT(new Runnable() { 336 335 @Override
Note:
See TracChangeset
for help on using the changeset viewer.