dsto.dfc.swing.forms
Class JComboBoxFormEditor

java.lang.Object
  extended by dsto.dfc.swing.forms.BasicFormEditorEventSource
      extended by dsto.dfc.swing.forms.AbstractFormEditor
          extended by dsto.dfc.swing.forms.JComboBoxFormEditor
All Implemented Interfaces:
FormEditor, Copyable, Disposable, ActionListener, Serializable, Cloneable, EventListener

public class JComboBoxFormEditor
extends AbstractFormEditor
implements FormEditor, Disposable, ActionListener

A form editor that can be used to bind JComboBox'es.

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

Field Summary
 
Fields inherited from class dsto.dfc.swing.forms.AbstractFormEditor
converter, description
 
Constructor Summary
JComboBoxFormEditor()
           
JComboBoxFormEditor(JComboBox comboBox)
           
JComboBoxFormEditor(JComboBox comboBox, String description)
           
JComboBoxFormEditor(JComboBox comboBox, ValueConverter converter, String description)
           
JComboBoxFormEditor(JComboBox comboBox, ValueConverter converter, String description, Class comboItemType)
          Creates a new JComboBoxFormEditor instance.
 
Method Summary
 void actionPerformed(ActionEvent e)
           
 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).
 JComboBox getComboBox()
           
 Component getEditorComponent()
          Get the component, if any, that acts as a UI for this editor.
 Object getEditorValue()
          Get the current value from the form editor.
 Class getPreferredValueType()
          Default implementation: returns java.lang.Object to indicate no preferred type.
 boolean isDirectEdit()
          True if the editor directly edits the value passed in with setValue ().
 void setComboBox(JComboBox newValue)
           
 void setComboItemType(Class newValue)
          Set the type of item in the combo box.
 void setEditorValue(Object newValue)
          Sets the value to be displayed/edited by the form editor.
 void setPreferredValueType(Class newValueType)
           
 
Methods inherited from class dsto.dfc.swing.forms.AbstractFormEditor
getEditorDescription, setEditorDescription
 
Methods inherited from class dsto.dfc.swing.forms.BasicFormEditorEventSource
addFormEditorListener, clone, fireEditComitted, fireEditCommitRequested, fireEditCommitted, removeFormEditorListener, setFormEditorEventSource
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface dsto.dfc.swing.forms.FormEditor
addFormEditorListener, getEditorDescription, removeFormEditorListener
 

Constructor Detail

JComboBoxFormEditor

public JComboBoxFormEditor()

JComboBoxFormEditor

public JComboBoxFormEditor(JComboBox comboBox)

JComboBoxFormEditor

public JComboBoxFormEditor(JComboBox comboBox,
                           String description)

JComboBoxFormEditor

public JComboBoxFormEditor(JComboBox comboBox,
                           ValueConverter converter,
                           String description)

JComboBoxFormEditor

public JComboBoxFormEditor(JComboBox comboBox,
                           ValueConverter converter,
                           String description,
                           Class comboItemType)
Creates a new JComboBoxFormEditor instance.

Parameters:
comboBox - The combo box to bind to.
converter - The value converter to use (may be null).
description - The description of the value being edited (eg "first name")
comboItemType - The type of items in the combo box's model. Used to determine what type to tell the converter to convert to on loading. May be null for no conversion.
Method Detail

setComboItemType

public void setComboItemType(Class newValue)
Set the type of item in the combo box. Default is to use the same type of value as the editor value type.


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

setComboBox

public void setComboBox(JComboBox newValue)

getComboBox

public JComboBox getComboBox()

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
Specified by:
isDirectEdit in class AbstractFormEditor

getPreferredValueType

public Class getPreferredValueType()
Description copied from class: AbstractFormEditor
Default implementation: returns java.lang.Object to indicate no preferred type.

Specified by:
getPreferredValueType in interface FormEditor
Overrides:
getPreferredValueType in class AbstractFormEditor

setPreferredValueType

public void setPreferredValueType(Class newValueType)

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
Specified by:
commitEdits in class AbstractFormEditor
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
Specified by:
setEditorValue in class AbstractFormEditor
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
Specified by:
getEditorValue in class AbstractFormEditor

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
Specified by:
getEditorComponent in class AbstractFormEditor

actionPerformed

public void actionPerformed(ActionEvent e)
Specified by:
actionPerformed in interface ActionListener


Copyright © 2008 Commonwealth of Australia