Changeset 2522 in josm for trunk


Ignore:
Timestamp:
2009-11-27T22:26:29+01:00 (12 years ago)
Author:
stoecker
Message:

fix #4011 - do not show again now remembers what it should do - patch by mjulius

File:
1 edited

Legend:

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

    r2512 r2522  
    5656
    5757    /**
     58     * Returns the preference value for the preference key "message." + <code>prefKey</code> + ".value".
     59     * The default value if the preference key is missing is -1.
     60     *
     61     * @param  the preference key
     62     * @return prefKey the preference value for the preference key "message." + <code>prefKey</code> + ".value"
     63     */
     64    public static Integer getDialogReturnValue(String prefKey) {
     65        return Main.pref.getInteger("message."+prefKey+".value", -1);
     66    }
     67
     68    /**
     69     * sets the value for the preference key "message." + <code>prefKey</code> + ".value".
     70     *
     71     * @param prefKey the key
     72     * @param value the value
     73     */
     74    public static void setDialogReturnValue(String prefKey, Integer value) {
     75        Main.pref.putInteger("message."+prefKey+".value", value);
     76    }
     77
     78    /**
    5879     * Displays an confirmation dialog with some option buttons given by <code>optionType</code>.
    5980     * It is always on top even if there are other open windows like detached dialogs,
     
    89110        MessagePanel pnl = new MessagePanel(preferenceKey, message);
    90111        int ret = JOptionPane.showOptionDialog(parent, pnl, title, optionType, messageType, null,options,defaultOption);
    91         pnl.remeberDialogShowingEnabled();
     112
     113        if(!pnl.getDialogShowingEnabled())
     114            setDialogShowingEnabled(preferenceKey, false);
    92115        return ret;
    93116    }
     
    124147     */
    125148    static public boolean showConfirmationDialog(String preferenceKey, Component parent, Object message, String title, int optionType, int messageType, int trueOption) throws HeadlessException {
    126         if (!getDialogShowingEnabled(preferenceKey))
    127             return true;
     149        if (!getDialogShowingEnabled(preferenceKey) && (getDialogReturnValue(preferenceKey) >= 0))
     150            return getDialogReturnValue(preferenceKey) == trueOption;
    128151        MessagePanel pnl = new MessagePanel(preferenceKey, message);
    129152        int ret = JOptionPane.showConfirmDialog(parent, pnl, title, optionType, messageType);
    130         pnl.remeberDialogShowingEnabled();
     153        if ((ret >= 0) && !pnl.getDialogShowingEnabled()) {
     154            setDialogShowingEnabled(preferenceKey, false);
     155            setDialogReturnValue(preferenceKey, ret);
     156        }
    131157        return ret == trueOption;
    132158    }
     
    155181        MessagePanel pnl = new MessagePanel(preferenceKey, message);
    156182        JOptionPane.showMessageDialog(parent, pnl, title, messageType);
    157         pnl.remeberDialogShowingEnabled();
     183        if(!pnl.getDialogShowingEnabled())
     184            setDialogShowingEnabled(preferenceKey, false);
    158185    }
    159186
     
    184211
    185212        public boolean getDialogShowingEnabled() {
    186             return cbShowDialog.isSelected();
     213            return !cbShowDialog.isSelected();
    187214        }
    188 
    189         public void remeberDialogShowingEnabled() {
    190             ConditionalOptionPaneUtil.setDialogShowingEnabled(preferenceKey, !getDialogShowingEnabled());
    191         }
    192215    }
    193216}
Note: See TracChangeset for help on using the changeset viewer.