SilverStream
Application Server 3.5

com.sssw.rt.form
Class AgcTreeControl

java.lang.Object
 |
 +--java.awt.Component
       |
       +--java.awt.Container
             |
             +--javax.swing.JComponent
                   |
                   +--javax.swing.JPanel
                         |
                         +--com.sssw.rt.atlas.AtPanel
                               |
                               +--com.sssw.rt.tview.TView
                                     |
                                     +--com.sssw.rt.form.AgcView
                                           |
                                           +--com.sssw.rt.form.AgcTreeControl
All Implemented Interfaces:
Accessible, AgiControl, AgiHelpInfo, AgiRowSetManager, ImageObserver, MenuContainer, Serializable

public class AgcTreeControl
extends AgcView
implements AgiRowSetManager, AgiHelpInfo

The AgcTreeControl (Tree) is a data-bound list control that displays a list of values to users who can browse the list of values and select a value from the list.

When the control is bound to a database column via the Data Column property, the value in the database sets the initially selected item in the tree. If the user makes a different selection, that value becomes the value associated with the current row. The selected value is saved to the database when you call updateRows() for the form.

In addition to being data-bound, the control is a data-loaded control in which a database table or other data source can provide the list of values. You can use methods of AgiRowSetManager to navigate the list. However, changes to the items do not affect the underlying data; therefore, calling updateRows() is not allowed. If you call it for the control, updateRows() throws AgoUnsupportedOperationException.

Properties:
Automatic Query, Choices, Control Type, Data Column, Display Value, Distinct, Enabled, Font Name, Font Size, Font Style, Height, Help Page, Left, Limit Rows, Load Choices, Maximum Rows, Name, Order By, Storage Value, Table, Tool Tip, Top, Values, Visible, Where Clause, Width
Events:
focusGained, focusLost, keyPressed, keyReleased, keyTyped, mouseClicked, mouseDragged, mouseEntered, mouseExited, mouseMoved, mousePressed, mouseReleased, validationFailed, validationTest, valueChanged, viewColumnResize, viewDoubleClick, viewHeaderRowClick, viewRowCollapse, viewRowExpand, viewSelectionChange
See Also:
AgoTreeControlNode, Serialized Form

Inner classes inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
Inner classes inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Field Summary
static int CHILD
          Adds the node after the specified node.
static int LAST
          Adds the node as the last node at the level of the specified node.
static int NEXT
          Adds the node underneath the specified node.
static int PREVIOUS
          Adds the node above the specified node.
 
Fields inherited from class com.sssw.rt.atlas.AtPanel
BGIMAGE_DRAW_CENTERED, BGIMAGE_DRAW_NORMAL, BGIMAGE_DRAW_STRETCH, BGIMAGE_DRAW_TILED
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Constructor Summary
AgcTreeControl()
           
 
Method Summary
 AgoTreeControlNode add(AgoTreeControlNode relative, int relationship, String text)
          Adds a new node to the control.
 AgoTreeControlNode add(AgoTreeControlNode relative, int relationship, String text, Object userData, Image image)
          Adds a new node with an associated object or image.
 void collapseNode(AgoTreeControlNode node)
          Collapses (hides) the children of a specified node
 void expandNode(AgoTreeControlNode node)
          Expands (shows) the children of a specified node.
 AgoTreeControlNode findNode(String text, Object userData, boolean recurse)
          Finds a node with the specified text and/or user data.
 AgoFontIdentifier getFontIdentifier()
          Get the font identifier.
 Color getForeground()
          Get the text color.
 AgoNodeEnumerator getNodeSelection()
          Get an enumeration object which encapsulates all the currently selected nodes in the view.
 AgoTreeControlNode getRootNode()
          Returns the control's root node.
 AgoTreeControlNode getSelectedNode()
          Returns the control's currently selected node.
 Object getValue()
          Returns the control's value.
 void remove(AgoTreeControlNode node)
          Removes a specified node from the control.
 void removeAll()
          Remove all nodes from this control.
 void setBackground(Color color)
          Set the background color of the tree control.
 void setCollapseExpandOnDoubleClick(boolean collapseexpand)
          Set the collapse/expand on doubleclick property
 void setFontIdentifier(AgoFontIdentifier fontidentifier)
          Assigns the SilverStream font object (AgoFontIdentifier) to the control's text.
 void setForeground(Color color)
          Set the color of the tree control's text.
 void setNodeSelection(Vector nodes, boolean generateEvents)
          Selects one or more nodes in the tree control.
 void setSelectedNode(AgoTreeControlNode node)
          Sets the selection to the specified node.
 void setValue(Object value)
          Selects the row whose value is equal to the specified value.
 
Methods inherited from class com.sssw.rt.form.AgcView
clearSelection, collapseNode, expandNode, getColumnValue, getCursorBandName, getMultiSelectType, getRootRowCursor, getRowSelection, getSelectedColumnIndex, getSelectedRowCursor, getTopRowCursor, initView, setMultiSelectType, setSelection, sort, sort
 
Methods inherited from class com.sssw.rt.tview.TView
getAgoViewFormat, getSearchable, reload, scrollHome, setAgoViewFormat, setSearchable
 
Methods inherited from class com.sssw.rt.atlas.AtPanel
addImpl, addNotify, clientPaint, clientPaint, deliverMouseEvent, deliverMouseMoveEvent, doAtCommand, drawTiledImage, enableAtCommands, getBackgroundImage, getBackgroundImageMode, getHelper, getTransparent, hide, hideToolTip, imageUpdate, isFocusTraversable, isOptimizedDrawingEnabled, ownedImage, paintBorder, paintComponent, paintImmediately, paintImmediately, paintNow, preprocessKeyEvent, processEvent, reshape, setBackgroundImage, setBackgroundImageMode, setTransparent, show, showToolTip
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUIClassID, paramString, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInsets, getInsets, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, isDoubleBuffered, isFocusCycleRoot, isLightweightComponent, isManagingFocus, isOpaque, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintChildren, print, printAll, processComponentKeyEvent, processFocusEvent, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, revalidate, scrollRectToVisible, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFont, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, remove, remove, removeContainerListener, setCursor, setLayout, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, inside, isDisplayable, isEnabled, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, setSize, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods implemented from interface com.sssw.rt.form.AgiControl
getComponent, getHelpInfo, setHelpInfo
 
Methods implemented from interface com.sssw.rt.util.AgiRowSetManager
clearRows, haveRowsChanged, query, query, refreshRows, updateRows
 

Field Detail

CHILD

public static final int CHILD
Adds the node after the specified node. The added node is indented to reflect the parent-child relationship.
See Also:
AgcTreeControl.add(AgoTreeControlNode, int, String), AgcTreeControl.add(AgoTreeControlNode, int, String, Object, Image)

NEXT

public static final int NEXT
Adds the node underneath the specified node. The added node is a sibling, so it is not indented.
See Also:
AgcTreeControl.add(AgoTreeControlNode, int, String), AgcTreeControl.add(AgoTreeControlNode, int, String, Object, Image)

PREVIOUS

public static final int PREVIOUS
Adds the node above the specified node. The added node is a sibling, so it is not indented.
See Also:
AgcTreeControl.add(AgoTreeControlNode, int, String), AgcTreeControl.add(AgoTreeControlNode, int, String, Object, Image)

LAST

public static final int LAST
Adds the node as the last node at the level of the specified node. The added node is a sibling, so it is not indented.
See Also:
AgcTreeControl.add(AgoTreeControlNode, int, String), AgcTreeControl.add(AgoTreeControlNode, int, String, Object, Image)
Constructor Detail

AgcTreeControl

public AgcTreeControl()
Method Detail

add

public AgoTreeControlNode add(AgoTreeControlNode relative,
                              int relationship,
                              String text)
Adds a new node to the control.
Parameters:
relative - specifies an existing node. The new node is created relative to this object. When this object is null, the new node is added after the last top-level node, and relationship is ignored.
relationship - specifies the relationship the new node has to the node specified by relative. For a list of possible values, see Field Summary.
text - specifies text to display at this node.
Example:

The following code fragment adds three top-level nodes, labeled A B and C. It also adds two child nodes to A, which are labeled one and two.

  AgoTreeControlNode node;
 
 	 // Add the first top-level node A.
  // If the first parameter is null, then the second parameter is
 	 // ignored, so we can just pass zero.
  node = ControlName1.add(null, 0, "A");
 	 // Add two child nodes under node A.
 	 ControlName1.add(node, AgcTreeControl.CHILD, "one");
 	 ControlName1.add(node, AgcTreeControl.CHILD, "two");
 	 // Add two more top-level nodes.
  ControlName1.add(null, 0, "B");
  ControlName1.add(null, 0, "C");
 
See Also:
AgcTreeControl.remove(AgoTreeControlNode), AgcTreeControl.removeAll(), AgoTreeControlNode, AgcTreeControl.add(AgoTreeControlNode, int, String, Object, Image)

add

public AgoTreeControlNode add(AgoTreeControlNode relative,
                              int relationship,
                              String text,
                              Object userData,
                              Image image)
Adds a new node with an associated object or image.
Parameters:
relative - specifies an existing node. The new node is created relative to this object. When this object is null, the new node is added after the last top-level node, and relationship is ignored.
relationship - specifies the relationship the new node has to the node specified by relative. For a list of possible values, see Field Summary.
text - specifies text to display at this node.
userData - specifies an Object. It can be any user-specified object. This can be null.
image - specifies the image to display at this node. This can be null.
See Also:
AgcTreeControl.remove(AgoTreeControlNode), AgcTreeControl.removeAll(), AgoTreeControlNode, AgcTreeControl.add(AgoTreeControlNode, int, String)

remove

public void remove(AgoTreeControlNode node)
Removes a specified node from the control.
Parameters:
node - the node to remove
Example:

The following code fragment illustrates how to remove a node.

  AgoTreeControlNode nodeToRemove;
  nodeToRemove = ControlName1.findNode("customer1",null,true);
  ControlName1.removeNode(nodeToRemove);
 
See Also:
AgcTreeControl.add(AgoTreeControlNode, int, String), AgcTreeControl.add(AgoTreeControlNode, int, String, Object, Image), AgcTreeControl.removeAll(), AgoTreeControlNode

removeAll

public void removeAll()
Remove all nodes from this control. Removes all nodes from the control.
Overrides:
removeAll in class Container
Example:

The following code fragment illustrates how to remove all of the rows from the AgcChoice control.

  ControlName1.removeAll();
 
See Also:
AgcTreeControl.add(AgoTreeControlNode, int, String), AgcTreeControl.add(AgoTreeControlNode, int, String, Object, Image), AgcTreeControl.remove(AgoTreeControlNode)

getRootNode

public AgoTreeControlNode getRootNode()
Returns the control's root node. Returns null if the tree is empty.

The control's root node is the first node on the top level. For example, a tree control is populated with a list of customers. The customers are ordered by CustomerID. Assuming that the query contained customers 1-50, the root node in this case would be the node where the CustomerID = 1.

Example:

The following code fragment illustrates how to obtain the root node.

  AgoTreeControlNode root;
  root = ControlName1.getRootNode();
 
See Also:
AgoTreeControlNode

getSelectedNode

public AgoTreeControlNode getSelectedNode()
Returns the control's currently selected node.

The node can be selected by the user, or programmatically using the setSelectedNode() method.

Example:

The following code fragment illustrates how to obtain the currently selected node.

  AgoTreeControlNode selectedNode;
  selectedNode = ControlName1.getSelectedNode();
 
See Also:
AgcTreeControl.setSelectedNode(AgoTreeControlNode), AgoTreeControlNode

setSelectedNode

public void setSelectedNode(AgoTreeControlNode node)
Sets the selection to the specified node.
Parameters:
node - specifies the node to select
Example:

The following code fragment illustrates how to find a node and then select it.

  AgoTreeControlNode node;
 
  node = ControlName1.findNode("customer1",null,true);
  ControlName1.setSelectedNode(node);
 
See Also:
AgcTreeControl.getSelectedNode()

getNodeSelection

public AgoNodeEnumerator getNodeSelection()
Get an enumeration object which encapsulates all the currently selected nodes in the view.
Example:

The following code fragment illustrates how to get the list of selected nodes and loop through them.

 	AgoNodeEnumerator e = ControlName1.getNodeSelection();
 	AgoTreeControlNode node;
 	while(e.hasMoreNodes())
 	{
 		node = e.getNextNode();
 		System.out.println("Node " + node.getText() + " is selected.");
 	}
 

setNodeSelection

public void setNodeSelection(Vector nodes,
                             boolean generateEvents)
                      throws AgoException
Selects one or more nodes in the tree control.
Parameters:
nodes - a Vector containing the nodes you want to select. The Vector elements are AgoTreeControlNode objects.
generateEvents - specifies whether each node selection should generate valueChanged events or no events.
Usage:
setNodeSelection() throws an exception if multiselect is not enabled and more than one node is specified.

expandNode

public void expandNode(AgoTreeControlNode node)
Expands (shows) the children of a specified node.
Parameters:
node - specifies the node to expand.
Example:

The following code fragment illustrates how to find a node and then expand it.

  AgoTreeControlNode node;
  node = ControlName1.findNode("customer1",null,true);
  ControlName1expandNode(node);
 
See Also:
AgcTreeControl.collapseNode(AgoTreeControlNode), AgoTreeControlNode

collapseNode

public void collapseNode(AgoTreeControlNode node)
Collapses (hides) the children of a specified node
Parameters:
node - specifies the node to collapse.
Example:

The following code fragment illustrates how to find a node then collapse it.

  AgoTreeControlNode node;
 
  node = ControlName1.findNode("customer1",null,true);
  ControlName1.collapseNode(node);
 
See Also:
AgcTreeControl.expandNode(AgoTreeControlNode), AgoTreeControlNode

findNode

public AgoTreeControlNode findNode(String text,
                                   Object userData,
                                   boolean recurse)
Finds a node with the specified text and/or user data.
Parameters:
text - specifies text to search for
userData - specifies an Object to search for The userData values are compared by the equals() method.
recurse - specifies whether to search for the text or userData recursively
Usage:

If text is null, then the control returns the first node that matches the userData (and vise versa). If recursive is false, the control only searches the top-level nodes. If recursive is true, the control searches all levels beginning with the root node.

Example:

The following code fragment illustrates how to find a node recursively.

  AgoTreeControlNode node;
  node = ControlName1.findNode("Smith",null,true);
 

setFontIdentifier

public void setFontIdentifier(AgoFontIdentifier fontidentifier)
Assigns the SilverStream font object (AgoFontIdentifier) to the control's text.
Parameters:
fontidentifier - specifies the AgoFontIdentifier object that assigns the font for the control.
Usage:

The AgoFontIdentifier object consists of three parts: a Font Name, a Font Style and a Font Size.

  • The Font Name can be one of these values: Dialog, SansSerif, Serif, Monospaced, Helvetica, TimesRoman, Courier, DialogInput, Zapfdingbats. At runtime, Java translates this value to the appropriate font installed on the system.
  • The Font Size can be any integer.
  • The Font Style can be one of these values:
      AgoFontIdentifier.PLAIN
      AgoFontIdentifier.BOLD
      AgoFontIdentifier.ITALIC
      AgoFontIdentifier.BOLD + AgoFontIdentifier.ITALIC
     
Example:

This code fragment illustrates how to construct a new AgoFontIdentifier object (called newFont) and how to call the setFontIdentifier() method:

  AgoFontIdentifier     newFont;
  String		   newName;
  int	           newSize;
  int		   newStyle;
 
  newName="TimesRoman";
  newSize=20;
  newStyle=AgoFontIdentifier.ITALIC;
  newFont=new AgoFontIdentifier(newName, newStyle, newSize);
 
  ControlName1.setFontIdentifier(newFont);
 
See Also:
AgcTreeControl.getFontIdentifier(), Font Name property, Font Size property, Font Style property

getFontIdentifier

public AgoFontIdentifier getFontIdentifier()
Get the font identifier.
See Also:
AgcTreeControl.setFontIdentifier(AgoFontIdentifier)

setForeground

public void setForeground(Color color)
Set the color of the tree control's text.
Overrides:
setForeground in class JComponent
Parameters:
color - the color

setBackground

public void setBackground(Color color)
Set the background color of the tree control.
Overrides:
setBackground in class JComponent
Parameters:
color - the color

getForeground

public Color getForeground()
Get the text color.
Overrides:
getForeground in class Component
Parameters:
color - the color

getValue

public Object getValue()
Returns the control's value. This is the internal value associated with the selected node. If the internal value is null, then the selected node's text is returned as a String. If no node is selected, then null is returned.
Example:
  Object value;
  value = ControlName1.getValue();
 
See Also:
AgcTreeControl.setValue(Object)

setValue

public void setValue(Object value)
Selects the row whose value is equal to the specified value.
Parameters:
value - specifies an internal value that specifies which row to select
Usage:

At design time the contents of the internal value can be set using the Property Inspector. It can be static or retrieved from the database. Each row can have its own internal value.

If the control is populated from a static list of data (that is the Load Choices property is set to Statically), the internal values can be set using the Values property.

If the control is populated from the database (that is the Load Choices property is set to From Table), the internal value can be set using the Storage value property.

Example:

A control is loaded statically:
The displayed text values are: Apple, Banana, Orange
The internal values are: 1, 2, 3
The following code fragment illustrates how to make Orange the selected item using setValue().

  int x=3;
  ControlName1.setValue(new Integer(x));
 

Note that this example uses the Integer class instead of the int primitive data type because an Object can not be cast to an int.

See Also:
AgcTreeControl.getValue()

setCollapseExpandOnDoubleClick

public void setCollapseExpandOnDoubleClick(boolean collapseexpand)
Set the collapse/expand on doubleclick property
Parameters:
collapseexpand - true sets the property, false unsets it

SilverStream
Application Server 3.5