Package org.openstreetmap.josm.gui
Class HelpAwareOptionPane
- java.lang.Object
-
- org.openstreetmap.josm.gui.HelpAwareOptionPane
-
public final class HelpAwareOptionPane extends java.lang.Object
Utility methods that display an option dialog with an additional help button that links to the JOSM help
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
HelpAwareOptionPane.ButtonSpec
A specification of a button that should be added to the options dialogprivate static class
HelpAwareOptionPane.DefaultAction
private static class
HelpAwareOptionPane.HelpAction
-
Constructor Summary
Constructors Modifier Constructor Description private
HelpAwareOptionPane()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static javax.swing.JButton
createHelpButton(java.lang.String helpTopic)
Creates the help buttonprivate static java.util.List<javax.swing.JButton>
createOptionButtons(HelpAwareOptionPane.ButtonSpec[] options, java.lang.String helpTopic)
Creates the list buttons to be displayed in the option pane dialog.private static void
doShowOptionDialog(java.awt.Component parentComponent, java.lang.String title, HelpAwareOptionPane.ButtonSpec[] options, HelpAwareOptionPane.ButtonSpec defaultOption, java.lang.String helpTopic, java.util.List<javax.swing.JButton> buttons, javax.swing.JOptionPane pane)
static void
showMessageDialogInEDT(java.awt.Component parentComponent, java.lang.Object msg, java.lang.String title, int messageType, java.lang.String helpTopic)
Run it in Event Dispatch Thread.static int
showOptionDialog(java.awt.Component parentComponent, java.lang.Object msg, java.lang.String title, int messageType, java.lang.String helpTopic)
Displays an option dialog which is aware of a help context.static int
showOptionDialog(java.awt.Component parentComponent, java.lang.Object msg, java.lang.String title, int messageType, javax.swing.Icon icon, HelpAwareOptionPane.ButtonSpec[] options, HelpAwareOptionPane.ButtonSpec defaultOption, java.lang.String helpTopic)
Displays an option dialog which is aware of a help context.
-
-
-
Constructor Detail
-
HelpAwareOptionPane
private HelpAwareOptionPane()
-
-
Method Detail
-
createOptionButtons
private static java.util.List<javax.swing.JButton> createOptionButtons(HelpAwareOptionPane.ButtonSpec[] options, java.lang.String helpTopic)
Creates the list buttons to be displayed in the option pane dialog.- Parameters:
options
- the option. If null, just creates an OK button and a help buttonhelpTopic
- the help topic. The context sensitive help of all buttons is equal to the context sensitive help of the whole dialog- Returns:
- the list of buttons
-
createHelpButton
private static javax.swing.JButton createHelpButton(java.lang.String helpTopic)
Creates the help button- Parameters:
helpTopic
- the help topic- Returns:
- the help button
-
showOptionDialog
public static int showOptionDialog(java.awt.Component parentComponent, java.lang.Object msg, java.lang.String title, int messageType, javax.swing.Icon icon, HelpAwareOptionPane.ButtonSpec[] options, HelpAwareOptionPane.ButtonSpec defaultOption, java.lang.String helpTopic)
Displays an option dialog which is aware of a help context. IfhelpTopic
isn't null, the dialog includes a "Help" button and launches the help browser if the user presses F1. If the user clicks on the "Help" button the option dialog remains open and JOSM launches the help browser.helpTopic
is the trailing part of a JOSM online help URL, i.e. the part after the leadinghttps://josm.openstreetmap.de/wiki/Help
. It should start with a leading '/' and it may include an anchor after a '#'.Examples
- /Dialogs/RelationEditor
- /Dialogs/RelationEditor#ConflictInData
- Parameters:
parentComponent
- the parent componentmsg
- the messagetitle
- the titlemessageType
- the message type (seeJOptionPane
)icon
- the icon to display. Can be null.options
- the list of options to display. Can be null.defaultOption
- the default option. Can be null.helpTopic
- the help topic. Can be null.- Returns:
- the index of the selected option or
JOptionPane.CLOSED_OPTION
-
doShowOptionDialog
private static void doShowOptionDialog(java.awt.Component parentComponent, java.lang.String title, HelpAwareOptionPane.ButtonSpec[] options, HelpAwareOptionPane.ButtonSpec defaultOption, java.lang.String helpTopic, java.util.List<javax.swing.JButton> buttons, javax.swing.JOptionPane pane)
-
showOptionDialog
public static int showOptionDialog(java.awt.Component parentComponent, java.lang.Object msg, java.lang.String title, int messageType, java.lang.String helpTopic)
Displays an option dialog which is aware of a help context.- Parameters:
parentComponent
- the parent componentmsg
- the messagetitle
- the titlemessageType
- the message type (seeJOptionPane
)helpTopic
- the help topic. Can be null.- Returns:
- the index of the selected option or
JOptionPane.CLOSED_OPTION
- See Also:
showOptionDialog(Component, Object, String, int, Icon, ButtonSpec[], ButtonSpec, String)
-
showMessageDialogInEDT
public static void showMessageDialogInEDT(java.awt.Component parentComponent, java.lang.Object msg, java.lang.String title, int messageType, java.lang.String helpTopic)
Run it in Event Dispatch Thread. This version does not return anything, so it is more likeshowMessageDialog
.It can be used, when you need to show a message dialog from a worker thread, e.g. from
PleaseWaitRunnable
.- Parameters:
parentComponent
- the parent componentmsg
- the messagetitle
- the titlemessageType
- the message type (seeJOptionPane
)helpTopic
- the help topic. Can be null.
-
-