Changeset 10615 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2016-07-23T20:04:31+02:00 (8 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/io
- Files:
-
- 25 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/ChangesetQuery.java
r10378 r10615 21 21 import org.openstreetmap.josm.tools.CheckParameterUtil; 22 22 import org.openstreetmap.josm.tools.Utils; 23 import org.openstreetmap.josm.tools.Utils.Function; 23 24 import org.openstreetmap.josm.tools.date.DateUtils; 24 25 … … 406 407 return value == null || value.isEmpty() 407 408 ? Collections.<Long>emptySet() : 408 new HashSet<>(Utils.transform(Arrays.asList(value.split(",")), new Utils.Function<String, Long>() { 409 @Override 410 public Long apply(String x) { 411 return Long.valueOf(x); 412 } 413 })); 409 new HashSet<>(Utils.transform(Arrays.asList(value.split(",")), (Function<String, Long>) x -> Long.valueOf(x))); 414 410 } 415 411 -
trunk/src/org/openstreetmap/josm/io/FileImporter.java
r10386 r10615 115 115 116 116 private static void displayCancel(final Throwable t) { 117 GuiHelper.runInEDTAndWait(new Runnable() { 118 @Override 119 public void run() { 120 Notification note = new Notification(t.getMessage()); 121 note.setIcon(JOptionPane.INFORMATION_MESSAGE); 122 note.setDuration(Notification.TIME_SHORT); 123 note.show(); 124 } 117 GuiHelper.runInEDTAndWait(() -> { 118 Notification note = new Notification(t.getMessage()); 119 note.setIcon(JOptionPane.INFORMATION_MESSAGE); 120 note.setDuration(Notification.TIME_SHORT); 121 note.show(); 125 122 }); 126 123 } -
trunk/src/org/openstreetmap/josm/io/FileWatcher.java
r9205 r10615 42 42 try { 43 43 watcher = FileSystems.getDefault().newWatchService(); 44 thread = new Thread(new Runnable() { 45 @Override 46 public void run() { 47 processEvents(); 48 } 49 }, "File Watcher"); 44 thread = new Thread((Runnable) this::processEvents, "File Watcher"); 50 45 } catch (IOException e) { 51 46 Main.error(e); -
trunk/src/org/openstreetmap/josm/io/GpxExporter.java
r10446 r10615 5 5 6 6 import java.awt.GridBagLayout; 7 import java.awt.event.ActionEvent;8 7 import java.awt.event.ActionListener; 9 8 import java.awt.event.KeyAdapter; … … 276 275 277 276 // CHECKSTYLE.ON: ParameterNumber 278 ActionListener authorActionListener = new ActionListener() { 279 @Override 280 public void actionPerformed(ActionEvent e) { 281 boolean b = author.isSelected(); 282 authorName.setEnabled(b); 283 email.setEnabled(b); 284 nameLabel.setEnabled(b); 285 emailLabel.setEnabled(b); 286 if (b) { 287 String sAuthorName = data.getString(META_AUTHOR_NAME); 288 if (sAuthorName == null) { 289 sAuthorName = Main.pref.get("lastAuthorName"); 290 } 291 authorName.setText(sAuthorName); 292 String sEmail = data.getString(META_AUTHOR_EMAIL); 293 if (sEmail == null) { 294 sEmail = Main.pref.get("lastAuthorEmail"); 295 } 296 email.setText(sEmail); 297 } else { 298 authorName.setText(""); 299 email.setText(""); 300 } 301 boolean isAuthorSet = !authorName.getText().isEmpty(); 302 GpxExporter.enableCopyright(data, copyright, predefined, copyrightYear, copyrightLabel, copyrightYearLabel, warning, 303 b && isAuthorSet); 304 } 277 ActionListener authorActionListener = e -> { 278 boolean b = author.isSelected(); 279 authorName.setEnabled(b); 280 email.setEnabled(b); 281 nameLabel.setEnabled(b); 282 emailLabel.setEnabled(b); 283 if (b) { 284 String sAuthorName = data.getString(META_AUTHOR_NAME); 285 if (sAuthorName == null) { 286 sAuthorName = Main.pref.get("lastAuthorName"); 287 } 288 authorName.setText(sAuthorName); 289 String sEmail = data.getString(META_AUTHOR_EMAIL); 290 if (sEmail == null) { 291 sEmail = Main.pref.get("lastAuthorEmail"); 292 } 293 email.setText(sEmail); 294 } else { 295 authorName.setText(""); 296 email.setText(""); 297 } 298 boolean isAuthorSet = !authorName.getText().isEmpty(); 299 GpxExporter.enableCopyright(data, copyright, predefined, copyrightYear, copyrightLabel, copyrightYearLabel, warning, 300 b && isAuthorSet); 305 301 }; 306 302 author.addActionListener(authorActionListener); … … 314 310 authorName.addKeyListener(authorNameListener); 315 311 316 predefined.addActionListener(new ActionListener() { 317 @Override 318 public void actionPerformed(ActionEvent e) { 319 JList<String> l = new JList<>(LICENSES); 320 l.setVisibleRowCount(LICENSES.length); 321 l.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); 322 int answer = JOptionPane.showConfirmDialog( 323 Main.parent, 324 new JScrollPane(l), 325 tr("Choose a predefined license"), 326 JOptionPane.OK_CANCEL_OPTION, 327 JOptionPane.QUESTION_MESSAGE 328 ); 329 if (answer != JOptionPane.OK_OPTION || l.getSelectedIndex() == -1) 330 return; 331 StringBuilder license = new StringBuilder(); 332 for (int i : l.getSelectedIndices()) { 333 if (i == 2) { 334 license = new StringBuilder("public domain"); 335 break; 336 } 337 if (license.length() > 0) { 338 license.append(", "); 339 } 340 license.append(URLS[i]); 341 } 342 copyright.setText(license.toString()); 343 copyright.setCaretPosition(0); 344 } 312 predefined.addActionListener(e -> { 313 JList<String> l = new JList<>(LICENSES); 314 l.setVisibleRowCount(LICENSES.length); 315 l.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); 316 int answer = JOptionPane.showConfirmDialog( 317 Main.parent, 318 new JScrollPane(l), 319 tr("Choose a predefined license"), 320 JOptionPane.OK_CANCEL_OPTION, 321 JOptionPane.QUESTION_MESSAGE 322 ); 323 if (answer != JOptionPane.OK_OPTION || l.getSelectedIndex() == -1) 324 return; 325 StringBuilder license = new StringBuilder(); 326 for (int i : l.getSelectedIndices()) { 327 if (i == 2) { 328 license = new StringBuilder("public domain"); 329 break; 330 } 331 if (license.length() > 0) { 332 license.append(", "); 333 } 334 license.append(URLS[i]); 335 } 336 copyright.setText(license.toString()); 337 copyright.setCaretPosition(0); 345 338 }); 346 339 -
trunk/src/org/openstreetmap/josm/io/GpxImporter.java
r10436 r10615 117 117 public static void addLayers(final GpxImporterData data) { 118 118 // FIXME: remove UI stuff from the IO subsystem 119 GuiHelper.runInEDT(new Runnable() { 120 @Override 121 public void run() { 122 if (data.markerLayer != null) { 123 Main.getLayerManager().addLayer(data.markerLayer); 124 } 125 if (data.gpxLayer != null) { 126 Main.getLayerManager().addLayer(data.gpxLayer); 127 } 128 data.postLayerTask.run(); 119 GuiHelper.runInEDT(() -> { 120 if (data.markerLayer != null) { 121 Main.getLayerManager().addLayer(data.markerLayer); 129 122 } 123 if (data.gpxLayer != null) { 124 Main.getLayerManager().addLayer(data.gpxLayer); 125 } 126 data.postLayerTask.run(); 130 127 }); 131 128 } … … 153 150 } 154 151 } 155 Runnable postLayerTask = new Runnable() { 156 @Override 157 public void run() { 158 if (!parsedProperly) { 159 String msg; 160 if (data.storageFile == null) { 161 msg = tr("Error occurred while parsing gpx data for layer ''{0}''. Only a part of the file will be available.", 162 gpxLayerName); 163 } else { 164 msg = tr("Error occurred while parsing gpx file ''{0}''. Only a part of the file will be available.", 165 data.storageFile.getPath()); 166 } 167 JOptionPane.showMessageDialog(null, msg); 152 Runnable postLayerTask = () -> { 153 if (!parsedProperly) { 154 String msg; 155 if (data.storageFile == null) { 156 msg = tr("Error occurred while parsing gpx data for layer ''{0}''. Only a part of the file will be available.", 157 gpxLayerName); 158 } else { 159 msg = tr("Error occurred while parsing gpx file ''{0}''. Only a part of the file will be available.", 160 data.storageFile.getPath()); 168 161 } 162 JOptionPane.showMessageDialog(null, msg); 169 163 } 170 164 }; -
trunk/src/org/openstreetmap/josm/io/MessageNotifier.java
r10181 r10615 65 65 final int unread = userInfo.getUnreadMessages(); 66 66 if (unread > 0 && unread != lastUnreadCount) { 67 GuiHelper.runInEDT(new Runnable() { 68 @Override 69 public void run() { 70 JPanel panel = new JPanel(new GridBagLayout()); 71 panel.add(new JLabel(trn("You have {0} unread message.", "You have {0} unread messages.", unread, unread)), 72 GBC.eol()); 73 panel.add(new UrlLabel(Main.getBaseUserUrl() + '/' + userInfo.getDisplayName() + "/inbox", 74 tr("Click here to see your inbox.")), GBC.eol()); 75 panel.setOpaque(false); 76 new Notification().setContent(panel) 77 .setIcon(JOptionPane.INFORMATION_MESSAGE) 78 .setDuration(Notification.TIME_LONG) 79 .show(); 80 } 67 GuiHelper.runInEDT(() -> { 68 JPanel panel = new JPanel(new GridBagLayout()); 69 panel.add(new JLabel(trn("You have {0} unread message.", "You have {0} unread messages.", unread, unread)), 70 GBC.eol()); 71 panel.add(new UrlLabel(Main.getBaseUserUrl() + '/' + userInfo.getDisplayName() + "/inbox", 72 tr("Click here to see your inbox.")), GBC.eol()); 73 panel.setOpaque(false); 74 new Notification().setContent(panel) 75 .setIcon(JOptionPane.INFORMATION_MESSAGE) 76 .setDuration(Notification.TIME_LONG) 77 .show(); 81 78 }); 82 79 lastUnreadCount = unread; -
trunk/src/org/openstreetmap/josm/io/MultiFetchOverpassObjectReader.java
r10300 r10615 17 17 @Override 18 18 protected String buildRequestString(final OsmPrimitiveType type, Set<Long> idPackage) { 19 final Utils.Function<Long, Object> toOverpassExpression = new Utils.Function<Long, Object>() { 20 @Override 21 public Object apply(Long x) { 22 return type.getAPIName() + '(' + x + ");>;"; 23 } 24 }; 19 final Utils.Function<Long, Object> toOverpassExpression = x -> type.getAPIName() + '(' + x + ");>;"; 25 20 final String query = '(' + Utils.join("", Utils.transform(idPackage, toOverpassExpression)) + ");out meta;"; 26 21 return "interpreter?data=" + Utils.encodeUrl(query); -
trunk/src/org/openstreetmap/josm/io/NMEAImporter.java
r10436 r10615 50 50 final File fileFinal = file; 51 51 52 GuiHelper.runInEDT(new Runnable() { 53 @Override 54 public void run() { 55 Main.getLayerManager().addLayer(gpxLayer); 56 if (Main.pref.getBoolean("marker.makeautomarkers", true)) { 57 MarkerLayer ml = new MarkerLayer(r.data, tr("Markers from {0}", fn), fileFinal, gpxLayer); 58 if (!ml.data.isEmpty()) { 59 Main.getLayerManager().addLayer(ml); 60 } 52 GuiHelper.runInEDT(() -> { 53 Main.getLayerManager().addLayer(gpxLayer); 54 if (Main.pref.getBoolean("marker.makeautomarkers", true)) { 55 MarkerLayer ml = new MarkerLayer(r.data, tr("Markers from {0}", fn), fileFinal, gpxLayer); 56 if (!ml.data.isEmpty()) { 57 Main.getLayerManager().addLayer(ml); 61 58 } 62 59 } … … 78 75 .append("</html>"); 79 76 if (success) { 80 SwingUtilities.invokeLater(new Runnable() { 81 @Override 82 public void run() { 83 new Notification( 84 "<h3>" + tr("NMEA import success:") + "</h3>" + msg.toString()) 85 .setIcon(JOptionPane.INFORMATION_MESSAGE) 86 .show(); 87 } 88 }); 77 SwingUtilities.invokeLater(() -> new Notification( 78 "<h3>" + tr("NMEA import success:") + "</h3>" + msg.toString()) 79 .setIcon(JOptionPane.INFORMATION_MESSAGE) 80 .show()); 89 81 } else { 90 82 HelpAwareOptionPane.showMessageDialogInEDT( -
trunk/src/org/openstreetmap/josm/io/OsmChangeImporter.java
r10436 r10615 53 53 // FIXME: remove UI stuff from IO subsystem 54 54 // 55 GuiHelper.runInEDT(new Runnable() { 56 @Override 57 public void run() { 58 if (dataSet.allPrimitives().isEmpty()) { 59 JOptionPane.showMessageDialog( 60 Main.parent, 61 tr("No data found in file {0}.", filePath), 62 tr("Open OsmChange file"), 63 JOptionPane.INFORMATION_MESSAGE); 64 } 65 Main.getLayerManager().addLayer(layer); 66 layer.onPostLoadFromFile(); 55 GuiHelper.runInEDT(() -> { 56 if (dataSet.allPrimitives().isEmpty()) { 57 JOptionPane.showMessageDialog( 58 Main.parent, 59 tr("No data found in file {0}.", filePath), 60 tr("Open OsmChange file"), 61 JOptionPane.INFORMATION_MESSAGE); 67 62 } 63 Main.getLayerManager().addLayer(layer); 64 layer.onPostLoadFromFile(); 68 65 }); 69 66 } -
trunk/src/org/openstreetmap/josm/io/OsmConnection.java
r10308 r10615 13 13 import java.nio.charset.StandardCharsets; 14 14 import java.util.Objects; 15 import java.util.concurrent.Callable;16 15 import java.util.concurrent.FutureTask; 17 16 … … 129 128 throw new MissingOAuthAccessTokenException(); 130 129 } 131 final Runnable authTask = new FutureTask<>(new Callable<OAuthAuthorizationWizard>() { 132 @Override 133 public OAuthAuthorizationWizard call() throws Exception { 134 // Concerning Utils.newDirectExecutor: Main.worker cannot be used since this connection is already 135 // executed via Main.worker. The OAuth connections would block otherwise. 136 final OAuthAuthorizationWizard wizard = new OAuthAuthorizationWizard( 137 Main.parent, apiUrl.toExternalForm(), Utils.newDirectExecutor()); 138 wizard.showDialog(); 139 OAuthAccessTokenHolder.getInstance().setSaveToPreferences(true); 140 OAuthAccessTokenHolder.getInstance().save(Main.pref, CredentialsManager.getInstance()); 141 return wizard; 142 } 130 final Runnable authTask = new FutureTask<>(() -> { 131 // Concerning Utils.newDirectExecutor: Main.worker cannot be used since this connection is already 132 // executed via Main.worker. The OAuth connections would block otherwise. 133 final OAuthAuthorizationWizard wizard = new OAuthAuthorizationWizard( 134 Main.parent, apiUrl.toExternalForm(), Utils.newDirectExecutor()); 135 wizard.showDialog(); 136 OAuthAccessTokenHolder.getInstance().setSaveToPreferences(true); 137 OAuthAccessTokenHolder.getInstance().save(Main.pref, CredentialsManager.getInstance()); 138 return wizard; 143 139 }); 144 140 // exception handling differs from implementation at GuiHelper.runInEDTAndWait() -
trunk/src/org/openstreetmap/josm/io/OsmImporter.java
r10436 r10615 92 92 93 93 // FIXME: remove UI stuff from IO subsystem 94 GuiHelper.runInEDT(new Runnable() { 95 @Override 96 public void run() { 97 OsmDataLayer layer = data.getLayer(); 98 Main.getLayerManager().addLayer(layer); 99 data.getPostLayerTask().run(); 100 data.getLayer().onPostLoadFromFile(); 101 } 94 GuiHelper.runInEDT(() -> { 95 OsmDataLayer layer = data.getLayer(); 96 Main.getLayerManager().addLayer(layer); 97 data.getPostLayerTask().run(); 98 data.getLayer().onPostLoadFromFile(); 102 99 }); 103 100 } … … 132 129 133 130 protected Runnable createPostLayerTask(final DataSet dataSet, final File associatedFile, final String layerName, final OsmDataLayer layer) { 134 return new Runnable() { 135 @Override 136 public void run() { 137 if (dataSet.allPrimitives().isEmpty()) { 138 String msg; 139 if (associatedFile == null) { 140 msg = tr("No data found for layer ''{0}''.", layerName); 141 } else { 142 msg = tr("No data found in file ''{0}''.", associatedFile.getPath()); 143 } 144 JOptionPane.showMessageDialog( 145 Main.parent, 146 msg, 147 tr("Open OSM file"), 148 JOptionPane.INFORMATION_MESSAGE); 131 return () -> { 132 if (dataSet.allPrimitives().isEmpty()) { 133 String msg; 134 if (associatedFile == null) { 135 msg = tr("No data found for layer ''{0}''.", layerName); 136 } else { 137 msg = tr("No data found in file ''{0}''.", associatedFile.getPath()); 149 138 } 150 layer.onPostLoadFromFile(); 139 JOptionPane.showMessageDialog( 140 Main.parent, 141 msg, 142 tr("Open OSM file"), 143 JOptionPane.INFORMATION_MESSAGE); 151 144 } 145 layer.onPostLoadFromFile(); 152 146 }; 153 147 } -
trunk/src/org/openstreetmap/josm/io/OsmReader.java
r10308 r10615 576 576 progressMonitor = NullProgressMonitor.INSTANCE; 577 577 } 578 ProgressMonitor.CancelListener cancelListener = new ProgressMonitor.CancelListener() { 579 @Override public void operationCanceled() { 580 cancel = true; 581 } 582 }; 578 ProgressMonitor.CancelListener cancelListener = () -> cancel = true; 583 579 progressMonitor.addCancelListener(cancelListener); 584 580 CheckParameterUtil.ensureParameterNotNull(source, "source"); -
trunk/src/org/openstreetmap/josm/io/OsmWriter.java
r10051 r10615 97 97 * Sorts {@code -1} → {@code -infinity}, then {@code +1} → {@code +infinity} 98 98 */ 99 protected static final Comparator<AbstractPrimitive> byIdComparator = new Comparator<AbstractPrimitive>() { 100 @Override public int compare(AbstractPrimitive o1, AbstractPrimitive o2) { 101 final long i1 = o1.getUniqueId(); 102 final long i2 = o2.getUniqueId(); 103 if (i1 < 0 && i2 < 0) { 104 return Long.compare(i2, i1); 105 } else { 106 return Long.compare(i1, i2); 107 } 99 protected static final Comparator<AbstractPrimitive> byIdComparator = (o1, o2) -> { 100 final long i1 = o1.getUniqueId(); 101 final long i2 = o2.getUniqueId(); 102 if (i1 < 0 && i2 < 0) { 103 return Long.compare(i2, i1); 104 } else { 105 return Long.compare(i1, i2); 108 106 } 109 107 }; … … 263 261 } 264 262 265 protected static final Comparator<Entry<String, String>> byKeyComparator = new Comparator<Entry<String, String>>() { 266 @Override 267 public int compare(Entry<String, String> o1, Entry<String, String> o2) { 268 return o1.getKey().compareTo(o2.getKey()); 269 } 270 }; 263 protected static final Comparator<Entry<String, String>> byKeyComparator = (o1, o2) -> o1.getKey().compareTo(o2.getKey()); 271 264 272 265 protected void addTags(Tagged osm, String tagname, boolean tagOpen) { -
trunk/src/org/openstreetmap/josm/io/WMSLayerImporter.java
r10436 r10615 85 85 86 86 // FIXME: remove UI stuff from IO subsystem 87 GuiHelper.runInEDT(new Runnable() { 88 @Override 89 public void run() { 90 Main.getLayerManager().addLayer(layer); 91 if (zoomTo != null) { 92 Main.map.mapView.zoomTo(zoomTo); 93 } 87 GuiHelper.runInEDT(() -> { 88 Main.getLayerManager().addLayer(layer); 89 if (zoomTo != null) { 90 Main.map.mapView.zoomTo(zoomTo); 94 91 } 95 92 }); -
trunk/src/org/openstreetmap/josm/io/auth/AbstractCredentialsAgent.java
r10378 r10615 46 46 } else if (noSuccessWithLastResponse || username.isEmpty() || password.isEmpty()) { 47 47 if (!GraphicsEnvironment.isHeadless()) { 48 GuiHelper.runInEDTAndWait(new Runnable() { 49 @Override 50 public void run() { 51 CredentialDialog dialog; 52 if (requestorType.equals(RequestorType.PROXY)) 53 dialog = CredentialDialog.getHttpProxyCredentialDialog( 54 username, password, host, getSaveUsernameAndPasswordCheckboxText()); 55 else 56 dialog = CredentialDialog.getOsmApiCredentialDialog( 57 username, password, host, getSaveUsernameAndPasswordCheckboxText()); 58 dialog.setVisible(true); 59 response.setCanceled(dialog.isCanceled()); 60 if (dialog.isCanceled()) 61 return; 62 response.setUsername(dialog.getUsername()); 63 response.setPassword(dialog.getPassword()); 64 response.setSaveCredentials(dialog.isSaveCredentials()); 65 } 48 GuiHelper.runInEDTAndWait(() -> { 49 CredentialDialog dialog; 50 if (requestorType.equals(RequestorType.PROXY)) 51 dialog = CredentialDialog.getHttpProxyCredentialDialog( 52 username, password, host, getSaveUsernameAndPasswordCheckboxText()); 53 else 54 dialog = CredentialDialog.getOsmApiCredentialDialog( 55 username, password, host, getSaveUsernameAndPasswordCheckboxText()); 56 dialog.setVisible(true); 57 response.setCanceled(dialog.isCanceled()); 58 if (dialog.isCanceled()) 59 return; 60 response.setUsername(dialog.getUsername()); 61 response.setPassword(dialog.getPassword()); 62 response.setSaveCredentials(dialog.isSaveCredentials()); 66 63 }); 67 64 } -
trunk/src/org/openstreetmap/josm/io/imagery/WMSImagery.java
r10612 r10615 35 35 import org.w3c.dom.Node; 36 36 import org.w3c.dom.NodeList; 37 import org.xml.sax.EntityResolver;38 37 import org.xml.sax.InputSource; 39 38 import org.xml.sax.SAXException; … … 217 216 try { 218 217 DocumentBuilder builder = Utils.newSafeDOMBuilder(); 219 builder.setEntityResolver(new EntityResolver() { 220 @Override 221 public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { 222 Main.info("Ignoring DTD " + publicId + ", " + systemId); 223 return new InputSource(new StringReader("")); 224 } 218 builder.setEntityResolver((publicId, systemId) -> { 219 Main.info("Ignoring DTD " + publicId + ", " + systemId); 220 return new InputSource(new StringReader("")); 225 221 }); 226 222 Document document = builder.parse(new InputSource(new StringReader(incomingData))); -
trunk/src/org/openstreetmap/josm/io/remotecontrol/AddTagsDialog.java
r10446 r10615 268 268 public static void addTags(final Map<String, String> args, final String sender, final Collection<? extends OsmPrimitive> primitives) { 269 269 if (args.containsKey("addtags")) { 270 GuiHelper.executeByMainWorkerInEDT(new Runnable() { 271 272 @Override 273 public void run() { 274 Set<String> tagSet = new HashSet<>(); 275 for (String tag : Utils.decodeUrl(args.get("addtags")).split("\\|")) { 276 if (!tag.trim().isEmpty() && tag.contains("=")) { 277 tagSet.add(tag.trim()); 278 } 270 GuiHelper.executeByMainWorkerInEDT(() -> { 271 Set<String> tagSet = new HashSet<>(); 272 for (String tag1 : Utils.decodeUrl(args.get("addtags")).split("\\|")) { 273 if (!tag1.trim().isEmpty() && tag1.contains("=")) { 274 tagSet.add(tag1.trim()); 279 275 } 280 if (!tagSet.isEmpty()) { 281 String[][] keyValue = new String[tagSet.size()][2]; 282 int i = 0; 283 for (String tag : tagSet) { 284 // support a = b===c as "a"="b===c" 285 String[] pair = tag.split("\\s*=\\s*", 2); 286 keyValue[i][0] = pair[0]; 287 keyValue[i][1] = pair.length < 2 ? "" : pair[1]; 288 i++; 289 } 290 addTags(keyValue, sender, primitives); 276 } 277 if (!tagSet.isEmpty()) { 278 String[][] keyValue = new String[tagSet.size()][2]; 279 int i = 0; 280 for (String tag2 : tagSet) { 281 // support a = b===c as "a"="b===c" 282 String[] pair = tag2.split("\\s*=\\s*", 2); 283 keyValue[i][0] = pair[0]; 284 keyValue[i][1] = pair.length < 2 ? "" : pair[1]; 285 i++; 291 286 } 287 addTags(keyValue, sender, primitives); 292 288 } 293 289 }); -
trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/AddNodeHandler.java
r10453 r10615 33 33 @Override 34 34 protected void handleRequest() { 35 GuiHelper.runInEDTAndWait(new Runnable() { 36 @Override public void run() { 37 addNode(args); 38 } 39 }); 35 GuiHelper.runInEDTAndWait(() -> addNode(args)); 40 36 } 41 37 -
trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/AddWayHandler.java
r10453 r10615 73 73 @Override 74 74 protected void handleRequest() throws RequestHandlerErrorException, RequestHandlerBadRequestException { 75 GuiHelper.runInEDTAndWait(new Runnable() { 76 @Override public void run() { 77 way = addWay(); 78 } 79 }); 75 GuiHelper.runInEDTAndWait(() -> way = addWay()); 80 76 // parse parameter addtags=tag1=value1|tag2=value2 81 77 AddTagsDialog.addTags(args, sender, Collections.singleton(way)); -
trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/ImageryHandler.java
r10436 r10615 14 14 import org.openstreetmap.josm.io.remotecontrol.PermissionPrefWithDefault; 15 15 import org.openstreetmap.josm.tools.Utils; 16 import org.openstreetmap.josm.tools.Utils.Function; 16 17 17 18 /** … … 102 103 } 103 104 } 104 GuiHelper.runInEDT(new Runnable() { 105 @Override 106 public void run() { 107 try { 108 Main.getLayerManager().addLayer(ImageryLayer.create(imgInfo)); 109 } catch (IllegalArgumentException e) { 110 Main.error(e, false); 111 } 105 GuiHelper.runInEDT(() -> { 106 try { 107 Main.getLayerManager().addLayer(ImageryLayer.create(imgInfo)); 108 } catch (IllegalArgumentException e) { 109 Main.error(e, false); 112 110 } 113 111 }); … … 134 132 public String[] getUsageExamples() { 135 133 final String types = Utils.join("|", Utils.transform(Arrays.asList(ImageryInfo.ImageryType.values()), 136 new Utils.Function<ImageryInfo.ImageryType, String>() { 137 @Override 138 public String apply(ImageryInfo.ImageryType x) { 139 return x.getTypeString(); 140 } 141 })); 134 (Function<ImageryType, String>) x -> x.getTypeString())); 142 135 return new String[] { 143 136 "/imagery?title=osm&type=tms&url=https://a.tile.openstreetmap.org/%7Bzoom%7D/%7Bx%7D/%7By%7D.png", -
trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/LoadAndZoomHandler.java
r10446 r10615 155 155 */ 156 156 if (args.containsKey("addtags")) { 157 GuiHelper.executeByMainWorkerInEDT(new Runnable() { 158 @Override 159 public void run() { 160 DataSet ds = Main.getLayerManager().getEditDataSet(); 161 if (ds == null) // e.g. download failed 162 return; 163 ds.clearSelection(); 164 } 157 GuiHelper.executeByMainWorkerInEDT(() -> { 158 DataSet ds = Main.getLayerManager().getEditDataSet(); 159 if (ds == null) // e.g. download failed 160 return; 161 ds.clearSelection(); 165 162 }); 166 163 } … … 170 167 if (args.containsKey("select") && PermissionPrefWithDefault.CHANGE_SELECTION.isAllowed()) { 171 168 // select objects after downloading, zoom to selection. 172 GuiHelper.executeByMainWorkerInEDT(new Runnable() { 173 @Override 174 public void run() { 175 Set<OsmPrimitive> newSel = new HashSet<>(); 176 DataSet ds = Main.getLayerManager().getEditDataSet(); 177 if (ds == null) // e.g. download failed 178 return; 179 for (SimplePrimitiveId id : toSelect) { 180 final OsmPrimitive p = ds.getPrimitiveById(id); 181 if (p != null) { 182 newSel.add(p); 183 forTagAdd.add(p); 184 } 185 } 186 toSelect.clear(); 187 ds.setSelected(newSel); 188 zoom(newSel, bbox); 189 if (Main.isDisplayingMapView() && Main.map.relationListDialog != null) { 190 Main.map.relationListDialog.selectRelations(null); // unselect all relations to fix #7342 191 Main.map.relationListDialog.dataChanged(null); 192 Main.map.relationListDialog.selectRelations(Utils.filteredCollection(newSel, Relation.class)); 193 } 169 GuiHelper.executeByMainWorkerInEDT(() -> { 170 Set<OsmPrimitive> newSel = new HashSet<>(); 171 DataSet ds = Main.getLayerManager().getEditDataSet(); 172 if (ds == null) // e.g. download failed 173 return; 174 for (SimplePrimitiveId id : toSelect) { 175 final OsmPrimitive p = ds.getPrimitiveById(id); 176 if (p != null) { 177 newSel.add(p); 178 forTagAdd.add(p); 179 } 180 } 181 toSelect.clear(); 182 ds.setSelected(newSel); 183 zoom(newSel, bbox); 184 if (Main.isDisplayingMapView() && Main.map.relationListDialog != null) { 185 Main.map.relationListDialog.selectRelations(null); // unselect all relations to fix #7342 186 Main.map.relationListDialog.dataChanged(null); 187 Main.map.relationListDialog.selectRelations(Utils.filteredCollection(newSel, Relation.class)); 194 188 } 195 189 }); … … 197 191 try { 198 192 final SearchCompiler.Match search = SearchCompiler.compile(args.get("search")); 199 Main.worker.submit(new Runnable() { 200 @Override 201 public void run() { 202 final DataSet ds = Main.getLayerManager().getEditDataSet(); 203 final Collection<OsmPrimitive> filteredPrimitives = Utils.filter(ds.allPrimitives(), search); 204 ds.setSelected(filteredPrimitives); 205 forTagAdd.addAll(filteredPrimitives); 206 zoom(filteredPrimitives, bbox); 207 } 193 Main.worker.submit(() -> { 194 final DataSet ds = Main.getLayerManager().getEditDataSet(); 195 final Collection<OsmPrimitive> filteredPrimitives = Utils.filter(ds.allPrimitives(), search); 196 ds.setSelected(filteredPrimitives); 197 forTagAdd.addAll(filteredPrimitives); 198 zoom(filteredPrimitives, bbox); 208 199 }); 209 200 } catch (SearchCompiler.ParseError ex) { … … 218 209 // add changeset tags after download if necessary 219 210 if (args.containsKey("changeset_comment") || args.containsKey("changeset_source")) { 220 Main.worker.submit(new Runnable() { 221 @Override 222 public void run() { 223 if (Main.getLayerManager().getEditDataSet() != null) { 224 if (args.containsKey("changeset_comment")) { 225 Main.getLayerManager().getEditDataSet().addChangeSetTag("comment", args.get("changeset_comment")); 226 } 227 if (args.containsKey("changeset_source")) { 228 Main.getLayerManager().getEditDataSet().addChangeSetTag("source", args.get("changeset_source")); 229 } 211 Main.worker.submit(() -> { 212 if (Main.getLayerManager().getEditDataSet() != null) { 213 if (args.containsKey("changeset_comment")) { 214 Main.getLayerManager().getEditDataSet().addChangeSetTag("comment", args.get("changeset_comment")); 215 } 216 if (args.containsKey("changeset_source")) { 217 Main.getLayerManager().getEditDataSet().addChangeSetTag("source", args.get("changeset_source")); 230 218 } 231 219 } … … 245 233 } else if (Main.isDisplayingMapView()) { 246 234 // make sure this isn't called unless there *is* a MapView 247 GuiHelper.executeByMainWorkerInEDT(new Runnable() { 248 @Override 249 public void run() { 250 BoundingXYVisitor bbox1 = new BoundingXYVisitor(); 251 bbox1.visit(bbox); 252 Main.map.mapView.zoomTo(bbox1); 253 } 235 GuiHelper.executeByMainWorkerInEDT(() -> { 236 BoundingXYVisitor bbox1 = new BoundingXYVisitor(); 237 bbox1.visit(bbox); 238 Main.map.mapView.zoomTo(bbox1); 254 239 }); 255 240 } … … 297 282 toSelect.add(SimplePrimitiveId.fromString(item)); 298 283 } catch (IllegalArgumentException ex) { 299 Main.warn( "RemoteControl: invalid selection '" + item + "' ignored");284 Main.warn(ex, "RemoteControl: invalid selection '" + item + "' ignored"); 300 285 } 301 286 } -
trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/LoadObjectHandler.java
r10446 r10615 68 68 newLayer, ps, referrers, relationMembers, args.get("layer_name"), null); 69 69 Main.worker.submit(task); 70 Main.worker.submit(new Runnable() { 71 @Override 72 public void run() { 73 final List<PrimitiveId> downloaded = task.getDownloadedId(); 74 final DataSet ds = Main.getLayerManager().getEditDataSet(); 75 if (downloaded != null) { 76 GuiHelper.runInEDT(new Runnable() { 77 @Override 78 public void run() { 79 ds.setSelected(downloaded); 80 } 81 }); 82 Collection<OsmPrimitive> downlPrim = new HashSet<>(); 83 for (PrimitiveId id : downloaded) { 84 downlPrim.add(ds.getPrimitiveById(id)); 85 } 86 AddTagsDialog.addTags(args, sender, downlPrim); 70 Main.worker.submit(() -> { 71 final List<PrimitiveId> downloaded = task.getDownloadedId(); 72 final DataSet ds = Main.getLayerManager().getEditDataSet(); 73 if (downloaded != null) { 74 GuiHelper.runInEDT(() -> ds.setSelected(downloaded)); 75 Collection<OsmPrimitive> downlPrim = new HashSet<>(); 76 for (PrimitiveId id : downloaded) { 77 downlPrim.add(ds.getPrimitiveById(id)); 87 78 } 88 ps.clear();79 AddTagsDialog.addTags(args, sender, downlPrim); 89 80 } 81 ps.clear(); 90 82 }); 91 83 } -
trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/OpenFileHandler.java
r8392 r10615 43 43 @Override 44 44 protected void handleRequest() throws RequestHandlerErrorException, RequestHandlerBadRequestException { 45 GuiHelper.runInEDTAndWait(new Runnable() { 46 @Override public void run() { 47 OpenFileAction.openFiles(Arrays.asList(new File(args.get("filename")))); 48 } 49 }); 45 GuiHelper.runInEDTAndWait(() -> OpenFileAction.openFiles(Arrays.asList(new File(args.get("filename"))))); 50 46 } 51 47 -
trunk/src/org/openstreetmap/josm/io/session/GenericSessionExporter.java
r10369 r10615 9 9 import java.awt.Insets; 10 10 import java.awt.event.ActionEvent; 11 import java.awt.event.ActionListener;12 11 import java.awt.event.ItemEvent; 13 import java.awt.event.ItemListener;14 12 import java.io.File; 15 13 import java.io.IOException; … … 153 151 } 154 152 155 link.addActionListener(new ActionListener() { 156 @Override 157 public void actionPerformed(ActionEvent e) { 158 cl.show(cards, "link"); 159 } 160 }); 161 include.addActionListener(new ActionListener() { 162 @Override 163 public void actionPerformed(ActionEvent e) { 164 cl.show(cards, "include"); 165 } 166 }); 153 link.addActionListener(e -> cl.show(cards, "link")); 154 include.addActionListener(e -> cl.show(cards, "include")); 167 155 168 156 topRow.add(export, GBC.std()); … … 175 163 p.add(cards, GBC.eol().insets(15, 0, 3, 3)); 176 164 177 export.addItemListener(new ItemListener() { 178 @Override 179 public void itemStateChanged(ItemEvent e) { 180 if (e.getStateChange() == ItemEvent.DESELECTED) { 181 GuiHelper.setEnabledRec(p, false); 182 export.setEnabled(true); 183 } else { 184 GuiHelper.setEnabledRec(p, true); 185 if (save != null && saveAction != null) { 186 save.setEnabled(saveAction.isEnabled()); 187 } 188 link.setEnabled(file != null && file.exists()); 165 export.addItemListener(e -> { 166 if (e.getStateChange() == ItemEvent.DESELECTED) { 167 GuiHelper.setEnabledRec(p, false); 168 export.setEnabled(true); 169 } else { 170 GuiHelper.setEnabledRec(p, true); 171 if (save != null && saveAction != null) { 172 save.setEnabled(saveAction.isEnabled()); 189 173 } 174 link.setEnabled(file != null && file.exists()); 190 175 } 191 176 }); -
trunk/src/org/openstreetmap/josm/io/session/SessionReader.java
r10404 r10615 553 553 public void show(final String title, final String message, final int icon, final ProgressMonitor progressMonitor) { 554 554 try { 555 SwingUtilities.invokeAndWait(new Runnable() { 556 @Override public void run() { 557 ExtendedDialog dlg = new ExtendedDialog( 558 Main.parent, 559 title, 560 new String[] {tr("Cancel"), tr("Skip layer and continue")} 561 ); 562 dlg.setButtonIcons(new String[] {"cancel", "dialogs/next"}); 563 dlg.setIcon(icon); 564 dlg.setContent(message); 565 dlg.showDialog(); 566 cancel = dlg.getValue() != 2; 567 } 555 SwingUtilities.invokeAndWait(() -> { 556 ExtendedDialog dlg = new ExtendedDialog( 557 Main.parent, 558 title, 559 new String[] {tr("Cancel"), tr("Skip layer and continue")} 560 ); 561 dlg.setButtonIcons(new String[] {"cancel", "dialogs/next"}); 562 dlg.setIcon(icon); 563 dlg.setContent(message); 564 dlg.showDialog(); 565 cancel = dlg.getValue() != 2; 568 566 }); 569 567 } catch (InvocationTargetException | InterruptedException ex) {
Note:
See TracChangeset
for help on using the changeset viewer.