Package jexer.ttree

Class TTreeViewWidget

  • All Implemented Interfaces:
    java.lang.Comparable<TWidget>, Scrollable

    public class TTreeViewWidget
    extends TScrollableWidget
    TTreeViewWidget wraps a tree view with horizontal and vertical scrollbars.
    • Constructor Detail

      • TTreeViewWidget

        public TTreeViewWidget​(TWidget parent,
                               int x,
                               int y,
                               int width,
                               int height)
        Public constructor.
        Parameters:
        parent - parent widget
        x - column relative to parent
        y - row relative to parent
        width - width of tree view
        height - height of tree view
      • TTreeViewWidget

        public TTreeViewWidget​(TWidget parent,
                               int x,
                               int y,
                               int width,
                               int height,
                               TAction action)
        Public constructor.
        Parameters:
        parent - parent widget
        x - column relative to parent
        y - row relative to parent
        width - width of tree view
        height - height of tree view
        action - action to perform when an item is selected
    • Method Detail

      • onMouseDown

        public void onMouseDown​(TMouseEvent mouse)
        Handle mouse press events.
        Overrides:
        onMouseDown in class TWidget
        Parameters:
        mouse - mouse button press event
      • onMouseUp

        public void onMouseUp​(TMouseEvent mouse)
        Handle mouse release events.
        Overrides:
        onMouseUp in class TWidget
        Parameters:
        mouse - mouse button release event
      • onMouseMotion

        public void onMouseMotion​(TMouseEvent mouse)
        Handle mouse motion events.
        Overrides:
        onMouseMotion in class TWidget
        Parameters:
        mouse - mouse motion event
      • onKeypress

        public void onKeypress​(TKeypressEvent keypress)
        Handle keystrokes.
        Overrides:
        onKeypress in class TWidget
        Parameters:
        keypress - keystroke event
      • setWidth

        public void setWidth​(int width)
        Override TWidget's width: we need to set child widget widths.
        Overrides:
        setWidth in class TWidget
        Parameters:
        width - new widget width
      • setHeight

        public void setHeight​(int height)
        Override TWidget's height: we need to set child widget heights.
        Overrides:
        setHeight in class TWidget
        Parameters:
        height - new widget height
      • reflowData

        public void reflowData()
        Resize text and scrollbars for a new width/height.
        Overrides:
        reflowData in class TScrollableWidget
      • getTreeView

        public TTreeView getTreeView()
        Get the underlying TTreeView.
        Returns:
        the TTreeView
      • getTreeRoot

        public final TTreeItem getTreeRoot()
        Get the root of the tree.
        Returns:
        the root of the tree
      • setTreeRoot

        public final void setTreeRoot​(TTreeItem treeRoot)
        Set the root of the tree.
        Parameters:
        treeRoot - the new root of the tree
      • setTreeRoot

        public void setTreeRoot​(TTreeItem treeRoot,
                                boolean centerWindow)
        Set treeRoot.
        Parameters:
        treeRoot - ultimate root of tree
        centerWindow - if true, move the window to put the root in view
      • getSelected

        public final TTreeItem getSelected()
        Get the tree view item that was selected.
        Returns:
        the selected item, or null if no item is selected
      • setSelected

        public void setSelected​(TTreeItem item,
                                boolean centerWindow)
        Set the new selected tree view item.
        Parameters:
        item - new item that became selected
        centerWindow - if true, move the window to put the selected into view
      • dispatch

        public void dispatch()
        Perform user selection action.