|
| Components |
|
| |||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||||
com.sas.swing.visuals.NodeView
public class NodeView
A NodeView object represents a single node in a
TreeView
object. It is constructed from a
NodeInterface object that is provided
from a data source to the TreeView. In addition to the information
provided by NodeInterface, NodeView provides viewer and hierarchical
specific information such as selected and expanded states, a reference
to its parent and its depth in the hierarchy. Additionally it provides
convenience methods for expanding ancestors and for finding siblings.
NodeView provides read only access to the NodeInterface provided by the data source. However, if the implementation of the underlying NodeInterface allows updates to the properties that it provides, it can be retrieved from NodeView and then cast to the appropriate type for the update.
NOTE: Do not confuse a NodeView with its underlying NodeInterface
object. It is easy to confuse NodeView with its underlying NodeInterface object
since they both implement NodeInterface. Confusion can especially arise
in calling the child retrieval methods since they return objects of type
SimpleNodeInterface. For example, calling getNodeChild on a NodeView
will return an object of type
SimpleNodeInterface. The actual type of
the object returned is NodeView and should be cast to a NodeView to be
treated as such. The following code demonstrates how to get the underlying
NodeInterface of a child node at index 3:
SimpleNodeInterface node = parentNode.getNodeChild(3); // get child 3
NodeView nodeV = (NodeView)node; // node is actually a NodeView so cast it
NodeInterface underlyingNode = nodeV.getNode(); // now get the NodeInterface
In the code example above, if the implementation of the underlying NodeInterface object was updatable, we could have cast it to the appropriate type and then performed the update.
A NodeView can provide 4 different
icons based on its state: default,
selected, expanded and expanded-selected.
In the absence of a value for one of these icons, one of the other icons
may be used. The inheritance hierarchy is as follows:
See Styles section in TreeView documentation.
NodeView allows a source NodeInterface to have its displayed text edited
in place under certain conditions. A node can be edited if the source NodeInterface
implements MutableNodeInterface and if the
NodeView has a
NodeStyle.EDITABLE
style value of true. In place editing can be initiated in two ways:
via the "Rename" popup menu item on the TreeView or by
calling setEditing(true) on the NodeView.
The text value that is edited (nodeText vs expandedNodeText) is controlled by the value
of the NodeStyle.EXPANDED_TEXT_DISPLAYED
style value.
Validation can be performed on the text entered through in place editing.
This is done by setting a
validator
on the TreeView. If a new text value is marked invalid by a validator, then
an error handler
can be set on either the TreeView or on the node's style to handle the error.
MutableNodeInterface,
NodeInterface,
SimpleNodeInterface,
NodeStyle,
TreeView| Field Summary | |
|---|---|
static java.lang.String |
NODE_EDITING_ERROR
Constant used to identify errors that occur when NodeView is in edit mode. |
static java.lang.String |
RB_KEY
|
| Constructor Summary | |
|---|---|
protected |
NodeView(TreeView treeView,
com.sas.models.NodeInterface node)
Constructs a NodeView object. |
| Method Summary | |
|---|---|
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
|
int |
countNodeChildren(int maximumChildCount)
Counts the children of the current node. |
com.sas.util.Command[] |
getCommands()
Returns a list of commands that can be executed on the current node. |
com.sas.visuals.IconInterface |
getDefaultIcon()
Returns the default icon for the current node. |
com.sas.collection.PropertyBagInterface |
getDefaultNodeStyle()
Returns the set of style properties that serve as the defaults for this node and for all of its descendants. |
int |
getDepth()
Returns the depth of the current node in the tree. |
com.sas.visuals.IconInterface |
getExpandedIcon()
Returns the expanded icon for the current node. |
com.sas.visuals.IconInterface |
getExpandedSelectedIcon()
Returns the expandedSelected icon for the current node. |
int |
getIndex(NodeView childNode,
int startIndex)
Returns the index in the child list of the specified node. |
NodeView |
getNextSibling()
Returns the sibling node immediately following the current node. |
com.sas.models.NodeInterface |
getNode()
Returns the NodeInterface object for the current node. |
com.sas.models.SimpleNodeInterface |
getNodeChild(int index)
Returns the child node at the specified 0-based index. |
int |
getNodeChildCount()
Returns the number of children. |
com.sas.models.SimpleNodeInterface[] |
getNodeChildren(int startIndex,
int count)
Returns a range of child nodes. |
java.lang.String |
getNodeExpandedText()
Returns the expanded text for the current node. |
com.sas.collection.PropertyBagInterface |
getNodeStyle()
Returns the set of style properties that serve as formatting and rendering defaults and hints for this node. |
java.lang.String |
getNodeText()
Returns the text for the current node. |
java.lang.String |
getNodeType()
Returns the type of the current node. |
NodeView |
getParent()
Returns the parent of the current node. |
NodeView |
getPreviousSibling()
Returns the sibling node immediately preceding the current node. |
com.sas.visuals.IconInterface |
getSelectedIcon()
Returns the selected icon for the current node. |
NodeState |
getSingleState()
Returns the state of the current NodeView object. |
NodeState |
getState()
Returns the state of the current NodeView object and all
descendants. |
int |
getVisibleNodeCount()
Returns the visible node count for the current node. |
boolean |
isEditing()
Indicates whether the current node is being edited in place or not. |
boolean |
isExpanded()
Indicates whether the current node is expanded. |
boolean |
isLeafNode()
Indicates if the current NodeView is a leaf (has no children). |
boolean |
isSelected()
Indicates whether the current node is selected. |
boolean |
isVisible()
Returns true if the node is visible and false if it is hidden. |
protected void |
notifyPropertyChange(java.beans.PropertyChangeEvent event)
Send a PropertyChangeEvent event to all the PropertyChangeListener objects in the listener list. |
void |
onAction()
Called whenever a node is double-clicked in the viewer. |
void |
onSelect()
Called whenever a node is selected in the viewer. |
void |
propertyChange(java.beans.PropertyChangeEvent event)
Handles PropertyChangeEvents received by the current node. |
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Remove a listener for the java.beans.PropertyChangeEvent event. |
void |
repopulate()
Directs the current node to refresh its child list from its underlying NodeInterface object. |
void |
setDefaultNodeStyle(com.sas.collection.PropertyBagInterface newValue)
Sets the set of style properties that serve as the defaults for this node and for all of its descendants. |
void |
setEditing(boolean newValue)
Directs the current node to enter or exit editing mode. |
void |
setExpanded(boolean newValue)
Controls whether the current node is expanded or collapsed. |
void |
setNodeStyle(com.sas.collection.PropertyBagInterface newValue)
Sets the set of style properties that serve as formatting and rendering defaults and hints for this node. |
void |
setSelected(boolean newValue)
Controls whether the current node is selected. |
void |
setState(NodeState state)
Restores the state of the current NodeView object from the specified
NodeState object. |
void |
setVisible()
Convience method to expand all ancestors. |
protected boolean |
supportsCommandsInterface()
Indicates whether the underlying NodeInterface implements com.sas.util.CommandsInterface. |
java.lang.String |
toString()
Returns the displayed text for the current node. |
void |
updateVisibleNodeCount()
Directs the current node to update its visible node count. |
| Field Detail |
|---|
public static final java.lang.String RB_KEY
public static final java.lang.String NODE_EDITING_ERROR
| Constructor Detail |
|---|
protected NodeView(TreeView treeView,
com.sas.models.NodeInterface node)
treeView - associated TreeView objectnode - source node| Method Detail |
|---|
public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
addPropertyChangeListener in interface com.sas.beans.PropertyChangeSourcePropertyChangeSource.addPropertyChangeListener(java.beans.PropertyChangeListener)public int countNodeChildren(int maximumChildCount)
countNodeChildren is an instruction to determine the number of children even though that number is not readily known. To limit the potential overhead of this determination, the maximum number of children to read may be specified.
countNodeChildren in interface com.sas.models.SimpleNodeInterfacemaxCount - Maximum number of children to read, or 0 to read indefinitely.
Implementations where the number of children is always known should
ignore this parameter. In cases where the total number of children
is unknown, but the number known so far is greater than maxCount
should return the larger known number. Thus maxCount is only used as
a limiting factor when the implementation has to actually do
computation (e.g. fetch observations).
public com.sas.util.Command[] getCommands()
getCommands in interface CommandsInterfacepublic com.sas.visuals.IconInterface getDefaultIcon()
getDefaultIcon in interface com.sas.models.NodeIconInterfacepublic com.sas.collection.PropertyBagInterface getDefaultNodeStyle()
setDefaultNodeStyle(com.sas.collection.PropertyBagInterface),
getNodeStyle(),
setNodeStyle(com.sas.collection.PropertyBagInterface)public int getDepth()
public com.sas.visuals.IconInterface getExpandedIcon()
getExpandedIcon in interface com.sas.models.NodeIconInterfacegetDefaultIcon()public com.sas.visuals.IconInterface getExpandedSelectedIcon()
getExpandedSelectedIcon in interface com.sas.models.NodeIconInterfacegetExpandedIcon()
public int getIndex(NodeView childNode,
int startIndex)
childNode - child node to find the index ofstartIndex - the position where the search should start
public NodeView getNextSibling()
public com.sas.models.NodeInterface getNode()
public com.sas.models.SimpleNodeInterface getNodeChild(int index)
NOTE: Although a SimpleNodeInterface object is returned the actual object type is NodeView. This object should not be confused with the NodeInterface object that was used to create it.
getNodeChild in interface com.sas.models.SimpleNodeInterfaceindex - the 0-based index of the child to get
public int getNodeChildCount()
getNodeChildCount in interface com.sas.models.SimpleNodeInterface
public com.sas.models.SimpleNodeInterface[] getNodeChildren(int startIndex,
int count)
NOTE: Although an array of SimpleNodeInterface objects is returned, the actual object types are NodeView. These objects should not be confused with the NodeInterface objects that were used to create them.
getNodeChildren in interface com.sas.models.SimpleNodeInterfacestartIndex - 0-based index which identifies the start of the rangecount - the amount of children to get
public java.lang.String getNodeExpandedText()
getNodeExpandedText in interface com.sas.models.NodeInterfacepublic com.sas.collection.PropertyBagInterface getNodeStyle()
setNodeStyle(com.sas.collection.PropertyBagInterface),
getDefaultNodeStyle(),
setDefaultNodeStyle(com.sas.collection.PropertyBagInterface)public java.lang.String getNodeText()
getNodeText in interface com.sas.models.NodeInterfacepublic java.lang.String getNodeType()
getNodeType in interface com.sas.models.NodeInterfacepublic NodeView getParent()
public NodeView getPreviousSibling()
public com.sas.visuals.IconInterface getSelectedIcon()
getSelectedIcon in interface com.sas.models.NodeIconInterfacegetDefaultIcon()public NodeState getSingleState()
NodeView object. That state is
returned as a NodeState object. The NodeState
object will contain
values for the selected and expanded properties. If the states of
descendants are also wanted, then getState should be called instead.
NodeView objectgetState()public NodeState getState()
NodeView object and all
descendants. The state is returned as a NodeState object.
The NodeState object will contain values for the selected
and expanded properties as well as a collection of the states
of each child (if children exist). If the state of only the
current NodeView object is wanted, then
getSingleState should be called instead.
NodeView objectgetSingleState()public int getVisibleNodeCount()
public boolean isEditing()
true if the current node is being
edited, false otherwisesetEditing(boolean)public boolean isExpanded()
true if the current node is expanded, otherwise falsesetExpanded(boolean)public boolean isLeafNode()
isLeafNode in interface com.sas.models.SimpleNodeInterfacetrue if the current node is a leaf, otherwise falsepublic boolean isSelected()
true if the current node is selected, otherwise falsesetSelected(boolean)public boolean isVisible()
NodeStyle.VISIBLE property being set. If the
NodeStyle.VISIBLE property is not set, true is returned.
NodeStylepublic void onAction()
public void onSelect()
public void propertyChange(java.beans.PropertyChangeEvent event)
propertyChange in interface java.beans.PropertyChangeListenerevent - the PropertyChangeEvent to handlepublic void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
removePropertyChangeListener in interface com.sas.beans.PropertyChangeSourcelistener - an object which handles PropertyChangeEvent eventsPropertyChangeSource.removePropertyChangeListener(java.beans.PropertyChangeListener)public void repopulate()
public void setDefaultNodeStyle(com.sas.collection.PropertyBagInterface newValue)
newValue - the new value for the defaultNodeStyle propertygetDefaultNodeStyle(),
getNodeStyle(),
setNodeStyle(com.sas.collection.PropertyBagInterface)public void setEditing(boolean newValue)
newValue - true if the current node is to be
edited, false otherwiseisEditing()public void setExpanded(boolean newValue)
newValue - expands the current node if true,
collapses it if falseisExpanded()public void setNodeStyle(com.sas.collection.PropertyBagInterface newValue)
newValue - the new value for the nodeStyle propertygetNodeStyle(),
getDefaultNodeStyle(),
setDefaultNodeStyle(com.sas.collection.PropertyBagInterface)public void setSelected(boolean newValue)
newValue - selects the current node if true,
deselects it if falseisSelected()public void setState(NodeState state)
NodeView object from the specified
NodeState object. If the specified NodeState object
contains NodeState
objects for the children of the current node, then they will also be
restored.
state - the state to restore to the current NodeView objectpublic void setVisible()
public java.lang.String toString()
toString in class java.lang.Objectpublic void updateVisibleNodeCount()
protected void notifyPropertyChange(java.beans.PropertyChangeEvent event)
event - the event to sendprotected boolean supportsCommandsInterface()
true if CommandsInterface is supported, otherwise falseCommandsInterface
|
| Components |
|
| |||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||||