|
org.netbeans.swing.outline 1.20 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.netbeans.swing.outline.DefaultOutlineModel
public class DefaultOutlineModel
Proxies a standard TreeModel and TableModel, translating events between
the two. Note that the constructor is not public; the TableModel that is
proxied is the OutlineModel's own. To make use of this class, implement
RowModel - that is a mini-table model in which the TreeModel is responsible
for defining the set of rows; it is passed an object from the tree, which
it may use to generate values for the other columns. Pass that and the
TreeModel you want to use to createOutlineModel.
A note on TableModelEvents produced by this model: There is a slight impedance mismatch between TableModelEvent and TreeModelEvent. When the tree changes, it is necessary to fire TableModelEvents to update the display. However, TreeModelEvents support changes to discontiguous segments of the model (i.e. "child nodes 3, 4 and 9 were deleted"). TableModelEvents have no such concept - they operate on contiguous ranges of rows. Therefore, one incoming TreeModelEvent may result in more than one TableModelEvent being fired. Discontiguous TreeModelEvents will be broken into their contiguous segments, which will be fired sequentially (in the case of removals, in reverse order). So, the example above would generate two TableModelEvents, the first indicating that row 9 was removed, and the second indicating that rows 3 and 4 were removed.
Clients which need to know whether the TableModelEvent they have just
received is one of a group (perhaps they update some data structure, and
should not do so until the table's state is fully synchronized with that
of the tree model) may call areMoreEventsPending().
In the case of TreeModelEvents which add items to an unexpanded tree node, a simple value change TableModelEvent will be fired for the row in question on the tree column index.
Note also that if the model is large-model, removal events may only indicate those indices which were visible at the time of removal, because less data is retained about the position of nodes which are not displayed. In this case, the only issue is the accuracy of the scrollbar in the model; in practice this is a non-issue, since it is based on the Outline's row count, which will be accurate.
A note to subclassers, if we even leave this class non-final: If you do not use ProxyTableModel and RowMapper (which probably means you are doing something wrong), do not fire structural changes from the TableModel. This class is designed such that the TreeModel is entirely in control of the count and contents of the rows of the table. It and only it may fire structural changes.
Note that this class enforces access only on the event dispatch thread with assertions. All events fired by the underlying table and tree model must be fired on the event dispatch thread.
| Constructor Summary | |
|---|---|
protected |
DefaultOutlineModel(TreeModel treeModel,
RowModel rowModel,
boolean largeModel,
String nodesColumnLabel)
Create a new instance of DefaultOutlineModel using the supplied tree model and row model, specifying if it is a large-model tree |
protected |
DefaultOutlineModel(TreeModel treeModel,
TableModel tableModel,
boolean largeModel,
String nodesColumnLabel)
Creates a new instance of DefaultOutlineModel. |
| Method Summary | |
|---|---|
void |
addTableModelListener(TableModelListener l)
|
void |
addTreeModelListener(TreeModelListener l)
|
boolean |
areMoreEventsPending()
Flag which is set to true while multiple TableModelEvents generated from a single TreeModelEvent are being fired, so clients can avoid any model queries until all pending changes have been fired. |
static OutlineModel |
createOutlineModel(TreeModel treeModel,
RowModel rowModel)
Create a small model OutlineModel using the supplied tree model and row model |
static OutlineModel |
createOutlineModel(TreeModel treeModel,
RowModel rowModel,
boolean isLargeModel)
Create an OutlineModel using the supplied tree model and row model, specifying if it is a large-model tree |
static OutlineModel |
createOutlineModel(TreeModel treeModel,
RowModel rowModel,
boolean isLargeModel,
String nodesColumnLabel)
Create an OutlineModel using the supplied tree model and row model, specifying if it is a large-model tree |
Object |
getChild(Object parent,
int index)
|
int |
getChildCount(Object parent)
|
Class |
getColumnClass(int columnIndex)
Delegates to the RowMapper for > 0 columns; column 0 always returns Object.class |
int |
getColumnCount()
|
String |
getColumnName(int columnIndex)
|
int |
getIndexOfChild(Object parent,
Object child)
|
AbstractLayoutCache |
getLayout()
Get the layout cache which is used to track the visual state of nodes. |
Object |
getRoot()
|
int |
getRowCount()
|
TreePathSupport |
getTreePathSupport()
Get the TreePathSupport object this model uses to manage
information about expanded nodes. |
Object |
getValueAt(int rowIndex,
int columnIndex)
|
boolean |
isCellEditable(int rowIndex,
int columnIndex)
|
boolean |
isLargeModel()
Determine if the model is a large-model. |
boolean |
isLeaf(Object node)
|
void |
removeTableModelListener(TableModelListener l)
|
void |
removeTreeModelListener(TreeModelListener l)
|
void |
setNodesColumnLabel(String label)
Change the label of the 'tree' column. |
protected void |
setTreeValueAt(Object aValue,
int rowIndex)
Sets the value of a 'tree' cell at given row number. |
void |
setValueAt(Object aValue,
int rowIndex,
int columnIndex)
Delegates to the RowModel (or TableModel) for non-0 columns |
void |
valueForPathChanged(TreePath path,
Object newValue)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
protected DefaultOutlineModel(TreeModel treeModel,
RowModel rowModel,
boolean largeModel,
String nodesColumnLabel)
treeModel - The tree modelrowModel - The row modellargeModel - true if it's a large model tree, false otherwise.nodesColumnLabel - Label of the node's column
protected DefaultOutlineModel(TreeModel treeModel,
TableModel tableModel,
boolean largeModel,
String nodesColumnLabel)
treeModel - The tree modeltableModel - The table modellargeModel - true if it's a large model tree, false otherwise.nodesColumnLabel - Label of the node's column| Method Detail |
|---|
public static OutlineModel createOutlineModel(TreeModel treeModel,
RowModel rowModel)
treeModel - The tree model that is the data model for the expandable
tree column of an OutlinerowModel - The row model which will supply values for each row based
on the tree node in that row in the tree model
public static OutlineModel createOutlineModel(TreeModel treeModel,
RowModel rowModel,
boolean isLargeModel)
treeModel - The tree modelrowModel - The row modelisLargeModel - true if it's a large model tree, false otherwise.
public static OutlineModel createOutlineModel(TreeModel treeModel,
RowModel rowModel,
boolean isLargeModel,
String nodesColumnLabel)
treeModel - The tree modelrowModel - The row modelisLargeModel - true if it's a large model tree, false otherwise.nodesColumnLabel - Label of the node's columnpublic final TreePathSupport getTreePathSupport()
OutlineModelTreePathSupport object this model uses to manage
information about expanded nodes. TreePathSupport implements
logic for tracking expanded nodes, manages TreeWillExpandListeners,
and is a repository for preserving expanded state information about nodes whose parents
are currently collapsed. JTree implements very similar logic internally
to itself.
(PENDING) It is not yet determined if TreePathSupport will remain a public class.
getTreePathSupport in interface OutlineModelpublic final AbstractLayoutCache getLayout()
OutlineModelVariableHeightLayoutCache or
FixedHeightLayoutCache.
getLayout in interface OutlineModelpublic boolean areMoreEventsPending()
This value is guaranteed to be true for the first group of related events, and false if tested in response to the final event.
true if more events are pending, false otherwise.
public final Object getChild(Object parent,
int index)
getChild in interface TreeModelpublic final int getChildCount(Object parent)
getChildCount in interface TreeModelpublic final Class getColumnClass(int columnIndex)
getColumnClass in interface TableModelpublic final int getColumnCount()
getColumnCount in interface TableModelpublic String getColumnName(int columnIndex)
getColumnName in interface TableModelpublic void setNodesColumnLabel(String label)
label - New label for tree column.
public final int getIndexOfChild(Object parent,
Object child)
getIndexOfChild in interface TreeModelpublic final Object getRoot()
getRoot in interface TreeModelpublic final int getRowCount()
getRowCount in interface TableModel
public final Object getValueAt(int rowIndex,
int columnIndex)
getValueAt in interface TableModel
public boolean isCellEditable(int rowIndex,
int columnIndex)
isCellEditable in interface TableModelpublic final boolean isLeaf(Object node)
isLeaf in interface TreeModelpublic final void addTableModelListener(TableModelListener l)
addTableModelListener in interface TableModelpublic final void addTreeModelListener(TreeModelListener l)
addTreeModelListener in interface TreeModelpublic final void removeTableModelListener(TableModelListener l)
removeTableModelListener in interface TableModelpublic final void removeTreeModelListener(TreeModelListener l)
removeTreeModelListener in interface TreeModel
public final void setValueAt(Object aValue,
int rowIndex,
int columnIndex)
setValueAt in interface TableModel
protected void setTreeValueAt(Object aValue,
int rowIndex)
aValue - rowIndex -
public final void valueForPathChanged(TreePath path,
Object newValue)
valueForPathChanged in interface TreeModelpublic boolean isLargeModel()
OutlineModel
isLargeModel in interface OutlineModel
|
org.netbeans.swing.outline 1.20 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||