TemplateJTreeModel

class TemplateJTreeModel(list: TemplateList = TemplateList(mutableListOf())) : TreeModel, EditableModel, RowsDnDSupport.RefinedDropSupport(source)

The underlying model of the TemplateJTree, which synchronizes its state with a TemplateList so that modifications to the model appear in the list and vice versa.

If the list is modified externally, this model should be notified using a fire method (e.g. fireNodeChanged). Except for the fire methods, the behavior of this model is undefined while uninformed of external changes.

Parameters

list

the list to be modeled

Constructors

Link copied to clipboard
constructor(list: TemplateList = TemplateList(mutableListOf()))

Properties

Link copied to clipboard
var viewIndexToModelIndex: (Int) -> Int

Converts the row index in the view to the corresponding row index in the model.

Link copied to clipboard
var wrapDrop: (() -> Unit) -> Unit

A wrapper provided by the view and used by TemplateJTreeModel.drop to ensure the view's selection and expansion state are retained.

Functions

Link copied to clipboard
open override fun addRow(): Nothing

Not implemented because this method is used only if this is a model for a table.

Link copied to clipboard
open override fun addTreeModelListener(listener: TreeModelListener)

Adds listener as a listener.

Link copied to clipboard
open override fun canDrop(fromIndex: Int, toIndex: Int, position: RowsDnDSupport.RefinedDropSupport.Position): Boolean

Invokes canMoveRow after converting fromIndex and toIndex using viewIndexToModelIndex.

Link copied to clipboard
open override fun canExchangeRows(oldIndex: Int, newIndex: Int): Boolean

Use canMoveRow instead.

Link copied to clipboard
fun canMoveRow(fromIndex: Int, toIndex: Int, position: RowsDnDSupport.RefinedDropSupport.Position): Boolean

Returns true if and only if moveRow can be invoked with the given parameters.

Link copied to clipboard
open override fun drop(fromIndex: Int, toIndex: Int, position: RowsDnDSupport.RefinedDropSupport.Position)

Invokes moveRow after converting fromIndex and toIndex using viewIndexToModelIndex.

Link copied to clipboard
open override fun exchangeRows(oldIndex: Int, newIndex: Int): Nothing

Use moveRow instead.

Link copied to clipboard

Informs listeners that node has been changed.

Link copied to clipboard
fun fireNodeInserted(node: StateNode?, parent: StateNode, index: Int)

Informs listeners that node has been inserted into this model as the indexth child of parent.

Link copied to clipboard
fun fireNodeRemoved(child: StateNode?, parent: StateNode, index: Int)

Informs listeners that child has been removed from this model, but was formerly the indexth child of parent.

Link copied to clipboard

Informs listeners that node's structure has been changed.

Link copied to clipboard
open override fun getChild(parent: Any, index: Int): StateNode

Returns the indexth child of parent.

Link copied to clipboard
open override fun getChildCount(parent: Any): Int

Returns the number of children of parent.

Link copied to clipboard
open override fun getIndexOfChild(parent: Any?, child: Any?): Int

Returns the relative index of child in parent, or -1 if (1) either parent or child is null, (2) either parent or child is not a StateNode, (3) either parent or child is not contained in this model, or (4) if child is not a child of parent.

Link copied to clipboard

Returns the parent of node, or null if node has no parent.

Link copied to clipboard
fun getPathToRoot(node: StateNode): TreePath

Returns the path from root to node.

Link copied to clipboard
open override fun getRoot(): StateNode

Returns root.

Link copied to clipboard
fun insertNode(parent: StateNode, child: StateNode, index: Int = getChildCount(parent))

Inserts child as the indexth child of parent.

Link copied to clipboard
fun insertNodeAfter(parent: StateNode, after: StateNode, child: StateNode)

Inserts child as a child into parent right after after.

Link copied to clipboard
open override fun isDropInto(component: JComponent?, fromIndex: Int, toIndex: Int): Boolean

Returns true if and only if the node at fromIndex can be moved Position.INTO the node at toIndex.

Link copied to clipboard
open override fun isLeaf(node: Any): Boolean

Returns true if and only if node is contained in this model and node does not have children.

Link copied to clipboard
fun moveRow(fromIndex: Int, toIndex: Int, position: RowsDnDSupport.RefinedDropSupport.Position)

Moves the node at row fromIndex near the node at row toIndex as specified by position.

Link copied to clipboard

Removes node from this model.

Link copied to clipboard
open override fun removeRow(index: Int): Nothing

Not implemented because this method is used only if this is a model for a table.

Link copied to clipboard
open override fun removeTreeModelListener(listener: TreeModelListener)

Removes listener as a listener.

Link copied to clipboard
open override fun valueForPathChanged(path: TreePath, newValue: Any): Nothing

Not implemented because this model does not contain an editor component.