Skip to content

Commit 064ab0a

Browse files
GerdPGerdP
authored andcommitted
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. git-svn-id: https://josm.openstreetmap.de/svn/trunk@19119 0c6e7542-c601-0410-84e7-c038aed88b3b
1 parent a3c38ac commit 064ab0a

File tree

1 file changed

+27
-16
lines changed

1 file changed

+27
-16
lines changed

src/org/openstreetmap/josm/actions/CombineWayAction.java

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,10 @@
1010
import java.util.ArrayList;
1111
import java.util.Collection;
1212
import java.util.Collections;
13-
import java.util.HashSet;
1413
import java.util.LinkedHashSet;
1514
import java.util.LinkedList;
1615
import java.util.List;
1716
import java.util.Objects;
18-
import java.util.Set;
1917
import java.util.stream.Collectors;
2018
import java.util.stream.IntStream;
2119

@@ -279,20 +277,6 @@ public void actionPerformed(ActionEvent event) {
279277
return;
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;
298282
try {
@@ -305,6 +289,10 @@ public void actionPerformed(ActionEvent event) {
305289
if (combineResult == null)
306290
return;
307291

292+
// see #18083: check if we will combine ways at nodes outside of the download area
293+
if (!checkAndConfirmCombineOutlyingWays(selectedWays))
294+
return;
295+
308296
final Way selectedWay = combineResult.a;
309297
UndoRedoHandler.getInstance().add(combineResult.b);
310298
Test test = new OverlappingWays();
@@ -346,4 +334,27 @@ protected void updateEnabledState(Collection<? extends OsmPrimitive> selection)
346334
setEnabled(numWays >= 2);
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
}

0 commit comments

Comments
 (0)