TemplateJTree

class TemplateJTree(originalTemplateList: TemplateList, currentTemplateList: TemplateList) : Tree(source)

A tree containing Templates and Schemes.

Changes made through this tree's interface (e.g. adding, removing, copying) are immediately reflected in the currentTemplateList. The originalTemplateList is used only as a reference point to determine what changes have occurred, for example when isModified is called or when the end user requests that changes are (partially) reverted.

If changes are made outside of this tree's interface (i.e. by directly operating on the currentTemplateList instance that was passed in the constructor), this tree's internal model becomes desynchronized, and must be resynchronized by invoking reload. Except for reload, the behaviour of this tree is undefined while desynchronized.

Internally, the currentTemplateList is loaded into a TemplateJTreeModel. The TemplateJTree class is the corresponding user interface class, which additionally provides (1) toolbars and buttons for manipulating the model, (2) node expansion and selection, and (3) handling for tracking and reversing modifications.

Parameters

originalTemplateList

the (read-only) original templates without modifications

currentTemplateList

the current templates, including modifications

Constructors

Link copied to clipboard
constructor(originalTemplateList: TemplateList, currentTemplateList: TemplateList)

Types

Link copied to clipboard
object Companion

Holds constants.

Properties

Link copied to clipboard

The currently selected node, or null if no node is selected, or null if the root is selected.

Link copied to clipboard

The currently selected scheme (or template), or null if no scheme is currently selected.

Link copied to clipboard

The currently selected template, or the parent of the currently selected non-template scheme, or null if no scheme is currently selected.

Functions

Link copied to clipboard
fun addScheme(newScheme: Scheme)

Adds newScheme at an appropriate location in the tree based on the currently selected node.

Link copied to clipboard
fun asDecoratedPanel(): JPanel

Returns a panel containing this tree decorated with accessible action buttons.

Link copied to clipboard
fun canMoveSchemeByOnePosition(scheme: Scheme, moveDown: Boolean): Boolean

Returns true if and only if moveSchemeByOnePosition can be invoked with these parameters.

Link copied to clipboard
fun expandAll()

Expands all Templates.

Link copied to clipboard
fun moveSchemeByOnePosition(scheme: Scheme, moveDown: Boolean)

Moves scheme by one position; down if moveDown is `true, and up otherwise.

Link copied to clipboard
fun reload(changedScheme: Scheme? = null)

Notifies the tree that external changes have been made to currentTemplateList, and resynchronizes the tree's model with the template list.

Link copied to clipboard
fun removeScheme(scheme: Scheme)

Removes scheme from the tree, and selects an appropriate other scheme.

Link copied to clipboard
fun replaceScheme(oldScheme: Scheme, newScheme: Scheme?)

Replaces oldScheme with newScheme in-place.