public class IlvBufferTreeListModel extends IlvDefaultTreeListModel
IlvTreeListModel
that
buffers (caches) the data of a given IlvTreeListModel
.
It is meant to be used when the access to the original
IlvTreeListModel
is slow.
Changes in the underlying model are propagated to this model if and
only if the isNotifying
method returns true
.
Note: This model supports adding and removing objects if and only
if the underlying IlvTreeListModel
is an instance of
IlvDefaultTreeListModel
. It supports adding and removing
columns if and only if the underlying IlvTreeListModel
is an instance of IlvBasicTreeListModel
.
BEFORE_COLUMN_REMOVED_MASK, BEFORE_DATA_CHANGE_MASK, BEFORE_OBJECTS_REMOVED_MASK, DURING_OBJECTS_REMOVED_MASK
Constructor and Description |
---|
IlvBufferTreeListModel(IlvTreeListModel model)
Creates a model that is fed by and caches the data of a given
IlvTreeListModel . |
Modifier and Type | Method and Description |
---|---|
void |
addChild(Object object,
Object parent)
Adds an object to the list of children of a parent object in the model.
|
void |
addChild(Object object,
Object[] data,
Object parent)
Adds an object to the list of children of a parent object in the model.
|
Object |
clone()
Returns a copy of this object.
|
void |
disconnect()
Drops references to objects to help garbage collection.
|
void |
dispose()
Cleans up this model and drops references to objects to
help garbage collection.
|
int |
getSupportedEventsMask()
Returns a bit mask denoting the optional kinds of events that are guaranteed
to be sent by this model to the registered listeners.
|
void |
insertChild(Object object,
Object[] data,
Object parent,
int index)
Adds an object to the list of children of a parent object in the model
at a given index.
|
void |
insertChild(Object object,
Object parent,
int index)
Adds an object to the list of children of a parent object in the model
at a given index.
|
void |
insertChildren(Object[] objects,
Object parent,
int index)
Adds some objects to the list of children of a parent object in the model
at a given index.
|
void |
insertColumn(int columnIndex,
IlvDataColumnInfo column)
Adds a column to the model at a given index.
|
void |
insertColumn(int columnIndex,
IlvDataColumnInfo column,
Map data)
Adds a column with given data to the model at a given index.
|
protected boolean |
isColumnComputed(int columnIndex)
Returns
true if setValueAtInternal and setDoubleAtInternal on a given
column have no effect. |
boolean |
isNotifying()
Returns
true when this model is a dynamically updated cache
of the underlying model. |
void |
removeAllChildren(Object parent)
Removes all children objects of a parent object in the model.
|
void |
removeChild(Object object,
Object parent)
Removes an object from the list of children of a parent object in the
model.
|
void |
removeChildren(Object[] objects,
Object parent,
int firstIndex)
Removes some consecutive children of a common parent object, and their
subtrees, from the model.
|
void |
removeColumn(int columnIndex)
Removes a column from the model.
|
void |
setChildren(Object parent,
List newChildren)
Replaces the set of children of a given object in the model.
|
void |
setColumnCount(int columnCount)
Sets the number of columns in the model.
|
protected boolean |
setDoubleAtInternal(double value,
Object object,
int columnIndex,
boolean forReal)
Does the equivalent of a
setDoubleAt() . |
void |
setNotifying(boolean dynamic)
Determines whether this model is a dynamically updated cache of the
underlying event (and therefore also sends events when the underlying
model changes).
|
void |
setRoot(Object object)
Changes the root object of the model.
|
protected boolean |
setValueAtInternal(Object value,
Object object,
int columnIndex,
boolean forReal)
Does the equivalent of a
setValueAt() . |
addColumnStorage, clear, getChildAt, getChildren, getDoubleAt, getIndexOf, getParent, getPath, getRoot, getValueAt, removeColumnStorage, setDoubleAt, setValueAt
addColumn, addColumn, fireModelEvent, getColumn, getColumnCount, getColumns, setColumn, setColumns
addTreeListModelListener, convertToDouble, endBatch, postOrderIterator, preOrderIterator, removeTreeListModelListener, startBatch
public IlvBufferTreeListModel(IlvTreeListModel model)
IlvTreeListModel
.protected boolean setValueAtInternal(Object value, Object object, int columnIndex, boolean forReal)
setValueAt()
. Instead of notifying, it simply returns
a boolean
indicating whether notification should be done.
If forReal is false
, the value is not actually set, but the
method still returns the same Boolean, indicating whether the given value is
different from the previous one.
setValueAtInternal
in class IlvDefaultTreeListModel
protected boolean setDoubleAtInternal(double value, Object object, int columnIndex, boolean forReal)
setDoubleAt()
. Instead of notifying, it simply returns
a boolean
indicating whether notification should be done.
If forReal is false
, the value is not actually set, but the
method still returns the same Boolean, indicating whether the given value is
different from the previous one.
setDoubleAtInternal
in class IlvDefaultTreeListModel
protected boolean isColumnComputed(int columnIndex)
true
if setValueAtInternal
and setDoubleAtInternal
on a given
column have no effect.isColumnComputed
in class IlvBasicTreeListModel
public int getSupportedEventsMask()
This implementation returns
BEFORE_DATA_CHANGE_MASK | BEFORE_OBJECTS_REMOVED_MASK | DURING_OBJECTS_REMOVED_MASK | BEFORE_COLUMN_REMOVED_MASK
.
It may need to be overridden in subclasses.
getSupportedEventsMask
in interface IlvTreeListModel
getSupportedEventsMask
in class IlvDefaultTreeListModel
IlvTreeListModel.BEFORE_DATA_CHANGE_MASK
,
IlvTreeListModel.BEFORE_OBJECTS_REMOVED_MASK
,
IlvTreeListModel.BEFORE_COLUMN_REMOVED_MASK
public void setRoot(Object object)
setRoot
in class IlvDefaultTreeListModel
object
- the new root, or null
public void setChildren(Object parent, List newChildren)
setChildren
in class IlvDefaultTreeListModel
public void addChild(Object object, Object parent)
addChild
in class IlvDefaultTreeListModel
object
- the child object to addparent
- specify where to insert the objectpublic void addChild(Object object, Object[] data, Object parent)
addChild
in class IlvDefaultTreeListModel
object
- object the child object to adddata
- The initial data of this object. It must be an array of
getColumnCount()
elements.parent
- specify where to insert the objectpublic void insertChild(Object object, Object parent, int index)
insertChild
in class IlvDefaultTreeListModel
object
- the child object to addparent
- specify where to insert the objectindex
- the new object's desired index, must be >= 0 and
<= parent.getChildren().size()
public void insertChild(Object object, Object[] data, Object parent, int index)
insertChild
in class IlvDefaultTreeListModel
object
- the child object to adddata
- The initial data of this object. It must be an array of
getColumnCount()
elements.parent
- specify where to insert the objectindex
- the new object's desired index, must be >= 0 and
<= parent.getChildren().size()
public void insertChildren(Object[] objects, Object parent, int index)
insertChildren
in class IlvDefaultTreeListModel
objects
- the objects to addparent
- specify where to insert the objectindex
- the first new object's desired index, must be >= 0 and
<= parent.getChildren().size()
public void removeChild(Object object, Object parent)
removeChild
in class IlvDefaultTreeListModel
public void removeChildren(Object[] objects, Object parent, int firstIndex)
removeChildren
in class IlvDefaultTreeListModel
objects
- the objects that were at indices firstIndex, ...,
firstIndex+objects.length-1 of
getChildren(parent).iterator()
parent
- where to find the objectsfirstIndex
- object to remove must be afterpublic void removeAllChildren(Object parent)
removeAllChildren
in class IlvDefaultTreeListModel
public void setColumnCount(int columnCount)
columnCount
and greater are discarded.setColumnCount
in class IlvBasicTreeListModel
columnCount
- the new number of columnspublic void insertColumn(int columnIndex, IlvDataColumnInfo column)
insertColumn
in class IlvBasicTreeListModel
columnIndex
- The new column desired index, must be >= 0 and
<= getColumnCount()
.column
- The meta information of this column.public void insertColumn(int columnIndex, IlvDataColumnInfo column, Map data)
insertColumn
in class IlvBasicTreeListModel
columnIndex
- The new column desired index, must be >= 0 and
<= getColumnCount()
.column
- The meta information of this column.data
- The initial data of this column. This should be a map
that assigns a value to every object in this model.public void removeColumn(int columnIndex)
removeColumn
in class IlvBasicTreeListModel
columnIndex
- The column index, must be >= 0 and
< getColumnCount()
.public boolean isNotifying()
true
when this model is a dynamically updated cache
of the underlying model. Returns false
when this model is
a snapshot buffer of the underlying model.setNotifying(boolean)
public void setNotifying(boolean dynamic)
Note: If setNotifying(true)
is called, after notification was
turned off, it has the effect of bringing the entire cache up to date;
this can be an expensive operation.
isNotifying()
public void dispose()
Note: After calling this function, this model is no longer functional.
dispose
in class IlvDefaultTreeListModel
public void disconnect()
Note: After calling this function, and after some changes occurred in the underlying model or columns, this model is no longer functional.
disconnect
in class IlvBasicTreeListModel
public Object clone()
clone
in class IlvDefaultTreeListModel
© Copyright 2024 Rogue Wave Software, Inc., a Perforce company.. All Rights Reserved.