public final class ConditionalOptionPaneUtil extends Object
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.Modifier and Type | Class and Description |
---|---|
private static class |
ConditionalOptionPaneUtil.MessagePanel
This is a message panel used in dialogs which can be enabled/disabled with a preference
setting.
|
Modifier and Type | Field and Description |
---|---|
static int |
DIALOG_DISABLED_OPTION |
Modifier | Constructor and Description |
---|---|
private |
ConditionalOptionPaneUtil()
this is a static utility class only
|
Modifier and Type | Method and Description |
---|---|
static Integer |
getDialogReturnValue(String prefKey)
Returns the preference value for the preference key "message." +
prefKey + ".value". |
static boolean |
getDialogShowingEnabled(String prefKey)
Replies the preference value for the preference key "message." +
prefKey . |
static void |
setDialogReturnValue(String prefKey,
Integer value)
sets the value for the preference key "message." +
prefKey + ".value". |
static void |
setDialogShowingEnabled(String prefKey,
boolean enabled)
sets the value for the preference key "message." +
prefKey . |
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 by
optionType . |
static void |
showMessageDialog(String preferenceKey,
Component parent,
Object message,
String title,
int messageType)
Displays an message in modal dialog with an OK button.
|
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 by
optionType . |
public static final int DIALOG_DISABLED_OPTION
private ConditionalOptionPaneUtil()
public static boolean getDialogShowingEnabled(String prefKey)
prefKey
.
The default value if the preference key is missing is true.prefKey
- the preference keyprefKey
public static void setDialogShowingEnabled(String prefKey, boolean enabled)
prefKey
.prefKey
- the keyenabled
- the valuepublic static Integer getDialogReturnValue(String prefKey)
prefKey
+ ".value".
The default value if the preference key is missing is -1.prefKey
- the preference keyprefKey
+ ".value"public static void setDialogReturnValue(String prefKey, Integer value)
prefKey
+ ".value".prefKey
- the keyvalue
- the valuepublic static int showOptionDialog(String preferenceKey, Component parent, Object message, String title, int optionType, int messageType, Object[] options, Object defaultOption) throws HeadlessException
optionType
.
It is always on top even if there are other open windows like detached dialogs,
relation editors, history browsers and the like.
Set optionType
to JOptionPane.YES_NO_OPTION
for a dialog with a YES and
a NO button.
Set optionType
to JOptionPane.YES_NO_CANCEL_OPTION
for a dialog with a YES,
a NO and a CANCEL button
Returns 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.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 nullJOptionPane.CLOSED_OPTION
if the dialog was closed.HeadlessException
public static boolean showConfirmationDialog(String preferenceKey, Component parent, Object message, String title, int optionType, int messageType, int trueOption) throws HeadlessException
optionType
.
It is always on top even if there are other open windows like detached dialogs,
relation editors, history browsers and the like.
Set optionType
to JOptionPane.YES_NO_OPTION
for a dialog with a YES and
a NO button.
Set optionType
to JOptionPane.YES_NO_CANCEL_OPTION
for a dialog with a YES,
a NO and a CANCEL button
Replies true, if the selected option is equal to trueOption
, otherwise false.
Replies true, if the dialog is not displayed because the respective preference option
preferenceKey
is set to false and the user has previously chosen
trueOption
.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 truetrueOption
, otherwise false.HeadlessException
JOptionPane.INFORMATION_MESSAGE
,
JOptionPane.WARNING_MESSAGE
,
JOptionPane.ERROR_MESSAGE
public static void showMessageDialog(String preferenceKey, Component parent, Object message, String title, int messageType)
preferenceKey
and value false
the dialog is not show.preferenceKey
- the preference keyparent
- the parent componentmessage
- the messagetitle
- the titlemessageType
- the message typeJOptionPane.INFORMATION_MESSAGE
,
JOptionPane.WARNING_MESSAGE
,
JOptionPane.ERROR_MESSAGE