|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.freehep.jas.plugin.tree.DefaultFTreeNodeAdapter
A FTreeNodeAdapter define the behaviour of FTreeNodes through its methods. This class is
the base class for each node adapter; each node adapter must extend this base class. The methods below
provide the default behavior for nodes on FTree and have to be overwritten if a different behavior is desired.
A FTreeNodeAdapter has to be registered with the FTree via its method
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 Summary | |
DefaultFTreeNodeAdapter(int priority)
The constructor of a FTreeNodeAdapter. |
|
DefaultFTreeNodeAdapter(int priority,
FTreeNodeObjectProvider objectProvider)
|
Method Summary | |
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. |
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. |
javax.swing.Icon |
icon(FTreeNode node,
javax.swing.Icon oldIcon,
boolean selected,
boolean expanded)
Returns the icon of a given node in a given selected/expanded state. |
javax.swing.JPopupMenu |
modifyPopupMenu(FTreeNode[] nodes,
javax.swing.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 DnD action is initiated on a set of nodes. |
boolean |
mouseClicked(FTreeNode node,
java.awt.event.MouseEvent mouseEvent,
java.awt.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)
This method is used by the FTreeLookupAdapter create a sorted list of FTreeNodeAdapters. |
boolean |
selectionChanged(FTreeSelectionEvent e)
The default selection behaviour is to cancel any existing selection, effectively reducing the tree to a SINGLE_SELECTION_MODEL. |
java.lang.String |
statusMessage(FTreeNode node,
java.lang.String oldMessage)
This method is invoked when the status message is to be displayied for a given node. |
java.lang.String |
text(FTreeNode node,
java.lang.String oldText)
The text to be displayied next to the icon for a given FTreeNode. |
java.lang.String |
toolTipMessage(FTreeNode node,
java.lang.String oldMessage)
This method is invoked when the tooltip is to be displayied for a given node. |
java.awt.Component |
treeCellRendererComponent(java.awt.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 this adapter. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public DefaultFTreeNodeAdapter(int priority)
priority
- The adapter's priority.public DefaultFTreeNodeAdapter(int priority, FTreeNodeObjectProvider objectProvider)
Method Detail |
public javax.swing.Icon icon(FTreeNode node, javax.swing.Icon oldIcon, boolean selected, boolean expanded)
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)
doubleClick
in interface FTreeNodeAdapter
node
- The FTreeNode for which the doubleClick action is to be provided.
public java.lang.String statusMessage(FTreeNode node, java.lang.String oldMessage)
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.
{@link FTreeAdapter#toolTipMessage(String) toolTipMessage}
public java.lang.String toolTipMessage(FTreeNode node, java.lang.String oldMessage)
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.
{@link FTreeAdapter#statusMessage(String) statusMessage}
public java.lang.String text(FTreeNode node, java.lang.String oldText)
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)
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)
nodeBeingDeleted
in interface FTreeNodeAdapter
node
- The FTreeNode being deleted.public javax.swing.JPopupMenu modifyPopupMenu(FTreeNode[] nodes, javax.swing.JPopupMenu menu)
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 got selected.menu
- The current menu as it will be popped up if unchanged. It is NEVER null.
public FTreeNodeTransferable modifyTransferable(FTreeNode[] nodes, FTreeNodeTransferable transferable)
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 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.
commandProcessor
in interface FTreeNodeAdapter
public boolean canTextBeChanged(FTreeNodeTextChangeEvent evt, boolean oldCanBeRenamed)
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)
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)
nodeTextChanged
in interface FTreeNodeAdapter
evt
- The FTreeNodeTextChangeEvent containing the information of the text change.public FTreeNodeObjectProvider treeNodeObjectProvider(FTreeNode node)
treeNodeObjectProvider
in interface FTreeNodeAdapter
node
- The FTreeNode for which the object provider is to be returned.
public int priority(FTree tree)
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)
selectionChanged
in interface FTreeNodeAdapter
e
- The FTreeSelectionEvent containing the information of the selection change.
public java.awt.Component treeCellRendererComponent(java.awt.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, java.awt.event.MouseEvent mouseEvent, java.awt.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 FTreeNodeStructureProvider nodeStructureProvider(FTreeNode node)
FTreeNodeAdapter
nodeStructureProvider
in interface FTreeNodeAdapter
node
- The FTreeNode for which the FTreeNodeStructureProvider is requested.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |