Ignore:
Timestamp:
2017-09-06T02:03:14+02:00 (2 years ago)
Author:
Don-vip
Message:

see #15229 - see #15182 - see #13036 - remove GUI stuff from Command and DeleteCommand

Location:
trunk/src/org/openstreetmap/josm/actions
Files:
5 edited

Legend:

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

    r12630 r12749  
    4646        setEnabled(selection != null && !selection.isEmpty());
    4747    }
     48
     49    /**
     50     * Check whether user is about to delete data outside of the download area.
     51     * Request confirmation if he is.
     52     * @param primitives the primitives to operate on
     53     * @param ignore {@code null} or a primitive to be ignored
     54     * @return true, if operating on outlying primitives is OK; false, otherwise
     55     * @since 12749 (moved from DeleteCommand)
     56     */
     57    public static boolean checkAndConfirmOutlyingDelete(Collection<? extends OsmPrimitive> primitives,
     58            Collection<? extends OsmPrimitive> ignore) {
     59        return checkAndConfirmOutlyingOperation("delete",
     60                tr("Delete confirmation"),
     61                tr("You are about to delete nodes outside of the area you have downloaded."
     62                        + "<br>"
     63                        + "This can cause problems because other objects (that you do not see) might use them."
     64                        + "<br>"
     65                        + "Do you really want to delete?"),
     66                tr("You are about to delete incomplete objects."
     67                        + "<br>"
     68                        + "This will cause problems because you don''t see the real object."
     69                        + "<br>" + "Do you really want to delete?"),
     70                primitives, ignore);
     71    }
    4872}
  • trunk/src/org/openstreetmap/josm/actions/JoinAreasAction.java

    r12728 r12749  
    505505
    506506        // TODO: Only display this warning when nodes outside dataSourceArea are deleted
    507         boolean ok = Command.checkAndConfirmOutlyingOperation("joinarea", tr("Join area confirmation"),
     507        boolean ok = checkAndConfirmOutlyingOperation("joinarea", tr("Join area confirmation"),
    508508                trn("The selected way has nodes outside of the downloaded data region.",
    509509                    "The selected ways have nodes outside of the downloaded data region.",
  • trunk/src/org/openstreetmap/josm/actions/JosmAction.java

    r12675 r12749  
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
     6import java.awt.GridBagLayout;
    67import java.awt.event.KeyEvent;
    78import java.util.Collection;
     
    1112
    1213import javax.swing.AbstractAction;
     14import javax.swing.JOptionPane;
     15import javax.swing.JPanel;
    1316
    1417import org.openstreetmap.josm.Main;
     18import org.openstreetmap.josm.command.Command;
    1519import org.openstreetmap.josm.data.SelectionChangedListener;
    1620import org.openstreetmap.josm.data.osm.DataSet;
     
    1822import org.openstreetmap.josm.data.osm.event.DatasetEventManager.FireMode;
    1923import org.openstreetmap.josm.data.osm.event.SelectionEventManager;
     24import org.openstreetmap.josm.gui.ConditionalOptionPaneUtil;
    2025import org.openstreetmap.josm.gui.MainApplication;
    2126import org.openstreetmap.josm.gui.layer.LayerManager.LayerAddEvent;
     
    2732import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeListener;
    2833import org.openstreetmap.josm.gui.progress.swing.PleaseWaitProgressMonitor;
     34import org.openstreetmap.josm.gui.widgets.JMultilineLabel;
    2935import org.openstreetmap.josm.tools.Destroyable;
    3036import org.openstreetmap.josm.tools.ImageProvider;
     
    394400        }
    395401    }
     402
     403    /**
     404     * Check whether user is about to operate on data outside of the download area.
     405     * Request confirmation if he is.
     406     *
     407     * @param operation the operation name which is used for setting some preferences
     408     * @param dialogTitle the title of the dialog being displayed
     409     * @param outsideDialogMessage the message text to be displayed when data is outside of the download area
     410     * @param incompleteDialogMessage the message text to be displayed when data is incomplete
     411     * @param primitives the primitives to operate on
     412     * @param ignore {@code null} or a primitive to be ignored
     413     * @return true, if operating on outlying primitives is OK; false, otherwise
     414     * @since 12749 (moved from Command)
     415     */
     416    public static boolean checkAndConfirmOutlyingOperation(String operation,
     417            String dialogTitle, String outsideDialogMessage, String incompleteDialogMessage,
     418            Collection<? extends OsmPrimitive> primitives,
     419            Collection<? extends OsmPrimitive> ignore) {
     420        int checkRes = Command.checkOutlyingOrIncompleteOperation(primitives, ignore);
     421        if ((checkRes & Command.IS_OUTSIDE) != 0) {
     422            JPanel msg = new JPanel(new GridBagLayout());
     423            msg.add(new JMultilineLabel("<html>" + outsideDialogMessage + "</html>"));
     424            boolean answer = ConditionalOptionPaneUtil.showConfirmationDialog(
     425                    operation + "_outside_nodes",
     426                    Main.parent,
     427                    msg,
     428                    dialogTitle,
     429                    JOptionPane.YES_NO_OPTION,
     430                    JOptionPane.QUESTION_MESSAGE,
     431                    JOptionPane.YES_OPTION);
     432            if (!answer)
     433                return false;
     434        }
     435        if ((checkRes & Command.IS_INCOMPLETE) != 0) {
     436            JPanel msg = new JPanel(new GridBagLayout());
     437            msg.add(new JMultilineLabel("<html>" + incompleteDialogMessage + "</html>"));
     438            boolean answer = ConditionalOptionPaneUtil.showConfirmationDialog(
     439                    operation + "_incomplete",
     440                    Main.parent,
     441                    msg,
     442                    dialogTitle,
     443                    JOptionPane.YES_NO_OPTION,
     444                    JOptionPane.QUESTION_MESSAGE,
     445                    JOptionPane.YES_OPTION);
     446            if (!answer)
     447                return false;
     448        }
     449        return true;
     450    }
    396451}
  • trunk/src/org/openstreetmap/josm/actions/SimplifyWayAction.java

    r12641 r12749  
    5353
    5454    protected boolean confirmWayWithNodesOutsideBoundingBox(List<? extends OsmPrimitive> primitives) {
    55         return DeleteCommand.checkAndConfirmOutlyingDelete(primitives, null);
     55        return DeleteAction.checkAndConfirmOutlyingDelete(primitives, null);
    5656    }
    5757
  • trunk/src/org/openstreetmap/josm/actions/UnGlueAction.java

    r12726 r12749  
    663663        if (selectedNode != null)
    664664            primitives.add(selectedNode);
    665         final boolean ok = Command.checkAndConfirmOutlyingOperation("unglue",
     665        final boolean ok = checkAndConfirmOutlyingOperation("unglue",
    666666                tr("Unglue confirmation"),
    667667                tr("You are about to unglue nodes outside of the area you have downloaded."
Note: See TracChangeset for help on using the changeset viewer.