Package org.svetovid.dialogs
Class AbstractDialogFactory
java.lang.Object
org.svetovid.dialogs.AbstractDialogFactory
- All Implemented Interfaces:
DialogFactory
- Direct Known Subclasses:
DefaultDialogFactory
This is a default implementation of a dialog factory used for showing various
types of dialog boxes containing messages, information, questions, etc. For
documentation see
DialogFactory
interface.- Version:
- 1.0
- Author:
- Ivan Pribela
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static class
protected class
protected class
-
Field Summary
Modifier and TypeFieldDescriptionprotected ResourceBundle
protected Clipboard
protected Icon
protected Icon
protected Icon
protected int
protected Icon
protected Icon
protected Icon
protected Icon
protected Icon
protected Icon
protected Icon
protected Locale
protected String[]
protected Icon
protected Icon
protected Icon
protected boolean
protected String[]
protected String[]
protected String[]
protected Icon
protected Icon
protected Icon
protected Icon
protected Icon
protected Icon
protected String[]
protected String[]
-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractDialogFactory
(Locale locale, Clipboard clipboard) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addAutoCloseSupport
(JDialog dialog, JOptionPane pane, int timeout) protected void
addAutoFocusSupport
(JDialog dialog, JOptionPane pane, JComponent component) protected void
addClipboardSupport
(JDialog dialog, JOptionPane pane, Clipboard clipboard, String text) protected void
protected void
appendStackTraceAsCause
(StringBuilder b, Throwable t, StackTraceElement[] originalStack) protected void
protected void
appendThrowable
(StringBuilder b, Throwable t, boolean isCause) boolean
askConfirmation
(Component component, String text) Displays confirmation message box containing desired message, and asking from the user to answer {code Yes} orNo
.protected boolean
askConfirmation
(Component component, String text, int timeout) askConfirmationWithCancel
(Component component, String text) Displays confirmation message box containing desired message, and asking from the user to answer Yes, No or Cancel.protected Boolean
askConfirmationWithCancel
(Component component, String text, int timeout) Displays login dialog box containing desired message, and asking for user name and password.protected LoginData
Displays login dialog box containing desired message, and asking for user name and password.protected LoginData
char[]
askPassword
(Component component, String text) Displays password dialog box containing desired message, and asking from the user to enter password.protected char[]
askPassword
(Component component, String text, int timeout) askQuestion
(Component component, String text) Displays question message box containing desired question, and asking the user to enter the answer.askQuestion
(Component component, String text, int timeout) askQuestion
(Component component, String text, Object[] options, Object defaultOption) Displays question message box containing desired question, and asking the user to choose one of the provided options.protected Object
askQuestion
(Component component, String text, Object[] options, Object defaultOption, int timeout) askQuestion
(Component component, String text, String answer) Displays question message box containing desired question, and asking the user to enter the answer.protected String
askQuestion
(Component component, String text, String answer, int timeout) protected String
protected static String
copyStringFromClipboard
(Clipboard clipboard) protected static void
copyStringToClipboard
(Clipboard clipboard, String text) protected JDialog
createDialog
(Component component, JOptionPane pane, String title, int timeout) protected JDialog
createDialog
(Component component, JOptionPane pane, String title, String text, int timeout) protected JDialog
createDialog
(Component component, JOptionPane pane, String title, JComponent focus, int timeout) protected JDialog
createDialog
(Component component, JOptionPane pane, String title, JComponent focus, String text, int timeout) protected void
destroyDialog
(JDialog dialog, JOptionPane pane) protected Clipboard
Returns a dialog icon of the desired type.protected Locale
protected void
setClipboard
(Clipboard newValue) protected void
boolean
showDialog
(Component component, Component content, String title, Icon icon) Displays a dialog with the given icon and title containing the supplied component.protected boolean
showDialog
(Component component, Component content, String title, Icon icon, int timeout) <T> T
showDialog
(Component component, DialogContent<T> content, String title, Icon icon) Displays a dialog with the given icon and title containing the supplied content.protected <T> T
showDialog
(Component component, DialogContent<T> content, String title, Icon icon, int timeout) void
Displays error message box containing desired message.protected void
void
Displays error message box containing desired message and optionally stack-trace of the supplied exception.protected void
void
showException
(Component component, Throwable th) Displays error message box containing stack-trace of the supplied exception.protected void
showException
(Component component, Throwable th, int timeout) void
showInformation
(Component component, String text) Displays informational message box containing desired message.protected void
showInformation
(Component component, String text, int timeout) void
showMessage
(Component component, String text) Displays message box containing desired message.protected void
showMessage
(Component component, String text, int timeout) void
showWarning
(Component component, String text) Displays warning message box containing desired message.protected void
showWarning
(Component component, String text, int timeout)
-
Field Details
-
locale
-
clipboard
-
defaultAutoCloseTimeout
protected int defaultAutoCloseTimeout -
bundle
-
okOptions
-
yesNoOptions
-
yesNoCancelOptions
-
okCancelOptions
-
loginExitOptions
-
okWithDetailsOptions
-
messageIcon
-
informationIcon
-
warningIcon
-
errorIcon
-
confirmationIcon
-
questionIcon
-
passwordIcon
-
loginIcon
-
exceptionIcon
-
timeoutIcon
-
findIcon
-
replaceIcon
-
fontIcon
-
colorIcon
-
folderIcon
-
fileIcon
-
dateIcon
-
timeIcon
-
logoIcon
-
newStackTraceStyle
protected boolean newStackTraceStyle
-
-
Constructor Details
-
AbstractDialogFactory
-
-
Method Details
-
getClipboard
-
setClipboard
-
getLocale
-
setLocale
-
showMessage
Description copied from interface:DialogFactory
Displays message box containing desired message.- Specified by:
showMessage
in interfaceDialogFactory
- Parameters:
component
- determines the frame in which the dialog is displayed; if the parentComponent has no Frame, a default Frame is used.text
- text which will be displayed in the message box.
-
showMessage
-
showInformation
Description copied from interface:DialogFactory
Displays informational message box containing desired message.- Specified by:
showInformation
in interfaceDialogFactory
- Parameters:
component
- determines the frame in which the dialog is displayed; if the parentComponent has no Frame, a default Frame is used.text
- text which will be displayed in the message box.
-
showInformation
-
showWarning
Description copied from interface:DialogFactory
Displays warning message box containing desired message.- Specified by:
showWarning
in interfaceDialogFactory
- Parameters:
component
- determines the frame in which the dialog is displayed; if the parentComponent has no Frame, a default Frame is used.text
- text which will be displayed in the message box.
-
showWarning
-
showError
Description copied from interface:DialogFactory
Displays error message box containing desired message.- Specified by:
showError
in interfaceDialogFactory
- Parameters:
component
- determines the frame in which the dialog is displayed; if the parentComponent has no Frame, a default Frame is used.text
- text which will be displayed in the message box.
-
showError
-
showError
Description copied from interface:DialogFactory
Displays error message box containing desired message and optionally stack-trace of the supplied exception.- Specified by:
showError
in interfaceDialogFactory
- Parameters:
component
- determines the frame in which the dialog is displayed; if the parentComponent has no Frame, a default Frame is used.text
- text which will be displayed in the message box.th
- exception which is used to build up the stack-trace information.
-
showError
-
showException
Description copied from interface:DialogFactory
Displays error message box containing stack-trace of the supplied exception.- Specified by:
showException
in interfaceDialogFactory
- Parameters:
component
- determines the frame in which the dialog is displayed; if the parentComponent has no Frame, a default Frame is used.th
- exception which is used to build up the stack-trace information.
-
showException
-
askConfirmation
Description copied from interface:DialogFactory
Displays confirmation message box containing desired message, and asking from the user to answer {code Yes} orNo
.- Specified by:
askConfirmation
in interfaceDialogFactory
- Parameters:
component
- determines the frame in which the dialog is displayed; if the parentComponent has no Frame, a default Frame is used.text
- text which will be displayed in the message box.- Returns:
true
if user answeredyes
;false
otherwise.
-
askConfirmation
-
askConfirmationWithCancel
Description copied from interface:DialogFactory
Displays confirmation message box containing desired message, and asking from the user to answer Yes, No or Cancel.- Specified by:
askConfirmationWithCancel
in interfaceDialogFactory
- Parameters:
component
- determines the frame in which the dialog is displayed; if the parentComponent has no Frame, a default Frame is used.text
- text which will be displayed in the message box.- Returns:
true
if user answeredyes
;false
if user answeredno
; andnull
otherwise.
-
askConfirmationWithCancel
-
askQuestion
Description copied from interface:DialogFactory
Displays question message box containing desired question, and asking the user to enter the answer.- Specified by:
askQuestion
in interfaceDialogFactory
- Parameters:
component
- determines the frame in which the dialog is displayed; if the parentComponent has no Frame, a default Frame is used.text
- text which will be displayed in the message box.- Returns:
String
containing text that user entered;null
if user has chosen not to answer.
-
askQuestion
-
askQuestion
Description copied from interface:DialogFactory
Displays question message box containing desired question, and asking the user to enter the answer.- Specified by:
askQuestion
in interfaceDialogFactory
- Parameters:
component
- determines the frame in which the dialog is displayed; if the parentComponent has no Frame, a default Frame is used.text
- text which will be displayed in the message box.answer
- the initial answer for user to modify.- Returns:
String
containing text that user entered;null
if user has chosen not to answer.
-
askQuestion
-
askQuestion
Description copied from interface:DialogFactory
Displays question message box containing desired question, and asking the user to choose one of the provided options.- Specified by:
askQuestion
in interfaceDialogFactory
- Parameters:
component
- determines the frame in which the dialog is displayed; if the parentComponent has no Frame, a default Frame is used.text
- text which will be displayed in the message box.options
- list of available options for the user to choose from.defaultOption
- initial option that is to be selected.- Returns:
- one of the options provided or
null
if user has chosen not to answer.
-
askQuestion
-
askPassword
Description copied from interface:DialogFactory
Displays password dialog box containing desired message, and asking from the user to enter password.- Specified by:
askPassword
in interfaceDialogFactory
- Parameters:
component
- determines the frame in which the dialog is displayed; if the parentComponent has no Frame, a default Frame is used.text
- text which will be displayed in the dialog box.- Returns:
- password entered by the user as an array of
char
;null
if user has chosen not to enter the password.
-
askPassword
-
askLogin
Description copied from interface:DialogFactory
Displays login dialog box containing desired message, and asking for user name and password.- Specified by:
askLogin
in interfaceDialogFactory
- Parameters:
component
- determines the frame in which the dialog is displayed; if the parentComponent has no Frame, a default Frame is used.text
- text which will be displayed in the dialog box.- Returns:
- user data (user name and password) stored in
LoginData
object;null
if user has chosen not to enter login data.
-
askLogin
-
askLogin
Description copied from interface:DialogFactory
Displays login dialog box containing desired message, and asking for user name and password.- Specified by:
askLogin
in interfaceDialogFactory
- Parameters:
component
- determines the frame in which the dialog is displayed; if the parentComponent has no Frame, a default Frame is used.text
- text which will be displayed in the dialog box.username
- default user name.- Returns:
- user data (user name and password) stored in
LoginData
object;null
if user has chosen not to enter login information.
-
askLogin
-
showDialog
Description copied from interface:DialogFactory
Displays a dialog with the given icon and title containing the supplied component.- Specified by:
showDialog
in interfaceDialogFactory
- Parameters:
component
- determines the frame in which the dialog is displayed; if the parentComponent has no Frame, a default Frame is used.content
- the component to display on the dialogtitle
- title of the dialogicon
- icon to display on the dialog- Returns:
true
if user answeredok
;false
otherwise.
-
showDialog
-
showDialog
Description copied from interface:DialogFactory
Displays a dialog with the given icon and title containing the supplied content.- Specified by:
showDialog
in interfaceDialogFactory
- Type Parameters:
T
- type of dialog content- Parameters:
component
- determines the frame in which the dialog is displayed; if the parentComponent has no Frame, a default Frame is used.content
- the component to display on the dialogtitle
- title of the dialogicon
- icon to display on the dialog- Returns:
- The object retrieved from the content component if user answered
ok
;null
otherwise.
-
showDialog
protected <T> T showDialog(Component component, DialogContent<T> content, String title, Icon icon, int timeout) -
getIcon
Description copied from interface:DialogFactory
Returns a dialog icon of the desired type.- Specified by:
getIcon
in interfaceDialogFactory
- Parameters:
type
- determines which icon to return: "question", "warning", "error", or other- Returns:
- Returns a dialog icon of the given type.
-
createDialog
-
createDialog
protected JDialog createDialog(Component component, JOptionPane pane, String title, JComponent focus, int timeout) -
createDialog
protected JDialog createDialog(Component component, JOptionPane pane, String title, String text, int timeout) -
createDialog
protected JDialog createDialog(Component component, JOptionPane pane, String title, JComponent focus, String text, int timeout) -
destroyDialog
-
addAutoFocusSupport
-
addClipboardSupport
protected void addClipboardSupport(JDialog dialog, JOptionPane pane, Clipboard clipboard, String text) -
addAutoCloseSupport
-
constructStackTrace
-
appendStackTrace
-
appendStackTraceAsCause
protected void appendStackTraceAsCause(StringBuilder b, Throwable t, StackTraceElement[] originalStack) -
appendThrowable
-
appendStackTraceElement
-
copyStringToClipboard
-
copyStringFromClipboard
-