dsto.dfc.swing.forms
Class JTreeSelectionFormEditor

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

public class JTreeSelectionFormEditor
extends BasicFormEditorEventSource
implements FormEditor, Disposable, TreeSelectionListener

Adapts JTree to act as a single-selection editor (the selected entry in the tree is the editor value).

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

Constructor Summary
JTreeSelectionFormEditor(JTree tree)
           
JTreeSelectionFormEditor(JTree tree, Class treeEntryClass, String description)
           
JTreeSelectionFormEditor(JTree tree, String description)
           
 
Method Summary
 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.
 Class getPreferredValueType()
          The preferred type of value for the editor.
 boolean isDirectEdit()
          True if the editor directly edits the value passed in with setValue ().
protected  void selectEntry(Object entry)
           
 void setEditorDescription(String newValue)
           
 void setEditorValue(Object value)
          Sets the value to be displayed/edited by the form editor.
 void valueChanged(TreeSelectionEvent e)
           
 
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, removeFormEditorListener
 

Constructor Detail

JTreeSelectionFormEditor

public JTreeSelectionFormEditor(JTree tree)

JTreeSelectionFormEditor

public JTreeSelectionFormEditor(JTree tree,
                                String description)

JTreeSelectionFormEditor

public JTreeSelectionFormEditor(JTree tree,
                                Class treeEntryClass,
                                String description)
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

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

setEditorDescription

public void setEditorDescription(String newValue)

getPreferredValueType

public Class getPreferredValueType()
Description copied from interface: FormEditor
The preferred type of value for the editor. Values conforming to this type may be safely passed to FormEditor.setEditorValue(java.lang.Object). May return java.lang.Object to indictate no preferred type.

Specified by:
getPreferredValueType 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

setEditorValue

public void setEditorValue(Object value)
                    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:
value - 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()
                      throws IllegalFormatException
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
Throws:
IllegalFormatException

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

commitEdits

public void commitEdits()
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

selectEntry

protected void selectEntry(Object entry)

valueChanged

public void valueChanged(TreeSelectionEvent e)
Specified by:
valueChanged in interface TreeSelectionListener


Copyright © 2008 Commonwealth of Australia