public class VizListComponent<T> extends ca.odell.glazedlists.TransformedList<T,T> implements IListComponent<T>
It implements the Component to match up with the ICE requirements and extends the TransformedList from GlazedLists to provide the generic, observable list capabilities.
It can be configured to provide a handle to an IElementSource that will provide valid, new elements upon request. This configuration is meant to facilitate the use of the ListComponent as a, for example, proxy for selections made from databases or similar tools. If getElementSource() returns null, clients should feel free to put whatever values they want into the List.
This class also realizes the WritableTableFormat interface from GlazedLists so that it can simply be "dropped in" to GlazedList tables in client UIs. This is handled using delegation instead of inheritance so that the format can be easily changed without re-initializing the list. Alternatively, the WritableTableFormat can just be retrieved with a getter too. If the table format is not provided, the behavior is unspecified, but this Component should probably not be put in a Form in that case.
Implementation noteUnfortunately, there are some tricky implementation details here related to extending TransformedList. The point of a TransformedList is to sit on top of a source list and manipulate it so it is a wrapper around another list, facilitating transformations to that list. This means that in the implementation of this class any work to register listeners or manipulate the list should be done to the source list, not "this" list. TransformedList is the suggested base class for extensions to GlazedLists instead of AbstractEventList, so we will have to live with this for now.
I also had to override the ListEventListener registration operations to make sure that the source list was registered. The TransformedList by defaults registers listeners against itself, not the source, but it processes all of the list additions, etc., through the source.iComponentListener
Constructor and Description |
---|
VizListComponent()
The default constructor.
|
VizListComponent(IElementSource<T> elementSource)
An alternative constructor that provides a handle to an IElementSource so
that clients have a source for valid, new elements to add to the list.
|
Modifier and Type | Method and Description |
---|---|
void |
addListEventListener(ca.odell.glazedlists.event.ListEventListener<? super T> listChangeListener)
Registers the specified listener to receive change updates for this list.
|
java.lang.Object |
clone() |
void |
copy(VizListComponent<T> list)
This operation copies the contents of the ListComponent into the current
object using a deep copy.
|
boolean |
equals(java.lang.Object otherObject) |
int |
getColumnCount() |
java.lang.String |
getColumnName(int column) |
java.lang.Object |
getColumnValue(T baseObject,
int column) |
java.lang.String |
getDescription() |
IElementSource<T> |
getElementSource()
This operation returns the element source which should be used to create
new elements to add to the list.
|
int |
getId() |
java.lang.String |
getName() |
ca.odell.glazedlists.gui.WritableTableFormat<T> |
getTableFormat()
This operation returns the GlazedList WritableTableFormat that is used to
describe this list or null if it was not set.
|
int |
hashCode() |
boolean |
isEditable(T baseObject,
int column) |
void |
listChanged(ca.odell.glazedlists.event.ListEvent<T> listChanges) |
void |
register(IVizUpdateableListener listener)
This operation registers a listener that realizes the IUpdateableListener
interface with the IUpdateable so that it can receive notifications of
changes to the IUpdateable if they are published.
|
void |
removeListEventListener(ca.odell.glazedlists.event.ListEventListener<? super T> listChangeListener)
Removes the specified listener from receiving change updates for this
list.
|
T |
setColumnValue(T baseObject,
java.lang.Object editedValue,
int column) |
void |
setDescription(java.lang.String description) |
void |
setElementSource(IElementSource<T> source)
This operation sets the element source that should be used by the list
|
void |
setId(int id) |
void |
setName(java.lang.String name) |
void |
setTableFormat(ca.odell.glazedlists.gui.WritableTableFormat<T> format)
This operation sets the GlazedList WritableTableFormat that should be
used to describe this List when used by client UI code or other clients
that need to know how to read the List.
|
void |
unregister(IVizUpdateableListener listener)
This operation unregisters a listener that realizes the
IUpdateableListener interface with the IUpdateable so that it will no
longer receive notifications of changes to the IUpdateable if they are
published.
|
void |
update(java.lang.String updatedKey,
java.lang.String newValue)
This operation notifies a class that has implemented IUpdateable that the
value associated with the particular key has been updated.
|
add, addAll, clear, dispose, get, remove, removeAll, retainAll, set, size
public VizListComponent()
public VizListComponent(IElementSource<T> elementSource)
elementSource
- the IElementSource from which new elements should be drawn.public void copy(VizListComponent<T> list)
list
- The list from which the values should be copied.public int hashCode()
public boolean equals(java.lang.Object otherObject)
public void register(IVizUpdateableListener listener)
IVizUpdateable
This operation registers a listener that realizes the IUpdateableListener interface with the IUpdateable so that it can receive notifications of changes to the IUpdateable if they are published.
register
in interface IVizUpdateable
listener
- The new listener that should be notified when the the Component's state changes.
IUpdateable#register(IUpdateableListener listener)
public void unregister(IVizUpdateableListener listener)
IVizUpdateable
This operation unregisters a listener that realizes the IUpdateableListener interface with the IUpdateable so that it will no longer receive notifications of changes to the IUpdateable if they are published.
unregister
in interface IVizUpdateable
listener
- The listener that should no longer receive updates.
IUpdateable#unregister(IUpdateableListener listener)
public void setId(int id)
Identifiable#setId(int id)
public java.lang.String getDescription()
Identifiable#getDescription()
public int getId()
Identifiable#getId()
public void setName(java.lang.String name)
Identifiable#setName(String name)
public java.lang.String getName()
Identifiable#getName()
public void setDescription(java.lang.String description)
Identifiable#setDescription(String description)
public void listChanged(ca.odell.glazedlists.event.ListEvent<T> listChanges)
public java.lang.Object clone()
clone
in class java.lang.Object
public void update(java.lang.String updatedKey, java.lang.String newValue)
IVizUpdateable
This operation notifies a class that has implemented IUpdateable that the value associated with the particular key has been updated.
update
in interface IVizUpdateable
updatedKey
- A unique key that describes the value that to be updated.
newValue
- The updated value of the key.
IUpdateable#update(String updatedKey, String newValue)
public int getColumnCount()
getColumnCount
in interface ca.odell.glazedlists.gui.TableFormat<T>
TableFormat.getColumnCount()
public java.lang.String getColumnName(int column)
getColumnName
in interface ca.odell.glazedlists.gui.TableFormat<T>
TableFormat.getColumnName(int)
public java.lang.Object getColumnValue(T baseObject, int column)
getColumnValue
in interface ca.odell.glazedlists.gui.TableFormat<T>
TableFormat.getColumnValue(java.lang.Object,
int)
public boolean isEditable(T baseObject, int column)
isEditable
in interface ca.odell.glazedlists.gui.WritableTableFormat<T>
WritableTableFormat.isEditable(java.lang.Object,
int)
public T setColumnValue(T baseObject, java.lang.Object editedValue, int column)
setColumnValue
in interface ca.odell.glazedlists.gui.WritableTableFormat<T>
public void setElementSource(IElementSource<T> source)
IListComponent
setElementSource
in interface IListComponent<T>
source
- the element source that provides a list of values that
*should* be used to seed new entries.public IElementSource<T> getElementSource()
IListComponent
getElementSource
in interface IListComponent<T>
public void setTableFormat(ca.odell.glazedlists.gui.WritableTableFormat<T> format)
IListComponent
setTableFormat
in interface IListComponent<T>
format
- The table format. Calls to this class' implementation of the
WritableTableFormat interface will be delegated to this
format.public ca.odell.glazedlists.gui.WritableTableFormat<T> getTableFormat()
IListComponent
getTableFormat
in interface IListComponent<T>
public void addListEventListener(ca.odell.glazedlists.event.ListEventListener<? super T> listChangeListener)
ListComponent also registers the listener to the underlying source list. Effectively, this method can be used to register glazed list listeners.
public void removeListEventListener(ca.odell.glazedlists.event.ListEventListener<? super T> listChangeListener)
ListComponent also removes the listener from the underlying source list. Effectively, this method can be used to unregister glazed list listeners.