public class IlvDefaultTreeListModel extends IlvBasicTreeListModel implements Cloneable
IlvTreeListModel
interface.
It stores the objects, the data values and the column info objects locally in this instance.
BEFORE_COLUMN_REMOVED_MASK, BEFORE_DATA_CHANGE_MASK, BEFORE_OBJECTS_REMOVED_MASK, DURING_OBJECTS_REMOVED_MASK
Constructor and Description |
---|
IlvDefaultTreeListModel()
Creates an empty model with no objects and zero columns.
|
IlvDefaultTreeListModel(IlvDataColumnInfo[] columns)
Creates an empty model with no objects and the given columns.
|
IlvDefaultTreeListModel(int numColumns)
Creates an empty model with no objects and the given number of columns.
|
IlvDefaultTreeListModel(Object root,
Collection objects,
IlvDataColumnInfo[] columns)
Creates a model with the given root, the given first-level objects and
the given columns.
|
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.
|
protected void |
addColumnStorage(int columnIndex,
int insertedColumnCount)
Adds storage for new columns.
|
void |
clear()
Removes all objects from the model.
|
Object |
clone()
Returns a copy of this object.
|
void |
dispose()
Cleans up this model and drops references to objects to
help garbage collection.
|
Object |
getChildAt(Object parent,
int index)
Returns the object at a given index in
getChildren(parent) . |
List |
getChildren(Object parent)
Returns the children objects of a given object in this model.
|
double |
getDoubleAt(Object object,
int columnIndex)
Returns the value for the attribute number
columnIndex
in the given object. |
int |
getIndexOf(Object parent,
Object object)
Returns the index of a model object in its parent's children list.
|
Object |
getParent(Object object)
Returns the parent object of a given object, or
null if
it is the root. |
TreePath |
getPath(Object object)
Returns the path from the root to the given object.
|
Object |
getRoot()
Returns the root object in this model, or
null if the model
is empty. |
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.
|
Object |
getValueAt(Object object,
int columnIndex)
Returns the value for the attribute number
columnIndex
in the given object. |
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 |
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.
|
protected void |
removeColumnStorage(int columnIndex,
int removedColumnCount)
Removes storage for columns that have been dropped.
|
void |
setChildren(Object parent,
List newChildren)
Replaces the set of children of a given object in the model.
|
void |
setDoubleAt(double value,
Object object,
int columnIndex)
Sets the value for the attribute number
columnIndex
in the given object to the given value . |
protected boolean |
setDoubleAtInternal(double value,
Object object,
int columnIndex,
boolean forReal)
Does a setDoubleAt(), except instead of notifying it simply returns
a
boolean indicating whether notification should be done. |
void |
setRoot(Object object)
Changes the root object of the model.
|
void |
setValueAt(Object value,
Object object,
int columnIndex)
Sets the value for the attribute number
columnIndex
in the given object to the given value . |
protected boolean |
setValueAtInternal(Object value,
Object object,
int columnIndex,
boolean forReal)
Does the equivalent of a
setValueAt() . |
addColumn, addColumn, disconnect, fireModelEvent, getColumn, getColumnCount, getColumns, insertColumn, insertColumn, isColumnComputed, removeColumn, setColumn, setColumnCount, setColumns
addTreeListModelListener, convertToDouble, endBatch, postOrderIterator, preOrderIterator, removeTreeListModelListener, startBatch
public IlvDefaultTreeListModel()
public IlvDefaultTreeListModel(int numColumns)
public IlvDefaultTreeListModel(IlvDataColumnInfo[] columns)
public IlvDefaultTreeListModel(Object root, Collection objects, IlvDataColumnInfo[] columns)
public Object getRoot()
null
if the model
is empty.getRoot
in interface IlvTreeListModel
public List getChildren(Object parent)
getChildren
in interface IlvTreeListModel
public TreePath getPath(Object object)
getPath
in interface IlvTreeListModel
getPath
in class IlvAbstractTreeListModel
object
- An object in the model.TreePath
whose first component is
getRoot()
and whose last component is the given
object.public Object getValueAt(Object object, int columnIndex)
columnIndex
in the given object.getValueAt
in interface IlvObjectModelWithColumns
getValueAt
in interface IlvTreeListModel
object
- The object (row) in which the value is to be looked up.columnIndex
- The column denoting the attribute whose value is to be
looked up.public double getDoubleAt(Object object, int columnIndex)
columnIndex
in the given object.
This method should only be used for columns whose type is
Double. For other types of columns, this method will do a conversion
from the object returned by getValueAt
, which may be
inefficient or inaccurate or raise exceptions.
getDoubleAt
in interface IlvObjectModelWithColumns
getDoubleAt
in interface IlvTreeListModel
object
- The object (row) in which the value is to be looked up.columnIndex
- The column denoting the attribute whose value is to be
looked up.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.
protected boolean setDoubleAtInternal(double value, Object object, int columnIndex, boolean forReal)
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, telling whether the given value is different from the previous one.
public void setValueAt(Object value, Object object, int columnIndex)
columnIndex
in the given object to the given value
.setValueAt
in interface IlvObjectModelWithColumns
setValueAt
in interface IlvTreeListModel
value
- The new value.object
- The object (row) in which the value is to be changed.columnIndex
- The column denoting the attribute whose value is to be
changed.public void setDoubleAt(double value, Object object, int columnIndex)
columnIndex
in the given object to the given value
.
This method should only be used for columns whose type is Double. For other types of columns, this method will do a conversion to the column type, which may be inefficient or inaccurate or raise exceptions.
setDoubleAt
in interface IlvObjectModelWithColumns
setDoubleAt
in interface IlvTreeListModel
value
- The new value.object
- The object (row) in which the value is to be changed.columnIndex
- The column denoting the attribute whose value is to be
changed.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 IlvBasicTreeListModel
IlvTreeListModel.BEFORE_DATA_CHANGE_MASK
,
IlvTreeListModel.BEFORE_OBJECTS_REMOVED_MASK
,
IlvTreeListModel.BEFORE_COLUMN_REMOVED_MASK
public Object getParent(Object object)
null
if
it is the root.public Object getChildAt(Object parent, int index)
getChildren(parent)
.parent
- the parent objectindex
- the index of the requested model objectIllegalArgumentException
- if the index is out of rangepublic int getIndexOf(Object parent, Object object)
parent
- the parent objectobject
- the model object for which the index is requestedIllegalArgumentException
- if the object is not contained in the
modelpublic void setRoot(Object object)
object
- the new root, or null
public void setChildren(Object parent, List newChildren)
public void addChild(Object object, Object parent)
object
- the child object to addparent
- specify where to insert the objectpublic void addChild(Object object, Object[] data, Object parent)
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)
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)
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)
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)
public void removeChildren(Object[] objects, Object parent, int firstIndex)
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)
public void clear()
protected void addColumnStorage(int columnIndex, int insertedColumnCount)
addColumnStorage
in class IlvBasicTreeListModel
protected void removeColumnStorage(int columnIndex, int removedColumnCount)
removeColumnStorage
in class IlvBasicTreeListModel
public void dispose()
Note: After calling this function, this model is no longer functional.
dispose
in class IlvBasicTreeListModel
public Object clone()
clone
in class IlvBasicTreeListModel
© Copyright 2024 Rogue Wave Software, Inc., a Perforce company.. All Rights Reserved.