Package org.esa.snap.rcp.util
Class Dialogs
- java.lang.Object
-
- org.esa.snap.rcp.util.Dialogs
-
public class Dialogs extends Object
Utility class which is used to display various commonly and frequently used message dialogs.- Since:
- 2.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Dialogs.Answer
-
Field Summary
Fields Modifier and Type Field Description static String
PREF_KEY_SUFFIX_DECISION
static String
PREF_KEY_SUFFIX_DONTSHOW
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
getDialogTitle(String titleText)
static Dialogs.Answer
requestDecision(String title, String message, boolean allowCancel, String preferencesKey)
Displays a modal dialog which requests a decision from the user.static File
requestFileForOpen(String title, boolean dirsOnly, FileFilter fileFilter, String preferencesKey)
Opens a standard file-open dialog box.static File
requestFileForSave(String title, boolean dirsOnly, FileFilter fileFilter, String defaultExtension, String fileName, JComponent accessory, String preferenceKey)
Opens a standard save dialog box.static Boolean
requestOverwriteDecision(String title, File file)
Opens question dialog asking the user whether or not to overwrite an existing file.static void
showError(String message)
Displays a modal dialog with the provided error message text.static void
showError(String title, String message)
Displays a modal dialog with the provided error message text.static void
showInformation(String message)
Displays a modal dialog with the provided information message text.static void
showInformation(String message, String preferencesKey)
Displays a modal dialog with the provided information message text.static void
showInformation(String title, String message, String preferencesKey)
Displays a modal dialog with the provided information message text.static void
showMessage(String title, String message, int messageType, String preferencesKey)
Displays a modal dialog with the provided message text.static void
showOutOfMemoryError(String message)
Displays a modal dialog indicating an 'Out of Memory'-error with the provided error message text.static void
showWarning(String message)
Displays a modal dialog with the provided warning message text.static void
showWarning(String title, String message, String preferencesKey)
Displays a modal dialog with the provided warning message text.
-
-
-
Field Detail
-
PREF_KEY_SUFFIX_DONTSHOW
public static final String PREF_KEY_SUFFIX_DONTSHOW
- See Also:
- Constant Field Values
-
PREF_KEY_SUFFIX_DECISION
public static final String PREF_KEY_SUFFIX_DECISION
- See Also:
- Constant Field Values
-
-
Method Detail
-
showInformation
public static void showInformation(String message)
Displays a modal dialog with the provided information message text.- Parameters:
message
- The message text to be displayed.
-
showInformation
public static void showInformation(String message, String preferencesKey)
Displays a modal dialog with the provided information message text.- Parameters:
message
- The message text to be displayed.preferencesKey
- If notnull
, a checkbox is displayed, and if checked the dialog will not be displayed again which lets users store the answer
-
showInformation
public static void showInformation(String title, String message, String preferencesKey)
Displays a modal dialog with the provided information message text.- Parameters:
title
- The dialog title. May benull
.message
- The information message text to be displayed.preferencesKey
- If notnull
, a checkbox is displayed, and if checked the dialog will not be displayed again which lets users store the answer
-
showWarning
public static void showWarning(String message)
Displays a modal dialog with the provided warning message text.- Parameters:
message
- The information message text to be displayed.
-
showWarning
public static void showWarning(String title, String message, String preferencesKey)
Displays a modal dialog with the provided warning message text.- Parameters:
title
- The dialog title. May benull
.message
- The warning message text to be displayed.preferencesKey
- If notnull
, a checkbox is displayed, and if checked the dialog will not be displayed again which lets users store the answer
-
showError
public static void showError(String message)
Displays a modal dialog with the provided error message text.- Parameters:
message
- The error message text to be displayed.
-
showError
public static void showError(String title, String message)
Displays a modal dialog with the provided error message text.- Parameters:
title
- The dialog title. May benull
.message
- The error message text to be displayed.
-
showOutOfMemoryError
public static void showOutOfMemoryError(String message)
Displays a modal dialog indicating an 'Out of Memory'-error with the provided error message text. It also displays a hint how to solve the problem.- Parameters:
message
- The error message text to be displayed.
-
showMessage
public static void showMessage(String title, String message, int messageType, String preferencesKey)
Displays a modal dialog with the provided message text.- Parameters:
title
- The dialog title. May benull
.message
- The message text to be displayed.messageType
- The type of the message.preferencesKey
- If notnull
, a checkbox is displayed, and if checked the dialog will not be displayed again which lets users store the answer
-
requestDecision
public static Dialogs.Answer requestDecision(String title, String message, boolean allowCancel, String preferencesKey)
Displays a modal dialog which requests a decision from the user.- Parameters:
title
- The dialog title. May benull
.message
- The question text to be displayed.allowCancel
- Iftrue
, the dialog also offers a cancel button.preferencesKey
- If notnull
, a checkbox is displayed, and if checked the dialog will not be displayed again which lets users store the answer- Returns:
Dialogs.Answer.YES
,Dialogs.Answer.NO
, orDialogs.Answer.CANCELLED
.
-
requestOverwriteDecision
public static Boolean requestOverwriteDecision(String title, File file)
Opens question dialog asking the user whether or not to overwrite an existing file. If the given file does not exists, the question dialog is not shown.- Parameters:
file
- the file to check for existance- Returns:
True
if the user confirms the dialog with 'yes' or the given file does not exist.
False
if the user does not want to overwrite the existing file.
null
if the user canceled the operation.
-
requestFileForOpen
public static File requestFileForOpen(String title, boolean dirsOnly, FileFilter fileFilter, String preferencesKey)
Opens a standard file-open dialog box.- Parameters:
title
- a dialog-box titledirsOnly
- whether or not to select only directoriesfileFilter
- the file filter to be used, can benull
preferencesKey
- the key under which the last directory the user visited is stored- Returns:
- the file selected by the user or
null
if the user canceled file selection
-
requestFileForSave
public static File requestFileForSave(String title, boolean dirsOnly, FileFilter fileFilter, String defaultExtension, String fileName, JComponent accessory, String preferenceKey)
Opens a standard save dialog box.- Parameters:
title
- A dialog-box title.dirsOnly
- Whether or not to select only directories.fileFilter
- The file filter to be used, can benull
.defaultExtension
- The extension used as default.fileName
- The initial filename.accessory
- An accessory UI component to be shown in thefile chooser
, can benull
.preferenceKey
- The key under which the last directory the user visited is stored.- Returns:
- The file selected by the user or
null
if the user cancelled the file selection.
-
-