Changeset 18134 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2021-08-20T13:53:36+02:00 (3 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/io/remotecontrol/handler
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/AddNodeHandler.java
r14221 r18134 6 6 import java.awt.Point; 7 7 import java.util.Collections; 8 import java.util.Map;9 8 10 9 import org.openstreetmap.josm.actions.AutoScaleAction; … … 39 38 @Override 40 39 protected void handleRequest() { 41 GuiHelper.runInEDT AndWait(() -> addNode(args));40 GuiHelper.runInEDT(this::addNode); 42 41 } 43 42 … … 78 77 /** 79 78 * Adds a node, implements the GET /add_node?lon=...&lat=... request. 80 * @param args request arguments81 79 */ 82 private void addNode( Map<String, String> args) {80 private void addNode() { 83 81 84 82 // Parse the arguments -
trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/AddWayHandler.java
r14273 r18134 44 44 private final List<LatLon> allCoordinates = new ArrayList<>(); 45 45 46 private Way way;47 48 46 /** 49 47 * The place to remember already added nodes (they are reused if needed @since 5845 … … 78 76 @Override 79 77 protected void handleRequest() throws RequestHandlerErrorException, RequestHandlerBadRequestException { 80 GuiHelper.runInEDTAndWait(() -> way = addWay()); 81 // parse parameter addtags=tag1=value1|tag2=value2 82 AddTagsDialog.addTags(args, sender, Collections.singleton(way)); 78 GuiHelper.runInEDT(this::addWay); 83 79 } 84 80 … … 158 154 } 159 155 160 /* 156 /** 161 157 * This function creates the way with given coordinates of nodes 162 158 */ 163 private WayaddWay() {159 private void addWay() { 164 160 addedNodes = new HashMap<>(); 165 161 Way way = new Way(); … … 179 175 MainApplication.getMap().mapView.repaint(); 180 176 } 181 return way; 177 // parse parameter addtags=tag1=value1|tag2=value2 178 AddTagsDialog.addTags(args, sender, Collections.singleton(way)); 182 179 } 183 180 } -
trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/LoadAndZoomHandler.java
r17330 r18134 34 34 import org.openstreetmap.josm.data.osm.search.SearchParseError; 35 35 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 36 import org.openstreetmap.josm.gui.ExceptionDialogUtil; 36 37 import org.openstreetmap.josm.gui.MainApplication; 37 38 import org.openstreetmap.josm.gui.MapFrame; … … 39 40 import org.openstreetmap.josm.gui.util.GuiHelper; 40 41 import org.openstreetmap.josm.io.OsmApiException; 42 import org.openstreetmap.josm.io.OsmTransferException; 41 43 import org.openstreetmap.josm.io.remotecontrol.AddTagsDialog; 42 44 import org.openstreetmap.josm.io.remotecontrol.PermissionPrefWithDefault; … … 155 157 Logging.info("RemoteControl: no download necessary"); 156 158 } else { 157 Future<?> future = osmTask.download(settings, new Bounds(minlat, minlon, maxlat, maxlon), 158 null /* let the task manage the progress monitor */); 159 MainApplication.worker.submit(new PostDownloadHandler(osmTask, future)) 160 .get(OSM_DOWNLOAD_TIMEOUT.get(), TimeUnit.SECONDS); 161 if (osmTask.isFailed()) { 162 Object error = osmTask.getErrorObjects().get(0); 163 throw error instanceof OsmApiException 164 ? new RequestHandlerOsmApiException((OsmApiException) error) 165 : new RequestHandlerErrorException(String.join(", ", osmTask.getErrorMessages())); 166 } 159 Future<?> future = MainApplication.worker.submit( 160 new PostDownloadHandler(osmTask, osmTask.download(settings, new Bounds(minlat, minlon, maxlat, maxlon), 161 null /* let the task manage the progress monitor */))); 162 GuiHelper.executeByMainWorkerInEDT(() -> { 163 try { 164 future.get(OSM_DOWNLOAD_TIMEOUT.get(), TimeUnit.SECONDS); 165 if (osmTask.isFailed()) { 166 Object error = osmTask.getErrorObjects().get(0); 167 throw error instanceof OsmApiException 168 ? (OsmApiException) error 169 : new OsmTransferException(String.join(", ", osmTask.getErrorMessages())); 170 } 171 } catch (InterruptedException | ExecutionException | TimeoutException | 172 OsmTransferException | RuntimeException ex) { // NOPMD 173 ExceptionDialogUtil.explainException(ex); 174 } 175 }); 167 176 } 168 177 } 169 178 } 170 } catch (RuntimeException | InterruptedException | ExecutionException | TimeoutExceptionex) { // NOPMD179 } catch (RuntimeException ex) { // NOPMD 171 180 Logging.warn("RemoteControl: Error parsing load_and_zoom remote control request:"); 172 181 Logging.error(ex); -
trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/OpenFileHandler.java
r17534 r18134 49 49 options.add(Options.ALLOW_WEB_RESOURCES); 50 50 } 51 GuiHelper.runInEDT AndWait(() ->51 GuiHelper.runInEDT(() -> 52 52 OpenFileAction.openFiles(Arrays.asList(new File(args.get("filename"))), options.toArray(new Options[0]))); 53 53 } -
trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/RequestHandler.java
r17330 r18134 97 97 /** 98 98 * Handle a specific command sent as remote control. 99 * Any time-consuming operation must be performed asynchronously to avoid delaying the HTTP response. 99 100 * 100 101 * This method of the subclass will do the real work.
Note:
See TracChangeset
for help on using the changeset viewer.