|
Components |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
com.sas.visuals.TreeView
public class TreeView
TreeView is a class which displays a hierarchical list of items. For
example, a TreeView could be used to display the files and directories
of a file system or the headings and subheadings of a document. Each item
in a TreeView is represented by a com.sas.visuals.NodeView object consisting
of a text label and optionally an image. Items which contain subitems can
be expanded or collapsed allowing the subitems to either be shown or hidden.
TreeView tv = new TreeView();
tv.initialize();
By default, TreeView is 148 pixels wide and 148 pixels tall. You can change these (as with all visual components) with:
setDefaultWidth (int width);
setDefaultHeight (int height);
Since defaultWidth and defaultHeight are class, or static, properties, they affect the size of all object instances. To change the size (and/or position) of a single instance use:
setBounds (int x, int y, int width, int height)
;
TreeView requires a model that implements
TreeInterface
.
If available, it will also utilize
StaticTreeNodeStyleInterface
To attach a model to TreeView:
setModelInterface(your-model);
And to detach the model:
setModelInterface(null);
Besides responding to events from its model, TreeView will fire events itself. TreeView fires the following events:
PropertyChangeEvents
ItemEvents
NodeActionEvents
PropertyChangeEvents are fired (as with other bean components) whenever a bound property is changed.
ItemEvents are fired whenever a node is selected or deselected.
NodeActionEvents (subclass of
ActionEvent
) are fired whenever an action
occurs on a node. Actions that can occur on a node are: expand, collapse, recursive expand
(by pressing * key on keypad), recursive collapse (by pressing / key on keypad) and double-click.
In order to listen for NodeActionEvents, listeners
should add themselves as ActionListeners
and cast the ActionEvent argument to a NodeActionEvent when received.
To register to receive PropertyChangeEvents:
addPropertyChangeListener(java.beans.PropertyChangeListener listener);
And to receive ItemEvents:
addItemListener(java.awt.event.ItemListener listener);
And to receive NodeActionEvents:
addActionListener(java.awt.event.ActionListener listener);
Here's a sample ItemEvent handler:
public void itemStateChanged(java.awt.event.ItemEvent event)
{
if (event.getStateChange() == java.awt.event.ItemEvent.SELECTED)
{
NodeView selectedNode = (NodeView)event.getItem();
System.out.println("selectedNode: " + selectedNode.getNodeText());
}
else //if (event.getStateChange() == java.awt.event.ItemEvent.DESELECTED)
{
NodeView deselectedNode = (NodeView)event.getItem();
System.out.println("deselectedNode: " + deselectedNode.getNodeText());
}
}
Here's a sample NodeActionEvent handler:
public void actionPerformed(java.awt.event.ActionEvent event)
{
if (event instanceof NodeActionEvent)
{
NodeActionEvent naEvent = (NodeActionEvent)event;
NodeView node = naEvent.getNode();
if (naEvent.getActionCommand() == NodeActionEvent.EXPANDED)
{
System.out.println("node expanded: "+node.getNodeText());
}
else if (naEvent.getActionCommand() == NodeActionEvent.COLLAPSED)
{
System.out.println("node collapsed: "+node.getNodeText());
}
}
}
A style is simply a collection of property names with associated values. TreeView uses styles to provide control over the formatting and rendering characteristics of nodes.
TreeView provides a specific style, NodeStyle
to use with nodes.
NodeStyle defines properties such as foregroundColor,
backgroundColor, and defaultIcon among many
others.
TreeView provides a default style which can be accessed, modified, and/or replaced via:
These styles serve as the defaults for all nodes in the tree. Consider the following example:
If you wanted every node to be red,
getDefaultNodeStyle().set(NodeStyle.FOREGROUND_COLOR, java.awt.Color.red);
By default, individual nodes do not have a style of their
own, but one may be assigned via
NodeView.setNodeStyle()
or
NodeView.setDefaultNodeStyle()
.
For example,
to change the foreground color for only the selected node:
NodeStyle nodeStyle = new NodeStyle();
nodeStyle.setForegroundColor(java.awt.Color.red);
getSelectedNode().setNodeStyle(nodeStyle);
And to change the foreground color for the selected node and all of its
descendants:
NodeStyle nodeStyle = new NodeStyle();
nodeStyle.setForegroundColor(java.awt.Color.red);
getSelectedNode().setDefaultNodeStyle(nodeStyle);
Each style does not have to (and rarely will) define every property associated with its type.
(Actually, styles are extensible so there is no notion of defining every property.) For example,
defaultNodeStyle might provide a value for backgroundColor,
but not foregroundColor. Instead choosing to defer to
NodeView.defaultNodeStyle for foregroundColor.
For example, to change the background color for all nodes and to change the foreground color for only the first child of the root node (as well as all of the first child's descendants):
getDefaultNodeStyle().set(NodeStyle.FOREGROUND_COLOR, java.awt.Color.red);
NodeStyle nodeStyle = new NodeStyle();
nodeStyle.setBackgroundColor(java.awt.Color.blue);
NodeView root = getRoot();
NodeView child1 = (NodeView)root.getNodeChild(0);
child1.setDefaultNodeStyle(nodeStyle);
And to change the foreground color to red for only the first child of the root node
but to change the foreground color to blue for all of the first child's descendants:
NodeStyle nodeStyle = new NodeStyle();
nodeStyle.setForegroundColor(java.awt.Color.red);
NodeStyle defaultNodeStyle = new NodeStyle();
defaultNodeStyle.setForegroundColor(java.awt.Color.blue);
NodeView root = getRoot();
root.setNodeStyle(nodeStyle);
root.setDefaultNodeStyle(defaultNodeStyle);
The typical listbox is a single column of selectable, but not editable, items. TreeView can be configured to look like a listbox if the model contains a root node with one level of children. First, to get the right appearance, you'll want to hide the root node. This can be accomplished via the customizer or with the following code:
setRootNodeVisible(false);
Then you'll want to hide the lines. Again this can be done via the customizer or with the following code:
setLineVisibility(TreeView.ALL_HIDDEN);
For example,
DefaultColorList
is model that has only
one level of nodes under the root node. To show it in the TreeView as a listbox:
setRootNodeVisible(false);
setLineVisibility(TreeView.ALL_HIDDEN);
setModelInterface(new com.sas.models.DefaultColorList());
TreeInterface
,
NodeActionEvent
,
Serialized FormField Summary | |
---|---|
static int |
ALL_HIDDEN
Visibility style specifying that all items are hidden. |
static int |
ALL_VISIBLE
Visibility style specifying that all items are visible. |
static int |
DOTTED_LINES
Line style specifying the lines in the TreeView to be dotted lines. |
static int |
IMAGES
Deprecated. Use getDefaultNodeStyle().set(NodeStyle.IMAGE_VISIBLE, Boolean.TRUE) instead. |
static int |
NO_IMAGES
Deprecated. Use getDefaultNodeStyle().set(NodeStyle.IMAGE_VISIBLE, Boolean.FALSE) instead. |
static int |
NO_LINES
Deprecated. Use setLineVisibility(TreeView.ALL_HIDDEN) instead. |
static java.lang.String |
RB_KEY
|
static int |
ROOT_HIDDEN
Visibility style specifying that the items associated with the root are hidden. |
static int |
SOLID_LINES
Line style specifying the lines in the TreeView to be solid lines. |
Fields inherited from interface com.sas.visuals.ScrollingInterface |
---|
SCROLL_BLOCK, SCROLL_COLUMN, SCROLL_ELEMENT, SCROLL_HALF_PAGE, SCROLL_MAXIMUM, SCROLL_PAGE, SCROLL_PIXEL, SCROLL_ROW |
Fields inherited from interface com.sas.visuals.ScrollbarVisibilityInterface |
---|
SCROLLBARS_ALWAYS, SCROLLBARS_AS_NEEDED, SCROLLBARS_NEVER |
Constructor Summary | |
---|---|
TreeView()
Constructs a TreeView object. |
Method Summary | |
---|---|
void |
addActionListener(java.awt.event.ActionListener listener)
Add an ActionListener. |
void |
addItemListener(java.awt.event.ItemListener listener)
Add an ItemListener. |
void |
adjustmentValueChanged(java.awt.event.AdjustmentEvent event)
Handles an AdjustmentEvent sent by the scrollbars. |
void |
attachModel(com.sas.ModelInterface model)
Attaches a model to the TreeView. |
java.awt.Dimension |
computePreferredSize()
Returns the preferred size of the TreeView. |
void |
contentsChanged(com.sas.collection.ContentsChangedEvent event)
Handles ContentsChangedEvent sent by the model. |
void |
detachModel(com.sas.ModelInterface mi)
Detaches model from the TreeView. |
int |
getButtonSize()
Returns the size of the tree buttons. |
int |
getButtonVisibility()
Returns the value of the buttonVisibility property. |
java.lang.Object |
getContext(int x,
int y)
Returns the NodeView object at the specified pixel location. |
com.sas.util.Command[] |
getContextCommands(java.lang.Object object,
int x,
int y)
Returns a list of commands associated with the TreeView. |
NodeView |
getCurrentNode()
Returns the current NodeView object. |
static int |
getDefaultHeight()
Returns the default height in pixels. |
com.sas.ModelInterface |
getDefaultModel()
Returns the default model. |
com.sas.collection.PropertyBagInterface |
getDefaultNodeStyle()
Returns the default NodeStyle object. |
static int |
getDefaultWidth()
Returns the default width in pixels. |
int |
getDisplayStyle()
Deprecated. Use NodeView.IMAGE_VISIBLE property of defaultNodeStyle. |
com.sas.models.TreeDnDDelegateInterface |
getDnDDelegate()
Returns the current DnDDelegate. |
static com.sas.beans.ExtendedBeanInfo |
getExtendedBeanInfo()
Returns property information about the TreeView. |
int |
getHorizontalScrollbarVisibility()
Returns the horizontal scrollbar's visibility. |
protected com.sas.visuals.IconInterface |
getIcon(java.lang.String nodeType)
Returns the icon for a given node type. |
int |
getImageGap()
Returns the image gap in pixels. |
java.awt.Dimension |
getImageSize()
Deprecated. Use NodeView.IMAGE_SIZE property of defaultNodeStyle. |
int |
getIndentSize()
Returns the indent in pixels. |
int |
getLineStyle()
Returns the line style for the tree. |
int |
getLineVisibility()
Returns the value of the lineVisibility property. |
com.sas.collection.StaticDictionaryInterface |
getNodeTypeStyles()
Returns the set of node types and their associated styles. |
NodeView |
getNodeView(com.sas.models.NodeInterface[] path)
Returns the NodeView object corresponding to the specified NodeInterface object path. |
NodeView |
getNodeView(com.sas.models.NodeInterface nodeI,
int count)
Returns the NodeView object corresponding to the specified NodeInterface object. |
NodeView |
getNodeView(java.awt.Point point)
Returns the node at a given point. |
NodeView |
getNodeView(com.sas.util.PredicateInterface predicate)
Returns the NodeView object for which the predicate evaluates to true. |
NodeView |
getNodeView(java.lang.String selectedString,
int count)
Returns the NodeView object containing the specified string. |
java.util.Vector |
getRequiredInterfaces()
Returns the required interfaces Vector for this component. |
NodeView |
getRoot()
Returns the root NodeView object. |
java.lang.String |
getSelectedItem()
Returns the value of the nodeExpandedText property for the selected NodeView object. |
NodeView |
getSelectedNode()
Returns the selected NodeView object. |
NodeView[] |
getSelectedNodes()
Returns the selected NodeView objects. |
java.lang.Object[] |
getSelectedObjects()
Returns the selected NodeView objects. |
java.lang.String |
getText()
Support for StringDataInterface. |
int |
getTextGap()
Deprecated. Use NodeView.TEXT_GAP property of defaultNodeStyle. |
int |
getTextPad()
Deprecated. Use NodeView.TEXT_PAD property of defaultNodeStyle. |
int |
getVerticalScrollbarVisibility()
Returns the vertical scrollbar's visibility. |
protected NodeView |
getVisibleNode(int index)
Retrieves a node from the visible node collection. |
void |
initialize()
Initializes the TreeView. |
void |
initializeComponent()
Sets the default, non-transient values and design time dependent values of TreeView. |
boolean |
isDefaultModelAttached()
Alias for (getDefaultModel() == getModelInterface() &&
(getDefaultModel() ! |
boolean |
isExtendedSelectionAllowed()
Returns the value of the extendedSelectionAllowed property. |
boolean |
isFocusTraversable()
Overridden to return true so that TreeView can receive focus when the
tab or tab-shift keys being pressed. |
boolean |
isKeyboardSelectable()
Returns the value of the keyboardSelectable property. |
static boolean |
isLeftMouseButton(java.awt.event.MouseEvent anEvent)
Deprecated. Use com.sas.awt.util.Util.isLeftMouseButton |
static boolean |
isMiddleMouseButton(java.awt.event.MouseEvent anEvent)
Deprecated. Use com.sas.awt.util.Util.isMiddleMouseButton |
boolean |
isNodeExpandedTextDisplayed()
Deprecated. Use NodeView.EXPANDED_TEXT_DISPLAYED property of defaultNodeStyle. |
boolean |
isPopupMenuVisible()
Returns whether a popup menu will be shown when TableView receives the popup event. |
static boolean |
isRightMouseButton(java.awt.event.MouseEvent anEvent)
Deprecated. Use com.sas.awt.util.Util.isRightMouseButton |
boolean |
isRootNodeVisible()
Returns the value of the rootNodeVisible property. |
void |
paint(java.awt.Graphics g)
Paints the TreeView. |
protected void |
processActionEvent(java.awt.event.ActionEvent event)
Processes action events occurring on the TreeView. |
protected void |
processEvent(java.awt.AWTEvent e)
Processes events occurring on the TreeView. |
protected void |
processFocusEvent(java.awt.event.FocusEvent event)
Processes focus events occurring on TreeView. |
protected void |
processItemEvent(java.awt.event.ItemEvent event)
Processes item events occurring on the TreeView. |
protected void |
processKeyEvent(java.awt.event.KeyEvent event)
Processes key events occurring on TreeView. |
protected void |
processMouseEvent(java.awt.event.MouseEvent event)
Processes mouse events on TreeView. |
protected void |
processMouseMotionEvent(java.awt.event.MouseEvent event)
Handles mouse motion events on TreeView. |
void |
propertyChange(java.beans.PropertyChangeEvent event)
Handles property change events on TreeView. |
void |
refresh()
Refreshes the TreeView. |
void |
refresh(com.sas.ModelInterface model)
Notifies the view that a model has changed. |
void |
removeActionListener(java.awt.event.ActionListener listener)
Removes an action listener. |
void |
removeItemListener(java.awt.event.ItemListener listener)
Removes an item listener. |
protected void |
render(java.awt.Graphics g)
Paints the nodes of TreeView. |
void |
repaint()
Repaints this component. |
void |
scrollHorizontally(int numUnits,
int unit)
Scrolls horizontally. |
void |
scrollToNode(NodeView node,
boolean selectNode)
Scrolls the specified node into view. |
void |
scrollVertically(int numUnits,
int unit)
Scrolls vertically. |
void |
setBounds(int x,
int y,
int width,
int height)
Override of Component.setBounds to be notified of resizes. |
void |
setButtonSize(int newValue)
Set the size of the tree buttons in pixels. |
void |
setButtonVisibility(int newValue)
Sets the value of the buttonVisibility property. |
void |
setCurrentNode(NodeView newValue)
Sets the current NodeView object. |
void |
setCursor(java.awt.Cursor cursor)
Overrides java.awt.Component.setCursor. |
static void |
setDefaultHeight(int newValue)
Sets the default height in pixels. |
void |
setDefaultModel(com.sas.ModelInterface newValue)
Sets the default model. |
void |
setDefaultNodeStyle(com.sas.collection.PropertyBagInterface newValue)
Sets the default NodeStyle object. |
void |
setDefaultValues()
Sets the default, non-transient values of TreeView. |
static void |
setDefaultWidth(int newValue)
Sets the default width in pixels. |
void |
setDisplayStyle(int newValue)
Deprecated. Use NodeView.IMAGE_VISIBLE property of defaultNodeStyle. |
void |
setDnDDelegate(com.sas.models.TreeDnDDelegateInterface newValue)
Sets the DnDDelegate on the TreeView. |
void |
setExtendedSelectionAllowed(boolean newValue)
Sets the value of the extendedSelectionAllowed property. |
void |
setFont(java.awt.Font newValue)
Sets the font to be used by the component for displaying text. |
void |
setHorizontalScrollbarVisibility(int newValue)
Sets the horizontal scrollbar's visibility. |
void |
setIcon(java.lang.String nodeType,
com.sas.visuals.IconInterface icon)
Associates an IconInterface with a node type. |
void |
setIcon(java.lang.String nodeType,
java.lang.String path)
Associates an image with a node type. |
void |
setImageGap(int newValue)
Sets the value of the image gap property. |
void |
setImageSize(java.awt.Dimension newValue)
Deprecated. Use NodeView.IMAGE_SIZE property of defaultNodeStyle. |
void |
setIndentSize(int newValue)
Set the value of the indent property. |
void |
setKeyboardSelectable(boolean newValue)
Sets the value of the keyboardSelectable property. |
void |
setLineStyle(int newValue)
Sets the line style for the tree. |
void |
setLineVisibility(int newValue)
Sets the value of the lineVisibility property. |
void |
setModelInterface(com.sas.ModelInterface newValue)
Specifies the model to display in the view. |
void |
setNodeExpandedTextDisplayed(boolean newValue)
Deprecated. Use NodeView.EXPANDED_TEXT_DISPLAYED property of defaultNodeStyle. |
void |
setPopupMenuVisible(boolean newValue)
Specifies whether a popup menu should be shown when TableView receives the popup event. |
void |
setRoot(com.sas.models.NodeInterface newRoot)
Set the root node of the TreeView. |
void |
setRootNodeVisible(boolean newValue)
Sets the value of the rootNodeVisible property. |
void |
setSelectedItem(java.lang.String text)
Sets the selected item to the specified string. |
void |
setText(java.lang.String text)
Support for StringDataInterface. |
void |
setTextGap(int gap)
Deprecated. Use NodeView.TEXT_GAP property of defaultNodeStyle. |
void |
setTextPad(int pad)
Deprecated. Use NodeView.TEXT_PAD property of defaultNodeStyle. |
void |
setVerticalScrollbarVisibility(int newValue)
Sets the vertical scrollbar's visibility. |
void |
update(java.awt.Graphics g)
This method tells the TreeView to repaint itself. |
Methods inherited from class com.sas.awt.Panel |
---|
remove, remove, removeAll |
Methods inherited from interface com.sas.awt.ContainerInterface |
---|
getComponents, getLayout, invalidate, setLayout, validate |
Field Detail |
---|
public static final java.lang.String RB_KEY
public static final int SOLID_LINES
public static final int DOTTED_LINES
public static final int NO_LINES
public static final int ALL_VISIBLE
public static final int ALL_HIDDEN
public static final int ROOT_HIDDEN
public static final int NO_IMAGES
public static final int IMAGES
Constructor Detail |
---|
public TreeView()
Method Detail |
---|
public static com.sas.beans.ExtendedBeanInfo getExtendedBeanInfo()
public static int getDefaultWidth()
public static void setDefaultWidth(int newValue)
newValue
- the new value for the default width in pixelspublic static int getDefaultHeight()
public static void setDefaultHeight(int newValue)
newValue
- the new value for the default height in pixelspublic static boolean isLeftMouseButton(java.awt.event.MouseEvent anEvent)
Util.isLeftMouseButton(java.awt.event.MouseEvent)
public static boolean isMiddleMouseButton(java.awt.event.MouseEvent anEvent)
Util.isMiddleMouseButton(java.awt.event.MouseEvent)
public static boolean isRightMouseButton(java.awt.event.MouseEvent anEvent)
Util.isRightMouseButton(java.awt.event.MouseEvent)
public void addActionListener(java.awt.event.ActionListener listener)
addActionListener
in interface ActionSource
listener
- an object which handles ActionEvent events
the listener is not added a second time if it already exists
in the list of listeners for this event.ActionSource
public void addItemListener(java.awt.event.ItemListener listener)
addItemListener
in interface java.awt.ItemSelectable
listener
- an object which handles ItemEvent events
the listener is not added a second time if it already exists
in the list of listeners for this event.public void adjustmentValueChanged(java.awt.event.AdjustmentEvent event)
adjustmentValueChanged
in interface java.awt.event.AdjustmentListener
event
- the event being handledpublic void attachModel(com.sas.ModelInterface model)
attachModel
in interface com.sas.ViewInterface
attachModel
in class PanelVisualComponent
model
- Model to attach toViewInterface.attachModel(com.sas.ModelInterface)
public java.awt.Dimension computePreferredSize()
computePreferredSize
in interface VisualInterface
computePreferredSize
in class PanelVisualComponent
VisualInterface.computePreferredSize()
public void contentsChanged(com.sas.collection.ContentsChangedEvent event)
contentsChanged
in interface com.sas.collection.ContentsChangedListener
event
- the event to handlepublic void detachModel(com.sas.ModelInterface mi)
detachModel
in interface com.sas.ViewInterface
detachModel
in class PanelVisualComponent
mi
- the model to detachViewInterface.detachModel(com.sas.ModelInterface)
public int getButtonSize()
setButtonSize(int)
public int getButtonVisibility()
ALL_VISIBLE
,
ALL_HIDDEN
, or ROOT_HIDDEN
.
setButtonVisibility(int)
public java.lang.Object getContext(int x, int y)
getContext
in interface ContextInterface
x
- the x position of the contexty
- the y position of the context
getNodeView(Point)
public com.sas.util.Command[] getContextCommands(java.lang.Object object, int x, int y)
ContextCommandsInterface
, that node's commands
are returned.
getContextCommands
in interface ContextCommandsInterface
context
- The object requesting the commands. This parameter is ignored.x
- The x position to pass to the context if the contextImplements the
com.sas.util.ContextInterface. If the position is not relevant to the
context then -1 should be used.y
- The y position to pass to the context if the contextImplements the
com.sas.util.ContextInterface. If the position is not relevant to the
context then -1 should be used.
public NodeView getCurrentNode()
public com.sas.ModelInterface getDefaultModel()
isDefaultModelAttached()
,
setDefaultModel(com.sas.ModelInterface)
public com.sas.collection.PropertyBagInterface getDefaultNodeStyle()
setDefaultNodeStyle(com.sas.collection.PropertyBagInterface)
,
NodeStyle
public int getDisplayStyle()
NO_IMAGES
and IMAGES
.
setDisplayStyle(int)
public com.sas.models.TreeDnDDelegateInterface getDnDDelegate()
TreeDnDDelegateInterface
,
setDnDDelegate(com.sas.models.TreeDnDDelegateInterface)
public int getHorizontalScrollbarVisibility()
getHorizontalScrollbarVisibility
in interface ScrollbarVisibilityInterface
SCROLLBARS_AS_NEEDED
,
SCROLLBARS_ALWAYS
, and SCROLLBARS_NEVER
.setHorizontalScrollbarVisibility(int)
public int getImageGap()
setImageGap(int)
public java.awt.Dimension getImageSize()
setImageSize(java.awt.Dimension)
public int getIndentSize()
setIndentSize(int)
public int getLineStyle()
SOLID_LINES
,
DOTTED_LINES
and NO_LINES
. NO_LINES
is deprecated
and its use is discouraged. The lineVisibility property should be used instead to not
draw any lines.
setLineStyle(int)
,
getLineVisibility()
,
setLineVisibility(int)
public com.sas.collection.StaticDictionaryInterface getNodeTypeStyles()
The node types are defined by the model in order to categorize nodes. For example, the nodes in a hierarchy representing a file system might be categorized as "Drive", "Directory" or "File".
The NodeStyles, one for each type, are provided by the view and can be individually customized. For example,
StaticDictionaryInterface map = TreeView.getNodeTypeStyles(); NodeStyle style = (NodeStyle)map.get("File"); style.setForegroundColor(java.awt.Color.red);
null
.StaticTreeNodeStyleInterface
public int getLineVisibility()
ALL_VISIBLE
,
ALL_HIDDEN
, or ROOT_HIDDEN
.
setLineVisibility(int)
public NodeView getNodeView(java.awt.Point point)
point
- the point at which to query for a node
public NodeView getNodeView(java.lang.String selectedString, int count)
selectedString
- text string used to search for a nodecount
- the occurrence of NodeView to return containing the string.
public NodeView getNodeView(com.sas.models.NodeInterface nodeI, int count)
nodeI
- the NodeInterface object for which to find the NodeView objectcount
- the nth NodeInterface object to match
java.lang.IllegalStateException
- if the tree is empty (root node is null)
java.lang.IllegalArgumentException
- if NodeI is null, or NodeI doesn't
exist in the treepublic NodeView getNodeView(com.sas.util.PredicateInterface predicate)
predicate
- the predicate to run on each NodeView
java.lang.IllegalStateException
- if the tree is empty (root node is null)
java.lang.IllegalArgumentException
- if the predicate is nullpublic NodeView getNodeView(com.sas.models.NodeInterface[] path)
path
- the NodeInterface object path for which to find the NodeView object
com.sas.ComponentException
- if the tree is empty (root node is null)
java.lang.IllegalArgumentException
- if path is null, or if a node in
path doesn't map to a NodeView objectpublic java.util.Vector getRequiredInterfaces()
getRequiredInterfaces
in interface com.sas.ViewInterface
getRequiredInterfaces
in class PanelVisualComponent
ViewInterface.getRequiredInterfaces()
public NodeView getRoot()
public java.lang.String getSelectedItem()
public NodeView getSelectedNode()
true
, null is returned.
public NodeView[] getSelectedNodes()
false
, null is returned.
public java.lang.Object[] getSelectedObjects()
true
this will return the same value as getSelectedNodes(). If it is
false
, this will return the same value as
getSelectedNode().
getSelectedObjects
in interface java.awt.ItemSelectable
getSelectedNode()
,
getSelectedNodes()
public java.lang.String getText()
getSelectedItem()
public int getTextGap()
setTextGap(int)
public int getTextPad()
setTextPad(int)
public int getVerticalScrollbarVisibility()
getVerticalScrollbarVisibility
in interface ScrollbarVisibilityInterface
SCROLLBARS_AS_NEEDED
,
SCROLLBARS_ALWAYS
, and SCROLLBARS_NEVER
.setVerticalScrollbarVisibility(int)
public void initialize()
initialize
in interface com.sas.ComponentInterface
initialize
in class PanelVisualComponent
ComponentInterface.initialize()
public void initializeComponent()
initializeComponent
in interface com.sas.ComponentInterface
initializeComponent
in class PanelVisualComponent
ComponentInterface.initializeComponent()
public final boolean isDefaultModelAttached()
(getDefaultModel() == getModelInterface() &&
(getDefaultModel() != null)
isDefaultModelAttached
in interface com.sas.ViewDefaultModelInterface
getDefaultModel()
public boolean isExtendedSelectionAllowed()
false
.
public boolean isFocusTraversable()
true
so that TreeView can receive focus when the
tab or tab-shift keys being pressed.
isFocusTraversable
in class java.awt.Component
public boolean isKeyboardSelectable()
true
, TreeView
will
search for the first occurrence of the node containing
the character that was typed. If a character is typed a second time,
TreeView
will search for the second occurrence of a node with
that character. If the backspace key is held while typing a character
TreeView
will search for the previous occurrence of that
character (stopping at the root node). The search uses
the getNodeView(String, int)
method and is not
case sensitive.
true
if keyboard selections is allowed, false
otherwisesetKeyboardSelectable(boolean)
,
getNodeView(String,int)
public boolean isNodeExpandedTextDisplayed()
true
to display the result of getNodeExpandedText,
false
to display the result of getNodeTextsetNodeExpandedTextDisplayed(boolean)
,
NodeView
,
NodeInterface
public boolean isPopupMenuVisible()
true
if the popup menu will be shown,
and false
otherwisesetPopupMenuVisible(boolean)
public boolean isRootNodeVisible()
false
all child nodes are
shifted over to the left and the TreeView
appears as if it is a forest.
NOTE: The rootNodeVisible property is different than the VISIBLE property on NodeStyle. If the root node has a NodeStyle with the VISIBLE property set to false, the root node and all of its descendants will not be visible (and therefore nothing will be displayed in the TreeView). If the rootNodeVisible property is false, the root node will not be displayed but its descendants may be displayed. Calling isVisible() on the root node will return true, when rootNodeVisible is false (unless the root node has a NodeStyle with the VISIBLE property set to false). This is true because the root node is considered visible from the sense that it could be displayed if the nodes were not shifted over to hide it.
true
if the root node is displayed,
false
if the root node is not displayedsetRootNodeVisible(boolean)
,
NodeView.isVisible()
public void paint(java.awt.Graphics g)
paint
in class PanelVisualComponent
g
- Graphics object to paint toVisualInterfaceSupport.paint(com.sas.ComponentInterface, com.sas.awt.VisualInterface, java.awt.Component, java.awt.Graphics)
public void propertyChange(java.beans.PropertyChangeEvent event)
propertyChange
in interface java.beans.PropertyChangeListener
propertyChange
in class PanelVisualComponent
event
- the event to handlePropertyChangeListener.propertyChange(java.beans.PropertyChangeEvent)
public void refresh()
refresh(TreeView.getModelInterface())
.
public void refresh(com.sas.ModelInterface model)
refresh
in interface com.sas.ViewInterface
refresh
in class PanelVisualComponent
model
- Model that has just been updatedViewInterface.refresh(com.sas.ModelInterface)
public void removeActionListener(java.awt.event.ActionListener listener)
removeActionListener
in interface ActionSource
listener
- an object which handles ActionEvent eventsActionSource
public void removeItemListener(java.awt.event.ItemListener listener)
removeItemListener
in interface java.awt.ItemSelectable
listener
- an object which handles ItemEvent eventspublic void repaint()
repaint
in class java.awt.Component
public void scrollHorizontally(int numUnits, int unit)
scrollHorizontally
in interface ScrollingInterface
numUnits
- Indicates the direction and amount to scroll. A positive number
scrolls forward (right). A negative number scrolls backward (left).
Over-scrolls are quietly handled. (e.g. scroll (5, PAGE) when there
are only 2 pages scrolls only 2 pages)unit
- Indicates how to interpret numUnits. Valid values are: SCROLL_PIXEL
,
SCROLL_PAGE
, SCROLL_HALF_PAGE
,
SCROLL_ELEMENT
, and SCROLL_MAXIMUM
;public void scrollToNode(NodeView node, boolean selectNode)
node
- the node to scroll toselectNode
- true
to select the node scrolled to,
otherwise false
public void scrollVertically(int numUnits, int unit)
scrollVertically
in interface ScrollingInterface
numUnits
- Indicates the direction and amount to scroll. A positive number
scrolls forward (down). A negative number scrolls backward (up).
Over-scrolls are quietly handled. (e.g. scroll (5, PAGE) when there
are only 2 pages scrolls only 2 pages)unit
- Indicates how to interpret numUnits. Valid units are: SCROLL_PAGE
,
SCROLL_HALF_PAGE
, SCROLL_ELEMENT
and SCROLL_MAXIMUM
.public void setBounds(int x, int y, int width, int height)
setBounds
in interface VisualInterface
setBounds
in class PanelVisualComponent
Component.setBounds(int,int,int,int)
public void setButtonSize(int newValue)
newValue
- the new size for the tree buttons in pixelsgetButtonSize()
public void setButtonVisibility(int newValue)
ALL_VISIBLE
,
ALL_HIDDEN
, or ROOT_HIDDEN
.
newValue
- the new value of the buttonVisibility propertygetButtonVisibility()
public void setCurrentNode(NodeView newValue)
newValue
- the new value for the current NodeView objectpublic void setCursor(java.awt.Cursor cursor)
setCursor
in class java.awt.Component
Component.setCursor(java.awt.Cursor)
public void setDefaultModel(com.sas.ModelInterface newValue)
newValue
- The new value to assign the defaultModel property.isDefaultModelAttached()
,
getDefaultModel()
public void setDefaultNodeStyle(com.sas.collection.PropertyBagInterface newValue)
newValue
- the new default NodeStyle valuegetDefaultNodeStyle()
,
NodeStyle
public void setDefaultValues()
setDefaultValues
in interface ContainerInterface
setDefaultValues
in interface VisualInterface
setDefaultValues
in interface com.sas.ComponentInterface
setDefaultValues
in class CompositePanel
ContainerInterface.setDefaultValues()
public void setDisplayStyle(int newValue)
NO_IMAGES
and IMAGES
.
newValue
- the new value for the display stylegetDisplayStyle()
public void setDnDDelegate(com.sas.models.TreeDnDDelegateInterface newValue)
newValue
- the new DnDDelegate to set on the TreeViewgetDnDDelegate()
public void setExtendedSelectionAllowed(boolean newValue)
false
.
newValue
- The new value to assign the extendedSelectionAllowed property.isExtendedSelectionAllowed()
public void setFont(java.awt.Font newValue)
VisualInterface
setFont
in interface VisualInterface
setFont
in class PanelVisualComponent
newValue
- the font to be used by the component for displaying text.VisualInterface.setFont(java.awt.Font)
public void setHorizontalScrollbarVisibility(int newValue)
setHorizontalScrollbarVisibility
in interface ScrollbarVisibilityInterface
newValue
- Indicates when the horizontal scrollbar should be displayed. Possible
values are SCROLLBARS_AS_NEEDED
,
SCROLLBARS_ALWAYS
, and SCROLLBARS_NEVER
.public void setIcon(java.lang.String nodeType, com.sas.visuals.IconInterface icon)
nodeType
- the type of the nodeicon
- the IconInterface to usepublic void setIcon(java.lang.String nodeType, java.lang.String path)
nodeType
- the type of the nodepath
- the path of the image file to insertpublic void setImageGap(int newValue)
newValue
- the new value for imageGapgetImageGap()
public void setImageSize(java.awt.Dimension newValue)
newValue
- the size in pixels
java.lang.IllegalArgumentException
- if size.height <= 0 or size.width <= 0
java.lang.NullPointerException
- if newValue == null
public void setIndentSize(int newValue)
newValue
- the amount of the indentgetIndentSize()
public void setKeyboardSelectable(boolean newValue)
true
, TreeView
will
search for the first occurrence of the node containing
the character that was typed. If a character is typed a second time,
TreeView
will search for the second occurrence of a node with
that character. If the backspace key is held while typing a character
TreeView
will search for the previous occurrence of that
character (stopping at the root node). The search uses
the getNodeView(String, int)
method and is not
case sensitive.
newValue
- true
to allow keyboard selections, false
otherwiseisKeyboardSelectable()
,
getNodeView(String,int)
public void setLineStyle(int newValue)
SOLID_LINES
,
DOTTED_LINES
and NO_LINES
. NO_LINES
is deprecated
and its use is discouraged. The lineVisibility property should be used instead to not
draw any lines.
NOTE: If this method is called with the NO_LINES
argument,
setLineVisibility(ALL_HIDDEN)
will be called internally.
Any subsequent call to this method with a different argument will need to be accompanied
by the call setLineVisibility(ALL_VISIBLE)
, otherwise lines will
not be displayed.
newValue
- the new value for the line stylegetLineStyle()
,
getLineVisibility()
,
setLineVisibility(int)
public void setLineVisibility(int newValue)
ALL_VISIBLE
,
ALL_HIDDEN
, or ROOT_HIDDEN
.
newValue
- the new value of the lineVisibility propertygetLineVisibility()
public void setModelInterface(com.sas.ModelInterface newValue)
TreeInterface
.
Pass null
to disassociate the view from its model.
setModelInterface
in interface com.sas.ViewInterface
setModelInterface
in class PanelVisualComponent
newValue
- The new value to assign the modelInterface property.TreeInterface
public void setNodeExpandedTextDisplayed(boolean newValue)
newValue
- true
to display the result of getNodeExpandedText,
false
to display the result of getNodeTextisNodeExpandedTextDisplayed()
,
NodeView
,
NodeInterface
public void setPopupMenuVisible(boolean newValue)
Note that setting this to true
does not guarantee that
a popup menu will be shown; just that
populatePopupMenu()
will be driven giving subclasses a chance to populate one.
In order to configure a popup menu without subclassing,
create a
PopupMenuAdapter and set popupMenuVisible to
false
, as the adapter has its own popup menu.
Any commands provided by TableView, or its subclasses, can still
be used with the adapter's menu because TableView implements
ContextCommandsInterface, and therefore it can be registered
with the adapter via addContextCommandsProducer()
.
newValue
- true
if the popup menu should be shown,
and false
otherwisepublic void setRoot(com.sas.models.NodeInterface newRoot)
setModelInterface(new Tree(newRoot))
.
root
- the node, as a NodeInterface object, to set as rootTree
public void setRootNodeVisible(boolean newValue)
false
all child nodes are
shifted over to the left and the TreeView
appears as if it is a forest.
NOTE: The rootNodeVisible property is different than the VISIBLE property on NodeStyle. If the root node has a NodeStyle with the VISIBLE property set to false, the root node and all of its descendants will not be visible (and therefore nothing will be displayed in the TreeView). If the rootNodeVisible property is false, the root node will not be displayed but its descendants may be displayed. Calling isVisible() on the root node will return true, when rootNodeVisible is false (unless the root node has a NodeStyle with the VISIBLE property set to false). This is true because the root node is considered visible from the sense that it could be displayed if the nodes were not shifted over to hide it.
newValue
- true
if the root node is displayed,
false
if the root node is not displayedisRootNodeVisible()
,
NodeView.isVisible()
public void setSelectedItem(java.lang.String text)
getNodeView
search method.
text
- the string to selectgetNodeView(String, int)
public void setText(java.lang.String text)
setSelectedItem(
text)
.
text
- the text to set as the selected itemgetText()
,
setSelectedItem(java.lang.String)
public void setTextGap(int gap)
gap
- the distance to set for the textGapgetTextGap()
public void setTextPad(int pad)
pad
- the distance to set for the textPadgetTextPad()
public void setVerticalScrollbarVisibility(int newValue)
setVerticalScrollbarVisibility
in interface ScrollbarVisibilityInterface
newValue
- Indicates when the vertical scrollbar should be displayed. Possible
values are SCROLLBARS_AS_NEEDED
,
SCROLLBARS_ALWAYS
, and SCROLLBARS_NEVER
.public void update(java.awt.Graphics g)
update
in class PanelVisualComponent
g
- the Graphics objectVisualInterfaceSupport.update(com.sas.ComponentInterface, com.sas.awt.VisualInterface, java.awt.Component, java.awt.Graphics)
protected com.sas.visuals.IconInterface getIcon(java.lang.String nodeType)
nodeType
- the type of the node to get the image for
protected NodeView getVisibleNode(int index)
index
- the index of a node in the visible node collection
protected void processActionEvent(java.awt.event.ActionEvent event)
event
- the event to processprotected void processEvent(java.awt.AWTEvent e)
processEvent
in class java.awt.Container
e
- the event to processprotected void processItemEvent(java.awt.event.ItemEvent event)
event
- the event to processprotected void processFocusEvent(java.awt.event.FocusEvent event)
processFocusEvent
in class java.awt.Component
event
- the event to handleprotected void processKeyEvent(java.awt.event.KeyEvent event)
processKeyEvent
in class java.awt.Component
event
- the event to handleprotected void processMouseEvent(java.awt.event.MouseEvent event)
processMouseEvent
in class java.awt.Component
event
- the event to handleprotected void processMouseMotionEvent(java.awt.event.MouseEvent event)
processMouseMotionEvent
in class java.awt.Component
event
- the event to handleprotected void render(java.awt.Graphics g)
g
- the Graphics object
|
Components |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |