java.lang.Objectucot.ui.gui.GUIUtils
public class GUIUtils
Miscallaneous utils used by the grapical userinterface.
Field Summary | |
---|---|
protected static java.lang.String |
DEFAULT_ERROR_HEADER
|
protected static java.lang.String |
DEFAULT_QUESTION_HEADER
|
protected static java.lang.String |
DEFAULT_WARNING_HEADER
|
protected static java.lang.String |
OK_CAPTION
|
Constructor Summary | |
---|---|
GUIUtils()
|
Method Summary | |
---|---|
static void |
centerDialog(javax.swing.JDialog dialog)
This method centers a given dialog to the center of the screen. |
static javax.swing.DefaultCellEditor |
createComboBoxCellEditor(java.lang.String[] values,
java.lang.String self,
java.lang.String selfPointer,
boolean allowSelf,
boolean addEmpty)
This method creates a new JComboBox Cell Editor for a JTable element from the given String array. |
static void |
printError(java.awt.Window win,
java.lang.String errorMessage)
Method for spawning error dialog with default header String
|
static void |
printError(java.awt.Window win,
java.lang.String errorMessage,
java.lang.String header)
Method for spawning error dialog. |
static void |
printInfo(java.awt.Window win,
java.lang.String info,
java.lang.String header)
Method for spawning info dialog. |
static void |
printWarning(java.awt.Window win,
java.lang.String warning)
Method for spawning warning dialog with dafault header String . |
static void |
printWarning(java.awt.Window win,
java.lang.String warning,
java.lang.String header)
Method for spawning warning dialog. |
static int |
questionDialog(java.awt.Window win,
java.lang.String question)
Method for spawning question dialog. |
static int |
questionDialog(java.awt.Window win,
java.lang.String question,
java.lang.String header)
Method for spawning question dialog with YES_NO_OPTION -option. |
static int |
questionDialog(java.awt.Window win,
java.lang.String question,
java.lang.String header,
int options)
Method for spawning question dialog with wanted options. |
static int |
showDialog(java.awt.Window parent,
int messageType,
java.lang.String message,
java.lang.String header,
int options)
Dialog spawner for warnings, errors and questions. |
static java.net.URL |
showOpenFileDialog(java.awt.Component owner,
java.util.Vector<CustomFileFilter> fileFilters)
Default open dialog spawner which assumes that all file types are not required to be shown when any file filters are manually defined. |
static java.net.URL |
showOpenFileDialog(java.awt.Component owner,
java.util.Vector<CustomFileFilter> fileFilters,
boolean acceptAllFileFiltersUsed)
Method for spawning a file chooser dialog. |
static ChoosedFile |
showSaveFileDialog(java.awt.Component owner,
java.util.Vector<CustomFileFilter> fileFilters)
Method for spawning a save file chooser dialog. |
static ChoosedFile |
showSaveFileDialog(java.awt.Component owner,
java.util.Vector<CustomFileFilter> fileFilters,
int fileSelectionMode)
Method for spawning a file save dialog. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final java.lang.String DEFAULT_ERROR_HEADER
protected static final java.lang.String DEFAULT_QUESTION_HEADER
protected static final java.lang.String DEFAULT_WARNING_HEADER
protected static final java.lang.String OK_CAPTION
Constructor Detail |
---|
public GUIUtils()
Method Detail |
---|
public static java.net.URL showOpenFileDialog(java.awt.Component owner, java.util.Vector<CustomFileFilter> fileFilters, boolean acceptAllFileFiltersUsed)
Method for spawning a file chooser dialog.
owner
- Parent of this dialog.fileFilters
- Allowed file extensions.acceptAllFileFiltersUsed
- Defines whether all file types
are allowed or not when any file filters are manually defined.
public static java.net.URL showOpenFileDialog(java.awt.Component owner, java.util.Vector<CustomFileFilter> fileFilters)
Default open dialog spawner which assumes that all file types are not required to be shown when any file filters are manually defined.
owner
- Parent of this dialog.fileFilters
- Allowed file extensions.
public static ChoosedFile showSaveFileDialog(java.awt.Component owner, java.util.Vector<CustomFileFilter> fileFilters, int fileSelectionMode)
Method for spawning a file save dialog.
owner
- Parent of this dialog.fileFilters
- Allowed file extensions.fileSelectionMode
- defines wether the user can select files,
directories or both.
public static ChoosedFile showSaveFileDialog(java.awt.Component owner, java.util.Vector<CustomFileFilter> fileFilters)
Method for spawning a save file chooser dialog.
owner
- Parent of this dialog.fileFilters
- Allowed file extensions.
public static int showDialog(java.awt.Window parent, int messageType, java.lang.String message, java.lang.String header, int options)
Dialog spawner for warnings, errors and questions.
parent
- Parent Window
for this dialog.messageType
- the type of message to be displayed:
ERROR_MESSAGE
,
INFORMATION_MESSAGE
,
WARNING_MESSAGE
,
QUESTION_MESSAGE
, or
PLAIN_MESSAGE
.message
- Message itself.header
- the String
to display in the dialog's title baroptions
- the options to display in the pane:
DEFAULT_OPTION
,
YES_NO_OPTION
,
YES_NO_CANCEL_OPTION, or
OK_CANCEL_OPTION
.
- Returns:
- User's choice.
public static void centerDialog(javax.swing.JDialog dialog)
This method centers a given dialog to the center of the screen.
dialog
- JDialog
to be centered.public static int questionDialog(java.awt.Window win, java.lang.String question)
Method for spawning question dialog.
win
- Parent Window
for this dialog.question
- The question String
to show.
public static void printWarning(java.awt.Window win, java.lang.String warning, java.lang.String header)
Method for spawning warning dialog.
win
- Parent Window
for this dialog.warning
- The warning String
to show.header
- the String
to display in the dialog's title barpublic static void printInfo(java.awt.Window win, java.lang.String info, java.lang.String header)
Method for spawning info dialog.
win
- Parent Window
for this dialog.info
- The info String
to show.header
- the String
to display in the dialog's title barpublic static void printWarning(java.awt.Window win, java.lang.String warning)
Method for spawning warning dialog with dafault header String
.
win
- Parent Window
for this dialog.warning
- The warning String
to show.public static void printError(java.awt.Window win, java.lang.String errorMessage, java.lang.String header)
Method for spawning error dialog.
win
- Parent Window
for this dialog.errorMessage
- The error String
to show.header
- the String
to display in the dialog's title barpublic static void printError(java.awt.Window win, java.lang.String errorMessage)
Method for spawning error dialog with default header String
win
- Parent Window
for this dialog.errorMessage
- The error String
to show.public static int questionDialog(java.awt.Window win, java.lang.String question, java.lang.String header, int options)
Method for spawning question dialog with wanted options.
Options available are:
DEFAULT_OPTION
,
YES_NO_OPTION
,
YES_NO_CANCEL_OPTION, or
OK_CANCEL_OPTION
.
Options are defined in JOptionPane
-class.
win
- Parent Window
for this dialog.question
- The question String
to show.header
- the String
to display in the dialog's title baroptions
- The options to display in the pane.
JOptionPane
public static int questionDialog(java.awt.Window win, java.lang.String question, java.lang.String header)
Method for spawning question dialog with YES_NO_OPTION
-option.
win
- Parent Window
for this dialog.question
- The question String
to show.header
- the String
to display in the dialog's title bar
public static javax.swing.DefaultCellEditor createComboBoxCellEditor(java.lang.String[] values, java.lang.String self, java.lang.String selfPointer, boolean allowSelf, boolean addEmpty)
This method creates a new JComboBox Cell Editor for a JTable element from the given String array. Duplicate entries from given array will be filtered and the array is sorted to alphabetical order.
values
- Available options in the JComboBox.allowSelf
- Allow self pointer in the list.self
- The name of the self object.selfPointer
- The name of the pointer used to point the self object.addEmpty
- Create an empty item to the beginning of the list.