public abstract class TreeGuiImpl extends BorderedPanelGuiImpl implements WidgetWithConfig<TreeConfig>, DataContainer
Modifier and Type | Class and Description |
---|---|
protected static class |
TreeGuiImpl.TreeEditor
Represents the tree node editor.
|
static class |
TreeGuiImpl.TreeNode
The class represents one tree node.
|
Modifier and Type | Field and Description |
---|---|
TreeBodyGuiImpl |
body
Tree view body.
|
protected TreeConfig |
config
Associated config instance
|
protected TreeGuiImpl.TreeNode |
currentNode
Currently selected node
|
protected TreeGuiImpl.TreeNode |
dropHighlightNode
Current drop highlight node
|
protected GuiColorResolver |
gc
Color resolver
|
protected GuiDriver<?,?> |
gd
Screen driver
|
protected GuiFontResolver |
gf
Font resolver
|
ScrollModel |
hModel
Horizontal scroll model
Note: this field is exposed to code external to FWD, so it should remain public.
|
private WidgetId |
id
Widget id
|
private java.util.HashMap<java.lang.Integer,TreeGuiImpl.TreeNode> |
idNodes
Map of node ids to nodes
|
(package private) java.util.logging.Logger |
LOGGER
Logger used to log all this treelist events
|
TreeGuiImpl.TreeNode |
rootNode
The root node.
|
protected GenericContainer |
scrollableContainer
The scrolling provider.
|
protected TreeGuiImpl.TreeNode |
topNode
The topmost node visible in the widget area
|
protected TreeGuiImpl.TreeEditor |
treeEditor
The tree label editor
|
protected ScrollModel |
vModel
Horizontal scroll model
|
border
location, mousePtr, nativeInsets, physicalLocation
Constructor and Description |
---|
TreeGuiImpl(WidgetId id,
TreeConfig cfg)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
afterConfigUpdate(TreeConfig beforeUpdate)
The method is called after the configuration associated with the
owner changes.
|
protected void |
buildTreeModel()
Builds tree model from the config's flat node entry list.
|
TreeConfig |
config()
Get externalizable widget config which can be used to restore widget
state after via network.
|
protected abstract TreeBodyGuiImpl |
createBody()
Creates new body implementation.
|
Widget<GuiOutputManager> |
currentFocus()
Get the current focus.
|
Widget<GuiOutputManager> |
defaultFocus()
Get the default focus.
|
(package private) void |
drawEditor()
Draws the tree node editor.
|
(package private) boolean |
ensureVisible(TreeGuiImpl.TreeNode node)
When the supplied node is not visible in the current view, the view is scrolled so that the
node becomes visible.
|
private TreeGuiImpl.TreeNode |
findFirstNodeWithText(java.lang.String nodeText)
Returns the first node that matches the provided node text.
|
TreeGuiImpl.TreeNode |
findNodeById(int nodeId)
Locate a
TreeGuiImpl.TreeNode instance by node id. |
(package private) boolean |
fireAfterLabelEdit(TreeGuiImpl.TreeNode node,
java.lang.String newLabel)
Fires the after label edit event.
|
private boolean |
fireBeforeLabelEdit(TreeGuiImpl.TreeNode node)
Fires the before label edit event.
|
private ThinClient.TriggerResult |
fireNodeCheckEvent(TreeGuiImpl.TreeNode node)
Triggers NODE-CHECK event.
|
protected boolean |
fireNodeExpansionTrigger(TreeConfig cfgTree,
int eventCode)
Firing the node expand/collapse trigger for tree node.
|
void |
firstFocus()
Don't change the the current focus.
|
TreeGuiImpl.TreeNode |
getCurrentNode()
Returns the current node.
|
private java.lang.String |
getCurrentNodeText()
Returns the text of the current node.
|
(package private) TreeGuiImpl.TreeNode |
getDropHighlightNode()
Returns the drop highlight node.
|
WidgetId |
getId()
Widget ID.
|
(package private) NativeRectangle |
getNodeCheckBoxBounds(TreeGuiImpl.TreeNode node)
Calculates the node check box bounds within its tree body.
|
ImageWrapper<?> |
getNodeImage(TreeGuiImpl.TreeNode node,
boolean nodeSelected)
Gets the image for the given node and its selected state.
|
(package private) NativeRectangle |
getNodeLabelBounds(TreeGuiImpl.TreeNode node)
Calculates the node label's bounds within its tree body.
|
protected abstract java.lang.String |
getNodeText(TreeGuiImpl.TreeNode node)
Returns the node text.
|
java.lang.String |
getText()
Get text representation of the selected value.
|
BaseDataType |
getValue()
Returns the BaseDataType instance representing the current value.
|
(package private) int |
getViewportFitRowCount()
Calculate the number of visible nodes that will at least partly fit in the widget's viewport.
|
protected int |
getVisibleNodeCount()
Get the total number of visible nodes in the tree.
|
boolean |
hasFocusable(Widget<GuiOutputManager> exclude)
Reports if there is at least 1 focusable widget that is not the given
widget.
|
java.lang.Integer |
hitTest(int x,
int y)
Get the TreeView node under mouse cursor.
|
void |
initialize(WidgetId id,
TreeConfig cfg)
Replacement API for the logic which should exist in the widget's c'tor, but the logic
can't be executed as it depends on the widget being registered into the official registry.
|
boolean |
isEditorActivated()
Tests if the tree editor is activated.
|
protected boolean |
isLabelsEditingSupported()
Tests if label's editing is supported or not.
|
boolean |
isModified()
Getting the modification state of the widget.
|
void |
lastFocus()
Don't change the current focus.
|
protected static void |
makeNodeConfigDirty(TreeConfig cfgTree)
Making config dirty for nodes entries.
|
protected abstract java.util.Comparator<TreeGuiImpl.TreeNode> |
nodeComparator()
Create a comparator capable to compare nodes based on current sorting column.
|
boolean |
preventFocusWhenMouseDownEventDefined()
Test if this widget must prevent receiving focus on mouse-down event.
|
void |
processKeyEvent(KeyInput event)
Process key event.
|
protected void |
repaintTree()
Repaints the tree part of the widget.
|
GuiFontResolver.FontCache |
resolveFontCache()
Resolves the font cache to be used during widget drawing operations.
|
(package private) void |
setCurrentNode(TreeGuiImpl.TreeNode node)
Sets the current node.
|
void |
setCurrentNode(TreeGuiImpl.TreeNode node,
boolean trigger,
boolean direct)
Sets the current node.
|
protected void |
setNodeExpansion(TreeGuiImpl.TreeNode node,
boolean expand)
Expands or collapses the supplied node.
|
void |
setValue(BaseDataType value)
Sets the BaseDataType instance representing the current value.
|
protected static void |
sortNodes(java.util.List<TreeGuiImpl.TreeNode> nodes,
java.util.Comparator<TreeGuiImpl.TreeNode> comparator)
Sort nodes recursively using the provided comparator.
|
boolean |
systemFocusGrabbed()
Grabs the system focus iff the tree editor is active.
|
(package private) void |
toggleCurrentNodeExpansion()
Expands or collapses the current node.
|
(package private) void |
toggleNodeCheck(TreeGuiImpl.TreeNode node)
Toggles node's check state.
|
(package private) void |
toggleNodeExpansion(TreeGuiImpl.TreeNode node)
Expands or collapses the supplied node.
|
protected java.lang.Iterable<TreeGuiImpl.TreeNode> |
visibleNodes()
Iterable for all visible (not collapsed) nodes in the tree.
|
draw, drawPanel, is3DBorder, isRMBEntrySupported, set3DBorder, setColorResolver, setCustomDraw, setId, setOptionalDraw
border, insets, isTransparent, setBorder, setTransparent
add, add, add, addContainerStateListener, addDirectly, belongsTo, checkWidget, childrenLocation, clipping, clipRectangle, copyState, currentFocus, cycleFocus, deregisterSelectedWidget, destroy, detach, dimension, doLayout, dumpCurrentWidgets, dumpWidgets, endSizeChange, findMouseSource, focus, focusTraversable, focusWorker, formatDump, get, getAllSelectedWidgets, getClipRect, getEffectiveScrollableSize, getFocusInt, getIgnoreFocus, getLayout, getScrollableSize, getTabItemList, height, minimumSize, moveAfterTabItem, moveBeforeTabItem, moveToBottom, moveToBottomInClass, moveToTop, moveToTopInClass, moveToZpos, nextFocus, normalizeZOrder, onWidgetAdded, onWidgetRemoved, paintOnTop, parentOf, prepareWidgets, prevFocus, reflectAncestorChange, reflectLocationChange, registerSelectedWidget, remove, removeContainerStateListener, repaint, replace, requestFocus, requestFocus, setFocus, setFocusInt, setHeight, setIgnoreFocus, setInsets, setLayout, setSize, setSize, setTabItemList, setWidth, startSizeChange, triggerContainerStateRedrawEnabled, unrealize, updateSizeWorker, widgets, widgetsAsList, widgetStateChanged, width
_setHidden, _setVisible, activateDirectManipulation, addFocusListener, addKeyListener, afterConfigUpdateBase, ancestor, ancestorId, autoResize, bounds, clear, clearWidget, clipRectangle, clipRectangle, clipWith, copyColors, createMouseHoverAction, deactivateDirectManipulation, debug, disable, disableTooltip, displayPhysicalLocation, drawCaret, enable, enableTooltip, enclosingFrame, forceCursorOnFocus, forceVisibility, getActualBounds, getAndResetBitmap, getAndSetBitmap, getBitmapCopy, getCachedScreenLocation, getCachedScreenPhysicalLocation, getCustomMousePointer, getDefaultEvent, getEffectiveMousePointer, getLoadedMousePointer, getMenuMouse, getMouseActions, getMousePosition, getPortableMouseEventCoordinates, getSelectedText, getState, getTextHeight, getTextHeightNative, getTextHeightNative, getTextWidth, getTextWidth, getTextWidthNative, getTextWidthNative, getVisiblePart, getZOrderClass, hasFocus, hidden, hide, highlighted, ignoreAction, initialHeight, initialWidth, isCurrent, isDirectManipulationActive, isDirectManipulationCapable, isDirectManipulationRequired, isDisplayed, isEnabled, isFocusable, isHeader, isMouseDrag, isRealized, isRepaintDisabled, isScreenLocationCached, isTabStop, isThreeD, isTotallyObscured, isVisible, isVisible, location, manageSystemActions, mouseActions, mouseClicked, mouseDragged, mouseEntered, mouseExited, mouseMoved, mousePressed, mouseReleased, mouseWheelMoved, moveToBottom, moveToTop, name, navigable, oleDoDrop, oleDrag, oleDragging, oleStartDragging, onOleDragging, onOleDropEnd, parent, parent, parentObject, parentOrSelf, parentOrSelfObject, physicalBounds, physicalDimension, physicalLocation, postprocessConfig, prepParentLocation, processDirectManipulationEvent, processEvent, processFocusEvent, processKeyEventForSelectableWidget, processKeyListeners, processMnemonic, processMnemonicImpl, processSystemKey, raiseLegacyMouseEvents, refresh, registerWidgetStateListener, repaint, repaint, requestSync, resetBitmap, resizeTo, resolveFont, resolvePopupMenuId, resolveTitleFont, screen, screenDimension, screenHeight, screenLocation, screenPhysicalLocation, screenWidth, setBitmap, setCachedScreenLocation, setCachedScreenPhysicalLocation, setEnabled, setHidden, setHighlighted, setLocation, setLocation, setMousePointer, setParent, setPhysicalLocation, setState, setVisible, show, showPopupMenu, supportsCustomMousePointer, sync, topLevelWindow, toString, translate, unregisterWidgetStateListener, window
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
widgetsAsList
addFocusListener, addKeyListener, ancestor, ancestorId, bounds, canMovetoTop, clearWidget, defaultMousePtr, displayPhysicalLocation, drawCaret, enclosingFrame, enforceDefaultMousePtr, forceCursorOnFocus, forceVisibility, getActualBounds, getCustomMousePointer, getEffectiveMousePointer, getLegacyWidget, getLoadedMousePointer, getMenuMouse, getMouseActions, getMousePosition, getSelectedText, getState, getTriggerWidget, getTriggerWidget, getVisiblePart, getZOrderClass, hasFocus, hasFocus, hidden, hide, highlighted, ignoreEnable, initialHeight, initialWidth, isCurrent, isDirectManipulable, isDirectManipulationActive, isDisplayed, isDroppable, isEnabled, isFocusable, isHeader, isInitialValueLayout, isLegacyFocus, isRealized, isRepaintDisabled, isTabStop, isThreeD, isTotallyObscured, isVisible, isVisible, location, maySwitchFocus, moveToBottom, moveToTop, name, navigable, oleDrag, parent, parent, parent, parentObject, parentOrSelf, parentOrSelfObject, physicalBounds, physicalDimension, physicalLocation, postprocessConfig, processDirectManipulationEvent, processEvent, processFocusEvent, processKeyListeners, processMnemonic, raiseLegacyMouseEvents, refreshWidget, registerWidgetStateListener, repaint, repaint, requestFocus, requestSync, resizeTo, resolvePopupMenuId, screen, screenLocation, screenPhysicalLocation, setEnabled, setHidden, setHighlighted, setLocation, setLocation, setMousePointer, setParent, setPhysicalLocation, setState, setVisible, show, supportsCustomMousePointer, topLevelWindow, unregisterWidgetStateListener, validateDisplayValue, window
public TreeBodyGuiImpl body
public TreeGuiImpl.TreeNode rootNode
public final ScrollModel hModel
protected TreeGuiImpl.TreeEditor treeEditor
protected TreeConfig config
protected TreeGuiImpl.TreeNode currentNode
protected TreeGuiImpl.TreeNode dropHighlightNode
protected GuiColorResolver gc
protected final GuiDriver<?,?> gd
protected GuiFontResolver gf
protected GenericContainer scrollableContainer
protected TreeGuiImpl.TreeNode topNode
protected final ScrollModel vModel
final java.util.logging.Logger LOGGER
private WidgetId id
private final java.util.HashMap<java.lang.Integer,TreeGuiImpl.TreeNode> idNodes
public TreeGuiImpl(WidgetId id, TreeConfig cfg)
id
- Widget id.cfg
- Config instance.public void afterConfigUpdate(TreeConfig beforeUpdate)
The implemented logic must be idempotent - the method must produce the same results if executed once or multiple times not relying on any particular call sequence or related state. This is necessary so that the method can be repeated or retried as often as necessary without causing unintended effects
afterConfigUpdate
in interface ConfigOwner<TreeConfig>
beforeUpdate
- Config reference capturing the config state before the owner's config was modified.public TreeConfig config()
Note that only very limited set of widgets actually have config. By default widget has no config.
config
in interface Widget<GuiOutputManager>
config
in interface ConfigOwner<TreeConfig>
config
in class AbstractWidget<GuiOutputManager>
public Widget<GuiOutputManager> currentFocus()
currentFocus
in interface Container<GuiOutputManager>
currentFocus
in class AbstractContainer<GuiOutputManager>
public Widget<GuiOutputManager> defaultFocus()
defaultFocus
in interface Container<GuiOutputManager>
defaultFocus
in class AbstractContainer<GuiOutputManager>
public void firstFocus()
firstFocus
in interface Container<GuiOutputManager>
firstFocus
in class AbstractContainer<GuiOutputManager>
public final TreeGuiImpl.TreeNode getCurrentNode()
public final GuiFontResolver.FontCache resolveFontCache()
public WidgetId getId()
getId
in interface Widget<GuiOutputManager>
getId
in class BorderedPanelGuiImpl
public final ImageWrapper<?> getNodeImage(TreeGuiImpl.TreeNode node, boolean nodeSelected)
node
- The tree nodenodeSelected
- The node selected statepublic java.lang.String getText()
FillIn
, for example) or label (for the
RadioButton
, for example).getText
in interface DataContainer
public final TreeGuiImpl.TreeNode findNodeById(int nodeId)
TreeGuiImpl.TreeNode
instance by node id.
Note: this method is exposed to code external to FWD, so it should remain public.nodeId
- A node id.TreeGuiImpl.TreeNode
or null
when no node found.public BaseDataType getValue()
getValue
in interface DataContainer
public boolean hasFocusable(Widget<GuiOutputManager> exclude)
hasFocusable
in interface Container<GuiOutputManager>
hasFocusable
in class AbstractContainer<GuiOutputManager>
exclude
- A widget to ignore or null
if any focusable widget will do.true
if there is at least one other widget that can be focused.public final java.lang.Integer hitTest(int x, int y)
null
value.x
- Mouse cursor x position.y
- Mouse cursor y position.null
if miss.public void initialize(WidgetId id, TreeConfig cfg)
This API is called after the widget is created and added to the registry.
initialize
in interface WidgetWithConfig<TreeConfig>
id
- The widget's ID.cfg
- Config instance.public final boolean isEditorActivated()
public boolean isModified()
isModified
in interface DataContainer
true
if the widget value was modified, false
otherwise.public void lastFocus()
lastFocus
in interface Container<GuiOutputManager>
lastFocus
in class AbstractContainer<GuiOutputManager>
public boolean preventFocusWhenMouseDownEventDefined()
true
.preventFocusWhenMouseDownEventDefined
in interface Widget<GuiOutputManager>
preventFocusWhenMouseDownEventDefined
in class AbstractWidget<GuiOutputManager>
public void processKeyEvent(KeyInput event)
processKeyEvent
in interface Widget<GuiOutputManager>
processKeyEvent
in class AbstractContainer<GuiOutputManager>
event
- Key event to process.public void setValue(BaseDataType value)
setValue
in interface DataContainer
value
- The value representing the current widget value.public boolean systemFocusGrabbed()
systemFocusGrabbed
in interface Widget<GuiOutputManager>
final int getViewportFitRowCount()
final void toggleCurrentNodeExpansion()
final void toggleNodeExpansion(TreeGuiImpl.TreeNode node)
node
- The node to expand or collapse, must not be null
final TreeGuiImpl.TreeNode getDropHighlightNode()
final void drawEditor()
final boolean fireAfterLabelEdit(TreeGuiImpl.TreeNode node, java.lang.String newLabel)
node
- The trigger nodenewLabel
- The new labelfinal void setCurrentNode(TreeGuiImpl.TreeNode node)
node
- The node to set as current.final boolean ensureVisible(TreeGuiImpl.TreeNode node)
node
- The node to make visible, must not be null
true
if this call resulted in any changefinal NativeRectangle getNodeLabelBounds(TreeGuiImpl.TreeNode node)
node
- The tree nodeNativeRectangle getNodeCheckBoxBounds(TreeGuiImpl.TreeNode node)
node
- The tree nodevoid toggleNodeCheck(TreeGuiImpl.TreeNode node)
node
- The subjected node.protected void buildTreeModel()
protected abstract TreeBodyGuiImpl createBody()
protected boolean fireNodeExpansionTrigger(TreeConfig cfgTree, int eventCode)
cfgTree
- The tree widget config.eventCode
- The code of the particular event to trigger.TRUE
if trigger result consumed, FALSE
otherwise.protected abstract java.lang.String getNodeText(TreeGuiImpl.TreeNode node)
node
- Tree node.protected final int getVisibleNodeCount()
protected boolean isLabelsEditingSupported()
protected abstract java.util.Comparator<TreeGuiImpl.TreeNode> nodeComparator()
null
if no sorting column is set in the tree.protected void setNodeExpansion(TreeGuiImpl.TreeNode node, boolean expand)
node
- The node to expand or collapse, must not be null
expand
- The desired expansion state.protected final java.lang.Iterable<TreeGuiImpl.TreeNode> visibleNodes()
protected static void makeNodeConfigDirty(TreeConfig cfgTree)
cfgTree
- The tree widget config.protected static final void sortNodes(java.util.List<TreeGuiImpl.TreeNode> nodes, java.util.Comparator<TreeGuiImpl.TreeNode> comparator)
nodes
- the nodes to sort.comparator
- the comparator to use when sortingprivate final boolean fireBeforeLabelEdit(TreeGuiImpl.TreeNode node)
node
- The trigger nodeprivate final TreeGuiImpl.TreeNode findFirstNodeWithText(java.lang.String nodeText)
nodeText
- The node text to match.private final java.lang.String getCurrentNodeText()
null
if no current node is selectedprivate ThinClient.TriggerResult fireNodeCheckEvent(TreeGuiImpl.TreeNode node)
node
- The checked node.public final void setCurrentNode(TreeGuiImpl.TreeNode node, boolean trigger, boolean direct)
node
- The node to set as current.trigger
- If true
, the method will post the input event Keyboard.SE_VALUE_CHANGED
.direct
- If true
, the method will post the input event Keyboard.SE_CHANGE_NODE_DIRECT
.protected void repaintTree()