public abstract class MyAbstractTreeTableModel<T extends MyTreeNode> extends Object implements MyTreeTableModel<T>
Modifier and Type | Field and Description |
---|---|
protected T |
absoluteRoot
The absolute root of the hierarchical structure.
|
protected EventListenerList |
listenerList |
protected T |
visibleRoot |
Constructor and Description |
---|
MyAbstractTreeTableModel(UploadPolicy uploadPolicy,
T root) |
Modifier and Type | Method and Description |
---|---|
void |
addTreeModelListener(TreeModelListener l) |
boolean |
cleanHierarchy()
This method removes all empty folders.
|
boolean |
cleanHierarchy(T node)
Cleans the hierarchy behind a given node.
|
void |
fireTreeNodesChanged(Object source,
TreePath path,
int[] childIndices,
T[] children)
This method must be called when one or more nodes are changed.
|
void |
fireTreeNodesInserted(Object source,
TreePath path,
int[] childIndices,
T[] children)
This method must be called when one or more nodes are changed.
|
void |
fireTreeNodesRemoved(Object source,
TreePath path,
int[] childIndices,
T[] children)
This method must be called when one or more nodes are changed.
|
void |
fireTreeStructureChanged(Object source,
TreePath path,
int[] childIndices,
T[] children)
This method must be called when one or more nodes are changed.
|
T |
getAbsoluteRoot() |
T |
getChild(Object parent,
int index) |
int |
getChildCount(Object child) |
int |
getIndexOfChild(Object parent,
Object child)
This is normally not called
|
T |
getRoot()
Get the visible root of the JTree view.
|
MyTreeTableCellRenderer |
getTree() |
TreePath |
getTreePath(T item)
This method build a
TreePath for the given item. |
abstract Object |
getValueAt(T nodeForRow,
int column)
Returns the value of a node in a column.
|
boolean |
isLeaf(Object node) |
void |
reload()
Invoke this method if you've modified the TreeNodes upon which this model depends.
|
void |
reload(T node)
Invoke this method if you've modified the TreeNodes upon which this model depends.
|
void |
remove(T item)
Removes an item from the TreeView.
|
void |
removeAndClean(T item)
Removes an item from the TreeView, detach its descendant, and remove the parent node if this node was the only
child of the parent.
|
void |
removeTreeModelListener(TreeModelListener l) |
void |
setRoot(T root)
Set the visible root of the JTree view.
|
void |
setTree(MyTreeTableCellRenderer tree) |
void |
valueForPathChanged(TreePath path,
Object newValue)
This is normally not called
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
attachObject, getColumnClass, getColumnCount, getColumnName, getColumnSizePercentage, getTreePathForObject, isCellEditable, setValueAt
protected T extends MyTreeNode absoluteRoot
protected T extends MyTreeNode visibleRoot
protected EventListenerList listenerList
public MyAbstractTreeTableModel(UploadPolicy uploadPolicy, T root)
public MyTreeTableCellRenderer getTree()
public void setTree(MyTreeTableCellRenderer tree)
setTree
in interface MyTreeTableModel<T extends MyTreeNode>
tree
- the tree to setpublic T getAbsoluteRoot()
public T getRoot()
MyTreeTableModel
getRoot
in interface TreeModel
getRoot
in interface MyTreeTableModel<T extends MyTreeNode>
MyTreeTableModel.getRoot()
public void setRoot(T root)
MyTreeTableModel
setRoot
in interface MyTreeTableModel<T extends MyTreeNode>
IllegalArgumentException
- If this root is not valid.MyTreeTableModel.setRoot(MyTreeNode)
public void remove(T item)
MyTreeTableModel
remove
in interface MyTreeTableModel<T extends MyTreeNode>
MyTreeTableModel.remove(MyTreeNode)
public void removeAndClean(T item)
MyTreeTableModel
removeAndClean
in interface MyTreeTableModel<T extends MyTreeNode>
MyTreeTableModel.remove(MyTreeNode)
public TreePath getTreePath(T item)
MyTreeTableModel
TreePath
for the given item. This item should be in the current tree.getTreePath
in interface MyTreeTableModel<T extends MyTreeNode>
MyTreeTableModel.getTreePath(MyTreeNode)
public void addTreeModelListener(TreeModelListener l)
addTreeModelListener
in interface TreeModel
public void removeTreeModelListener(TreeModelListener l)
removeTreeModelListener
in interface TreeModel
public boolean cleanHierarchy()
MyTreeTableModel
cleanHierarchy
in interface MyTreeTableModel<T extends MyTreeNode>
MyTreeTableModel.reload()
method is called.MyTreeTableModel.cleanHierarchy()
public boolean cleanHierarchy(T node)
MyTreeTableModel.cleanHierarchy()
public void reload()
MyTreeTableModel
Invoke this method if you've modified the TreeNodes upon which this model depends. The model will notify all of its listeners that the model has changed. It will fire the events, necessary to update the layout caches and repaint the tree. The tree will not be properly refreshed if you call the JTree.repaint instead.
This method will refresh the information about whole tree from the root. If only part of the tree should be
refreshed, it is more effective to call #reload(TreeNode)
.
Note: code taken from the JDK DefaultTreeModel.
reload
in interface MyTreeTableModel<T extends MyTreeNode>
MyTreeTableModel.reload()
public void reload(T node)
MyTreeTableModel
reload
in interface MyTreeTableModel<T extends MyTreeNode>
node
- - the tree node, from which the tree nodes have changed (inclusive). If you do not know this node,
call MyTreeTableModel.reload()
instead.MyTreeTableModel.reload(MyTreeNode)
public void fireTreeNodesChanged(Object source, TreePath path, int[] childIndices, T[] children)
MyTreeTableModel
fireTreeNodesChanged
in interface MyTreeTableModel<T extends MyTreeNode>
source
- - the Object responsible for generating the event (typically the creator of the event object passes
this for its value)path
- - a TreePath object that identifies the path to the parent of the modified item(s)childIndices
- - an array of int that specifies the index values of the modified itemschildren
- - an array of Object containing the inserted, removed, or changed objectsMyTreeTableModel#fireTreeNodesChanged(MyTreeNode, MyTreeNode[], int[], MyTreeNode[])
public void fireTreeNodesInserted(Object source, TreePath path, int[] childIndices, T[] children)
MyTreeTableModel
fireTreeNodesInserted
in interface MyTreeTableModel<T extends MyTreeNode>
source
- - the Object responsible for generating the event (typically the creator of the event object passes
this for its value)path
- - a TreePath object that identifies the path to the parent of the modified item(s)childIndices
- - an array of int that specifies the index values of the modified itemschildren
- - an array of Object containing the inserted, removed, or changed objectsMyTreeTableModel#fireTreeNodesInserted(MyTreeNode, MyTreeNode[], int[], MyTreeNode[])
public void fireTreeNodesRemoved(Object source, TreePath path, int[] childIndices, T[] children)
MyTreeTableModel
fireTreeNodesRemoved
in interface MyTreeTableModel<T extends MyTreeNode>
source
- - the Object responsible for generating the event (typically the creator of the event object passes
this for its value)path
- - a TreePath object that identifies the path to the parent of the modified item(s)childIndices
- - an array of int that specifies the index values of the modified itemschildren
- - an array of Object containing the inserted, removed, or changed objectsMyTreeTableModel#fireTreeNodesRemoved(MyTreeNode, MyTreeNode[], int[], MyTreeNode[])
public void fireTreeStructureChanged(Object source, TreePath path, int[] childIndices, T[] children)
MyTreeTableModel
fireTreeStructureChanged
in interface MyTreeTableModel<T extends MyTreeNode>
source
- - the Object responsible for generating the event (typically the creator of the event object passes
this for its value)path
- - a TreePath object that identifies the path to the parent of the modified item(s)childIndices
- - an array of int that specifies the index values of the modified itemschildren
- - an array of Object containing the inserted, removed, or changed objectsMyTreeTableModel#fireTreeStructureChanged(MyTreeNode, MyTreeNode[], int[], MyTreeNode[])
public final T getChild(Object parent, int index)
getChild
in interface TreeModel
TreeModel.getChild(Object, int)
public final int getChildCount(Object child)
getChildCount
in interface TreeModel
TreeModel.getChildCount(Object)
public final boolean isLeaf(Object node)
isLeaf
in interface TreeModel
TreeModel.isLeaf(Object)
public final void valueForPathChanged(TreePath path, Object newValue)
valueForPathChanged
in interface TreeModel
TreeModel.valueForPathChanged(TreePath, Object)
public final int getIndexOfChild(Object parent, Object child)
getIndexOfChild
in interface TreeModel
TreeModel.getIndexOfChild(Object, Object)
public abstract Object getValueAt(T nodeForRow, int column)
MyTreeTableModel
getValueAt
in interface MyTreeTableModel<T extends MyTreeNode>
nodeForRow
- Nodecolumn
- Column numberCopyright © 2015. All rights reserved.