Changeset 2929 in josm for trunk/src/org
- Timestamp:
- 2010-02-03T05:23:56+01:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/ConditionalOptionPaneUtil.java
r2831 r2929 87 87 * a NO and a CANCEL button 88 88 * 89 * Re plies true, if the selected option is equal to <code>trueOption</code>, otherwise false.90 * Replies true, if the dialog is not displayed because the respective preference option91 * <code>preferenceKey</code> is set to false.89 * Returns one of the constants JOptionPane.YES_OPTION, JOptionPane.NO_OPTION, 90 * JOptionPane.CANCEL_OPTION or JOptionPane.CLOSED_OPTION depending on the action chosen by 91 * the user. 92 92 * 93 93 * @param preferenceKey the preference key … … 100 100 * @param defaultOption the default option 101 101 * 102 * 103 * @return the index of the selected option. {@see JOptionPane#CLOSED_OPTION} if the dialog was closed. 104 * {@see ConditionalOptionPaneUtil#DIALOG_DISABLED_OPTION} if the dialog is disabled. 105 * 102 * @return the option selected by user. {@see JOptionPane#CLOSED_OPTION} if the dialog was closed. 106 103 */ 107 104 static public int showOptionDialog(String preferenceKey, Component parent, Object message, String title, int optionType, int messageType, Object [] options, Object defaultOption) throws HeadlessException { 108 if (!getDialogShowingEnabled(preferenceKey)) 109 return DIALOG_DISABLED_OPTION; 105 int ret = getDialogReturnValue(preferenceKey); 106 if (!getDialogShowingEnabled(preferenceKey) && ((ret == JOptionPane.YES_OPTION) || (ret == JOptionPane.NO_OPTION))) 107 return ret; 110 108 MessagePanel pnl = new MessagePanel(false, message); 111 int ret = JOptionPane.showOptionDialog(parent, pnl, title, optionType, messageType, null,options,defaultOption);112 113 if (!pnl.getDialogShowingEnabled())109 ret = JOptionPane.showOptionDialog(parent, pnl, title, optionType, messageType, null, options, defaultOption); 110 111 if (((ret == JOptionPane.YES_OPTION) || (ret == JOptionPane.NO_OPTION)) && !pnl.getDialogShowingEnabled()) { 114 112 setDialogShowingEnabled(preferenceKey, false); 113 setDialogReturnValue(preferenceKey, ret); 114 } 115 115 return ret; 116 116 } 117 117 118 118 /** 119 * Displays a nconfirmation dialog with some option buttons given by <code>optionType</code>.119 * Displays a confirmation dialog with some option buttons given by <code>optionType</code>. 120 120 * It is always on top even if there are other open windows like detached dialogs, 121 121 * relation editors, history browsers and the like. … … 129 129 * Replies true, if the selected option is equal to <code>trueOption</code>, otherwise false. 130 130 * Replies true, if the dialog is not displayed because the respective preference option 131 * <code>preferenceKey</code> is set to false. 131 * <code>preferenceKey</code> is set to false and the user has previously chosen 132 * <code>trueOption</code>. 132 133 * 133 134 * @param preferenceKey the preference key … … 147 148 */ 148 149 static public boolean showConfirmationDialog(String preferenceKey, Component parent, Object message, String title, int optionType, int messageType, int trueOption) throws HeadlessException { 149 if (!getDialogShowingEnabled(preferenceKey) && (getDialogReturnValue(preferenceKey) >= 0)) 150 return getDialogReturnValue(preferenceKey) == trueOption; 150 int ret = getDialogReturnValue(preferenceKey); 151 if (!getDialogShowingEnabled(preferenceKey) && ((ret == JOptionPane.YES_OPTION) || (ret == JOptionPane.NO_OPTION))) 152 return ret == trueOption; 151 153 MessagePanel pnl = new MessagePanel(false, message); 152 intret = JOptionPane.showConfirmDialog(parent, pnl, title, optionType, messageType);153 if (( ret >= 0) && !pnl.getDialogShowingEnabled()) {154 ret = JOptionPane.showConfirmDialog(parent, pnl, title, optionType, messageType); 155 if (((ret == JOptionPane.YES_OPTION) || (ret == JOptionPane.NO_OPTION)) && !pnl.getDialogShowingEnabled()) { 154 156 setDialogShowingEnabled(preferenceKey, false); 155 157 setDialogReturnValue(preferenceKey, ret); … … 181 183 MessagePanel pnl = new MessagePanel(false, message); 182 184 JOptionPane.showMessageDialog(parent, pnl, title, messageType); 183 if(!pnl.getDialogShowingEnabled()) 185 if(!pnl.getDialogShowingEnabled()) { 184 186 setDialogShowingEnabled(preferenceKey, false); 187 } 185 188 } 186 189
Note:
See TracChangeset
for help on using the changeset viewer.