|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component java.awt.Container java.awt.Window java.awt.Dialog javax.swing.JDialog dsto.dfc.swing.controls.DfcDialog dsto.dfc.swing.controls.DfcOkCancelDialog dsto.dfc.swing.forms.FormDialog
public class FormDialog
A Form-compatible extension of DfcOkCancelDialog designed to contain FormEditor's. Clients should use this class by adding a FormEditor-compatible component as the main dialog panel (via setFormPanel ()) and NOT by using setDialogPanel () in the usual way for DfcOkCancelDialog's. The main dialog panel will be committed when the user selects either OK or Apply.
NOTE: There are two modes this dialog can be used in: bound and
non-bound. In bound mode, the editor inside the dialog is bound to
a property of the dialog's editor value. In this mode, changes to
the form dialog's value can be updated automatically when the OK
button is pressed (to enable cancelling, FormDialog is set to be in
deferred commit mode so that edits are not committed into the form
value until the OK or Apply button is pressed even if child editors
fire an editCommitted event). Bound mode is enabled when setFormPanel(FormEditor,String)
is used. In non bound mode (the
default), the editor value for the dialog and the panel is the
same, and is cloned when it is passed into the dialog's
setEditorValue () method. In this mode it is up to the client to
store the edited value when OK or Apply is pressed.
Eg for non bound mode:
FormDialog dialog = new FormDialog ("Test"); Person person = new Person ("Foo"); // PersonCustomizer is a form editor for Person objects PersonCustomizer personEditor = new PersonCustomizer (); dialog.setFormPanel (personEditor); dialog.setEditorValue (person); // clones person before setting dialog.show (); // show and edit person if (!dialog.isCancelled ()) { Person newPerson = (Person)dialog.getEditorValue (); // do something with edited newPerson }
TIP: If no natural class makes sense as the editor value for this dialog in bound mode, clients can implement a special property for loading/saving the editor value. For example: a command that pops up a FormDialog could provide a "dialogValue" property and bind itself as the form value.
Form
,
DfcOkCancelDialog
,
Serialized FormNested Class Summary |
---|
Nested classes/interfaces inherited from class dsto.dfc.swing.controls.DfcDialog |
---|
DfcDialog.CmdCancel |
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 |
---|
Fields inherited from class dsto.dfc.swing.controls.DfcOkCancelDialog |
---|
listeners, OK_ACCELERATOR, okListener |
Fields inherited from class dsto.dfc.swing.controls.DfcDialog |
---|
ALIGN_CENTER_CLIENT, ALIGN_CENTER_SCREEN, ALIGN_NONE, CANCEL_ACCELERATOR |
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 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()
|
|
FormDialog(Component client,
String title,
boolean modal)
|
Method Summary | |
---|---|
void |
addEditor(String property,
FormEditor editor)
|
void |
addEditor(String property,
FormEditor editor,
ValueConverter converter)
Add an editor for a given property of the form value. |
void |
addFormEditorListener(FormEditorListener l)
|
void |
commitEdits()
Commit any changes not already committed into the value of this editor (eg a text editor will attempt to perform any uncommitted text conversions at this point). |
void |
dispose()
Dispose of the object (unregister listeners, close open resources etc). |
Component |
getEditorComponent()
Get the component, if any, that acts as a UI for this editor. |
String |
getEditorDescription()
Get a short description of the value being edited for this editor (eg 'host name'). |
Object |
getEditorValue()
Get the current value from the form editor. |
FormEditor |
getFormPanel()
|
Class |
getPreferredValueType()
Default implementation: returns java.lang.Object to indicate no preferred type. |
boolean |
isBoundMode()
|
boolean |
isDeferredCommit()
True if editor commit requests from child editors are deferred until commitEdits () is explicitly called on this form. |
boolean |
isDirectEdit()
True if the editor directly edits the value passed in with setValue (). |
boolean |
removeEditor(FormEditor editor)
Remove a bound form editor. |
void |
removeFormEditorListener(FormEditorListener l)
|
boolean |
saveResult()
Do not override. |
void |
setDeferredCommit(boolean newValue)
|
void |
setEditorValue(Object newValue)
Sets the value to be displayed/edited by the form editor. |
void |
setFormPanel(FormEditor panel)
Set the main panel for the dialog. |
void |
setFormPanel(FormEditor panel,
String property)
Set the main panel for the dialog. |
Methods inherited from class dsto.dfc.swing.controls.DfcOkCancelDialog |
---|
addActionListener, apply, button_actionPerformed, cancel, enableOkAccelerator, fireActionEvent, getApplyButton, getCancelButton, getOkButton, isCancelled, ok, removeActionListener, setCancelled |
Methods inherited from class dsto.dfc.swing.controls.DfcDialog |
---|
cancelButton_actionPerformed, getAlignMode, getButtonPanel, getCancelCommand, getContentPanel, getDialogPanel, placeWindow, setAlignMode, setContentPanel, setDialogPanel, setVisible, this_windowClosing |
Methods inherited from class java.awt.Dialog |
---|
addNotify, getModalityType, getTitle, hide, isModal, isResizable, isUndecorated, setModal, setModalityType, setResizable, setTitle, setUndecorated, show, toBack |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public FormDialog(Component client, String title, boolean modal)
public FormDialog()
Method Detail |
---|
public void dispose()
Disposable
dispose
in interface Disposable
dispose
in class DfcDialog
public Class getPreferredValueType()
getPreferredValueType
in interface FormEditor
public boolean isBoundMode()
public void setFormPanel(FormEditor panel)
panel
- The main panel (must both extend Component and
implement the FormEditor interface).public void setFormPanel(FormEditor panel, String property)
panel
- The main panel (must both extend Component and
implement the FormEditor interface). May be null to unset form panel.property
- The property of the dialog editor value
value to bind to the panel. May be null for no binding.public FormEditor getFormPanel()
public boolean saveResult()
saveResult
in class DfcOkCancelDialog
public void addEditor(String property, FormEditor editor)
addEditor
in interface Form
public void addEditor(String property, FormEditor editor, ValueConverter converter)
Form
addEditor
in interface Form
property
- The property name.editor
- The editor for the property.converter
- The value converter that will be used to convert
values into the editor's format (determined by FormEditor.getPreferredValueType()
and from the editor back to the
property value. May be null for no conversion.Form.removeEditor(dsto.dfc.swing.forms.FormEditor)
public boolean removeEditor(FormEditor editor)
Form
removeEditor
in interface Form
Form.addEditor(java.lang.String, dsto.dfc.swing.forms.FormEditor)
public boolean isDeferredCommit()
Form
isDeferredCommit
in interface Form
public void setDeferredCommit(boolean newValue)
setDeferredCommit
in interface Form
public String getEditorDescription()
FormEditor
getEditorDescription
in interface FormEditor
public boolean isDirectEdit()
FormEditor
isDirectEdit
in interface FormEditor
public void commitEdits() throws IllegalFormatException
FormEditor
commitEdits
in interface FormEditor
IllegalFormatException
- if the commit failed because of
an illegal input or other error. The source specified by the
exception should be the FormEditor instance that caused the error
(ie either this editor or a child).public void setEditorValue(Object newValue) throws IllegalFormatException
FormEditor
setEditorValue
in interface FormEditor
newValue
- The value to display.
IllegalFormatException
- if the value was not in the
correct format for display by this editor. The source specified
by the exception should be this FormEditor instance or a child.public Object getEditorValue()
FormEditor
getEditorValue
in interface FormEditor
public Component getEditorComponent()
FormEditor
getEditorComponent
in interface FormEditor
public void addFormEditorListener(FormEditorListener l)
addFormEditorListener
in interface FormEditor
public void removeFormEditorListener(FormEditorListener l)
removeFormEditorListener
in interface FormEditor
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |