|
Holger's Java API |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
java.awt.Window
java.awt.Dialog
javax.swing.JDialog
com.antelmann.util.gui.FormDialog<T>
public class FormDialog<T>
allows easy display and handling of forms in a dialog. Initially, the dialog is instantiated modal, but this may be changed. The FormDialog contains a given form and embeds it into a dialog adding an OK-button and a CANCEL-button. Upon pressing OK, the form will be processed by a FormValidator. In addition, this class provides some generally useful static methods for forms.
FormValidator,
FormFrame,
Serialized Form| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class javax.swing.JDialog |
|---|
JDialog.AccessibleJDialog |
| Nested classes/interfaces inherited from class java.awt.Dialog |
|---|
Dialog.AccessibleAWTDialog, Dialog.ModalExclusionType, Dialog.ModalityType |
| Nested classes/interfaces inherited from class java.awt.Window |
|---|
Window.AccessibleAWTWindow |
| Nested classes/interfaces inherited from class java.awt.Container |
|---|
Container.AccessibleAWTContainer |
| Nested classes/interfaces inherited from class java.awt.Component |
|---|
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy |
| Field Summary | |
|---|---|
static int |
APPLY
indicates that the APPLY-button has been pressed |
static int |
CANCEL
indicates that the CANCEL-button has been pressed |
static int |
CLOSED
indicates that the dialog has been closed w/o pressing a button |
static int |
OK
indicates that the OK-button has been pressed |
| Fields inherited from class javax.swing.JDialog |
|---|
accessibleContext, rootPane, rootPaneCheckingEnabled |
| Fields inherited from class java.awt.Dialog |
|---|
DEFAULT_MODALITY_TYPE |
| Fields inherited from class java.awt.Component |
|---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
| Fields inherited from interface com.antelmann.util.gui.Form |
|---|
EDIT_PROPERTY_KEY |
| Fields inherited from interface javax.swing.WindowConstants |
|---|
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE |
| Fields inherited from interface java.awt.image.ImageObserver |
|---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
|---|---|
FormDialog(Component parent,
String title,
JComponent container,
FormValidator<T> validator)
constructs a modal dialog using a container as a form and adding buttons for OK, CANCEL. |
|
FormDialog(Component parent,
String title,
JComponent container,
FormValidator<T> validator,
boolean applyOption)
|
|
FormDialog(Component parent,
String title,
JComponent container,
FormValidator<T> validator,
boolean applyOption,
Logger logger)
this constructor allows to further specify whether an apply button should be available on the dialog |
|
FormDialog(Component parent,
String title,
JComponent container,
FormValidator<T> validator,
Logger logger)
this cunstructor allows to futher specify a Logger which logs when a button of this form is pressed; in addition, all window events are logged. |
|
| Method Summary | |
|---|---|
void |
actionPerformed(ActionEvent ev)
performs the action upon pressing the OK button. |
void |
addListener(FormListener l)
|
void |
applyAction()
programmatically presses the apply button action on this dialog. |
void |
cancelAction()
programmatic cancel button action on this dialog |
boolean |
checkForClose()
returns true only if the form has actually been disposed |
boolean |
disposeForm(boolean forceWithoutConfirm)
allows to programmatically close the form. |
void |
enableEscapeForCancel()
|
boolean |
getApplyAlwaysEnabled()
if false (the default), the apply button (if available) is only turned on by calling the propertyChange() method and will be disabled after each time the button is pressed |
JPanel |
getButtonContainer()
provides the container that contains the functional buttons of the Form, so that other additional buttons may be added here |
JPanel |
getButtonPanel()
returns the panel that contains the buttons for the available form actions (ok, cancel, apply) so that another special button may be added. |
Action |
getCancelAction()
|
Exception |
getException()
if an exception was thrown during commitFormAction(), this method returns it - or null. |
JComponent |
getFormComponent()
|
Container |
getFormContainer()
provides access to the overall window, dialog, frame, internal frame or other that holds the form with the formComponent and all the functional buttons that belong to the form |
FormListener[] |
getFormListeners()
|
FormValidator<T> |
getFormValidator()
|
Logger |
getLogger()
provides access to the logger used to capture events (and exeptions) upon pressing buttons |
Action |
getOKAction()
|
T |
getRelevantValue()
returns the value returned by the FormValidator on commitFormAction()
if the OK button was successfully pressed or if at any time the APPLY button was successfully pressed. |
boolean |
getWarnOnClose()
determines whether a warning is displayed upon cancel if the form is marked as changed (false by default) |
boolean |
hasApplyButton()
indicates whether the dialog is to be displayed with an apply option |
boolean |
isDirty()
returns true if the propertyChange() method was called after any saving action (apply or ok) |
boolean |
isValidateOnChange()
|
Object |
performSaveAction()
programmatically performs the action that would commonly be performed upon pressing 'save' on the form. |
int |
processForm()
calls setVisible(true), processes the form and returns what button was pressed. |
void |
propertyChange(PropertyChangeEvent evt)
implemented to provide feedback to the APPLY-button, if applicable. |
boolean |
removeListener(FormListener l)
|
void |
setApplyAlwaysEnabled(boolean flag)
|
void |
setValidateOnChange(boolean okOnValidationOnly)
|
void |
setWarnOnClose(boolean flag)
if set to true, a warning is displayed when the form is closed w/o saving if it is marked changed |
| Methods inherited from class java.awt.Dialog |
|---|
addNotify, getModalityType, getTitle, hide, isModal, isResizable, isUndecorated, setModal, setModalityType, setResizable, setTitle, setUndecorated, setVisible, show, toBack |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int OK
public static final int CANCEL
public static final int CLOSED
public static final int APPLY
| Constructor Detail |
|---|
public FormDialog(Component parent,
String title,
JComponent container,
FormValidator<T> validator)
parent - the component that created this dialogtitle - the title for this form dialogcontainer - the component that is representing the form that will be displayed in this dialogvalidator - a FormValidator specifying the behavior of the form upon pressing OKprocessForm()
public FormDialog(Component parent,
String title,
JComponent container,
FormValidator<T> validator,
Logger logger)
public FormDialog(Component parent,
String title,
JComponent container,
FormValidator<T> validator,
boolean applyOption)
public FormDialog(Component parent,
String title,
JComponent container,
FormValidator<T> validator,
boolean applyOption,
Logger logger)
| Method Detail |
|---|
public FormValidator<T> getFormValidator()
getFormValidator in interface Formpublic JComponent getFormComponent()
getFormComponent in interface Formpublic void addListener(FormListener l)
addListener in interface Formpublic boolean removeListener(FormListener l)
removeListener in interface Formpublic FormListener[] getFormListeners()
getFormListeners in interface Formpublic JPanel getButtonPanel()
public JPanel getButtonContainer()
Form
getButtonContainer in interface Formpublic Logger getLogger()
public boolean getWarnOnClose()
Form
getWarnOnClose in interface Formpublic void setWarnOnClose(boolean flag)
Form
setWarnOnClose in interface Formpublic void cancelAction()
public boolean checkForClose()
public boolean disposeForm(boolean forceWithoutConfirm)
Form
disposeForm in interface FormforceWithoutConfirm - if true, the form will be disposed no matter what;
if false, a confirmation dialog may appear if the form
is dirty and warnOnClose is true
public boolean getApplyAlwaysEnabled()
public void setApplyAlwaysEnabled(boolean flag)
public void applyAction()
public boolean hasApplyButton()
public boolean isValidateOnChange()
public void setValidateOnChange(boolean okOnValidationOnly)
public void actionPerformed(ActionEvent ev)
actionPerformed in interface ActionListenerpublic Object performSaveAction()
FormFormValidator.validateForm(Component)
and then call FormValidator.commitFormAction(Component); also this method
resets the Form.isDirty() status if the commit was successful.
performSaveAction in interface Formpublic int processForm()
setVisible(true), processes the form and returns what button was pressed.
The dialog stays visible until either OK was pressed and the validation and commit action went smooth, or
if CANCEL was pressed. Last, the dialog may also have been closed w/o a button.
Note that even though the dialog was closed through something other than OK, the commit action of
the form could still have been performed through the apply button (if applicable).
OK, CANCEL or CLOSEDFormDialogpublic Action getOKAction()
public Action getCancelAction()
public void enableEscapeForCancel()
public void propertyChange(PropertyChangeEvent evt)
propertyChange in interface PropertyChangeListenerpublic boolean isDirty()
isDirty in interface Formpublic T getRelevantValue()
FormValidator on commitFormAction()
if the OK button was successfully pressed or if at any time the APPLY button was successfully pressed.
If the commit action was never successfully executed, this method returns null.
getRelevantValue in interface ValueRetriever<T>FormValidator.commitFormAction(Component)public Exception getException()
commitFormAction(), this method returns it - or null.
In case an exception was thrown, it will already have been displayed to the user.
FormValidator.commitFormAction(Component)public Container getFormContainer()
Form
getFormContainer in interface Form
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||