Changeset 19119 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2024-06-20T06:45:59+02:00 (3 months ago)
Author:
GerdP
Message:

fix #23735: Combine ways refused
(patch 23735-2.patch)

  • rewrite check so that it checks if the parents of the combined ways are known instead of the parents of the connection node(s)
  • show dialog with hint about download parents action that allows to continue

TODO: implement full automatic download of parents in all relavant action or add download button in the common dialog.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/CombineWayAction.java

    r19078 r19119  
    1111import java.util.Collection;
    1212import java.util.Collections;
    13 import java.util.HashSet;
    1413import java.util.LinkedHashSet;
    1514import java.util.LinkedList;
    1615import java.util.List;
    1716import java.util.Objects;
    18 import java.util.Set;
    1917import java.util.stream.Collectors;
    2018import java.util.stream.IntStream;
     
    280278        }
    281279
    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 
    296280        // combine and update gui
    297281        Pair<Way, Command> combineResult;
     
    304288
    305289        if (combineResult == null)
     290            return;
     291
     292        // see #18083: check if we will combine ways at nodes outside of the download area
     293        if (!checkAndConfirmCombineOutlyingWays(selectedWays))
    306294            return;
    307295
     
    347335    }
    348336
     337    /**
     338     * Check whether user is about to combine ways with unknown parents.
     339     * Request confirmation if he is.
     340     * @param ways the primitives to operate on
     341     * @return true, if operating on outlying primitives is OK; false, otherwise
     342     */
     343    private static boolean checkAndConfirmCombineOutlyingWays(Collection<Way> ways) {
     344        DownloadReferrersAction action = MainApplication.getMenu().downloadReferrers;
     345        final String downloadHint = tr("You should use {0}->{1}({2}) first.",
     346                MainApplication.getMenu().editMenu.getText(), action.getValue(NAME), action.getShortcut().toString());
     347        return Boolean.TRUE.equals(GuiHelper.runInEDTAndWaitAndReturn(() -> checkAndConfirmOutlyingOperation("combine",
     348                tr("Combine confirmation"),
     349                tr("You are about to combine ways which can be members of relations not yet downloaded."
     350                        + "<br>"
     351                        + "This can lead to damaging these parent relations (that you do not see)."
     352                        + "<br>"
     353                        + "{0}"
     354                        + "<br><br>"
     355                        + "Do you really want to combine without downloading?", downloadHint),
     356                "", // not used, we never combine incomplete ways
     357                ways, Collections.emptyList())));
     358    }
     359
    349360}
Note: See TracChangeset for help on using the changeset viewer.