dsto.dfc.swing.forms
Class FormPanel

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by dsto.dfc.swing.forms.FormPanel
All Implemented Interfaces:
Form, FormEditor, Disposable, ImageObserver, MenuContainer, Customizer, Serializable, Accessible
Direct Known Subclasses:
BasicEnumeratedTermCustomizer, GradientPanel, LogWindowPopperEditor, MultiplexFormEditor

public class FormPanel
extends JPanel
implements Form, Customizer, Disposable

A form editor container that hosts FormEditor's bound to properties of the editor value. Use the addEditor method to bind child editors to properties of the panel's editor value.

Also implements the Beans Customizer interface, with the setObject () method delegated to setEditorValue ().

Version:
$Revision$
Author:
Matthew
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
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 javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
FormPanel()
           
 
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).
 void fireEditComitted()
          Deprecated. Supports old typo, use fireEditCommitted instead.
 void fireEditCommitRequested()
           
 void fireEditCommitted()
           
 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.
 Class getPreferredValueType()
          Default implementation: returns java.lang.Object to indicate no preferred type.
 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)
           
 void setDeferredCommit(boolean newValue)
           
 void setDirectEdit(boolean newValue)
           
 void setEditorValue(Object newValue)
          Sets the value to be displayed/edited by the form editor.
 void setObject(Object bean)
           
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.beans.Customizer
addPropertyChangeListener, removePropertyChangeListener
 

Constructor Detail

FormPanel

public FormPanel()
Method Detail

dispose

public void dispose()
Description copied from interface: Disposable
Dispose of the object (unregister listeners, close open resources etc). It should be safe to call this method more than once. Note for beans that support client event listeners: if there are listeners registered when this is called, this method should do nothing.

Specified by:
dispose in interface Disposable

setObject

public void setObject(Object bean)
Specified by:
setObject in interface Customizer

getPreferredValueType

public Class getPreferredValueType()
Default implementation: returns java.lang.Object to indicate no preferred type.

Specified by:
getPreferredValueType in interface FormEditor

isDeferredCommit

public boolean isDeferredCommit()
Description copied from interface: Form
True if editor commit requests from child editors are deferred until commitEdits () is explicitly called on this form. This can be used to implement forms where the user can apply changes via commitEdits () or cancel edits by simply not calling commitEdits () without having to copy the value being edited by the form. When in deferred commit mode, the form will copy values before passing them to setValue () on "direct edit" child FormEditor's and handle editCommitRequested events from sub-editors by calling commit () but not storing the subeditor's value.

Specified by:
isDeferredCommit in interface Form

setDeferredCommit

public void setDeferredCommit(boolean newValue)
Specified by:
setDeferredCommit in interface Form

addEditor

public void addEditor(String property,
                      FormEditor editor)
Specified by:
addEditor in interface Form

addEditor

public void addEditor(String property,
                      FormEditor editor,
                      ValueConverter converter)
Description copied from interface: Form
Add an editor for a given property of the form value.

Specified by:
addEditor in interface Form
Parameters:
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.
See Also:
Form.removeEditor(dsto.dfc.swing.forms.FormEditor)

removeEditor

public boolean removeEditor(FormEditor editor)
Description copied from interface: Form
Remove a bound form editor.

Specified by:
removeEditor in interface Form
Returns:
True if the editor was removed.
See Also:
Form.addEditor(java.lang.String, dsto.dfc.swing.forms.FormEditor)

getEditorDescription

public String getEditorDescription()
Description copied from interface: FormEditor
Get a short description of the value being edited for this editor (eg 'host name'). May be null.

Specified by:
getEditorDescription in interface FormEditor

isDirectEdit

public boolean isDirectEdit()
Description copied from interface: FormEditor
True if the editor directly edits the value passed in with setValue (). If false, the parent editor will be reponsible for retrieving the value from the editor and storing it.

Specified by:
isDirectEdit in interface FormEditor

setDirectEdit

public void setDirectEdit(boolean newValue)

commitEdits

public void commitEdits()
                 throws IllegalFormatException
Description copied from interface: FormEditor
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). Only editors that need support editing in non-atomic sessions (such as text fields) will generally do anything when this method is called. If commit is made that has not been signalled with a previous editCommitted event, the editor should fire an editCommitted event at this point. Composite editors, such as forms, will generally forward this request to their child editors.

Specified by:
commitEdits in interface FormEditor
Throws:
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).

setEditorValue

public void setEditorValue(Object newValue)
                    throws IllegalFormatException
Description copied from interface: FormEditor
Sets the value to be displayed/edited by the form editor.

Specified by:
setEditorValue in interface FormEditor
Parameters:
newValue - The value to display.
Throws:
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.

getEditorValue

public Object getEditorValue()
Description copied from interface: FormEditor
Get the current value from the form editor. At least one call to setValue () must be made beforehand.

Specified by:
getEditorValue in interface FormEditor

getEditorComponent

public Component getEditorComponent()
Description copied from interface: FormEditor
Get the component, if any, that acts as a UI for this editor. May return null if not associated with a component.

Specified by:
getEditorComponent in interface FormEditor

addFormEditorListener

public void addFormEditorListener(FormEditorListener l)
Specified by:
addFormEditorListener in interface FormEditor

removeFormEditorListener

public void removeFormEditorListener(FormEditorListener l)
Specified by:
removeFormEditorListener in interface FormEditor

fireEditComitted

public void fireEditComitted()
Deprecated. Supports old typo, use fireEditCommitted instead.


fireEditCommitted

public void fireEditCommitted()

fireEditCommitRequested

public void fireEditCommitRequested()


Copyright © 2008 Commonwealth of Australia