Changeset 9387 in josm
- Timestamp:
- 2016-01-10T14:29:30+01:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/UnGlueAction.java
r9315 r9387 37 37 import org.openstreetmap.josm.data.osm.RelationMember; 38 38 import org.openstreetmap.josm.data.osm.Way; 39 import org.openstreetmap.josm.gui.DefaultNameFormatter; 39 40 import org.openstreetmap.josm.gui.ExtendedDialog; 40 41 import org.openstreetmap.josm.gui.MapView; … … 78 79 @Override 79 80 public void actionPerformed(ActionEvent e) { 81 try { 82 unglue(e); 83 } catch (UserCancelException ignore) { 84 Main.debug(ignore.getMessage()); 85 } finally { 86 cleanup(); 87 } 88 } 89 90 protected void unglue(ActionEvent e) throws UserCancelException { 80 91 81 92 Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected(); … … 84 95 int errorTime = Notification.TIME_DEFAULT; 85 96 if (checkSelectionOneNodeAtMostOneWay(selection)) { 86 if (!checkAndConfirmOutlyingUnglue()) { 87 // FIXME: Leaving action without clearing selectedNode, selectedWay, selectedNodes 88 return; 89 } 97 checkAndConfirmOutlyingUnglue(); 90 98 int count = 0; 91 99 for (Way w : OsmPrimitive.getFilteredList(selectedNode.getReferrers(), Way.class)) { … … 115 123 } 116 124 } else if (checkSelectionOneWayAnyNodes(selection)) { 117 if (!checkAndConfirmOutlyingUnglue()) { 118 // FIXME: Leaving action without clearing selectedNode, selectedWay, selectedNodes 119 return; 120 } 125 checkAndConfirmOutlyingUnglue(); 121 126 Set<Node> tmpNodes = new HashSet<>(); 122 127 for (Node n : selectedNodes) { … … 167 172 .show(); 168 173 } 169 174 } 175 176 private void cleanup() { 170 177 selectedNode = null; 171 178 selectedWay = null; … … 535 542 cmds.add(new ChangeCommand(w, modifyWay(selectedNode, w, cmds, newNodes))); 536 543 } 544 notifyWayPartOfRelation(parentWays); 537 545 } else { 538 546 cmds.add(new ChangeCommand(selectedWay, modifyWay(selectedNode, selectedWay, cmds, newNodes))); 547 notifyWayPartOfRelation(Collections.singleton(selectedWay)); 539 548 } 540 549 … … 599 608 } 600 609 cmds.add(new ChangeNodesCommand(way, newNodes)); 610 notifyWayPartOfRelation(Collections.singleton(way)); 601 611 try { 602 612 final PropertiesMembershipDialog dialog = PropertiesMembershipDialog.showIfNecessary(Collections.singleton(selectedNode), false); … … 637 647 } 638 648 cmds.add(new ChangeCommand(selectedWay, tmpWay)); // only one changeCommand for a way, else garbage will happen 649 notifyWayPartOfRelation(Collections.singleton(selectedWay)); 639 650 640 651 Main.main.undoRedo.add(new SequenceCommand( … … 658 669 } 659 670 660 protected boolean checkAndConfirmOutlyingUnglue(){671 protected void checkAndConfirmOutlyingUnglue() throws UserCancelException { 661 672 List<OsmPrimitive> primitives = new ArrayList<>(2 + (selectedNodes == null ? 0 : selectedNodes.size())); 662 673 if (selectedNodes != null) … … 664 675 if (selectedNode != null) 665 676 primitives.add(selectedNode); 666 returnCommand.checkAndConfirmOutlyingOperation("unglue",677 final boolean ok = Command.checkAndConfirmOutlyingOperation("unglue", 667 678 tr("Unglue confirmation"), 668 679 tr("You are about to unglue nodes outside of the area you have downloaded." … … 676 687 + "<br>" + "Do you really want to unglue?"), 677 688 primitives, null); 689 if (!ok) { 690 throw new UserCancelException(); 691 } 692 } 693 694 protected void notifyWayPartOfRelation(final Iterable<Way> ways) { 695 final Set<String> affectedRelations = new HashSet<>(); 696 for (Way way : ways) { 697 for (OsmPrimitive ref : way.getReferrers()) { 698 if (ref instanceof Relation && ref.isUsable()) { 699 affectedRelations.add((ref.getDisplayName(DefaultNameFormatter.getInstance()))); 700 } 701 } 702 } 703 final String msg1 = trn("Unglueing affected {0} relation: {1}", "Unglueing affected {0} relations: {1}", 704 affectedRelations.size(), affectedRelations.size(), Utils.joinAsHtmlUnorderedList(affectedRelations)); 705 final String msg2 = trn("Ensure that the relation has not been broken!", "Ensure that the relations have not been broken!", 706 affectedRelations.size()); 707 new Notification("<html>" + msg1 + msg2).setIcon(JOptionPane.WARNING_MESSAGE).show(); 678 708 } 679 709 }
Note:
See TracChangeset
for help on using the changeset viewer.