Ignore:
Timestamp:
2014-01-02T00:58:33+01:00 (12 years ago)
Author:
simon04
Message:

fix #8969 fix #9394 - add "Do not show again (this session)" choice, and in addition "Do not show again (this operation)" if a bulk operation has been marked in the code

The dialog displays 3 or 4 radio boxes with the labels:

  • "Show this dialog again the next time"
  • "Do not show again (this operation)"
  • "Do not show again (this session)"
  • "Do not show again (remembers choice)"
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/ExtendedDialog.java

    r6443 r6594  
    2020import javax.swing.Icon;
    2121import javax.swing.JButton;
    22 import javax.swing.JCheckBox;
    2322import javax.swing.JComponent;
    2423import javax.swing.JDialog;
     
    7978    private String togglePref = "";
    8079    private int toggleValue = -1;
    81     private String toggleCheckboxText = tr("Do not show again (remembers choice)");
    82     private JCheckBox toggleCheckbox = null;
     80    private ConditionalOptionPaneUtil.MessagePanel togglePanel;
    8381    private Component parent;
    8482    private Component content;
     
    372370
    373371        if (toggleable) {
    374             toggleCheckbox = new JCheckBox(toggleCheckboxText);
    375             boolean showDialog = Main.pref.getBoolean("message."+ togglePref, true);
    376             toggleCheckbox.setSelected(!showDialog);
     372            togglePanel = new ConditionalOptionPaneUtil.MessagePanel(null, false);
    377373            gc.gridx = icon != null ? 1 : 0;
    378374            gc.gridy = y++;
    379375            gc.anchor = GridBagConstraints.LINE_START;
    380376            gc.insets = new Insets(5,contentInsets.left,5,contentInsets.right);
    381             cp.add(toggleCheckbox, gc);
     377            cp.add(togglePanel, gc);
    382378        }
    383379
     
    546542
    547543    /**
    548      * Overwrites the default "Don't show again" text of the toggle checkbox
    549      * if you want to give more information. Only has an effect if
    550      * <code>toggleEnable</code> is set.
    551      * @param text The toggle checkbox text
    552      * @return {@code this}
    553      */
    554     public ExtendedDialog setToggleCheckboxText(String text) {
    555         this.toggleCheckboxText = text;
    556         return this;
    557     }
    558 
    559     /**
    560544     * Sets the button that will react to ENTER.
    561545     * @param defaultButtonIdx The button index (starts to )
     
    597581    public final boolean toggleCheckState() {
    598582        toggleable = togglePref != null && !togglePref.isEmpty();
    599 
    600         toggleValue = Main.pref.getInteger("message."+togglePref+".value", -1);
    601         // No identifier given, so return false (= show the dialog)
    602         if (!toggleable || toggleValue == -1)
    603             return false;
    604         // The pref is true, if the dialog should be shown.
    605         return !(Main.pref.getBoolean("message."+ togglePref, true));
     583        toggleValue = ConditionalOptionPaneUtil.getDialogReturnValue(togglePref);
     584        return toggleable && toggleValue != -1;
    606585    }
    607586
     
    612591    private void toggleSaveState() {
    613592        if (!toggleable ||
    614                 toggleCheckbox == null ||
     593                togglePanel == null ||
    615594                cancelButtonIdx.contains(result) ||
    616595                result == ExtendedDialog.DialogClosedOtherwise)
    617596            return;
    618         Main.pref.put("message."+ togglePref, !toggleCheckbox.isSelected());
    619         Main.pref.putInteger("message."+togglePref+".value", result);
     597        togglePanel.getNotShowAgain().store(togglePref, result);
    620598    }
    621599
Note: See TracChangeset for help on using the changeset viewer.