| 282 | | // see #18083: check if we will combine ways at nodes outside of the download area |
| 283 | | Set<Node> endNodesOutside = new HashSet<>(); |
| 284 | | for (Way w : selectedWays) { |
| 285 | | final Node[] endnodes = {w.firstNode(), w.lastNode()}; |
| 286 | | for (Node n : endnodes) { |
| 287 | | if (!n.isNew() && !n.isReferrersDownloaded() && !endNodesOutside.add(n)) { |
| 288 | | new Notification(tr("Combine ways refused<br>" + "(A shared node may have additional referrers)")) |
| 289 | | .setIcon(JOptionPane.INFORMATION_MESSAGE).show(); |
| 290 | | return; |
| 291 | | |
| 292 | | } |
| 293 | | } |
| 294 | | } |
| 295 | | |
| | 293 | // see #18083 and #23735: check if we know the parents of the combined ways |
| | 294 | Collection<OsmPrimitive> missingParents = selectedWays.stream().filter(w -> !w.isReferrersDownloaded()) |
| | 295 | .collect(Collectors.toList()); |
| | 296 | if (!missingParents.isEmpty() && Boolean.TRUE.equals(PROP_DOWNLOAD_PARENTS.get()) |
| | 297 | && event.getSource() != this) { // avoid endless recursion |
| | 298 | MainApplication.worker.submit(() -> { |
| | 299 | new DownloadReferrersTask(getLayerManager().getEditLayer(), missingParents).run(); |
| | 300 | GuiHelper.runInEDT(() -> actionPerformed(new ActionEvent(this, 0, null))); |
| | 301 | }); |
| | 302 | return; |
| | 303 | } |
| | 304 | if (!checkAndConfirmCombineOutlyingWays(selectedWays)) |
| | 305 | return; |
| | 348 | /** |
| | 349 | * Check whether user is about to combine ways with unknown parents. |
| | 350 | * Request confirmation if he is. |
| | 351 | * @param ways the primitives to operate on |
| | 352 | * @return true, if operating on outlying primitives is OK; false, otherwise |
| | 353 | */ |
| | 354 | private static boolean checkAndConfirmCombineOutlyingWays(Collection<Way> ways) { |
| | 355 | DownloadReferrersAction action = MainApplication.getMenu().downloadReferrers; |
| | 356 | final String downloadHint = tr("You should use {0}->{1}({2}) first.", |
| | 357 | MainApplication.getMenu().editMenu.getText(), action.getValue(NAME), action.getShortcut().toString()); |
| | 358 | return Boolean.TRUE.equals(GuiHelper.runInEDTAndWaitAndReturn(() -> checkAndConfirmOutlyingOperation("combine", |
| | 359 | tr("Combine confirmation"), |
| | 360 | tr("You are about to combine ways which can be members of relations not yet downloaded." |
| | 361 | + "<br>" |
| | 362 | + "This can lead to damaging these parent relations (that you do not see)." |
| | 363 | + "<br>" |
| | 364 | + "{0}" |
| | 365 | + "<br><br>" |
| | 366 | + "Do you really want to combine without downloading?", downloadHint), |
| | 367 | "", // not used, we never combine incomplete ways |
| | 368 | ways, Collections.emptyList()))); |
| | 369 | } |
| | 370 | |