public class DefaultFTreeNodeAdapterProxy extends Object implements FTreeNodeAdapter
registerFTreeNodeAdapter()
by providing a Class.
This Class is used to assign the given FTreeNodeAdapter to FTreeNodes by inheritance. So, if an adapter is registered
for class A and on the FTree there is a node of type B that inherits from A, the behaviour of the node B will be handled
by the adapter registered for class A.
At the constructor leven the adapter's priority is specified. This priority is used internally by each method to order
the adapters in the case when there are multiple adapters contributing to the behavior of a given node. Depending on the method
this ordering can either be from the lower to the higher priority or from the higher to the lower priority.
Depending on the method the node's behavior will either be provided by all the adapters in the priority-sorted list or by
only one of such adapters. In the first case (like for popup menus) the ordering will be from low to high priority, giving
the higher priority adapters a chance to overwrite the lower priority adapters. In the second case (like for double click)
the ordering will be from high to low priority and the behavior will be given by only one adapter: the first one in
such list that overwrites the default behavior (see the method's documentation for more details).Constructor and Description |
---|
DefaultFTreeNodeAdapterProxy(Class clazz) |
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 popupmenu is to be displayied 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 displayied for a given node.
|
String |
text(FTreeNode node,
String oldText)
The text to be displayied next to the icon for a given FTreeNode.
|
String |
toolTipMessage(FTreeNode node,
String oldMessage)
This method is invoked when the tooltip is to be displayied 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.
|
public DefaultFTreeNodeAdapterProxy(Class clazz)
public Icon icon(FTreeNode node, Icon oldIcon, boolean selected, boolean expanded)
FTreeNodeAdapter
icon
in interface FTreeNodeAdapter
node
- The FTreeNode for which the icon is to be provided.oldIcon
- The icon as provided by the lower priority adapers. It can never be null.selected
- true if the node is currently selected.expanded
- true if the node is currently expanded.public boolean doubleClick(FTreeNode node)
FTreeNodeAdapter
doubleClick
in interface FTreeNodeAdapter
node
- The FTreeNode for which the doubleClick action is to be provided.true
if a doubleClick behavior is provided. false
otherwise.public String statusMessage(FTreeNode node, String oldMessage)
FTreeNodeAdapter
statusMessage
in interface FTreeNodeAdapter
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.FTreeAdapter#toolTipMessage(String) toolTipMessage}
public String toolTipMessage(FTreeNode node, String oldMessage)
FTreeNodeAdapter
statusMessage
.
To avoid slowing down the rendering of the FTree the tooltip message information is cached after the
first time in the corresponding node. So the tooltip message cannot change unless the node's information is reset.toolTipMessage
in interface FTreeNodeAdapter
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.FTreeAdapter#statusMessage(String) statusMessage}
public String text(FTreeNode node, String oldText)
FTreeNodeAdapter
text
in interface FTreeNodeAdapter
node
- The FTreeNode for which the text shoud be provided.oldText
- The current text as provided by previous adapters. It can be null.public boolean allowsChildren(FTreeNode node, boolean allowsChildren)
FTreeNodeAdapter
allowsChildren
in interface FTreeNodeAdapter
node
- The FTreeNode for which allowsChildren is invoked.allowsChildren
- The returned boolean by the lower priority adapters.true
if the node has a substructure.public void nodeBeingDeleted(FTreeNode node)
FTreeNodeAdapter
nodeBeingDeleted
in interface FTreeNodeAdapter
node
- The FTreeNode being deleted.public JPopupMenu modifyPopupMenu(FTreeNode[] nodes, JPopupMenu menu)
FTreeNodeAdapter
modifyPopupMenu
in interface FTreeNodeAdapter
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.public FTreeNodeTransferable modifyTransferable(FTreeNode[] nodes, FTreeNodeTransferable transferable)
FTreeNodeAdapter
modifyTransferable
in interface FTreeNodeAdapter
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.public org.freehep.util.commanddispatcher.CommandProcessor commandProcessor(FTreeNode[] selectedNodes)
FTreeNodeAdapter
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.commandProcessor
in interface FTreeNodeAdapter
public boolean canTextBeChanged(FTreeNodeTextChangeEvent evt, boolean oldCanBeRenamed)
FTreeNodeAdapter
canTextBeChanged
in interface FTreeNodeAdapter
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.public boolean acceptNewText(FTreeNodeTextChangeEvent evt, boolean oldAcceptNewName)
FTreeNodeAdapter
acceptNewText
in interface FTreeNodeAdapter
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.public void nodeTextChanged(FTreeNodeTextChangeEvent evt)
FTreeNodeAdapter
consume()
method.
This will end the propagation of the event to lower priority adapters.nodeTextChanged
in interface FTreeNodeAdapter
evt
- The FTreeNodeTextChangeEvent containing the information of the text change.public int priority(FTree tree)
FTreeNodeAdapter
priority
in interface FTreeNodeAdapter
tree
- The FTree on which the adapter will act.public void checkForChildren(FTreeNode node)
FTreeNodeAdapter
checkForChildren
in interface FTreeNodeAdapter
node
- The FTreeNode for which the sub-structure is being requested.public boolean selectionChanged(FTreeSelectionEvent e)
FTreeNodeAdapter
selectionChanged
in interface FTreeNodeAdapter
e
- The FTreeSelectionEvent containing the information of the selection change.true
if selection behavior, other than the default one, is provided.
false
otherwise.public Component treeCellRendererComponent(Component component, FTreeNode node, boolean sel, boolean expanded, boolean leaf, boolean hasFocus)
FTreeNodeAdapter
treeCellRendererComponent
in interface FTreeNodeAdapter
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.public boolean mouseClicked(FTreeNode node, MouseEvent mouseEvent, Dimension dimension)
FTreeNodeAdapter
mouseClicked
in interface FTreeNodeAdapter
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 interal representation.true
if a non trivial behavior is provided.public FTreeNodeObjectProvider treeNodeObjectProvider(FTreeNode node)
FTreeNodeAdapter
objectForClass()
is invoked.treeNodeObjectProvider
in interface FTreeNodeAdapter
node
- The FTreeNode for which the object provider is to be returned.public FTreeNodeStructureProvider nodeStructureProvider(FTreeNode node)
FTreeNodeAdapter
nodeStructureProvider
in interface FTreeNodeAdapter
node
- The FTreeNode for which the FTreeNodeStructureProvider is requested.Copyright © 2014. All Rights Reserved.