Package jexer.ttree
Class TTreeItem
- java.lang.Object
-
- jexer.TWidget
-
- jexer.ttree.TTreeItem
-
- All Implemented Interfaces:
java.lang.Comparable<TWidget>
- Direct Known Subclasses:
TDirectoryTreeItem
public class TTreeItem extends TWidget
TTreeItem is a single item in a tree view.
-
-
Field Summary
Fields Modifier and Type Field Description protected int
level
Tree level.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
draw()
Draw this item to a window.java.util.List<TTreeItem>
expandTree(java.lang.String prefix, boolean last)
Recursively expand the tree into a linear array of items.int
getMaximumColumn()
Get the length of the widest item to display.java.lang.String
getPrefix()
Get the vertical bars and such along the left side.java.lang.String
getText()
Get the displayable text for this item.TTreeView
getTreeView()
Get the parent TTreeView.boolean
isExpandable()
Get expandable value.boolean
isExpanded()
Get expanded value.boolean
isSelected()
Get selected value.void
onExpand()
Called when this item is expanded or collapsed.void
onKeypress(TKeypressEvent keypress)
Handle keystrokes.void
onMouseUp(TMouseEvent mouse)
Handle mouse release events.void
setExpandable(boolean expandable)
Set expandable value.void
setExpanded(boolean expanded)
Set expanded value.void
setSelectable(boolean selectable)
Set selectable value.void
setSelected(boolean selected)
Set selected value.void
setText(java.lang.String text)
Set the displayable text for this item.void
unselect()
Recursively unselect me and my children.-
Methods inherited from class jexer.TWidget
activate, activate, activate, activateAll, addButton, addCalendar, addCheckBox, addCheckBox, addComboBox, addDirectoryList, addDirectoryList, addDirectoryList, addDirectoryList, addEditor, addField, addField, addField, addField, addImage, addImage, addLabel, addLabel, addLabel, addLabel, addLabel, addLabel, addList, addList, addList, addList, addPanel, addPasswordField, addPasswordField, addPasswordField, addProgressBar, addRadioGroup, addRadioGroup, addSpinner, addSplitPane, addTable, addTable, addText, addText, addTreeViewWidget, addTreeViewWidget, close, compareTo, doRepaint, drawBox, drawBox, drawBoxShadow, drawChildren, fileOpenBox, fileOpenBox, fileOpenBox, fileOpenBox, fileSaveBox, getAbsoluteX, getAbsoluteY, getActiveChild, getApplication, getAttrXY, getChildren, getClipboard, getCursorAbsoluteX, getCursorAbsoluteY, getCursorX, getCursorY, getHeight, getLayoutManager, getParent, getScreen, getTheme, getWidth, getWindow, getX, getY, handleEvent, hasChild, hLineXY, inputBox, inputBox, inputBox, isAbsoluteActive, isActive, isCursorVisible, isDrawable, isEchoKeystrokes, isEnabled, isVisible, messageBox, messageBox, mouseWouldHit, onCommand, onIdle, onMenu, onMouseDoubleClick, onMouseDown, onMouseMotion, onResize, putAll, putAttrXY, putAttrXY, putCharXY, putCharXY, putCharXY, putStringXY, putStringXY, remove, remove, remove, remove, removeAll, resetTabOrder, setActive, setCursorVisible, setCursorX, setCursorY, setDimensions, setEchoKeystrokes, setEchoKeystrokes, setEnabled, setHeight, setLayoutManager, setParent, setupForTWindow, setVisible, setWidth, setWindow, setX, setY, splitHorizontal, splitVertical, switchWidget, toPrettyString, toPrettyString, toString, vLineXY
-
-
-
-
Constructor Detail
-
TTreeItem
public TTreeItem(TTreeView view, java.lang.String text, boolean expanded)
Public constructor.- Parameters:
view
- root TTreeViewtext
- text for this itemexpanded
- if true, have it expanded immediately
-
-
Method Detail
-
onMouseUp
public void onMouseUp(TMouseEvent mouse)
Handle mouse release events.
-
onExpand
public void onExpand()
Called when this item is expanded or collapsed. this.expanded will be true if this item was just expanded from a mouse click or keypress.
-
onKeypress
public void onKeypress(TKeypressEvent keypress)
Handle keystrokes.- Overrides:
onKeypress
in classTWidget
- Parameters:
keypress
- keystroke event
-
getTreeView
public final TTreeView getTreeView()
Get the parent TTreeView.- Returns:
- the parent TTreeView
-
getText
public final java.lang.String getText()
Get the displayable text for this item.- Returns:
- the displayable text for this item
-
setText
public final void setText(java.lang.String text)
Set the displayable text for this item.- Parameters:
text
- the displayable text for this item
-
isExpanded
public final boolean isExpanded()
Get expanded value.- Returns:
- if true, this item is expanded
-
setExpanded
public final void setExpanded(boolean expanded)
Set expanded value.- Parameters:
expanded
- new value
-
isExpandable
public final boolean isExpandable()
Get expandable value.- Returns:
- if true, this item is expandable
-
setExpandable
public final void setExpandable(boolean expandable)
Set expandable value.- Parameters:
expandable
- new value
-
getPrefix
public final java.lang.String getPrefix()
Get the vertical bars and such along the left side.- Returns:
- the vertical bars and such along the left side
-
isSelected
public final boolean isSelected()
Get selected value.- Returns:
- if true, this item is selected
-
setSelected
public final void setSelected(boolean selected)
Set selected value.- Parameters:
selected
- new value
-
setSelectable
public final void setSelectable(boolean selectable)
Set selectable value.- Parameters:
selectable
- new value
-
getMaximumColumn
public int getMaximumColumn()
Get the length of the widest item to display.- Returns:
- the maximum number of columns for this item or its children
-
expandTree
public java.util.List<TTreeItem> expandTree(java.lang.String prefix, boolean last)
Recursively expand the tree into a linear array of items.- Parameters:
prefix
- vertical bar of parent levels and such that is set on each childlast
- if true, this is the "last" leaf node of a tree- Returns:
- additional items to add to the array
-
unselect
public void unselect()
Recursively unselect me and my children.
-
-