|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
dsto.dfc.swing.forms.FormPanel
dsto.dfc.swing.forms.MultiplexFormEditor
public class MultiplexFormEditor
A form editor that allows selection from a number of different predefined value types. The possible values are presented in a tab pane, with the editor for each sort of value in each tab. As the user selects different tabs, the editor value is switched to the value contained in the tab, and the new value's editor is activated, allowing the user to customize the value.
Editors may be added by adding "template" editor values via addEditorValue(java.lang.Object)
, which adds the value as a template for new ones
and adds an editor for the value using its BeanInfo customizer. A
slightly more intuitive way is to simply add an editor using
Component.add (editor, null), ensuring first that the editor has a
sensible default value loaded (ie not null). This also allows
editors to be added using visual GUI designers.
The tab name and icon for the editor are chosen from the icon and
display name specified by the editor's BeanInfo. If none are
specified, and the editor value is Iconic
, then
the icon and name from this is used instead.
Example
This editor could be used in the case where a property of type Book is being edited on a BookOrder bean. If Book is an interface with two concrete implementations, Novel and Magazine, this editor could be used as follows:
ArrayList bookTemplates = new ArrayList (); bookTemplates.add (new Magazine ("New Magazine")); bookTemplates.add (new Novel ("New Novel")); MultiplexFormEditor bookEditor = new MultiplexFormEditor (bookTemplates); Form orderForm = ...; BookOrder order = ...; orderForm.addEditor ("book", bookEditor); orderForm.setEditorValue (order);This would allow the user to select either a Novel or a Magazine as the value of "book" on a BookOrder and to set whatever specific properties are available on each.
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 | |
---|---|
protected FormEditor |
activeEditor
|
protected ArrayList |
editors
|
protected ArrayList |
editorValues
|
protected boolean |
tabListenerEnabled
|
protected JTabbedPane |
tabPane
|
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 | |
---|---|
MultiplexFormEditor()
|
|
MultiplexFormEditor(List editorValues)
Creates a new MultiplexFormEditor. |
Method Summary | |
---|---|
void |
addEditorValue(Object newValue)
Add a new editor template value. |
protected void |
addImpl(Component component,
Object constraint,
int index)
|
protected void |
addNewEditor(FormEditor editor)
Adds a FormEditor to the end of the editor list. |
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 |
editCommitRequested(ChangeEvent e)
Signals that the editor is ready to commit a value into the model. |
void |
editCommitted(ChangeEvent e)
Signals that an edit has been committed into the model. |
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. |
protected int |
getIndexForValue(Class valueClass)
Get the index for a given editor class (corresponds to index into strategies list and index of editor tab in tab pane). |
JTabbedPane |
getTabPane()
|
boolean |
isDirectEdit()
True if the editor directly edits the value passed in with setValue (). |
void |
setEditorValue(Object newValue)
Sets the current editor value. |
protected void |
tabChanged(ChangeEvent e)
Called when selected tab changes. |
Methods inherited from class dsto.dfc.swing.forms.FormPanel |
---|
addEditor, addEditor, addFormEditorListener, fireEditComitted, fireEditCommitRequested, fireEditCommitted, getEditorDescription, getPreferredValueType, isDeferredCommit, removeEditor, removeFormEditorListener, setDeferredCommit, setDirectEdit, setObject |
Methods inherited from class javax.swing.JPanel |
---|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI |
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 |
Field Detail |
---|
protected JTabbedPane tabPane
protected FormEditor activeEditor
protected ArrayList editorValues
protected ArrayList editors
protected boolean tabListenerEnabled
Constructor Detail |
---|
public MultiplexFormEditor()
public MultiplexFormEditor(List editorValues)
editorValues
- The editor template values. These should be
of different classes and must also be cloneable (preferably
Copyable
). A tab and an editor is
created for each value type. The editor is the value's Bean
customizer, which must also implement the FormEditor interface.
The name and icon for the tab come either via the Iconic
interface (if implemented) or from the
JavaBean 16x16 icon and display name.addEditorValue(java.lang.Object)
Method Detail |
---|
public void dispose()
Disposable
dispose
in interface Disposable
dispose
in class FormPanel
protected void addImpl(Component component, Object constraint, int index)
addImpl
in class Container
public void addEditorValue(Object newValue)
MultiplexFormEditor(List)
public JTabbedPane getTabPane()
public boolean isDirectEdit()
FormEditor
isDirectEdit
in interface FormEditor
isDirectEdit
in class FormPanel
public void setEditorValue(Object newValue) throws IllegalFormatException
setEditorValue
in interface FormEditor
setEditorValue
in class FormPanel
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
getEditorValue
in class FormPanel
public void commitEdits() throws IllegalFormatException
FormEditor
commitEdits
in interface FormEditor
commitEdits
in class FormPanel
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 Component getEditorComponent()
FormEditor
getEditorComponent
in interface FormEditor
getEditorComponent
in class FormPanel
public void editCommitted(ChangeEvent e)
FormEditorListener
editCommitted
in interface FormEditorListener
public void editCommitRequested(ChangeEvent e)
FormEditorListener
editCommitRequested
in interface FormEditorListener
protected void addNewEditor(FormEditor editor)
protected int getIndexForValue(Class valueClass)
protected void tabChanged(ChangeEvent e)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |