public interface FTreeNodeAdapter
DefaultFTreeNodeAdapter
,
overriding the desired methods.
FTreeNodeAdapters need to be registered with the FTreeNodeAdapterRegistry
, and this can be
done in two ways:
- FTreeNodeAdapters can be registered directly with the FTreeNodeAdapterRegistry through
its registerNodeAdapter(FTreeNodeAdapter, Class)
method. In this
case, for a given FTreeNode, the FTreeNodeAdapters are selected based on the node's type, i.e. the FTreeNodeAdapter is
assigned to any node whose type inherits from the class for which the adapter has been registered.
- register an FTreeNodeAdapterProvider
by using the FTreeNodeAdapterRegistry's method
registerNodeAdapterProvider(FTreeNodeAdapterProvider)
. In
this case the adapters for a given FTreeNode are selected by asking the adapter provider for the adapters compatible with
the node's type.
If multiple adapters are present for a given FTreeNode, they are ordered by priority.
Depending on the specific method this ordering can either ascending or descending and the behavior can be either provided
by only one adapter or by the cumulative contribution of all of them (see each method's documentation for further details).
When multiple adapters contribute to a given method (like for popup menus), the
adapters are ordered by lower to higher priority, giving the higher priority adapters
the possibility to override the behavior of lower priority ones.
If only one adapter is to provide the behavior (like for double click), the adapters
are ordered from the higher priority to the lower ones and the first node with non-trivial
behavior is used (see the method's documentation for further information on the
expected default behaviors and what is considered trivial).Modifier and Type | Method and Description |
---|---|
boolean |
acceptNewText(FTreeNodeTextChangeEvent evt,
boolean oldAcceptNewName)
Invoked when a node's text is being changed to check if the corresponding adapters accept the
new text.
|
boolean |
allowsChildren(FTreeNode node,
boolean allowsChildren)
This method is invoked to check if the adapter allows the node to have a substructure.
|
boolean |
canTextBeChanged(FTreeNodeTextChangeEvent evt,
boolean oldCanBeRenamed)
Check if the given node's text can be changed.
|
void |
checkForChildren(FTreeNode node)
This method is invoked when the FTree needs to know about a given FTreeNode's structure.
|
org.freehep.util.commanddispatcher.CommandProcessor |
commandProcessor(FTreeNode[] selectedNodes)
Invoked after each selection change to get the CommandProcessor for the selected nodes.
|
boolean |
doubleClick(FTreeNode node)
This method defines the double click behavior of the given node.
|
Icon |
icon(FTreeNode node,
Icon oldIcon,
boolean selected,
boolean expanded)
Returns the icon of a given node in a given selected/expanded state.
|
JPopupMenu |
modifyPopupMenu(FTreeNode[] nodes,
JPopupMenu menu)
This method is invoked when a popup menu is to be displayed for a given set of nodes.
|
FTreeNodeTransferable |
modifyTransferable(FTreeNode[] nodes,
FTreeNodeTransferable transferable)
This method is invoked when a Drag and Drop action is initiated on a set of nodes.
|
boolean |
mouseClicked(FTreeNode node,
MouseEvent mouseEvent,
Dimension dimension)
This method is invoked every time a mouse click event occurs on the
representation of the FTreeNode.
|
void |
nodeBeingDeleted(FTreeNode node)
Invoked when the given node is being removed from then FTree.
|
FTreeNodeStructureProvider |
nodeStructureProvider(FTreeNode node)
Get the FTreeNodeStructureProvider for a given node.
|
void |
nodeTextChanged(FTreeNodeTextChangeEvent evt)
The FTree does not change the text of a node.
|
int |
priority(FTree tree)
The FTreeNodeAdapter's priority for a given tree.
|
boolean |
selectionChanged(FTreeSelectionEvent e)
This method is invoked on a node's adapters starting from the highest priority
one when the selected nodes have changed.
|
String |
statusMessage(FTreeNode node,
String oldMessage)
This method is invoked when the status message is to be displayed for a given node.
|
String |
text(FTreeNode node,
String oldText)
The text to be displayed next to the icon for a given FTreeNode.
|
String |
toolTipMessage(FTreeNode node,
String oldMessage)
This method is invoked when the tooltip is to be displayed for a given node.
|
Component |
treeCellRendererComponent(Component component,
FTreeNode node,
boolean sel,
boolean expanded,
boolean leaf,
boolean hasFocus)
This method is invoked on all adapters, starting from the lower priority one
each time the corresponding FTreeNode is to be rendered in the FTree.
|
FTreeNodeObjectProvider |
treeNodeObjectProvider(FTreeNode node)
Get the FTreeNodeObjectProvider for a given node.
|
Icon icon(FTreeNode node, Icon oldIcon, boolean selected, boolean expanded)
node
- The FTreeNode for which the icon is to be provided.oldIcon
- The icon as provided by the lower priority adapters. It can never be null.selected
- true if the node is currently selected.expanded
- true if the node is currently expanded.boolean doubleClick(FTreeNode node)
node
- The FTreeNode for which the doubleClick action is to be provided.true
if a doubleClick behavior is provided. false
otherwise.String statusMessage(FTreeNode node, String oldMessage)
node
- The FTreeNode for which the status message is to be provided.oldMessage
- The current message as modified by previous adapters. It is never null.String toolTipMessage(FTreeNode node, String oldMessage)
node
- The fTreeNode for which the status message is to be provided.oldMessage
- The current message as modified by previous adapters. It is never null.String text(FTreeNode node, String oldText)
node
- The FTreeNode for which the text should be provided.oldText
- The current text as provided by previous adapters. It can be null.boolean allowsChildren(FTreeNode node, boolean allowsChildren)
node
- The FTreeNode for which allowsChildren is invoked.allowsChildren
- The returned boolean by the lower priority adapters.true
if the node has a substructure.void nodeBeingDeleted(FTreeNode node)
node
- The FTreeNode being deleted.JPopupMenu modifyPopupMenu(FTreeNode[] nodes, JPopupMenu menu)
nodes
- The array of FTreeNode for which the popup menu is to be provided. The nodes are in
the order in which they were selected.menu
- The current menu as it will be popped up if unchanged. It is never null.FTreeNodeTransferable modifyTransferable(FTreeNode[] nodes, FTreeNodeTransferable transferable)
nodes
- The set of FTreeNode being dragged. The nodes are ordered as they were selected.transferable
- The FTreeNodeTransferable carrying the data of the DnD action.org.freehep.util.commanddispatcher.CommandProcessor commandProcessor(FTreeNode[] selectedNodes)
selectedNodes()
should be used
within this method to get the list of the selected FTreeNodes. Such list is not provided as
an argument to this method to avoid each adapter having to store such list.boolean canTextBeChanged(FTreeNodeTextChangeEvent evt, boolean oldCanBeRenamed)
evt
- The FTreeNodeTextChangeEvent containing the information for this change of text.oldCanBeRenamed
- The result as given by lower priority adapters.true
if the name of this node can be changed.boolean acceptNewText(FTreeNodeTextChangeEvent evt, boolean oldAcceptNewName)
evt
- The FTreeNodeTextChangeEvent containing the information for this change of text.oldAcceptNewName
- The result of lower priority adapters.true
if the new name has been accepted.void nodeTextChanged(FTreeNodeTextChangeEvent evt)
consume()
method.
This will end the propagation of the event to lower priority adapters.evt
- The FTreeNodeTextChangeEvent containing the information of the text change.FTreeNodeObjectProvider treeNodeObjectProvider(FTreeNode node)
objectForClass()
is invoked.node
- The FTreeNode for which the object provider is to be returned.int priority(FTree tree)
tree
- The FTree on which the adapter will act.void checkForChildren(FTreeNode node)
node
- The FTreeNode for which the sub-structure is being requested.boolean selectionChanged(FTreeSelectionEvent e)
e
- The FTreeSelectionEvent containing the information of the selection change.true
if selection behavior, other than the default one, is provided.
false
otherwise.Component treeCellRendererComponent(Component component, FTreeNode node, boolean sel, boolean expanded, boolean leaf, boolean hasFocus)
component
- The FTreeNode's renderer as provided by lower priority adapters.node
- The FTreeNode for which the rendering is taking place.sel
- true
if the node is selected.expanded
- true
if the node is expanded.leaf
- true
if the node is a leaf.hasFocus
- true
if the node has focus.boolean mouseClicked(FTreeNode node, MouseEvent mouseEvent, Dimension dimension)
node
- The FTreeNode on which the mouse has been clicked.mouseEvent
- The MouseEvent describing the click.dimension
- The location of the click in the FTreeNode's internal representation.true
if a non trivial behavior is provided.FTreeNodeStructureProvider nodeStructureProvider(FTreeNode node)
node
- The FTreeNode for which the FTreeNodeStructureProvider is requested.Copyright © 2016. All rights reserved.