|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.ccg.values.ValuesEditorAdapter
public abstract class ValuesEditorAdapter
Helper class to form a base for those wishing to implement a
ValuesEditor.
This class serves as a good starting point for those wishing to implement a
ValuesEditor. It provides the following common
services:
createObjectInstance
implementation (you may choose/need to override this if the default
constructor for your associated class is not available or desirable).ChangeListeners (your
implmentation can use the fireChangeEvent if it
needs to notify others that the user has changed some values).proxyDocumentListener with the text fields
document so that if the user modifies the text, all of the
ChangeListeners will be notified.If you derive a new class from this adapter, you will then need/want to implement the following:
getObjectClasstoObjectfromObjectvalidategetComponentcreateObjectInstance (optional)init (optional)
The TimeSpanEditor implementation provides a
example of how this class is used. See TimeSpanEditor.java for details.
ValuesEditor,
TimeSpanEditor.java| Field Summary |
|---|
| Fields inherited from interface com.ccg.values.ValuesHolder |
|---|
HAS_FROM, HAS_TO, HAS_TO_FROM |
| Constructor Summary | |
|---|---|
protected |
ValuesEditorAdapter()
Constructs the object and makes it ready for the addition of listeners. |
| Method Summary | |
|---|---|
void |
addChangeListener(ChangeListener cl)
Add a "change listener" to notify if the user modifies ANY of the values in the Swing component. |
Object |
checkArgument(Object o)
Verify that a object is of the type recognized by this class. |
Object |
createObjectInstance()
Creates a new instance of a object (with default values set) which the editor is designed to work with. |
protected void |
fireChangeEvent()
Notify all registered listeners that the user has changed something in the GUI. |
int |
getCapabilities()
Determine what the ValuesHolder implementation
supports. |
protected ChangeListener |
getProxyChangeListener()
Get a "proxy" for ChangeEvents. |
protected DocumentListener |
getProxyDocumentListener()
Get a "proxy" for DocumentEvents. |
protected InputMethodListener |
getProxyInputMethodListener()
Get a "proxy" for InputMethodEvents. |
protected ItemListener |
getProxyItemListener()
Get a "proxy" for ItemEvents. |
protected ListDataListener |
getProxyListDataListener()
Get a "proxy" for ListDataEvents. |
TableModelListener |
getProxyTableModelListener()
Get a "proxy" for TableModelEvents. |
void |
init(Lookup props)
Set the properties to be used when constructing the visual component. |
void |
removeChangeListener(ChangeListener l)
Remove a "change listener" that had been previously added. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface com.ccg.values.ValuesEditor |
|---|
getComponent, validate |
| Methods inherited from interface com.ccg.values.ValuesHolder |
|---|
fromObject, getObjectClass, toObject |
| Constructor Detail |
|---|
protected ValuesEditorAdapter()
| Method Detail |
|---|
public int getCapabilities()
ValuesHolder implementation
supports.
This method returns HAS_TO_FROM indicating that the
ValuesHolder interface is fully supported. This
means that values can be transferred in both directions - from the object
to the GUI component and from the GUI component to the object. Any
derived class which does not support either of these operations, will
need to override this method and indicate what they do support.
getCapabilities in interface ValuesHolderValuesHolder.HAS_TO_FROM.ValuesHolder.getCapabilities()public Object createObjectInstance()
This default implementation, simply uses the default constructor for the
object class which is associated with the editor.
Derived classes will want to override if they would like to change this
(maybe the default constructor isn't what you'd like your default to be).
createObjectInstance in interface ValuesEditorfromObject or toObject
implementation.public void init(Lookup props)
The adapter makes the assumption that no special properties are recognized by your implemenation (it simply ignores the properties passed and returns).
init in interface ValuesEditorprops - Set of properties (implementation dependent) to initialize object with
(must not be null).public final void addChangeListener(ChangeListener cl)
This method allows developers to determine when the state of the graphical component becomes "dirty" (modified by the user).
addChangeListener in interface ValuesEditorcl - The ChangeListener to notify of modifications.public final void removeChangeListener(ChangeListener l)
added.
removeChangeListener in interface ValuesEditorcl - The ChangeListener to remove from the notification
list.protected final void fireChangeEvent()
This method will invoke the stateChanged method on each ChangeListener which
has been added.
protected final ChangeListener getProxyChangeListener()
ChangeEvents.
The object returned by this method can be added as a "proxy" for events.
When a event occurs, it will be "proxied" into a
ChangeEvent and delivered for the object as a whole.
ChangeListener which will invoke the
fireChangeEvent() when it is triggered.public TableModelListener getProxyTableModelListener()
TableModelEvents.
The object returned by this method can be added as a "proxy" for events.
When a event occurs, it will be "proxied" into a
TableModelEvent and delivered for the object as a
whole.
TableModelListener which will invoke the
fireChangeEvent() when it is triggered.protected final InputMethodListener getProxyInputMethodListener()
InputMethodEvents.
The object returned by this method can be added as a "proxy" for events.
When a event occurs, it will be "proxied" into a
ChangeEvent and delivered for the object as a whole.
getInputMethodListener which will invoke
the fireChangeEvent() when it is triggered.protected final DocumentListener getProxyDocumentListener()
DocumentEvents.
The object returned by this method can be added as a "proxy" for events.
When a event occurs, it will be "proxied" into a
ChangeEvent and delivered for the object as a whole.
getDocumentListener which will invoke the
fireChangeEvent() when it is triggered.protected final ListDataListener getProxyListDataListener()
ListDataEvents.
The object returned by this method can be added as a "proxy" for events.
When a event occurs, it will be "proxied" into a
ChangeEvent and delivered for the object as a whole.
ListDataListener which will invoke the
fireChangeEvent() when it is triggered.protected final ItemListener getProxyItemListener()
ItemEvents.
The object returned by this method can be added as a "proxy" for events.
When a event occurs, it will be "proxied" into a
ChangeEvent and delivered for the object as a whole.
ItemListener which will invoke the
fireChangeEvent() when it is triggered.
public final Object checkArgument(Object o)
throws NullPointerException,
IllegalArgumentException
This method is typically used by the toObject and
fromObject methods. It verifies that the object is of
the proper type (and throws an exception if not). For example, in the
implementation of the TimeSpanEditor might use it in the following manner:
public Class getObjectClass() {
return TimeSpan.class;
}
public void fromObject(Object o) throws ... {
TimeSpan ts = (TimeSpan) checkArgument(o);
...
}
NullPointerException - If you pass null.
IllegalArgumentException - If the object you pass is not a instance of the object class supported.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||