com.sas.visuals
Class TreeView

com.sas.visuals.TreeView
All Implemented Interfaces:
ActionSource, CompositeInterface, ContainerInterface, com.sas.awt.print.PrintableInterface, VisualInterface, com.sas.beans.PropertyChangeSource, com.sas.beans.VetoableChangeSource, com.sas.collection.ContentsChangedListener, com.sas.ComponentInterface, com.sas.DesignTimeDropTargetInterface, com.sas.LinkPropertiesInterface, com.sas.ModelInterface, ContextCommandsInterface, ContextInterface, ValidatorInterface, com.sas.ViewDefaultModelInterface, com.sas.ViewInterface, MultipleValueEventSourceInterface, ScrollbarVisibilityInterface, ScrollingInterface, java.awt.event.AdjustmentListener, java.awt.image.ImageObserver, java.awt.ItemSelectable, java.awt.MenuContainer, java.beans.PropertyChangeListener, java.io.ObjectInputValidation, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible

public class TreeView
implements java.awt.event.AdjustmentListener, ActionSource, com.sas.collection.ContentsChangedListener, ContextCommandsInterface, ContextInterface, java.awt.ItemSelectable, ScrollingInterface, ScrollbarVisibilityInterface, com.sas.ViewDefaultModelInterface


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.

Creation

TreeView tv = new TreeView();
tv.initialize();

Size

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);

Model

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);

Events

Besides responding to events from its model, TreeView will fire events itself. TreeView fires the following events:

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());
       }
    }
 }
 

Styles

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);

Using TreeView as a Listbox

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());

See Also:
TreeInterface, NodeActionEvent, Serialized Form

Field 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 class com.sas.awt.PanelContainerComponent
addNotify, clone, dragEnter, dragLeave, dragOver, drop, getContainerInterfaceSupportInfo, getErrorHandler, getInsets, getValidator, isIDEDnDDropBarrier, isIDEDnDDropTarget, isValid, removeNotify, setContainerInterfaceSupportInfo, setErrorHandler, setIDEDnDDropBarrier, setIDEDnDDropTarget, setInsets, setInsets, setValidator, superAddNotify, superGetInsets, superRemoveNotify, superSetDefaultValues
 
Methods inherited from class com.sas.awt.PanelVisualComponent
addLink, addPropertyChangeListener, addVetoableChangeListener, anyPropertyChangeListeners, attachView, detachView, dumpComponent, firePropertyChange, firePropertyChange, fireVetoableChange, getBackgroundColor, getBorder, getComponentDescription, getComponentSupportInfo, getEventMethod, getEventValues, getFont, getForegroundColor, getHeight, getHorizontalPosition, getLinkInfo, getMinimumSize, getModelInterface, getPageBounds, getPreferredSize, getPrePainter, getPrintOptionsPanel, getVerticalPosition, getViewInterfaceSupportInfo, getVisualInterfaceSupportInfo, getWidth, isDesignTime, isEnabled, isFocus, isLinked, isTransparent, isVisible, pageExists, print, printFinalize, printInitialize, queryLinks, queryLinks, removeAllLinks, removeInterfaceTraps, removeLink, removePropertyChangeListener, removeVetoableChangeListener, setBackgroundColor, setBorder, setComponentDescription, setComponentSupportInfo, setEnabled, setFocus, setForegroundColor, setHeight, setHorizontalPosition, setLinkInfo, setPreferredSize, setPrePainter, setRequiredInterfaces, setTransparent, setVerticalPosition, setViewInterfaceSupportInfo, setVisible, setVisualInterfaceSupportInfo, setWidth, superGetFont, superGetMinimumSize, superGetPreferredSize, superIsEnabled, superIsVisible, superPaint, superSetBounds, superSetEnabled, superSetFont, superSetVisible, superUpdate, supportsListenerInterface, supportsRequiredInterfaces, trapInterfaceEvents, validateObject
 
Methods inherited from interface com.sas.awt.ContainerInterface
getComponents, getLayout, invalidate, setLayout, validate
 
Methods inherited from interface com.sas.awt.VisualInterface
getBackgroundColor, getBorder, getFont, getForegroundColor, getHeight, getHorizontalPosition, getMinimumSize, getPreferredSize, getPrePainter, getVerticalPosition, getVisualInterfaceSupportInfo, getWidth, isEnabled, isFocus, isTransparent, isVisible, setBackgroundColor, setBorder, setEnabled, setFocus, setForegroundColor, setHeight, setHorizontalPosition, setPreferredSize, setPrePainter, setTransparent, setVerticalPosition, setVisible, setVisualInterfaceSupportInfo, setWidth, superGetFont, superGetMinimumSize, superGetPreferredSize, superIsEnabled, superIsVisible, superPaint, superSetBounds, superSetEnabled, superSetFont, superSetVisible, superUpdate
 

Field Detail

RB_KEY

public static final java.lang.String RB_KEY
See Also:
Constant Field Values

SOLID_LINES

public static final int SOLID_LINES
Line style specifying the lines in the TreeView to be solid lines.

See Also:
Constant Field Values

DOTTED_LINES

public static final int DOTTED_LINES
Line style specifying the lines in the TreeView to be dotted lines.

See Also:
Constant Field Values

NO_LINES

public static final int NO_LINES
Deprecated. Use setLineVisibility(TreeView.ALL_HIDDEN) instead.
Line style specifying the TreeView not to display lines.

See Also:
Constant Field Values

ALL_VISIBLE

public static final int ALL_VISIBLE
Visibility style specifying that all items are visible.

See Also:
Constant Field Values

ALL_HIDDEN

public static final int ALL_HIDDEN
Visibility style specifying that all items are hidden.

See Also:
Constant Field Values

ROOT_HIDDEN

public static final int ROOT_HIDDEN
Visibility style specifying that the items associated with the root are hidden.

See Also:
Constant Field Values

NO_IMAGES

public static final int NO_IMAGES
Deprecated. Use getDefaultNodeStyle().set(NodeStyle.IMAGE_VISIBLE, Boolean.FALSE) instead.
Display style specifying the TreeView not to display images for each node.

See Also:
Constant Field Values

IMAGES

public static final int IMAGES
Deprecated. Use getDefaultNodeStyle().set(NodeStyle.IMAGE_VISIBLE, Boolean.TRUE) instead.
Display style specifying the TreeView to display images for each node.

See Also:
Constant Field Values
Constructor Detail

TreeView

public TreeView()
Constructs a TreeView object.

Method Detail

getExtendedBeanInfo

public static com.sas.beans.ExtendedBeanInfo getExtendedBeanInfo()
Returns property information about the TreeView.

Returns:
an ExtendedBeanInfo object containing property information about the TreeView.

getDefaultWidth

public static int getDefaultWidth()
Returns the default width in pixels.

Returns:
default width of TreeView in pixels

setDefaultWidth

public static void setDefaultWidth(int newValue)
Sets the default width in pixels.

Parameters:
newValue - the new value for the default width in pixels

getDefaultHeight

public static int getDefaultHeight()
Returns the default height in pixels.

Returns:
default height of TreeView in pixels

setDefaultHeight

public static void setDefaultHeight(int newValue)
Sets the default height in pixels.

Parameters:
newValue - the new value for the default height in pixels

isLeftMouseButton

public static boolean isLeftMouseButton(java.awt.event.MouseEvent anEvent)
Deprecated. Use com.sas.awt.util.Util.isLeftMouseButton

See Also:
Util.isLeftMouseButton(java.awt.event.MouseEvent)

isMiddleMouseButton

public static boolean isMiddleMouseButton(java.awt.event.MouseEvent anEvent)
Deprecated. Use com.sas.awt.util.Util.isMiddleMouseButton

See Also:
Util.isMiddleMouseButton(java.awt.event.MouseEvent)

isRightMouseButton

public static boolean isRightMouseButton(java.awt.event.MouseEvent anEvent)
Deprecated. Use com.sas.awt.util.Util.isRightMouseButton

See Also:
Util.isRightMouseButton(java.awt.event.MouseEvent)

addActionListener

public void addActionListener(java.awt.event.ActionListener listener)
Add an ActionListener. Adds a listener for the java.awt.event.ActionEvent event.

Specified by:
addActionListener in interface ActionSource
Parameters:
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.
See Also:
ActionSource

addItemListener

public void addItemListener(java.awt.event.ItemListener listener)
Add an ItemListener. Adds a listener for the java.awt.event.ItemEvent event.

Specified by:
addItemListener in interface java.awt.ItemSelectable
Parameters:
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.

adjustmentValueChanged

public void adjustmentValueChanged(java.awt.event.AdjustmentEvent event)
Handles an AdjustmentEvent sent by the scrollbars.

Specified by:
adjustmentValueChanged in interface java.awt.event.AdjustmentListener
Parameters:
event - the event being handled

attachModel

public void attachModel(com.sas.ModelInterface model)
Attaches a model to the TreeView.

Specified by:
attachModel in interface com.sas.ViewInterface
Overrides:
attachModel in class PanelVisualComponent
Parameters:
model - Model to attach to
See Also:
ViewInterface.attachModel(com.sas.ModelInterface)

computePreferredSize

public java.awt.Dimension computePreferredSize()
Returns the preferred size of the TreeView.

Specified by:
computePreferredSize in interface VisualInterface
Overrides:
computePreferredSize in class PanelVisualComponent
Returns:
the preferred size of the TreeView
See Also:
VisualInterface.computePreferredSize()

contentsChanged

public void contentsChanged(com.sas.collection.ContentsChangedEvent event)
Handles ContentsChangedEvent sent by the model.

Specified by:
contentsChanged in interface com.sas.collection.ContentsChangedListener
Parameters:
event - the event to handle

detachModel

public void detachModel(com.sas.ModelInterface mi)
Detaches model from the TreeView.

Specified by:
detachModel in interface com.sas.ViewInterface
Overrides:
detachModel in class PanelVisualComponent
Parameters:
mi - the model to detach
See Also:
ViewInterface.detachModel(com.sas.ModelInterface)

getButtonSize

public int getButtonSize()
Returns the size of the tree buttons. The buttons are the small rectangles that contain either a '+' or '-' to indicate that a node is exanded or collapsed. The size is measured in pixels and applies to both the width and the height of the button.

Returns:
the size of the tree buttons in pixels
See Also:
setButtonSize(int)

getButtonVisibility

public int getButtonVisibility()
Returns the value of the buttonVisibility property. The buttonVisibility property controls which buttons are drawn. The buttons are the +/- rectangles that indicate if a node is expandable or collapsible. The possible values for buttonVisibility are the visibility style values: ALL_VISIBLE, ALL_HIDDEN, or ROOT_HIDDEN.

Returns:
the value of the buttonVisibility property
See Also:
setButtonVisibility(int)

getContext

public java.lang.Object getContext(int x,
                                   int y)
Returns the NodeView object at the specified pixel location. This is an alias to getNodeView(Point).

Specified by:
getContext in interface ContextInterface
Parameters:
x - the x position of the context
y - the y position of the context
Returns:
the NodeView object at the specified x and y location
See Also:
getNodeView(Point)

getContextCommands

public com.sas.util.Command[] getContextCommands(java.lang.Object object,
                                                 int x,
                                                 int y)
Returns a list of commands associated with the TreeView. If the x and y location describes the position of a node and that node is an instance of ContextCommandsInterface, that node's commands are returned.

Specified by:
getContextCommands in interface ContextCommandsInterface
Parameters:
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.
Returns:
An array of commands or null if there are no commands for the x and y location.

getCurrentNode

public NodeView getCurrentNode()
Returns the current NodeView object.

Returns:
current NodeView object or null

getDefaultModel

public com.sas.ModelInterface getDefaultModel()
Returns the default model. The default model will be used as the TreeView's model whenever its model would otherwise be null.

Returns:
The default model.
See Also:
isDefaultModelAttached(), setDefaultModel(com.sas.ModelInterface)

getDefaultNodeStyle

public com.sas.collection.PropertyBagInterface getDefaultNodeStyle()
Returns the default NodeStyle object. The default NodeStyle provides style information for the display and sizing of nodes.

Returns:
the default NodeStyle object
See Also:
setDefaultNodeStyle(com.sas.collection.PropertyBagInterface), NodeStyle

getDisplayStyle

public int getDisplayStyle()
Deprecated. Use NodeView.IMAGE_VISIBLE property of defaultNodeStyle.

Returns the display style for the tree. The two possible values for display style are NO_IMAGES and IMAGES.

Returns:
the display style for the tree.
See Also:
setDisplayStyle(int)

getDnDDelegate

public com.sas.models.TreeDnDDelegateInterface getDnDDelegate()
Returns the current DnDDelegate. Drag and drop operations are allowed when the DnDDelegate is non-null. The default value is null.

Returns:
the current DnDDelegate
See Also:
TreeDnDDelegateInterface, setDnDDelegate(com.sas.models.TreeDnDDelegateInterface)

getHorizontalScrollbarVisibility

public int getHorizontalScrollbarVisibility()
Returns the horizontal scrollbar's visibility.

Specified by:
getHorizontalScrollbarVisibility in interface ScrollbarVisibilityInterface
Returns:
Indicates when the horizontal scrollbar should be displayed. Possible values are SCROLLBARS_AS_NEEDED, SCROLLBARS_ALWAYS, and SCROLLBARS_NEVER.
See Also:
setHorizontalScrollbarVisibility(int)

getImageGap

public int getImageGap()
Returns the image gap in pixels. The image gap is the distance in between the vertical line connecting a node to the tree and either a node's image, if displayed, or a node's text label.

Returns:
the value of the imageGap property
See Also:
setImageGap(int)

getImageSize

public java.awt.Dimension getImageSize()
Deprecated. Use NodeView.IMAGE_SIZE property of defaultNodeStyle.

Returns the image size in pixels. The imageSize property controls the size of all images displayed in a TreeView.

Returns:
the value of the imageSize property
See Also:
setImageSize(java.awt.Dimension)

getIndentSize

public int getIndentSize()
Returns the indent in pixels. The indent is the distance between tree levels. The same indent value is used for all levels.

Returns:
the value of the indent property
See Also:
setIndentSize(int)

getLineStyle

public int getLineStyle()
Returns the line style for the tree. The possible values are 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.

Returns:
the value of the lineStyle property
See Also:
setLineStyle(int), getLineVisibility(), setLineVisibility(int)

getNodeTypeStyles

public com.sas.collection.StaticDictionaryInterface getNodeTypeStyles()
Returns the set of node types and their associated styles. The set is represented as a StaticDictionaryInterface with String keys corresponding to the types and NodeStyle values corresponding to the styles.

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);
  

Returns:
The value of the nodeTypeStyles property; will never be null.
See Also:
StaticTreeNodeStyleInterface

getLineVisibility

public int getLineVisibility()
Returns the value of the lineVisibility property. The lineVisibility property controls where the lines that connect the nodes of the tree are drawn. The possible values for lineVisibility are the visibility style values: ALL_VISIBLE, ALL_HIDDEN, or ROOT_HIDDEN.

Returns:
the value of the lineVisibility property
See Also:
setLineVisibility(int)

getNodeView

public NodeView getNodeView(java.awt.Point point)
Returns the node at a given point. If there is not a node at the point specified null is returned. The point is the pixel position relative to the top, left corner of the TreeView.

Parameters:
point - the point at which to query for a node
Returns:
the node at the specified point, otherwise null

getNodeView

public NodeView getNodeView(java.lang.String selectedString,
                            int count)
Returns the NodeView object containing the specified string. Count specifies which occurrence of NodeView to return since more than one NodeView can have the same string. If the string is not found in any node, null is returned. The specified string is compared with the nodeText property of NodeView.

Parameters:
selectedString - text string used to search for a node
count - the occurrence of NodeView to return containing the string.
Returns:
the NodeView object with matching text string if found, otherwise null.

getNodeView

public NodeView getNodeView(com.sas.models.NodeInterface nodeI,
                            int count)
Returns the NodeView object corresponding to the specified NodeInterface object. Since NodeInterface objects can be non-unique, the nth occurrence of the NodeInterface object can be specified to be returned.

Parameters:
nodeI - the NodeInterface object for which to find the NodeView object
count - the nth NodeInterface object to match
Returns:
the corresponding NodeView, otherwise an exception is thrown
Throws:
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 tree

getNodeView

public NodeView getNodeView(com.sas.util.PredicateInterface predicate)
Returns the NodeView object for which the predicate evaluates to true. This can be used, for example, to find the NodeView object that was created for an underlying NodeInterface object.

Parameters:
predicate - the predicate to run on each NodeView
Returns:
the NodeView object that satisfies the predicate
Throws:
java.lang.IllegalStateException - if the tree is empty (root node is null)
java.lang.IllegalArgumentException - if the predicate is null

getNodeView

public NodeView getNodeView(com.sas.models.NodeInterface[] path)
Returns the NodeView object corresponding to the specified NodeInterface object path. The path should contain nodes in the order of ancestors to descendants as the path index increases.

Parameters:
path - the NodeInterface object path for which to find the NodeView object
Returns:
the corresponding NodeView object, otherwise an exception is thrown
Throws:
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 object

getRequiredInterfaces

public java.util.Vector getRequiredInterfaces()
Returns the required interfaces Vector for this component.

Specified by:
getRequiredInterfaces in interface com.sas.ViewInterface
Overrides:
getRequiredInterfaces in class PanelVisualComponent
Returns:
the required interfaces Vector for this component.
See Also:
ViewInterface.getRequiredInterfaces()

getRoot

public NodeView getRoot()
Returns the root NodeView object.

Returns:
root NodeView object

getSelectedItem

public java.lang.String getSelectedItem()
Returns the value of the nodeExpandedText property for the selected NodeView object. If nothing is selected, null is returned.

Returns:
value of the nodeExpandedText property for the seleted NodeView object, otherwise null

getSelectedNode

public NodeView getSelectedNode()
Returns the selected NodeView object. If extendedSelectionAllowed is true, null is returned.

Returns:
selected NodeView object, otherwise null

getSelectedNodes

public NodeView[] getSelectedNodes()
Returns the selected NodeView objects. If extendedSelectionAllowed is false, null is returned.

Returns:
selected NodeView objects, otherwise null

getSelectedObjects

public java.lang.Object[] getSelectedObjects()
Returns the selected NodeView objects. If extendedSelectionAllowed is true this will return the same value as getSelectedNodes(). If it is false, this will return the same value as getSelectedNode().

Specified by:
getSelectedObjects in interface java.awt.ItemSelectable
Returns:
selected NodeView objects, otherwise null
See Also:
getSelectedNode(), getSelectedNodes()

getText

public java.lang.String getText()
Support for StringDataInterface. This is an alias for getSelectedItem().

Returns:
the selected item's text
See Also:
getSelectedItem()

getTextGap

public int getTextGap()
Deprecated. Use NodeView.TEXT_GAP property of defaultNodeStyle.

Returns the text gap in pixels. The text gap is the distance between the image and the text. This property is only used by nodes that have an associated image.

Returns:
the value of the textGap property
See Also:
setTextGap(int)

getTextPad

public int getTextPad()
Deprecated. Use NodeView.TEXT_PAD property of defaultNodeStyle.

Returns the text pad in pixels. The text pad is the distance between the text and its selection border on either side. For example, a textPad of 3 would mean that there are 3 pixels between the selection border and the text on the left and also 3 pixels between the text and the selection border on the right.

Returns:
the value of the textPad property
See Also:
setTextPad(int)

getVerticalScrollbarVisibility

public int getVerticalScrollbarVisibility()
Returns the vertical scrollbar's visibility.

Specified by:
getVerticalScrollbarVisibility in interface ScrollbarVisibilityInterface
Returns:
Indicates when the vertical scrollbar should be displayed. Possible values are SCROLLBARS_AS_NEEDED, SCROLLBARS_ALWAYS, and SCROLLBARS_NEVER.
See Also:
setVerticalScrollbarVisibility(int)

initialize

public void initialize()
Initializes the TreeView. Initialize should be called after a new TreeView object is contructed.

Specified by:
initialize in interface com.sas.ComponentInterface
Overrides:
initialize in class PanelVisualComponent
See Also:
ComponentInterface.initialize()

initializeComponent

public void initializeComponent()
Sets the default, non-transient values and design time dependent values of TreeView. This is a framework method and is not intended to be called by the user.

Specified by:
initializeComponent in interface com.sas.ComponentInterface
Overrides:
initializeComponent in class PanelVisualComponent
See Also:
ComponentInterface.initializeComponent()

isDefaultModelAttached

public final boolean isDefaultModelAttached()
Alias for (getDefaultModel() == getModelInterface() && (getDefaultModel() != null)

Specified by:
isDefaultModelAttached in interface com.sas.ViewDefaultModelInterface
See Also:
getDefaultModel()

isExtendedSelectionAllowed

public boolean isExtendedSelectionAllowed()
Returns the value of the extendedSelectionAllowed property. extendedSelectionAllowed controls whether more than one can be made. The default value is false.

Returns:
The value of the extendedSelectionAllowed property.

isFocusTraversable

public boolean isFocusTraversable()
Overridden to return true so that TreeView can receive focus when the tab or tab-shift keys being pressed.

Overrides:
isFocusTraversable in class java.awt.Component

isKeyboardSelectable

public boolean isKeyboardSelectable()
Returns the value of the keyboardSelectable property. The keyboardSelectable property controls whether nodes begining with a typed character are selected as a result of the keystroke. If keyboardSelectable is 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.

Returns:
true if keyboard selections is allowed, false otherwise
See Also:
setKeyboardSelectable(boolean), getNodeView(String,int)

isNodeExpandedTextDisplayed

public boolean isNodeExpandedTextDisplayed()
Deprecated. Use NodeView.EXPANDED_TEXT_DISPLAYED property of defaultNodeStyle.

Returns the value of the nodeExpandedTextDisplayed property. nodeExpandedTextDisplayed controls whether the text that is displayed for each node is the return of getNodeText or getNodeExpandedText from the NodeView object.

Returns:
true to display the result of getNodeExpandedText, false to display the result of getNodeText
See Also:
setNodeExpandedTextDisplayed(boolean), NodeView, NodeInterface

isPopupMenuVisible

public boolean isPopupMenuVisible()
Returns whether a popup menu will be shown when TableView receives the popup event.

Returns:
trueif the popup menu will be shown, and false otherwise
See Also:
setPopupMenuVisible(boolean)

isRootNodeVisible

public boolean isRootNodeVisible()
Returns the value of the rootNodeVisible property. The rootNodeVisible property controls whether or not the root node is displayed. If rootNodeVisible is 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.

Returns:
true if the root node is displayed, false if the root node is not displayed
See Also:
setRootNodeVisible(boolean), NodeView.isVisible()

paint

public void paint(java.awt.Graphics g)
Paints the TreeView.

Overrides:
paint in class PanelVisualComponent
Parameters:
g - Graphics object to paint to
See Also:
VisualInterfaceSupport.paint(com.sas.ComponentInterface, com.sas.awt.VisualInterface, java.awt.Component, java.awt.Graphics)

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent event)
Handles property change events on TreeView.

Specified by:
propertyChange in interface java.beans.PropertyChangeListener
Overrides:
propertyChange in class PanelVisualComponent
Parameters:
event - the event to handle
See Also:
PropertyChangeListener.propertyChange(java.beans.PropertyChangeEvent)

refresh

public void refresh()
Refreshes the TreeView. TreeView will reread the data from its model discard any previous data. This is an alias to: refresh(TreeView.getModelInterface()).


refresh

public void refresh(com.sas.ModelInterface model)
Notifies the view that a model has changed.

Specified by:
refresh in interface com.sas.ViewInterface
Overrides:
refresh in class PanelVisualComponent
Parameters:
model - Model that has just been updated
See Also:
ViewInterface.refresh(com.sas.ModelInterface)

removeActionListener

public void removeActionListener(java.awt.event.ActionListener listener)
Removes an action listener. Nothing happens if the listener is not in the list of listeners for this event.

Specified by:
removeActionListener in interface ActionSource
Parameters:
listener - an object which handles ActionEvent events
See Also:
ActionSource

removeItemListener

public void removeItemListener(java.awt.event.ItemListener listener)
Removes an item listener. Nothing happens if the listener is not in the list of listeners for this event.

Specified by:
removeItemListener in interface java.awt.ItemSelectable
Parameters:
listener - an object which handles ItemEvent events

repaint

public void repaint()
Repaints this component.

Overrides:
repaint in class java.awt.Component

scrollHorizontally

public void scrollHorizontally(int numUnits,
                               int unit)
Scrolls horizontally.

Specified by:
scrollHorizontally in interface ScrollingInterface
Parameters:
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;

scrollToNode

public void scrollToNode(NodeView node,
                         boolean selectNode)
Scrolls the specified node into view. This node will be at the top of the viewable area or as far up as possible. The specified node will be selected if specified.

Parameters:
node - the node to scroll to
selectNode - true to select the node scrolled to, otherwise false

scrollVertically

public void scrollVertically(int numUnits,
                             int unit)
Scrolls vertically.

Specified by:
scrollVertically in interface ScrollingInterface
Parameters:
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.

setBounds

public void setBounds(int x,
                      int y,
                      int width,
                      int height)
Override of Component.setBounds to be notified of resizes.

Specified by:
setBounds in interface VisualInterface
Overrides:
setBounds in class PanelVisualComponent
See Also:
Component.setBounds(int,int,int,int)

setButtonSize

public void setButtonSize(int newValue)
Set the size of the tree buttons in pixels.

Parameters:
newValue - the new size for the tree buttons in pixels
See Also:
getButtonSize()

setButtonVisibility

public void setButtonVisibility(int newValue)
Sets the value of the buttonVisibility property. The buttonVisibility property controls which buttons are drawn. The buttons are the +/- rectangles that indicate if a node is expandable or collapsible. The possible values for buttonVisibility are the visibility style values: ALL_VISIBLE, ALL_HIDDEN, or ROOT_HIDDEN.

Parameters:
newValue - the new value of the buttonVisibility property
See Also:
getButtonVisibility()

setCurrentNode

public void setCurrentNode(NodeView newValue)
Sets the current NodeView object.

Parameters:
newValue - the new value for the current NodeView object

setCursor

public void setCursor(java.awt.Cursor cursor)
Overrides java.awt.Component.setCursor.

Overrides:
setCursor in class java.awt.Component
See Also:
Component.setCursor(java.awt.Cursor)

setDefaultModel

public void setDefaultModel(com.sas.ModelInterface newValue)
Sets the default model. The default model will be used as the view's model whenever its model would otherwise be null.

Parameters:
newValue - The new value to assign the defaultModel property.
See Also:
isDefaultModelAttached(), getDefaultModel()

setDefaultNodeStyle

public void setDefaultNodeStyle(com.sas.collection.PropertyBagInterface newValue)
Sets the default NodeStyle object. The default NodeStyle provides style information for the display and sizing of nodes.

Parameters:
newValue - the new default NodeStyle value
See Also:
getDefaultNodeStyle(), NodeStyle

setDefaultValues

public void setDefaultValues()
Sets the default, non-transient values of TreeView. This is a framework method and is not intended to be called by the user.

Specified by:
setDefaultValues in interface ContainerInterface
Specified by:
setDefaultValues in interface VisualInterface
Specified by:
setDefaultValues in interface com.sas.ComponentInterface
Overrides:
setDefaultValues in class CompositePanel
See Also:
ContainerInterface.setDefaultValues()

setDisplayStyle

public void setDisplayStyle(int newValue)
Deprecated. Use NodeView.IMAGE_VISIBLE property of defaultNodeStyle.

Sets the display style for the tree. The possible values are NO_IMAGES and IMAGES.

Parameters:
newValue - the new value for the display style
See Also:
getDisplayStyle()

setDnDDelegate

public void setDnDDelegate(com.sas.models.TreeDnDDelegateInterface newValue)
Sets the DnDDelegate on the TreeView.

Parameters:
newValue - the new DnDDelegate to set on the TreeView
See Also:
getDnDDelegate()

setExtendedSelectionAllowed

public void setExtendedSelectionAllowed(boolean newValue)
Sets the value of the extendedSelectionAllowed property. extendedSelectionAllowed controls whether more than one can be made. The default value is false.

Parameters:
newValue - The new value to assign the extendedSelectionAllowed property.
See Also:
isExtendedSelectionAllowed()

setFont

public void setFont(java.awt.Font newValue)
Description copied from interface: VisualInterface
Sets the font to be used by the component for displaying text. Note that some very complex components may use additional or alternate fonts to display text.

Specified by:
setFont in interface VisualInterface
Overrides:
setFont in class PanelVisualComponent
Parameters:
newValue - the font to be used by the component for displaying text.
See Also:
VisualInterface.setFont(java.awt.Font)

setHorizontalScrollbarVisibility

public void setHorizontalScrollbarVisibility(int newValue)
Sets the horizontal scrollbar's visibility.

Specified by:
setHorizontalScrollbarVisibility in interface ScrollbarVisibilityInterface
Parameters:
newValue - Indicates when the horizontal scrollbar should be displayed. Possible values are SCROLLBARS_AS_NEEDED, SCROLLBARS_ALWAYS, and SCROLLBARS_NEVER.

setIcon

public void setIcon(java.lang.String nodeType,
                    com.sas.visuals.IconInterface icon)
Associates an IconInterface with a node type. All nodes of the specified type will use the specified image.

Parameters:
nodeType - the type of the node
icon - the IconInterface to use

setIcon

public void setIcon(java.lang.String nodeType,
                    java.lang.String path)
Associates an image with a node type. All nodes of the specified type will use the specified image.

Parameters:
nodeType - the type of the node
path - the path of the image file to insert

setImageGap

public void setImageGap(int newValue)
Sets the value of the image gap property. The image gap is the distance in pixels between the vertical line connecting a node to the tree and either a node's image (if displayed) or a node's text label.

Parameters:
newValue - the new value for imageGap
See Also:
getImageGap()

setImageSize

public void setImageSize(java.awt.Dimension newValue)
Deprecated. Use NodeView.IMAGE_SIZE property of defaultNodeStyle.

Set the size in pixels of the images in the tree.

Parameters:
newValue - the size in pixels
Throws:
java.lang.IllegalArgumentException - if size.height <= 0 or size.width <= 0
java.lang.NullPointerException - if newValue == null

setIndentSize

public void setIndentSize(int newValue)
Set the value of the indent property. The indent is number of the pixels horizontally between tree levels.

Parameters:
newValue - the amount of the indent
See Also:
getIndentSize()

setKeyboardSelectable

public void setKeyboardSelectable(boolean newValue)
Sets the value of the keyboardSelectable property. The keyboardSelectable property controls whether nodes begining with a typed character are selected as a result of the keystroke. If keyboardSelectable is 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.

Parameters:
newValue - true to allow keyboard selections, false otherwise
See Also:
isKeyboardSelectable(), getNodeView(String,int)

setLineStyle

public void setLineStyle(int newValue)
Sets the line style for the tree. The possible values are 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.

Parameters:
newValue - the new value for the line style
See Also:
getLineStyle(), getLineVisibility(), setLineVisibility(int)

setLineVisibility

public void setLineVisibility(int newValue)
Sets the value of the lineVisibility property. The lineVisibility property controls where the lines that connect the nodes of the tree are drawn. The possible values for lineVisibility are the visibility style values: ALL_VISIBLE, ALL_HIDDEN, or ROOT_HIDDEN.

Parameters:
newValue - the new value of the lineVisibility property
See Also:
getLineVisibility()

setModelInterface

public void setModelInterface(com.sas.ModelInterface newValue)
Specifies the model to display in the view. The model must implement TreeInterface. Pass null to disassociate the view from its model.

Specified by:
setModelInterface in interface com.sas.ViewInterface
Overrides:
setModelInterface in class PanelVisualComponent
Parameters:
newValue - The new value to assign the modelInterface property.
See Also:
TreeInterface

setNodeExpandedTextDisplayed

public void setNodeExpandedTextDisplayed(boolean newValue)
Deprecated. Use NodeView.EXPANDED_TEXT_DISPLAYED property of defaultNodeStyle.

Sets the value of the nodeExpandedTextDisplayed property. nodeExpandedTextDisplayed controls whether the text that is displayed for each node is the return of getNodeText or getNodeExpandedText from the NodeView object.

Parameters:
newValue - true to display the result of getNodeExpandedText, false to display the result of getNodeText
See Also:
isNodeExpandedTextDisplayed(), NodeView, NodeInterface

setPopupMenuVisible

public void setPopupMenuVisible(boolean newValue)
Specifies whether a popup menu should be shown when TableView receives the popup event.

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().

Parameters:
newValue - trueif the popup menu should be shown, and false otherwise

setRoot

public void setRoot(com.sas.models.NodeInterface newRoot)
Set the root node of the TreeView. This sets the model interface for the TreeView. If the NodeInterface argument is an instance of TreeInterface and ModelInterface, then it is set as the model of the TreeView. Otherwise, a com.sas.models.Tree object is set as the model with the NodeInterface argument as the root of that Tree object. In the latter case, setRoot is an alias for setModelInterface(new Tree(newRoot)).

Parameters:
root - the node, as a NodeInterface object, to set as root
See Also:
Tree

setRootNodeVisible

public void setRootNodeVisible(boolean newValue)
Sets the value of the rootNodeVisible property. The rootNodeVisible property controls whether or not the root node is displayed. If rootNodeVisible is 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.

Parameters:
newValue - true if the root node is displayed, false if the root node is not displayed
See Also:
isRootNodeVisible(), NodeView.isVisible()

setSelectedItem

public void setSelectedItem(java.lang.String text)
Sets the selected item to the specified string. If more than one item matches the specified string, the one with the smallest index is selected. This method uses the getNodeView search method.

Parameters:
text - the string to select
See Also:
getNodeView(String, int)

setText

public void setText(java.lang.String text)
Support for StringDataInterface. This is an alias for setSelectedItem(text).

Parameters:
text - the text to set as the selected item
See Also:
getText(), setSelectedItem(java.lang.String)

setTextGap

public void setTextGap(int gap)
Deprecated. Use NodeView.TEXT_GAP property of defaultNodeStyle.

Sets the value of the textGap property. The text gap is the distance in pixels between the image and the text. This is not used if there is not an image displayed for a node. This value must be greater than or equal to zero.

Parameters:
gap - the distance to set for the textGap
See Also:
getTextGap()

setTextPad

public void setTextPad(int pad)
Deprecated. Use NodeView.TEXT_PAD property of defaultNodeStyle.

Set the value of the textPad property. The text pad is the distance between the text and its selection border on either side. For example, a textPad of 3 would mean that there are 3 pixels between the selection border and the text on the left and also 3 pixels between the text and the selection border on the right. This value must be greater than zero.

Parameters:
pad - the distance to set for the textPad
See Also:
getTextPad()

setVerticalScrollbarVisibility

public void setVerticalScrollbarVisibility(int newValue)
Sets the vertical scrollbar's visibility.

Specified by:
setVerticalScrollbarVisibility in interface ScrollbarVisibilityInterface
Parameters:
newValue - Indicates when the vertical scrollbar should be displayed. Possible values are SCROLLBARS_AS_NEEDED, SCROLLBARS_ALWAYS, and SCROLLBARS_NEVER.

update

public void update(java.awt.Graphics g)
This method tells the TreeView to repaint itself. It is called by the TreeView whenever something changes or is updated in the TreeView.

Overrides:
update in class PanelVisualComponent
Parameters:
g - the Graphics object
See Also:
VisualInterfaceSupport.update(com.sas.ComponentInterface, com.sas.awt.VisualInterface, java.awt.Component, java.awt.Graphics)

getIcon

protected com.sas.visuals.IconInterface getIcon(java.lang.String nodeType)
Returns the icon for a given node type. If the image for a given type is not in the image list, null is returned.

Parameters:
nodeType - the type of the node to get the image for
Returns:
the image associated with nodeType

getVisibleNode

protected NodeView getVisibleNode(int index)
Retrieves a node from the visible node collection. The visible node collection is defined as a collection containing all expanded nodes.

Parameters:
index - the index of a node in the visible node collection
Returns:
the NodeView object at index if a node exists at that position, otherwise null

processActionEvent

protected void processActionEvent(java.awt.event.ActionEvent event)
Processes action events occurring on the TreeView.

Parameters:
event - the event to process

processEvent

protected void processEvent(java.awt.AWTEvent e)
Processes events occurring on the TreeView.

Overrides:
processEvent in class java.awt.Container
Parameters:
e - the event to process

processItemEvent

protected void processItemEvent(java.awt.event.ItemEvent event)
Processes item events occurring on the TreeView.

Parameters:
event - the event to process

processFocusEvent

protected void processFocusEvent(java.awt.event.FocusEvent event)
Processes focus events occurring on TreeView.

Overrides:
processFocusEvent in class java.awt.Component
Parameters:
event - the event to handle

processKeyEvent

protected void processKeyEvent(java.awt.event.KeyEvent event)
Processes key events occurring on TreeView.

Overrides:
processKeyEvent in class java.awt.Component
Parameters:
event - the event to handle

processMouseEvent

protected void processMouseEvent(java.awt.event.MouseEvent event)
Processes mouse events on TreeView.

Overrides:
processMouseEvent in class java.awt.Component
Parameters:
event - the event to handle

processMouseMotionEvent

protected void processMouseMotionEvent(java.awt.event.MouseEvent event)
Handles mouse motion events on TreeView.

Overrides:
processMouseMotionEvent in class java.awt.Component
Parameters:
event - the event to handle

render

protected void render(java.awt.Graphics g)
Paints the nodes of TreeView. This is called from paint().

Parameters:
g - the Graphics object



Copyright © 2009 SAS Institute Inc. All Rights Reserved.