public class IlvTreeToTreeListModel extends IlvDefaultTreeListModel
IlvTreeListModel
, based on a
Swing TreeModel
.
Note: This model does not support adding and removing objects. You should
use the underlying TreeModel
for this purpose (assuming it is
an instance of DefaultTreeModel
and its nodes are instances
of MutableTreeNode
).
BEFORE_COLUMN_REMOVED_MASK, BEFORE_DATA_CHANGE_MASK, BEFORE_OBJECTS_REMOVED_MASK, DURING_OBJECTS_REMOVED_MASK
Constructor and Description |
---|
IlvTreeToTreeListModel(TreeModel model,
IlvPropertyConnector propaccess)
Creates a model backed by a given
TreeModel , with zero columns. |
IlvTreeToTreeListModel(TreeModel model,
IlvPropertyConnector propaccess,
IlvDataColumnInfo[] columns)
Creates a model backed by a given
TreeModel , with the given columns. |
IlvTreeToTreeListModel(TreeModel model,
IlvPropertyConnector propaccess,
IlvDataColumnInfo[] columns,
int eventsMaskHint)
Creates a model backed by a given
TreeModel , with the given columns. |
IlvTreeToTreeListModel(TreeModel model,
IlvPropertyConnector propaccess,
int eventsMaskHint)
Creates a model backed by a given
TreeModel , with zero columns. |
Modifier and Type | Method and Description |
---|---|
void |
addChild(Object object,
Object parent)
This method throws an
UnsupportedOperationException . |
void |
addChild(Object object,
Object[] data,
Object parent)
This method throws an
UnsupportedOperationException . |
protected void |
addColumnStorage(int columnIndex,
int insertedColumnCount)
Adds storage for new columns.
|
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.
|
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. |
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)
This method throws an
UnsupportedOperationException . |
void |
insertChild(Object object,
Object parent,
int index)
This method throws an
UnsupportedOperationException . |
void |
insertChildren(Object[] objects,
Object parent,
int index)
This method throws an
UnsupportedOperationException . |
protected boolean |
isColumnComputed(int columnIndex)
Returns
true if setValueAtInternal and setDoubleAtInternal have no effect on a given
column. |
void |
removeAllChildren(Object parent)
This method throws an
UnsupportedOperationException . |
void |
removeChild(Object object,
Object parent)
This method throws an
UnsupportedOperationException . |
void |
removeChildren(Object[] objects,
Object parent,
int firstIndex)
This method throws an
UnsupportedOperationException . |
protected void |
removeColumnStorage(int columnIndex,
int removedColumnCount)
Removes storage for columns that have been dropped.
|
void |
setChildren(Object parent,
List newChildren)
This method throws an
UnsupportedOperationException . |
protected boolean |
setDoubleAtInternal(double value,
Object object,
int columnIndex,
boolean forReal)
Does the equivalent of a
setDoubleAt() . |
void |
setRoot(Object object)
This method throws an
UnsupportedOperationException . |
protected boolean |
setValueAtInternal(Object value,
Object object,
int columnIndex,
boolean forReal)
Does the equivalent of a
setValueAt() . |
clear, getChildAt, getIndexOf, setDoubleAt, setValueAt
addColumn, addColumn, fireModelEvent, getColumn, getColumnCount, getColumns, insertColumn, insertColumn, removeColumn, setColumn, setColumnCount, setColumns
addTreeListModelListener, convertToDouble, endBatch, postOrderIterator, preOrderIterator, removeTreeListModelListener, startBatch
public IlvTreeToTreeListModel(TreeModel model, IlvPropertyConnector propaccess)
TreeModel
, with zero columns.model
- A TreeModel
.propaccess
- The way to access the properties of the model nodes.public IlvTreeToTreeListModel(TreeModel model, IlvPropertyConnector propaccess, int eventsMaskHint)
TreeModel
, with zero columns.model
- A TreeModel
.propaccess
- The way to access the properties of the model nodes.eventsMaskHint
- Desired events mask. This is just a hint; there is
no guarantee that the event types designated by the
mask are supported by this model.public IlvTreeToTreeListModel(TreeModel model, IlvPropertyConnector propaccess, IlvDataColumnInfo[] columns)
TreeModel
, with the given columns.model
- A TreeModel
.propaccess
- The way to access the properties of the model nodes.columns
- The initial list of columns.public IlvTreeToTreeListModel(TreeModel model, IlvPropertyConnector propaccess, IlvDataColumnInfo[] columns, int eventsMaskHint)
TreeModel
, with the given columns.model
- A TreeModel
.propaccess
- The way to access the properties of the model nodes.columns
- The initial list of columns.eventsMaskHint
- Desired events mask. This is just a hint; there is
no guarantee that the event types designated by the
mask are supported by this model.public Object getRoot()
null
if the model
is empty.getRoot
in interface IlvTreeListModel
getRoot
in class IlvDefaultTreeListModel
public List getChildren(Object parent)
getChildren
in interface IlvTreeListModel
getChildren
in class IlvDefaultTreeListModel
public TreePath getPath(Object object)
getPath
in interface IlvTreeListModel
getPath
in class IlvDefaultTreeListModel
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
getValueAt
in class IlvDefaultTreeListModel
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
getDoubleAt
in class IlvDefaultTreeListModel
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.
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
have no effect on a given
column.isColumnComputed
in class IlvBasicTreeListModel
public int getSupportedEventsMask()
This implementation returns
BEFORE_OBJECTS_REMOVED_MASK | DURING_OBJECTS_REMOVED_MASK | BEFORE_COLUMN_REMOVED_MASK
,
intersected with the eventsMaskHint constructor argument.
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 Object getParent(Object object)
null
if
it is the root.getParent
in class IlvDefaultTreeListModel
public void setRoot(Object object)
UnsupportedOperationException
.setRoot
in class IlvDefaultTreeListModel
object
- the new root, or null
public void setChildren(Object parent, List newChildren)
UnsupportedOperationException
.setChildren
in class IlvDefaultTreeListModel
public void addChild(Object object, Object parent)
UnsupportedOperationException
.addChild
in class IlvDefaultTreeListModel
object
- the child object to addparent
- specify where to insert the objectpublic void addChild(Object object, Object[] data, Object parent)
UnsupportedOperationException
.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)
UnsupportedOperationException
.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)
UnsupportedOperationException
.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)
UnsupportedOperationException
.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)
UnsupportedOperationException
.removeChild
in class IlvDefaultTreeListModel
public void removeChildren(Object[] objects, Object parent, int firstIndex)
UnsupportedOperationException
.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)
UnsupportedOperationException
.removeAllChildren
in class IlvDefaultTreeListModel
protected void addColumnStorage(int columnIndex, int insertedColumnCount)
IlvDefaultTreeListModel
addColumnStorage
in class IlvDefaultTreeListModel
protected void removeColumnStorage(int columnIndex, int removedColumnCount)
IlvDefaultTreeListModel
removeColumnStorage
in class IlvDefaultTreeListModel
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, 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.