Changeset 2522 in josm for trunk/src/org
- Timestamp:
- 2009-11-27T22:26:29+01:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/ConditionalOptionPaneUtil.java
r2512 r2522 56 56 57 57 /** 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 /** 58 79 * Displays an confirmation dialog with some option buttons given by <code>optionType</code>. 59 80 * It is always on top even if there are other open windows like detached dialogs, … … 89 110 MessagePanel pnl = new MessagePanel(preferenceKey, message); 90 111 int ret = JOptionPane.showOptionDialog(parent, pnl, title, optionType, messageType, null,options,defaultOption); 91 pnl.remeberDialogShowingEnabled(); 112 113 if(!pnl.getDialogShowingEnabled()) 114 setDialogShowingEnabled(preferenceKey, false); 92 115 return ret; 93 116 } … … 124 147 */ 125 148 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; 128 151 MessagePanel pnl = new MessagePanel(preferenceKey, message); 129 152 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 } 131 157 return ret == trueOption; 132 158 } … … 155 181 MessagePanel pnl = new MessagePanel(preferenceKey, message); 156 182 JOptionPane.showMessageDialog(parent, pnl, title, messageType); 157 pnl.remeberDialogShowingEnabled(); 183 if(!pnl.getDialogShowingEnabled()) 184 setDialogShowingEnabled(preferenceKey, false); 158 185 } 159 186 … … 184 211 185 212 public boolean getDialogShowingEnabled() { 186 return cbShowDialog.isSelected();213 return !cbShowDialog.isSelected(); 187 214 } 188 189 public void remeberDialogShowingEnabled() {190 ConditionalOptionPaneUtil.setDialogShowingEnabled(preferenceKey, !getDialogShowingEnabled());191 }192 215 } 193 216 }
Note:
See TracChangeset
for help on using the changeset viewer.