Changeset 18181 in josm


Ignore:
Timestamp:
2021-08-26T15:33:04+02:00 (3 years ago)
Author:
Don-vip
Message:

fix #4504 - display notification when an outlying operation is ignored due to saved preference

File:
1 edited

Legend:

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

    r16553 r18181  
    2424import org.openstreetmap.josm.gui.ConditionalOptionPaneUtil;
    2525import org.openstreetmap.josm.gui.MainApplication;
     26import org.openstreetmap.josm.gui.Notification;
    2627import org.openstreetmap.josm.gui.help.HelpUtil;
    2728import org.openstreetmap.josm.gui.layer.LayerManager.LayerAddEvent;
     
    513514        int checkRes = Command.checkOutlyingOrIncompleteOperation(primitives, ignore);
    514515        if ((checkRes & Command.IS_OUTSIDE) != 0) {
    515             JPanel msg = new JPanel(new GridBagLayout());
    516             msg.add(new JMultilineLabel("<html>" + outsideDialogMessage + "</html>"));
    517             boolean answer = ConditionalOptionPaneUtil.showConfirmationDialog(
    518                     operation + "_outside_nodes",
    519                     MainApplication.getMainFrame(),
    520                     msg,
    521                     dialogTitle,
    522                     JOptionPane.YES_NO_OPTION,
    523                     JOptionPane.QUESTION_MESSAGE,
    524                     JOptionPane.YES_OPTION);
     516            boolean answer = showConfirmOutlyingOperationDialog(operation + "_outside_nodes", outsideDialogMessage, dialogTitle);
    525517            if (!answer)
    526518                return false;
    527519        }
    528520        if ((checkRes & Command.IS_INCOMPLETE) != 0) {
    529             JPanel msg = new JPanel(new GridBagLayout());
    530             msg.add(new JMultilineLabel("<html>" + incompleteDialogMessage + "</html>"));
    531             boolean answer = ConditionalOptionPaneUtil.showConfirmationDialog(
    532                     operation + "_incomplete",
    533                     MainApplication.getMainFrame(),
    534                     msg,
    535                     dialogTitle,
    536                     JOptionPane.YES_NO_OPTION,
    537                     JOptionPane.QUESTION_MESSAGE,
    538                     JOptionPane.YES_OPTION);
     521            boolean answer = showConfirmOutlyingOperationDialog(operation + "_incomplete", incompleteDialogMessage, dialogTitle);
    539522            if (!answer)
    540523                return false;
     
    542525        return true;
    543526    }
     527
     528    private static boolean showConfirmOutlyingOperationDialog(String preferenceKey, String dialogMessage, String dialogTitle) {
     529        JPanel msg = new JPanel(new GridBagLayout());
     530        msg.add(new JMultilineLabel("<html>" + dialogMessage + "</html>"));
     531        boolean answer = ConditionalOptionPaneUtil.showConfirmationDialog(
     532                preferenceKey,
     533                MainApplication.getMainFrame(),
     534                msg,
     535                dialogTitle,
     536                JOptionPane.YES_NO_OPTION,
     537                JOptionPane.QUESTION_MESSAGE,
     538                JOptionPane.YES_OPTION);
     539        if (!answer && JOptionPane.NO_OPTION == ConditionalOptionPaneUtil.getDialogReturnValue(preferenceKey)) {
     540            String message = tr("Operation was not performed, as per {0} preference", preferenceKey);
     541            new Notification(message).show();
     542            Logging.info(message);
     543        }
     544        return answer;
     545    }
    544546}
Note: See TracChangeset for help on using the changeset viewer.