Changeset 16558 in josm for trunk


Ignore:
Timestamp:
2020-06-07T15:56:16+02:00 (4 years ago)
Author:
GerdP
Message:

fix #19138: Warn when you try to delete a node which is part of a way which is hidden by a filter

  • add check and dialog similar to that which is done when a node is moved
File:
1 edited

Legend:

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

    r15152 r16558  
    2323import org.openstreetmap.josm.data.osm.Relation;
    2424import org.openstreetmap.josm.data.osm.WaySegment;
     25import org.openstreetmap.josm.gui.ExtendedDialog;
    2526import org.openstreetmap.josm.gui.MainApplication;
    2627import org.openstreetmap.josm.gui.MapFrame;
     
    161162        if (c != null) {
    162163            UndoRedoHandler.getInstance().add(c);
     164            if (changesHiddenWay(c)) {
     165                final ConfirmDeleteDialog ed = new ConfirmDeleteDialog();
     166                ed.setContent(tr("Are you sure that you want to delete elements with attached ways that are hidden by filters?"));
     167                ed.toggleEnable("deletedHiddenElements");
     168                if (ed.showDialog().getValue() != 1) {
     169                    UndoRedoHandler.getInstance().undo(1);
     170                    return;
     171                }
     172            }
     173
    163174            //FIXME: This should not be required, DeleteCommand should update the selection, otherwise undo/redo won't work.
    164175            lm.getEditDataSet().setSelected();
     
    426437        giveUserFeedback(oldEvent, modifiers);
    427438    }
     439
     440    private boolean changesHiddenWay(Command c) {
     441        return c.getParticipatingPrimitives().stream().anyMatch(OsmPrimitive::isDisabledAndHidden);
     442    }
     443
     444    static class ConfirmDeleteDialog extends ExtendedDialog {
     445        ConfirmDeleteDialog() {
     446            super(MainApplication.getMainFrame(),
     447                    tr("Delete elements"),
     448                    tr("Delete them"), tr("Undo delete"));
     449            setButtonIcons("dialogs/delete", "cancel");
     450            setCancelButton(2);
     451        }
     452    }
     453
    428454}
Note: See TracChangeset for help on using the changeset viewer.