Class Organigram
- java.lang.Object
-
- org.zkoss.zk.ui.AbstractComponent
-
- org.zkoss.zk.ui.HtmlBasedComponent
-
- org.zkoss.zul.impl.XulElement
-
- org.zkoss.zkmax.zul.Organigram
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,Component
,Scope
,ComponentCtrl
public class Organigram extends XulElement
A container which can be used to draw a hierarchical organizational chart, you can specify aTreeModel
to render the data.Event:
SelectEvent
is sent when user changes the selection.
To retrieve what is selected in Organigram with a
TreeSelectableModel
, you shall useTreeSelectableModel.isPathSelected(int[])
to check whether the current path is selected inTreeSelectableModel
rather than usinggetSelectedItem()
. That is, you shall operate on the item of theTreeSelectableModel
rather than on theOrgitem
of theOrganigram
if you use theTreeSelectableModel
andTreeModel
.To retrieve what are opened nodes in Organigram with a
TreeOpenableModel
, you shall useTreeOpenableModel.isPathOpened(int[])
to check whether the current path is opened inTreeOpenableModel
rather than usingOrgitem.isOpen()
. That is, you shall operate on the item of theTreeOpenableModel
rather than on theOrgitem
of theOrganigram
if you use theTreeOpenableModel
andTreeModel
.- Since:
- 8.6.0
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.zkoss.zk.ui.HtmlBasedComponent
HtmlBasedComponent.ExtraCtrl
-
Nested classes/interfaces inherited from class org.zkoss.zk.ui.AbstractComponent
AbstractComponent.Children, AbstractComponent.ForwardInfo, AbstractComponent.TargetInfo
-
-
Field Summary
-
Fields inherited from class org.zkoss.zk.ui.HtmlBasedComponent
_zclass
-
Fields inherited from interface org.zkoss.zk.ui.Component
APPLICATION_SCOPE, COMPONENT_SCOPE, DESKTOP_SCOPE, PAGE_SCOPE, REQUEST_SCOPE, SESSION_SCOPE, SPACE_SCOPE
-
Fields inherited from interface org.zkoss.zk.ui.sys.ComponentCtrl
AFTER_CHILD_ADDED, AFTER_CHILD_REMOVED, AFTER_PAGE_ATTACHED, AFTER_PAGE_DETACHED, AFTER_PARENT_CHANGED, CE_BUSY_IGNORE, CE_DUPLICATE_IGNORE, CE_IMPORTANT, CE_NON_DEFERRABLE, CE_REPEAT_IGNORE
-
-
Constructor Summary
Constructors Constructor Description Organigram()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
beforeChildAdded(Component child, Component insertBefore)
Default: does nothing.void
clear()
Clears all child Orgitems (Orgitem
.java.lang.Object
clone()
Clones the component.int
getItemCount()
Returns the number of childOrgitem
.<T> OrgitemRenderer<T>
getItemRenderer()
Returns the renderer to render each item, or null if the default renderer is used.java.util.Collection<Orgitem>
getItems()
Returns a readonly list of all descendingOrgitem
(children's children and so on).<T> TreeModel<T>
getModel()
Returns the tree model associated with this Organigram, or null if this Organigram is not associated with any tree data model.Orgchildren
getOrgchildren()
Returns the Orgchildren that this Organigram owns.Orgitem
getSelectedItem()
Returns the selected item.int
getVisibleItemCount()
Returns the number of visible descendantOrgitem
.java.lang.String
getZclass()
Returns the ZK Cascading Style class for this component.boolean
insertBefore(Component newChild, Component refChild)
Inserts a child before the reference child.void
onChildRemoved(Component child)
Default: handles special event listeners.void
onInitRender()
Handles a private event, onInitRender.void
onPageAttached(Page newpage, Page oldpage)
Default: handles special event listeners.void
onPageDetached(Page page)
Default: handles special event listeners.void
renderItem(Orgitem item)
Renders the specifiedOrgitem
, if not loaded yet, withgetItemRenderer()
.protected void
renderProperties(ContentRenderer renderer)
Renders the content of this component, excluding the enclosing tags and children.void
service(AuRequest request, boolean everError)
Processes an AU request.void
sessionDidActivate(Page page)
Notification that the session, which owns this component, has just been activated (a.k.a., deserialized).void
sessionWillPassivate(Page page)
Notification that the session, which owns this component, is about to be passivated (a.k.a., serialized).void
setItemRenderer(java.lang.String clsnm)
Sets the renderer by use of a class name.void
setItemRenderer(OrgitemRenderer<?> renderer)
Sets the renderer which is used to render each item ifgetModel()
is not null.void
setModel(TreeModel<?> model)
Sets the tree model associated with this Organigram.void
setSelectedItem(Orgitem selectedItem)
Deselects previous selected item and selects the given item.-
Methods inherited from class org.zkoss.zul.impl.XulElement
getContext, getCtrlKeys, getPopup, getPropertyAccess, getTooltip, setContext, setContext, setContextAttributes, setCtrlKeys, setPopup, setPopup, setPopupAttributes, setTooltip, setTooltip, setTooltipAttributes
-
Methods inherited from class org.zkoss.zk.ui.HtmlBasedComponent
addSclass, evalCSSFlex, focus, getAction, getClientAction, getDraggable, getDroppable, getExtraCtrl, getHeight, getHflex, getLeft, getRenderdefer, getSclass, getStyle, getTabindex, getTabindexInteger, getTooltiptext, getTop, getVflex, getWidth, getZindex, getZIndex, removeSclass, removeSclass, setAction, setClass, setClientAction, setDraggable, setDroppable, setFocus, setHeight, setHeight0, setHeightDirectly, setHflex, setHflex0, setHflexDirectly, setLeft, setLeftDirectly, setRenderdefer, setSclass, setStyle, setTabindex, setTabindex, setTooltiptext, setTop, setTopDirectly, setVflex, setVflex0, setVflexDirectly, setWidth, setWidth0, setWidthDirectly, setZclass, setZindex, setZIndex, setZIndexDirectly
-
Methods inherited from class org.zkoss.zk.ui.AbstractComponent
addAnnotation, addCallback, addClientEvent, addEventHandler, addEventListener, addEventListener, addForward, addForward, addForward, addForward, addMoved, addRedrawCallback, addScopeListener, addShadowRoot, addShadowRootBefore, addSharedEventHandlerMap, appendChild, applyProperties, beforeChildRemoved, beforeParentChanged, destroyIndexCacheMap, detach, didActivate, didActivate, didDeserialize, didDeserialize, disableBindingAnnotation, disableClientUpdate, disableHostChanged, enableBindingAnnotation, enableHostChanged, getAnnotatedProperties, getAnnotatedPropertiesBy, getAnnotation, getAnnotations, getAnnotations, getAttribute, getAttribute, getAttribute, getAttributeOrFellow, getAttributes, getAttributes, getAuService, getAutag, getCallback, getChildren, getClientAttribute, getClientDataAttribute, getClientEvents, getDefaultMold, getDefinition, getDesktop, getEventHandler, getEventHandlerNames, getEventListenerMap, getEventListeners, getFellow, getFellow, getFellowIfAny, getFellowIfAny, getFellows, getFirstChild, getForwards, getId, getIndexCacheMap, getLastChild, getMold, getNextSibling, getPage, getParent, getPreviousSibling, getRedrawCallback, getRoot, getShadowFellowIfAny, getShadowRoots, getShadowVariable, getShadowVariable, getShadowVariable0, getSpaceOwner, getSpecialRendererOutput, getStubonly, getSubBindingAnnotationCount, getTemplate, getTemplateNames, getUuid, getWidgetAttributeNames, getWidgetClass, getWidgetListener, getWidgetListenerNames, getWidgetOverride, getWidgetOverrideNames, hasAttribute, hasAttribute, hasAttribute, hasAttributeOrFellow, hasBindingAnnotation, hasFellow, hasFellow, hasSubBindingAnnotation, initIndexCacheMap, invalidate, isChildable, isDisabledHostChanged, isInitialized, isInvalidated, isListenerAvailable, isVisible, onChildAdded, onParentChanged, onWrongValue, query, queryAll, redraw, redrawChildren, removeAttribute, removeAttribute, removeAttribute, removeCallback, removeChild, removeEventListener, removeForward, removeForward, removeRedrawCallback, removeScopeListener, removeShadowRoot, render, render, render, renderPropertiesOnly, replace, response, response, response, service, setAttribute, setAttribute, setAttribute, setAuService, setAutag, setClientAttribute, setClientDataAttribute, setDefinition, setDefinition, setId, setMold, setPage, setPageBefore, setParent, setStubonly, setStubonly, setSubBindingAnnotationCount, setTemplate, setVisible, setVisibleDirectly, setWidgetClass, setWidgetListener, setWidgetOverride, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdateWidgetListener, smartUpdateWidgetOverride, toString, updateByClient, updateSubBindingAnnotationCount, willPassivate, willPassivate, willSerialize, willSerialize
-
-
-
-
Method Detail
-
getOrgchildren
public Orgchildren getOrgchildren()
Returns the Orgchildren that this Organigram owns.- Returns:
- Orgchildren
-
getItems
public java.util.Collection<Orgitem> getItems()
Returns a readonly list of all descendingOrgitem
(children's children and so on).Note: the performance of the size method of returned collection is no good.
- Returns:
- readonly list of all descending
Orgitem
-
getItemCount
public int getItemCount()
Returns the number of childOrgitem
. The same asgetItems()
.size().Note: the performance of this method is no good.
- Returns:
- the number of child
Orgitem
.
-
getVisibleItemCount
public int getVisibleItemCount()
Returns the number of visible descendantOrgitem
. Descendants include direct children, grand children and so on.- Returns:
- the number of visible descendant
Orgitem
.
-
getSelectedItem
public Orgitem getSelectedItem()
Returns the selected item. Note: Organigram only accepts one selected item.- Returns:
- the selected item.
-
setSelectedItem
public void setSelectedItem(Orgitem selectedItem)
Deselects previous selected item and selects the given item. Note: Organigram only accepts one selected item.- Parameters:
selectedItem
- the item will be selected
-
clear
public void clear()
Clears all child Orgitems (Orgitem
.Note: after clear,
getOrgchildren()
won't be null, but it has no child.
-
beforeChildAdded
public void beforeChildAdded(Component child, Component insertBefore)
Description copied from class:AbstractComponent
Default: does nothing.- Specified by:
beforeChildAdded
in interfaceComponentCtrl
- Overrides:
beforeChildAdded
in classAbstractComponent
- Parameters:
child
- the child to be added (never null).insertBefore
- another child component that the new child will be inserted before it. If null, the new child will be the last child.- See Also:
ComponentCtrl.beforeChildAdded(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.Component)
-
insertBefore
public boolean insertBefore(Component newChild, Component refChild)
Description copied from interface:Component
Inserts a child before the reference child.You could use
Component.setParent(org.zkoss.zk.ui.Component)
orComponent.appendChild(org.zkoss.zk.ui.Component)
instead of this method, unless you want to control where to put the child.Note:
Component.setParent(org.zkoss.zk.ui.Component)
always calls backComponent.insertBefore(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.Component)
and/orComponent.removeChild(org.zkoss.zk.ui.Component)
, whileComponent.insertBefore(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.Component)
andComponent.removeChild(org.zkoss.zk.ui.Component)
always calls backComponent.setParent(org.zkoss.zk.ui.Component)
, if the parent is changed. Thus, you don't need to override bothComponent.insertBefore(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.Component)
andComponent.setParent(org.zkoss.zk.ui.Component)
, if you want to customize the behavior.If you would like to monitor if a component is attached or detached from a page, you could register a desktop listener implementing
UiLifeCycle
.- Specified by:
insertBefore
in interfaceComponent
- Overrides:
insertBefore
in classAbstractComponent
- Parameters:
newChild
- the new child to be inserted.refChild
- the child before which you want the new child being inserted. If null, the new child is append to the end.- Returns:
- true if newChild is added successfully or moved; false if it already has the specified child and the order doesn't change.
-
onChildRemoved
public void onChildRemoved(Component child)
Description copied from class:AbstractComponent
Default: handles special event listeners.- Specified by:
onChildRemoved
in interfaceComponentCtrl
- Overrides:
onChildRemoved
in classAbstractComponent
- See Also:
ComponentCtrl.onChildRemoved(org.zkoss.zk.ui.Component)
-
onPageAttached
public void onPageAttached(Page newpage, Page oldpage)
Description copied from class:AbstractComponent
Default: handles special event listeners.- Specified by:
onPageAttached
in interfaceComponentCtrl
- Overrides:
onPageAttached
in classAbstractComponent
- Parameters:
newpage
- the new page (never null).oldpage
- the previous page, if any, or null if it didn't belong to any page.- See Also:
ComponentCtrl.onPageAttached(org.zkoss.zk.ui.Page, org.zkoss.zk.ui.Page)
-
onPageDetached
public void onPageDetached(Page page)
Description copied from class:AbstractComponent
Default: handles special event listeners.- Specified by:
onPageDetached
in interfaceComponentCtrl
- Overrides:
onPageDetached
in classAbstractComponent
- Parameters:
page
- the previous page (never null)- See Also:
ComponentCtrl.onPageDetached(org.zkoss.zk.ui.Page)
-
clone
public java.lang.Object clone()
Description copied from interface:Component
Clones the component. All of its children and descendants are cloned. Also, ID are preserved.- Specified by:
clone
in interfaceComponent
- Overrides:
clone
in classXulElement
- Returns:
- the new component. Notice that it doesn't belong to any page, nor desktop. It doesn't have a parent, either.
-
sessionWillPassivate
public void sessionWillPassivate(Page page)
Description copied from interface:ComponentCtrl
Notification that the session, which owns this component, is about to be passivated (a.k.a., serialized).Note: only root components are notified by this method.
- Specified by:
sessionWillPassivate
in interfaceComponentCtrl
- Overrides:
sessionWillPassivate
in classAbstractComponent
-
sessionDidActivate
public void sessionDidActivate(Page page)
Description copied from interface:ComponentCtrl
Notification that the session, which owns this component, has just been activated (a.k.a., deserialized).Note: only root components are notified by this method.
- Specified by:
sessionDidActivate
in interfaceComponentCtrl
- Overrides:
sessionDidActivate
in classAbstractComponent
-
getModel
public <T> TreeModel<T> getModel()
Returns the tree model associated with this Organigram, or null if this Organigram is not associated with any tree data model.- Returns:
- the tree model associated with this Organigram
-
setModel
public void setModel(TreeModel<?> model)
Sets the tree model associated with this Organigram.- Parameters:
model
- the tree model to associate, or null to dissociate any previous model.- Throws:
UiException
- if failed to initialize with the model
-
onInitRender
public void onInitRender()
Handles a private event, onInitRender. It is used only for implementation, and you rarely need to invoke it explicitly.
-
getItemRenderer
public <T> OrgitemRenderer<T> getItemRenderer()
Returns the renderer to render each item, or null if the default renderer is used.
-
setItemRenderer
public void setItemRenderer(OrgitemRenderer<?> renderer)
Sets the renderer which is used to render each item ifgetModel()
is not null.Note: changing a render will cause the Organigram to re-render.
- Parameters:
renderer
- the renderer, or null to use the default.
-
setItemRenderer
public void setItemRenderer(java.lang.String clsnm) throws java.lang.ClassNotFoundException, java.lang.NoSuchMethodException, java.lang.IllegalAccessException, java.lang.InstantiationException, java.lang.reflect.InvocationTargetException
Sets the renderer by use of a class name. It creates an instance automatically.- Parameters:
clsnm
- the class name of renderer- Throws:
java.lang.ClassNotFoundException
java.lang.NoSuchMethodException
java.lang.IllegalAccessException
java.lang.InstantiationException
java.lang.reflect.InvocationTargetException
-
renderItem
public void renderItem(Orgitem item)
Renders the specifiedOrgitem
, if not loaded yet, withgetItemRenderer()
.It does nothing if
getModel()
returns null.- Parameters:
item
- the item to be rendered
-
service
public void service(AuRequest request, boolean everError)
Description copied from class:HtmlBasedComponent
Processes an AU request.Default: it handles onClick, onDoubleClick, onRightClick onMove, onSize, onZIndex.
- Specified by:
service
in interfaceComponentCtrl
- Overrides:
service
in classHtmlBasedComponent
everError
- whether any error ever occurred before processing this request.- See Also:
AbstractComponent.setAuService(org.zkoss.zk.au.AuService)
-
renderProperties
protected void renderProperties(ContentRenderer renderer) throws java.io.IOException
Description copied from class:HtmlBasedComponent
Renders the content of this component, excluding the enclosing tags and children.- Overrides:
renderProperties
in classXulElement
- Throws:
java.io.IOException
-
getZclass
public java.lang.String getZclass()
Description copied from class:HtmlBasedComponent
Returns the ZK Cascading Style class for this component. It usually depends on the implementation of the mold (AbstractComponent.getMold()
).Default: null (the default value depends on element).
HtmlBasedComponent.setZclass(java.lang.String)
) will completely replace the default style of a component. In other words, the default style of a component is associated with the default value ofHtmlBasedComponent.getZclass()
. Once it is changed, the default style won't be applied at all. If you want to perform small adjustments, useHtmlBasedComponent.setSclass(java.lang.String)
instead.- Overrides:
getZclass
in classHtmlBasedComponent
- See Also:
HtmlBasedComponent.getSclass()
-
-