Changeset 2718 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2009-12-31T13:13:43+01:00 (14 years ago)
Author:
stoecker
Message:

remember result of dont-show-again also in ExtendedDialog

File:
1 edited

Legend:

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

    r2715 r2718  
    3131public class ExtendedDialog extends JDialog {
    3232    private int result = 0;
    33     public static final int DialogNotShown = -99;
    3433    public static final int DialogClosedOtherwise = 0;
    3534    private boolean toggleable = false;
     
    3736    private WindowGeometry defaultWindowGeometry = null;
    3837    private String togglePref = "";
     38    private int toggleValue = -1;
    3939    private String toggleCheckboxText = tr("Do not show again");
    4040    private JCheckBox toggleCheckbox = null;
     
    169169        // Check if the user has set the dialog to not be shown again
    170170        if(toggleCheckState(togglePref)) {
    171             result = ExtendedDialog.DialogNotShown;
     171            result = toggleValue;
    172172            return this;
    173173        }
     
    185185     * @return int * The selected button. The count starts with 1.
    186186     *             * A return value of ExtendedDialog.DialogClosedOtherwise means the dialog has been closed otherwise.
    187      *             * A return value of ExtendedDialog.DialogNotShown means the
    188      *               dialog has been toggled off in the past
    189187     */
    190188    public int getValue() {
     
    373371     * Calling this will offer the user a "Do not show again" checkbox for the
    374372     * dialog. Default is to not offer the choice; the dialog will be shown
    375      * every time. If the dialog is not shown due to the previous choice of the
    376      * user, the result <code>ExtendedDialog.DialogNotShown</code> is returned
     373     * every time.
    377374     * @param togglePref  The preference to save the checkbox state to
    378375     */
     
    428425        toggleable = togglePref != null && !togglePref.equals("");
    429426
     427        toggleValue = Main.pref.getInteger("message."+togglePref+".value", -1);
    430428        // No identifier given, so return false (= show the dialog)
    431         if(!toggleable)
     429        if(!toggleable || toggleValue == -1)
    432430            return false;
    433431        this.togglePref = togglePref;
     
    444442            return;
    445443        Main.pref.put("message."+ togglePref, !toggleCheckbox.isSelected());
     444        Main.pref.putInteger("message."+togglePref+".value", result);
    446445    }
    447446
Note: See TracChangeset for help on using the changeset viewer.