org.zkoss.zul
Class Tree

java.lang.Object
  extended by org.zkoss.zk.ui.AbstractComponent
      extended by org.zkoss.zk.ui.HtmlBasedComponent
          extended by org.zkoss.zul.impl.XulElement
              extended by org.zkoss.zul.Tree
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, org.zkoss.zk.ui.Component, org.zkoss.zk.ui.sys.ComponentCtrl

public class Tree
extends XulElement

A container which can be used to hold a tabular or hierarchical set of rows of elements.

Event:

  1. org.zkoss.zk.ui.event.SelectEvent is sent when user changes the selection.

Default HtmlBasedComponent.getSclass(): tree.

Author:
tomyeh
See Also:
Serialized Form

Nested Class Summary
protected  class Tree.ExtraCtrl
          A utility class to implement AbstractComponent.getExtraCtrl().
 
Field Summary
 
Fields inherited from class org.zkoss.zk.ui.HtmlBasedComponent
RS_NO_DISPLAY, RS_NO_HEIGHT, RS_NO_WIDTH
 
Fields inherited from interface org.zkoss.zk.ui.Component
APPLICATION_SCOPE, COMPONENT_SCOPE, DESKTOP_SCOPE, PAGE_SCOPE, REQUEST_SCOPE, SESSION_SCOPE, SPACE_SCOPE
 
Constructor Summary
Tree()
           
 
Method Summary
 void addItemToSelection(Treeitem item)
          Selects the given item, without deselecting any other items that are already selected..
 void clear()
          Clears all child tree items (Treeitem.
 void clearSelection()
          Clears the selection.
 java.lang.Object clone()
           
 int getItemCount()
          Returns the number of child Treeitem.
 java.util.Collection getItems()
          Returns a readonly list of all descending Treeitem (children's children and so on).
 java.lang.String getName()
          Returns the name of this component.
 java.lang.String getOuterAttrs()
           
 int getPageSize()
          Returns the page size that is used by all Treechildren to display a portion of their child Treeitem, or -1 if no limitation.
 int getRows()
          Returns the rows.
 int getSelectedCount()
          Returns the number of items being selected.
 Treeitem getSelectedItem()
          Returns the selected item.
 java.util.Set getSelectedItems()
          Returns all selected items.
 java.lang.String getSeltype()
          Returns the seltype.
 Treechildren getTreechildren()
          Returns the treechildren that this tree owns (might null).
 Treecols getTreecols()
          Returns the treecols that this tree owns (might null).
 Treefoot getTreefoot()
          Returns the treefoot that this tree owns (might null).
 boolean insertBefore(org.zkoss.zk.ui.Component child, org.zkoss.zk.ui.Component refChild)
           
 boolean isCheckmark()
          Returns whether the check mark shall be displayed in front of each item.
 boolean isMultiple()
          Returns whether multiple selections are allowed.
 boolean isVflex()
          Returns whether to grow and shrink vertical to fit their given space, so called vertial flexibility.
protected  java.lang.Object newExtraCtrl()
           
 void onChildAdded(org.zkoss.zk.ui.Component child)
           
 void onChildRemoved(org.zkoss.zk.ui.Component child)
           
 void removeItemFromSelection(Treeitem item)
          Deselects the given item without deselecting other items.
 void selectAll()
          Selects all items.
 void selectItem(Treeitem item)
          Deselects all of the currently selected items and selects the given item.
 void setCheckmark(boolean checkmark)
          Sets whether the check mark shall be displayed in front of each item.
 void setHeight(java.lang.String height)
           
 void setMultiple(boolean multiple)
          Sets whether multiple selections are allowed.
 void setName(java.lang.String name)
          Sets the name of this component.
 void setPageSize(int size)
          Sets the page size that is used by all Treechildren to display a portion of their child Treeitem.
 void setRows(int rows)
          Sets the rows.
 void setSelectedItem(Treeitem item)
          Deselects all of the currently selected items and selects the given item.
 void setSeltype(java.lang.String seltype)
          Sets the seltype.
 void setVflex(boolean vflex)
          Sets whether to grow and shrink vertical to fit their given space, so called vertial flexibility.
 void smartUpdate(java.lang.String attr, java.lang.String value)
           
 void toggleItemSelection(Treeitem item)
          If the specified item is selected, it is deselected.
 
Methods inherited from class org.zkoss.zul.impl.XulElement
getAction, getAllOnClickAttrs, getContext, getInnerAttrs, getPopup, getTooltip, setAction, setContext, setPopup, setTooltip
 
Methods inherited from class org.zkoss.zk.ui.HtmlBasedComponent
addEventListener, appendAsapAttr, focus, getDraggable, getDroppable, getHeight, getLeft, getRealStyle, getRealStyleFlags, getSclass, getStyle, getTooltiptext, getTop, getWidth, getZIndex, isAsapRequired, removeEventListener, setClass, setDraggable, setDroppable, setLeft, setSclass, setStyle, setTooltiptext, setTop, setWidth, setZIndex
 
Methods inherited from class org.zkoss.zk.ui.AbstractComponent
addAnnotation, addAnnotation, addEventHandler, addSharedAnnotationMap, addSharedEventHandlerMap, appendChild, applyProperties, containsVariable, detach, equals, getAnnotatedProperties, getAnnotatedPropertiesBy, getAnnotation, getAnnotation, getAnnotations, getAnnotations, getAttribute, getAttribute, getAttributes, getAttributes, getChildren, getDefinition, getDesktop, getEventHandler, getExtraCtrl, getFellow, getFellowIfAny, getId, getListenerIterator, getMold, getMoldURI, getNamespace, getPage, getParent, getPropagatee, getRoot, getSpaceOwner, getUuid, getVariable, invalidate, isChildable, isListenerAvailable, isVisible, onDrawNewChild, onWrongValue, redraw, removeAttribute, removeAttribute, removeChild, response, sessionDidActivate, sessionWillPassivate, setAttribute, setAttribute, setComponentDefinition, setId, setMold, setPage, setParent, setVariable, setVisible, smartUpdate, smartUpdate, toString, unsetVariable
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Tree

public Tree()
Method Detail

getTreecols

public Treecols getTreecols()
Returns the treecols that this tree owns (might null).


getTreefoot

public Treefoot getTreefoot()
Returns the treefoot that this tree owns (might null).


getTreechildren

public Treechildren getTreechildren()
Returns the treechildren that this tree owns (might null).


getRows

public int getRows()
Returns the rows. Zero means no limitation.

Default: 0.


setRows

public void setRows(int rows)
             throws org.zkoss.zk.ui.WrongValueException
Sets the rows.

Note: if both setHeight(java.lang.String) is specified with non-empty, setRows(int) is ignored

Throws:
org.zkoss.zk.ui.WrongValueException

getName

public java.lang.String getName()
Returns the name of this component.

Default: null.

Don't use this method if your application is purely based on ZK's event-driven model.

The name is used only to work with "legacy" Web application that handles user's request by servlets. It works only with HTTP/HTML-based browsers. It doesn't work with other kind of clients.


setName

public void setName(java.lang.String name)
Sets the name of this component.

Don't use this method if your application is purely based on ZK's event-driven model.

The name is used only to work with "legacy" Web application that handles user's request by servlets. It works only with HTTP/HTML-based browsers. It doesn't work with other kind of clients.

Parameters:
name - the name of this component.

isCheckmark

public final boolean isCheckmark()
Returns whether the check mark shall be displayed in front of each item.

Default: false.


setCheckmark

public void setCheckmark(boolean checkmark)
Sets whether the check mark shall be displayed in front of each item.

The check mark is a checkbox if isMultiple() returns true. It is a radio button if isMultiple() returns false.


isVflex

public final boolean isVflex()
Returns whether to grow and shrink vertical to fit their given space, so called vertial flexibility.

Note: this attribute is ignored if setRows(int) is specified

Default: false.


setVflex

public void setVflex(boolean vflex)
Sets whether to grow and shrink vertical to fit their given space, so called vertial flexibility.

Note: this attribute is ignored if setRows(int) is specified


getSeltype

public java.lang.String getSeltype()
Returns the seltype.

Default: "single".


setSeltype

public void setSeltype(java.lang.String seltype)
                throws org.zkoss.zk.ui.WrongValueException
Sets the seltype. Currently, only "single" is supported.

Throws:
org.zkoss.zk.ui.WrongValueException

isMultiple

public boolean isMultiple()
Returns whether multiple selections are allowed.

Default: false.


setMultiple

public void setMultiple(boolean multiple)
Sets whether multiple selections are allowed.


getItems

public java.util.Collection getItems()
Returns a readonly list of all descending Treeitem (children's children and so on).

Note: the performance of the size method of returned collection is no good.


getItemCount

public int getItemCount()
Returns the number of child Treeitem. The same as getItems().size().

Note: the performance of this method is no good.


selectItem

public void selectItem(Treeitem item)
Deselects all of the currently selected items and selects the given item.

It is the same as setSelectedItem(org.zkoss.zul.Treeitem).

Parameters:
item - the item to select. If null, all items are deselected.

addItemToSelection

public void addItemToSelection(Treeitem item)
Selects the given item, without deselecting any other items that are already selected..


removeItemFromSelection

public void removeItemFromSelection(Treeitem item)
Deselects the given item without deselecting other items.


toggleItemSelection

public void toggleItemSelection(Treeitem item)
If the specified item is selected, it is deselected. If it is not selected, it is selected. Other items in the tree that are selected are not affected, and retain their selected state.


clearSelection

public void clearSelection()
Clears the selection.


selectAll

public void selectAll()
Selects all items.


getSelectedItem

public Treeitem getSelectedItem()
Returns the selected item.


setSelectedItem

public void setSelectedItem(Treeitem item)
Deselects all of the currently selected items and selects the given item.

It is the same as selectItem(org.zkoss.zul.Treeitem).


getSelectedItems

public java.util.Set getSelectedItems()
Returns all selected items.


getSelectedCount

public int getSelectedCount()
Returns the number of items being selected.


clear

public void clear()
Clears all child tree items (Treeitem.

Note: after clear, getTreechildren() won't be null, but it has no child


getPageSize

public int getPageSize()
Returns the page size that is used by all Treechildren to display a portion of their child Treeitem, or -1 if no limitation.

Default: 10.

Since:
2.4.1

setPageSize

public void setPageSize(int size)
                 throws org.zkoss.zk.ui.WrongValueException
Sets the page size that is used by all Treechildren to display a portion of their child Treeitem.

Parameters:
size - the page size. If non-positive, there won't be any limitation. In other wordss, all Treeitem are shown. Notice: since the browser's JavaScript engine is slow to handle huge trees, it is better not to set a non-positive size if your tree is huge.
Throws:
org.zkoss.zk.ui.WrongValueException
Since:
2.4.1

setHeight

public void setHeight(java.lang.String height)
Overrides:
setHeight in class org.zkoss.zk.ui.HtmlBasedComponent

smartUpdate

public void smartUpdate(java.lang.String attr,
                        java.lang.String value)
Specified by:
smartUpdate in interface org.zkoss.zk.ui.Component
Overrides:
smartUpdate in class org.zkoss.zk.ui.AbstractComponent

insertBefore

public boolean insertBefore(org.zkoss.zk.ui.Component child,
                            org.zkoss.zk.ui.Component refChild)
Specified by:
insertBefore in interface org.zkoss.zk.ui.Component
Overrides:
insertBefore in class org.zkoss.zk.ui.AbstractComponent

onChildAdded

public void onChildAdded(org.zkoss.zk.ui.Component child)
Specified by:
onChildAdded in interface org.zkoss.zk.ui.Component
Overrides:
onChildAdded in class org.zkoss.zk.ui.AbstractComponent

onChildRemoved

public void onChildRemoved(org.zkoss.zk.ui.Component child)
Specified by:
onChildRemoved in interface org.zkoss.zk.ui.Component
Overrides:
onChildRemoved in class org.zkoss.zk.ui.AbstractComponent

getOuterAttrs

public java.lang.String getOuterAttrs()
Overrides:
getOuterAttrs in class XulElement

clone

public java.lang.Object clone()
Specified by:
clone in interface org.zkoss.zk.ui.Component
Overrides:
clone in class org.zkoss.zk.ui.AbstractComponent

newExtraCtrl

protected java.lang.Object newExtraCtrl()
Overrides:
newExtraCtrl in class org.zkoss.zk.ui.HtmlBasedComponent


Copyright © 2005-2007 Potix Corporation. All Rights Reserved.