Ticket #4011: ConfirmationDialog.patch
| File ConfirmationDialog.patch, 2.8 KB (added by , 16 years ago) |
|---|
-
src/org/openstreetmap/josm/gui/ConditionalOptionPaneUtil.java
55 55 } 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, 60 81 * relation editors, history browsers and the like. … … 123 144 * @see JOptionPane#ERROR_MESSAGE 124 145 */ 125 146 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;147 if (!getDialogShowingEnabled(preferenceKey) && (getDialogReturnValue(preferenceKey) >= 0)) 148 return getDialogReturnValue(preferenceKey) == trueOption; 128 149 MessagePanel pnl = new MessagePanel(preferenceKey, message); 129 150 int ret = JOptionPane.showConfirmDialog(parent, pnl, title, optionType, messageType); 130 pnl.remeberDialogShowingEnabled(); 151 if ((ret >= 0) && !pnl.getDialogShowingEnabled()) { 152 setDialogShowingEnabled(preferenceKey, false); 153 setDialogReturnValue(preferenceKey, ret); 154 } 131 155 return ret == trueOption; 132 156 } 133 157 … … 183 207 } 184 208 185 209 public boolean getDialogShowingEnabled() { 186 return cbShowDialog.isSelected();210 return !cbShowDialog.isSelected(); 187 211 } 188 212 189 213 public void remeberDialogShowingEnabled() { 190 ConditionalOptionPaneUtil.setDialogShowingEnabled(preferenceKey, !getDialogShowingEnabled());214 ConditionalOptionPaneUtil.setDialogShowingEnabled(preferenceKey, getDialogShowingEnabled()); 191 215 } 192 216 } 193 217 }
