Class ConditionalOptionPaneUtil
They wrap the methods provided by JOptionPane. Within JOSM you should use these
methods rather than the bare methods from JOptionPane because the methods provided
by ConditionalOptionPaneUtil ensure that a dialog window is always on top and isn't hidden by one of the
JOSM windows for detached dialogs, relation editors, history browser and the like.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThis is a message panel used in dialogs which can be enabled/disabled with a preference setting.(package private) static enumAn enum designating how long to not show this message again, i.e., for how long to store -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final StringThe prefix for config optionsstatic final inta set indication that (preference key) is or may be stored for the currently active bulk operation(preference key => return value) mappings valid for the current session(preference key => return value) mappings valid for the current operation (no, those two maps cannot be combined) -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivatethis is a static utility class only -
Method Summary
Modifier and TypeMethodDescriptionstatic voidendBulkOperation(String prefKey) Marks the ending of a bulk operation.static intgetDialogReturnValue(String prefKey) Returns the preference value for the preference key "message." +prefKey+ ".value".static booleanisInBulkOperation(String prefKey) Determines whether the key has been marked to be part of a bulk operation (in order to provide a "Do not show again (this operation)" option).private static booleanisYesOrNo(int returnCode) static booleanshowConfirmationDialog(String preferenceKey, Component parent, Object message, String title, int optionType, int messageType, int trueOption) Displays a confirmation dialog with some option buttons given byoptionType.static voidshowMessageDialog(String preferenceKey, Component parent, Object message, String title, int messageType) Displays an message in modal dialog with an OK button.static intshowOptionDialog(String preferenceKey, Component parent, Object message, String title, int optionType, int messageType, Object[] options, Object defaultOption) Displays an confirmation dialog with some option buttons given byoptionType.static voidstartBulkOperation(String prefKey) Marks the beginning of a bulk operation in order to provide a "Do not show again (this operation)" option.
-
Field Details
-
DIALOG_DISABLED_OPTION
- See Also:
-
sessionChoices
(preference key => return value) mappings valid for the current operation (no, those two maps cannot be combined) -
immediateChoices
(preference key => return value) mappings valid for the current session -
immediateActive
a set indication that (preference key) is or may be stored for the currently active bulk operation -
CONFIG_PREFIX
The prefix for config options- See Also:
-
-
Constructor Details
-
ConditionalOptionPaneUtil
private ConditionalOptionPaneUtil()this is a static utility class only
-
-
Method Details
-
getDialogReturnValue
Returns the preference value for the preference key "message." +prefKey+ ".value". The default value if the preference key is missing is -1.- Parameters:
prefKey- the preference key- Returns:
- the preference value for the preference key "message." +
prefKey+ ".value"
-
startBulkOperation
Marks the beginning of a bulk operation in order to provide a "Do not show again (this operation)" option.- Parameters:
prefKey- the preference key
-
isInBulkOperation
Determines whether the key has been marked to be part of a bulk operation (in order to provide a "Do not show again (this operation)" option).- Parameters:
prefKey- the preference key- Returns:
trueif the key has been marked to be part of a bulk operation
-
endBulkOperation
Marks the ending of a bulk operation. Removes the "Do not show again (this operation)" result value.- Parameters:
prefKey- the preference key
-
showOptionDialog
public static int showOptionDialog(String preferenceKey, Component parent, Object message, String title, int optionType, int messageType, Object[] options, Object defaultOption) Displays an confirmation dialog with some option buttons given byoptionType. It is always on top even if there are other open windows like detached dialogs, relation editors, history browsers and the like.Set
optionTypetoJOptionPane.YES_NO_OPTIONfor a dialog with a YES and a NO button.Set
optionTypetoJOptionPane.YES_NO_CANCEL_OPTIONfor a dialog with a YES, a NO and a CANCEL buttonReturns one of the constants JOptionPane.YES_OPTION, JOptionPane.NO_OPTION, JOptionPane.CANCEL_OPTION or JOptionPane.CLOSED_OPTION depending on the action chosen by the user.
- Parameters:
preferenceKey- the preference keyparent- the parent componentmessage- the messagetitle- the titleoptionType- the option typemessageType- the message typeoptions- a list of optionsdefaultOption- the default option; only meaningful if options is used; can be null- Returns:
- the option selected by user.
JOptionPane.CLOSED_OPTIONif the dialog was closed.
-
showConfirmationDialog
public static boolean showConfirmationDialog(String preferenceKey, Component parent, Object message, String title, int optionType, int messageType, int trueOption) Displays a confirmation dialog with some option buttons given byoptionType. It is always on top even if there are other open windows like detached dialogs, relation editors, history browsers and the like.Set
optionTypetoJOptionPane.YES_NO_OPTIONfor a dialog with a YES and a NO button.Set
optionTypetoJOptionPane.YES_NO_CANCEL_OPTIONfor a dialog with a YES, a NO and a CANCEL buttonReplies true, if the selected option is equal to
trueOption, otherwise false. Replies true, if the dialog is not displayed because the respective preference optionpreferenceKeyis set to false and the user has previously chosentrueOption.- Parameters:
preferenceKey- the preference keyparent- the parent componentmessage- the messagetitle- the titleoptionType- the option typemessageType- the message typetrueOption- if this option is selected the method replies true- Returns:
- true, if the selected option is equal to
trueOption, otherwise false. - See Also:
-
isYesOrNo
-
showMessageDialog
public static void showMessageDialog(String preferenceKey, Component parent, Object message, String title, int messageType) Displays an message in modal dialog with an OK button. Makes sure the dialog is always on top even if there are other open windows like detached dialogs, relation editors, history browsers and the like.If there is a preference with key
preferenceKeyand valuefalsethe dialog is not show.- Parameters:
preferenceKey- the preference keyparent- the parent componentmessage- the messagetitle- the titlemessageType- the message type- See Also:
-