- Timestamp:
- 2015-11-02T20:27:07+01:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java
r8931 r8977 54 54 import org.openstreetmap.josm.tools.Pair; 55 55 import org.openstreetmap.josm.tools.Shortcut; 56 import org.openstreetmap.josm.tools.Utils; 56 57 57 58 /** … … 810 811 811 812 /** 812 * Present warning in case of large and possibly unwanted movements and undo 813 * unwanted movements. 813 * Present warning in the following cases and undo unwanted movements: <ul> 814 * <li>large and possibly unwanted movements</li> 815 * <li>movement of node with attached ways that are hidden by filters</li> 816 * </ul> 814 817 * 815 818 * @param e the mouse event causing the action (mouse released) 816 819 */ 817 820 private void confirmOrUndoMovement(MouseEvent e) { 821 if (movesHiddenWay()) { 822 final ExtendedDialog ed = new ConfirmMoveDialog(); 823 ed.setContent(tr("Are you sure that you want to move elements with attached ways that are hidden by filters?")); 824 ed.toggleEnable("movedHiddenElements"); 825 ed.showDialog(); 826 if (ed.getValue() != 1) { 827 Main.main.undoRedo.undo(); 828 } 829 } 818 830 int max = Main.pref.getInteger("warn.move.maxelements", 20), limit = max; 819 831 for (OsmPrimitive osm : getCurrentDataSet().getSelected()) { … … 826 838 } 827 839 if (limit < 0) { 828 ExtendedDialog ed = new ExtendedDialog( 829 Main.parent, 830 tr("Move elements"), 831 new String[]{tr("Move them"), tr("Undo move")}); 832 ed.setButtonIcons(new String[]{"reorder", "cancel"}); 840 final ExtendedDialog ed = new ConfirmMoveDialog(); 833 841 ed.setContent( 834 842 /* for correct i18n of plural forms - see #9110 */ … … 836 844 "You moved more than {0} elements. " + "Moving a large number of elements is often an error.\n" + "Really move them?", 837 845 max, max)); 838 ed.setCancelButton(2);839 846 ed.toggleEnable("movedManyElements"); 840 847 ed.showDialog(); … … 849 856 } 850 857 getCurrentDataSet().fireSelectionChanged(); 858 } 859 860 static class ConfirmMoveDialog extends ExtendedDialog { 861 public ConfirmMoveDialog() { 862 super(Main.parent, 863 tr("Move elements"), 864 new String[]{tr("Move them"), tr("Undo move")}); 865 setButtonIcons(new String[]{"reorder", "cancel"}); 866 setCancelButton(2); 867 868 } 869 } 870 871 private boolean movesHiddenWay() { 872 final Collection<OsmPrimitive> elementsToTest = new HashSet<>(getCurrentDataSet().getSelected()); 873 for (Way osm : Utils.filteredCollection(getCurrentDataSet().getSelected(), Way.class)) { 874 elementsToTest.addAll(osm.getNodes()); 875 } 876 for (OsmPrimitive node : Utils.filteredCollection(elementsToTest, Node.class)) { 877 for (Way ref : Utils.filteredCollection(node.getReferrers(), Way.class)) { 878 if (ref.isDisabledAndHidden()) { 879 return true; 880 } 881 } 882 } 883 return false; 851 884 } 852 885
Note:
See TracChangeset
for help on using the changeset viewer.