amber.server.component
Class TreeListHandler

java.lang.Object
  |
  +--java.awt.Component
        |
        +--amber.server.component.ComponentHandler
              |
              +--amber.server.component.TreeListHandler
All Implemented Interfaces:
ApplicationInterface, java.awt.image.ImageObserver, java.awt.ItemSelectable, java.awt.MenuContainer, java.io.Serializable

public class TreeListHandler
extends ComponentHandler
implements java.io.Serializable

This class handles the requirements for the manipulation of the packets moving to and from a tree list component. It is designed to look like a tree control and interacts with the ApplicationInterface as if the tree were running on the server rather than the Browser.

The remote client class also responds to information stored in the parameters field of the XYConstraints object when this handler is added to a panel. The allowed parameters are separated in the string by '|' characters. Any unused trailing parameters are optional and will assume default values, however the parameter order is fixed.

For example, if the component takes 4 parameters which are ints, a valid parameter string would be:

"1|2|3"

In this case the fourth parameter would assume the default value.

The parameter elements for this component are:

Component Parameters
NameTypeDescriptionRepeatsDefault

Version:
1.0.0
Author:
Dr. David J. Knowles
See Also:
XYConstraints, ApplicationInterface, ComponentHandler, PTreeList, TreeList, Serialized Form

Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
Field Summary
static byte AddLine
           
static byte ChangeSelection
           
static byte ClearTree
           
static byte DeleteLine
           
static byte GetIndexAtPoint
           
static byte GetIndexAtPointResponse
           
static byte GetSelectedIndex
           
static byte GetSelectedIndexResponse
           
static byte GetSelectedLine
           
static byte GetSelectedLineResponse
           
static byte InsertLine
           
static byte NodesDefaultOpen
           
static byte ReplaceLine
           
static byte SetOpenState
           
static byte ToggleLineOpen
           
 
Fields inherited from class amber.server.component.ComponentHandler
actionCommand, active, ApplicationId, CancelReturn, dataEncoder, DefaultTimeout, enabledState, encoderBytes, id, InvalidId, MaximumId, NoReturn, OkCancelType, OkReturn, OkType, OkYesReturn, parentPage, responsePackets, timeoutValue, UnchangeableInvalidId, visibleState, YesNoCancelType, YesNoType, YesReturn
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
TreeListHandler()
          Default constructor.
TreeListHandler(ApplicationInterface pageHandler)
          The initialising constructor.
TreeListHandler(int id, ApplicationInterface pageHandler)
          The initialising constructor.
 
Method Summary
protected  void add(java.lang.String item, java.lang.String image, int type)
          This adds a string to the end of the tree.
 void add(amber.server.component.TreeNode item)
          This adds a tree node to the end of the parent in the list.
protected  void addTopNode(amber.server.component.TreeNode item)
          Adds a node in the list at the end of the list.
 void deselect()
          Deselects all items in the tree.
protected  int determineNesting(amber.server.component.TreeNode item)
          Given the specified node this function determines how many levels of parents it has.
 java.util.Vector getChildren(amber.server.component.TreeNode node)
          Returns the children of the specified parent.
 boolean getDefaultNodeOpen()
          This function can be used to get the behaviour of the list when child nodes are added.
 int getIndex(amber.server.component.TreeNode node)
          Returns the index of the node with respect to its parent.
 amber.server.component.TreeNode getItem(amber.server.component.TreeNode parent, int index)
          Returns the item specified by the parent and the relative index.
 int getItemCount()
          Returns the total number of items in the list.
 int getItemCount(amber.server.component.TreeNode parent)
          Counts the number of items in the sub-tree.
 amber.server.component.TreeNode[] getItems()
          Returns all the items in the tree.
protected  int getLastParentEntry(amber.server.component.TreeNode item)
          Gets the index of the last item which has the same parent as this item.
 java.lang.String getPanelType()
          This function returns the panel component to use with this class.
protected  int getSelectedIndex()
          Return the index of the item selected in the tree.
 amber.server.component.TreeNode getSelectedItem()
          Return the text value of the selected item in the tree.
protected  void insert(java.lang.String item, java.lang.String image, int index, int type)
          Inserts the line at the location specified by the index in the tree.
 void insert(amber.server.component.TreeNode item, int index)
          This inserts a tree node to the end of the parent in the list.
protected  void insertNode(amber.server.component.TreeNode item, int index)
          Inserts a node in the list at the specified location.
 boolean isChildNode(amber.server.component.TreeNode parent, amber.server.component.TreeNode child)
          This function determines if the input TreeNode is a child of the parent.
protected  int locateChildNode(amber.server.component.TreeNode itemParent, int index)
          Finds the child node of this parent which matches the specified index.
protected  int locationToIndex(java.awt.Point pointInList)
          This function converts a physical point location in the tree into a line index.
 amber.server.component.TreeNode locationToItem(java.awt.Point pointInList)
          This function converts a physical point location in the tree into a TreeNode item.
protected  void remove(int position)
          Removes an item in the tree.
 void remove(amber.server.component.TreeNode node)
          Removes an item in the tree.
 void remove(amber.server.component.TreeNode parent, int index)
          Removes an item in the tree.
 void removeAll()
          Removes all items in the tree.
 void removeAll(amber.server.component.TreeNode parent)
          Removes all child items in the tree based off the current parent node.
protected  void replaceItem(java.lang.String newValue, int index)
          Replaces the line specified by the index in the tree.
protected  void replaceItem(java.lang.String newValue, java.lang.String image, int index, int type)
          Replaces the line specified by the index in the tree.
 void replaceItem(amber.server.component.TreeNode newValue, int index)
          Replaces the line specified by the index in the tree.
 void replaceItem(amber.server.component.TreeNode newValue, amber.server.component.TreeNode oldValue)
          Replaces the line specified by the input node in the tree.
 void resetState()
          This function resets the component to a default state.
 void select(amber.server.component.TreeNode node)
          Selects a specific TreeNode in the tree.
 void select(amber.server.component.TreeNode node, int index)
          Selects a specific line in the tree.
 void setDefaultNodeOpen(boolean state)
          This function can be used to set the behaviour of the list when child nodes are added.
protected  void setItemOpenState(int index, boolean state)
          Toggles the open state of the specified line.
 void setNodeOpenState(amber.server.component.TreeNode node, boolean state)
          Sets the open state of a node in the tree.
protected  void setSelection(int index, boolean state)
          Sets the selection state of a line in the list.
protected  void toggleItemState(int index)
          Toggles the open state of the specified line.
 void toggleNodeOpenState(amber.server.component.TreeNode node)
          Toggles the open state of a node in the tree.
 void updateNode(amber.server.component.TreeNode node)
          Updates the contents of the node in the tree.
 
Methods inherited from class amber.server.component.ComponentHandler
addActionListener, addComponentListener, addEventMask, addFocusListener, addItemListener, addKeyListener, addMouseListener, addMouseMotionListener, addNotify, addReceivedPacket, addTextListener, addWindowListener, booleanToInt, createDataInput, directPacket, displayMessageBox, fireWindowActivated, fireWindowClosed, fireWindowClosing, fireWindowDeactivated, fireWindowDeiconified, fireWindowEvent, fireWindowIconified, fireWindowOpened, forceComponentGetUrl, forceComponentGetUrl, forwardEventPacket, generateActionEvent, generateFocusEvent, generateItemEvent, generateKeyEvent, generateMouseEvent, getActionCommand, getBounds, getComponentStructure, getDefaultParameters, getEventMask, getFontCharacteristics, getFontCharacteristics, getFontCharacteristics, getFontCharacteristics, getFontStyle, getId, getLocation, getLog, getModalObject, getParentApplication, getParentContainer, getParentServer, getResponsePacket, getSelectedObjects, getSize, getTimeout, getValidId, getX, getY, handleMessages, handlePacket, internalForwardPacket, internalGetBounds, intToBoolean, isActive, isApplicationActive, isComponentModal, isConnected, isEnabled, isMyId, isVisible, processActionEvent, processComponentEvent, processCurrentPacket, processEvent, processFocusEvent, processItemEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processNormalResponse, processTextEvent, queryMessageBox, removeActionListener, removeComponentListener, removeEventMask, removeFocusListener, removeItemListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removeTextListener, removeWindowListener, requestFocus, restart, sendPacket, sendPacketAndBlock, sendPendingPackets, setActionCommand, setActive, setBackground, setComponentModal, setConnectedState, setCursor, setEnabled, setEventMask, setFont, setFont, setFontStyle, setForeground, setForegroundBackground, setId, setLog, setModalObject, setParentApplication, setParentContainer, setParentServer, setTimeout, setVisible, setX, setY, shutDown, shutDownClient, shutDownClient, start
 
Methods inherited from class java.awt.Component
action, add, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getAccessibleContext, getAlignmentX, getAlignmentY, getBackground, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getInputContext, getInputMethodRequests, getListeners, getLocale, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getName, getParent, getPeer, getPreferredSize, getSize, getToolkit, getTreeLock, getWidth, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isDisplayable, isDoubleBuffered, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paint, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, remove, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, reshape, resize, resize, setBounds, setBounds, setComponentOrientation, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, update, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ClearTree

public static final byte ClearTree

GetSelectedIndex

public static final byte GetSelectedIndex

GetSelectedIndexResponse

public static final byte GetSelectedIndexResponse

GetSelectedLine

public static final byte GetSelectedLine

GetSelectedLineResponse

public static final byte GetSelectedLineResponse

AddLine

public static final byte AddLine

InsertLine

public static final byte InsertLine

DeleteLine

public static final byte DeleteLine

ChangeSelection

public static final byte ChangeSelection

ReplaceLine

public static final byte ReplaceLine

GetIndexAtPoint

public static final byte GetIndexAtPoint

GetIndexAtPointResponse

public static final byte GetIndexAtPointResponse

ToggleLineOpen

public static final byte ToggleLineOpen

SetOpenState

public static final byte SetOpenState

NodesDefaultOpen

public static final byte NodesDefaultOpen
Constructor Detail

TreeListHandler

public TreeListHandler()
Default constructor.

TreeListHandler

public TreeListHandler(ApplicationInterface pageHandler)
The initialising constructor. This constructor dynamically requests a valid ID value from the ApplicationInterface.
Parameters:
pageHandler - The handle to the main ApplicationInterface which handles the functions of page overall. residing on the browser.

TreeListHandler

public TreeListHandler(int id,
                       ApplicationInterface pageHandler)
The initialising constructor.
Parameters:
id - The int containing the id of the corresponding remote component residing on the browser.
pageHandler - The handle to the main ApplicationInterface which handles the functions of page overall.
Method Detail

resetState

public void resetState()
This function resets the component to a default state. It is used to resynchronize the visual and internal versions of the component. IT SHOULD NEVER BE CALLED BY THE APPLICATION CODE.
Overrides:
resetState in class ComponentHandler

add

public void add(amber.server.component.TreeNode item)
         throws ComponentHandlerException
This adds a tree node to the end of the parent in the list.
Parameters:
item - TreeNode containing information on the tree node.
Throws:
ComponentHandlerException - with messaging errors.

insert

public void insert(amber.server.component.TreeNode item,
                   int index)
            throws ComponentHandlerException
This inserts a tree node to the end of the parent in the list.
Parameters:
item - TreeNode containing information on the tree node.
index - int containing the index to insert the node in the children of this particular parent.
Throws:
ComponentHandlerException - with messaging errors.

updateNode

public void updateNode(amber.server.component.TreeNode node)
                throws ComponentHandlerException
Updates the contents of the node in the tree.
Parameters:
node - TreeNode containing the new information.
Throws:
ComponentHandlerException - with messaging errors.

replaceItem

public void replaceItem(amber.server.component.TreeNode newValue,
                        amber.server.component.TreeNode oldValue)
                 throws ComponentHandlerException
Replaces the line specified by the input node in the tree.
Parameters:
newValue - TreeNode containing the node to replace the old node with.
oldValue - TreeNode containing the node which is to be replaced.
Throws:
ComponentHandlerException - with messaging errors.

replaceItem

public void replaceItem(amber.server.component.TreeNode newValue,
                        int index)
                 throws ComponentHandlerException
Replaces the line specified by the index in the tree.
Parameters:
newValue - TreeNode containing the node to replace the old node with.
index - int location of the object in the tree to replace relative to the parent.
Throws:
ComponentHandlerException - with messaging errors.

removeAll

public void removeAll()
               throws ComponentHandlerException
Removes all items in the tree.
Throws:
ComponentHandlerException - with messaging errors.

removeAll

public void removeAll(amber.server.component.TreeNode parent)
               throws ComponentHandlerException
Removes all child items in the tree based off the current parent node.
Parameters:
parent - TreeNode parent of the children to remove from the list.
Throws:
ComponentHandlerException - with messaging errors.

remove

public void remove(amber.server.component.TreeNode node)
            throws ComponentHandlerException
Removes an item in the tree.
Parameters:
node - TreeNode to remove from the list.
Throws:
ComponentHandlerException - with messaging errors.

remove

public void remove(amber.server.component.TreeNode parent,
                   int index)
            throws ComponentHandlerException
Removes an item in the tree.
Parameters:
parent - TreeNode parent of the node to remove from the list.
index - int index of the node to remove from the children of the parent.
Throws:
ComponentHandlerException - with messaging errors.

getIndex

public int getIndex(amber.server.component.TreeNode node)
Returns the index of the node with respect to its parent. The items are considered to be as a linear list of items within a parent.
Parameters:
node - TreeNode to find.
Returns:
int index of the item in the list or -1 if the item does not exist.

getChildren

public java.util.Vector getChildren(amber.server.component.TreeNode node)
Returns the children of the specified parent. It will only return the direct children i.e. those at the next lower level of nesting. Any children of those nodes are ignored.
Parameters:
node - TreeNode parent of the children to find.
Returns:
Vector containing the children of the parent node.

getSelectedItem

public amber.server.component.TreeNode getSelectedItem()
                                                throws ComponentHandlerException
Return the text value of the selected item in the tree.
Returns:
TreeNode matching the selected item or null if none is selected.
Throws:
ComponentHandlerException - with messaging errors.

locationToItem

public amber.server.component.TreeNode locationToItem(java.awt.Point pointInList)
                                               throws ComponentHandlerException
This function converts a physical point location in the tree into a TreeNode item. This is typically used in drag and drop situations.
Parameters:
pointInList - Point containing the location to convert.
Returns:
TreeNode which matches this point.
Throws:
ComponentHandlerException - with messaging errors.

getItems

public amber.server.component.TreeNode[] getItems()
Returns all the items in the tree.
Returns:
items. Array of TreeNode containing all the nodes in the tree.

getItemCount

public int getItemCount()
Returns the total number of items in the list.
Returns:
count. int numbers of nodes in the tree.

getItemCount

public int getItemCount(amber.server.component.TreeNode parent)
Counts the number of items in the sub-tree.
Parameters:
parent - TreeNode parent to count the nodes of.
Returns:
count. int numbers of nodes in the sub-tree.

getItem

public amber.server.component.TreeNode getItem(amber.server.component.TreeNode parent,
                                               int index)
Returns the item specified by the parent and the relative index.
Parameters:
parent - TreeNode parent of the children nodes.
index - int index offset of the child to get.
Returns:
TreeNode found or null if there is no such node.

select

public void select(amber.server.component.TreeNode node)
            throws ComponentHandlerException
Selects a specific TreeNode in the tree.
Parameters:
node - TreeNode to select.
Throws:
ComponentHandlerException - with messaging errors.

toggleNodeOpenState

public void toggleNodeOpenState(amber.server.component.TreeNode node)
                         throws ComponentHandlerException
Toggles the open state of a node in the tree.
Parameters:
node - TreeNode to toggle.
Throws:
ComponentHandlerException - with messaging errors.

setNodeOpenState

public void setNodeOpenState(amber.server.component.TreeNode node,
                             boolean state)
                      throws ComponentHandlerException
Sets the open state of a node in the tree. This defines whether child nodes are visible.
Parameters:
node - TreeNode to open/close.
state - boolean which defines the state of parent node being open. true is open.
Throws:
ComponentHandlerException - with messaging errors.

select

public void select(amber.server.component.TreeNode node,
                   int index)
            throws ComponentHandlerException
Selects a specific line in the tree.
Parameters:
index - int line number to select.
Throws:
ComponentHandlerException - with messaging errors.

deselect

public void deselect()
              throws ComponentHandlerException
Deselects all items in the tree.
Throws:
ComponentHandlerException - with messaging errors.

isChildNode

public boolean isChildNode(amber.server.component.TreeNode parent,
                           amber.server.component.TreeNode child)
This function determines if the input TreeNode is a child of the parent.
Parameters:
parent - TreeNode to test to see if this is the parent.
child - TreeNode to test to see if this is a child of the parent.
Returns:
boolean true if the child belongs to the parent.

setDefaultNodeOpen

public void setDefaultNodeOpen(boolean state)
                        throws ComponentHandlerException
This function can be used to set the behaviour of the list when child nodes are added. The default behaviour is for the parent to open when a child is added.
Parameters:
state - The state of the behaviour, when true adding a child to a parent forces the parent to open.
Throws:
ComponentHandlerException - with messaging errors.

getDefaultNodeOpen

public boolean getDefaultNodeOpen()
This function can be used to get the behaviour of the list when child nodes are added. The default behaviour is for the parent to open when a child is added.
Returns:
The state of the behaviour, when true adding a child to a parent forces the parent to open.

locationToIndex

protected int locationToIndex(java.awt.Point pointInList)
                       throws ComponentHandlerException
This function converts a physical point location in the tree into a line index. This is typically used in drag and drop situations.
Parameters:
pointInList - Point containing the location to convert.
Returns:
int line number which matches this point.
Throws:
ComponentHandlerException - with messaging errors.

remove

protected void remove(int position)
               throws ComponentHandlerException
Removes an item in the tree.
Parameters:
position - int position of the object to remove.
Throws:
ComponentHandlerException - with messaging errors.

getLastParentEntry

protected int getLastParentEntry(amber.server.component.TreeNode item)
Gets the index of the last item which has the same parent as this item.
Parameters:
item - TreeNode in this level of the tree to find the last node of.

locateChildNode

protected int locateChildNode(amber.server.component.TreeNode itemParent,
                              int index)
Finds the child node of this parent which matches the specified index.
Parameters:
itemParent - TreeNode parent of the item to locate.
index - int location index of the child node to find.
Returns:
int index of the node to locate.

addTopNode

protected void addTopNode(amber.server.component.TreeNode item)
                   throws ComponentHandlerException
Adds a node in the list at the end of the list.
Parameters:
item - TreeNode to add.
Throws:
ComponentHandlerException - with messaging errors.

determineNesting

protected int determineNesting(amber.server.component.TreeNode item)
Given the specified node this function determines how many levels of parents it has.
Parameters:
item - TreeNode to compute the nesting level for.
Returns:
int number of levels of parents.

insertNode

protected void insertNode(amber.server.component.TreeNode item,
                          int index)
                   throws ComponentHandlerException
Inserts a node in the list at the specified location.
Parameters:
item - TreeNode to insert.
index - int index of the node relative to the parent.
Throws:
ComponentHandlerException - with messaging errors.

add

protected void add(java.lang.String item,
                   java.lang.String image,
                   int type)
            throws ComponentHandlerException
This adds a string to the end of the tree.
Parameters:
item - String containing the text of the line.
image - String URL of the image to display before the text.
type - int containing the type of line. Major lines are 0, increasing values for type decrease the size of the string.
Throws:
ComponentHandlerException - with messaging errors.

insert

protected void insert(java.lang.String item,
                      java.lang.String image,
                      int index,
                      int type)
               throws ComponentHandlerException
Inserts the line at the location specified by the index in the tree.
Parameters:
item - String line text.
image - String URL of the image to display before the text.
index - int line number of the line to insert.
type - int containing the indentation of the line in the tree. Higher numbers are greater indentations. In effect higher numbers are child lines of lower numbers.
Throws:
ComponentHandlerException - with messaging errors.

replaceItem

protected void replaceItem(java.lang.String newValue,
                           int index)
                    throws ComponentHandlerException
Replaces the line specified by the index in the tree.
Parameters:
newValue - String containing the text of the line.
index - int line number of the line to replace.
Throws:
ComponentHandlerException - with messaging errors.

replaceItem

protected void replaceItem(java.lang.String newValue,
                           java.lang.String image,
                           int index,
                           int type)
                    throws ComponentHandlerException
Replaces the line specified by the index in the tree.
Parameters:
newValue - String containing the text of the line.
image - String URL of the image to display before the text.
index - int line number of the line to replace.
type - int which defines the nesting of the list items. Higher numbers are children of lower numbers.
Throws:
ComponentHandlerException - with messaging errors.

getSelectedIndex

protected int getSelectedIndex()
                        throws ComponentHandlerException
Return the index of the item selected in the tree.
Returns:
int containing the index of the selected tree item or -1 if there is no selected item.
Throws:
ComponentHandlerException - with messaging errors.

toggleItemState

protected void toggleItemState(int index)
                        throws ComponentHandlerException
Toggles the open state of the specified line. Thus the line will display child lines or if already open will close displaying only the parent.
Parameters:
index - int line number to toggle the open state.
Throws:
ComponentHandlerException - with messaging errors.

setItemOpenState

protected void setItemOpenState(int index,
                                boolean state)
                         throws ComponentHandlerException
Toggles the open state of the specified line. Thus the line will display child lines or if already open will close displaying only the parent.
Parameters:
index - int line number to toggle the open state.
Throws:
ComponentHandlerException - with messaging errors.

setSelection

protected void setSelection(int index,
                            boolean state)
                     throws ComponentHandlerException
Sets the selection state of a line in the list.
Parameters:
index - int line number to select/deselect (ignored in deselect).
state - boolean state to set the line to.
Throws:
ComponentHandlerException - with messaging errors.

getPanelType

public java.lang.String getPanelType()
This function returns the panel component to use with this class.
Overrides:
getPanelType in class ComponentHandler
Returns:
String containing the panel type to use.


Copyright © 2002 Clearfield Research Ltd. All Rights Reserved.