Package org.opencms.gwt.client.ui.tree
Class CmsTreeItem
java.lang.Object
com.google.gwt.user.client.ui.UIObject
com.google.gwt.user.client.ui.Widget
com.google.gwt.user.client.ui.Composite
org.opencms.gwt.client.ui.CmsListItem
org.opencms.gwt.client.ui.tree.CmsTreeItem
- All Implemented Interfaces:
com.google.gwt.event.logical.shared.HasAttachHandlers
,com.google.gwt.event.shared.HasHandlers
,com.google.gwt.user.client.EventListener
,com.google.gwt.user.client.ui.HasVisibility
,com.google.gwt.user.client.ui.IsRenderable
,com.google.gwt.user.client.ui.IsWidget
,I_CmsDraggable
,I_CmsListItem
,I_CmsTruncable
- Direct Known Subclasses:
CmsCategoryTreeItem
,CmsGalleryTreeItem
,CmsLazyTreeItem
,CmsLazyTreeItem.LoadingItem
,CmsModelPageTreeItem
List tree item implementation.
Implemented as:
<li class='listTreeItem listTreeItem*state*'> <span class='listTreeItemImage'></span> <div class='listTreeItemContent'>...*content*</div> <ul class='listTreeItemChildren'> *children* </ul> </li>Where state can be
opened
, closed
or leaf
.- Since:
- 8.0.0
-
Nested Class Summary
Nested classes/interfaces inherited from class org.opencms.gwt.client.ui.CmsListItem
CmsListItem.MoveHandle
Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject
com.google.gwt.user.client.ui.UIObject.DebugIdImpl, com.google.gwt.user.client.ui.UIObject.DebugIdImplEnabled
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
The duration of the animations.protected CmsList<CmsTreeItem>
The children list.protected CmsToggleButton
The element showing the open/close icon.Fields inherited from class org.opencms.gwt.client.ui.CmsListItem
m_checkbox, m_decoratedPanel, m_decorationWidgets, m_decorationWidth, m_id, m_listItemWidget, m_mainWidget, m_panel, m_placeholder, m_provisionalParent, MOVE_HANDLE_MARKER_CLASS
Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
CmsTreeItem
(boolean showOpeners) Default constructor.CmsTreeItem
(boolean showOpeners, com.google.gwt.user.client.ui.Widget mainWidget) Creates a new list tree item containing a main widget.CmsTreeItem
(boolean showOpeners, com.google.gwt.user.client.ui.Widget mainWidget, String icon) Creates a new tree item with a 24px wide icon.CmsTreeItem
(boolean showOpeners, CmsCheckBox checkbox, com.google.gwt.user.client.ui.Widget mainWidget) Creates a new list tree item containing a main widget and a check box. -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(com.google.gwt.user.client.ui.Widget w) Unsupported operation.void
addChild
(CmsTreeItem item) Adds a child list item.protected void
adopt
(CmsTreeItem item) Adopts the given item.void
clear()
void
Removes all children.void
Closes all empty child entries.protected CmsToggleButton
Creates the button for opening/closing this item.protected void
executeOpen
(boolean fireEvents) Executes the open call.protected void
Fires the close event.protected void
fireOpen()
Fires the open event on the tree.getChild
(int index) Returns the child tree item at the given position.Returns the tree item with the given id.int
Helper method which gets the number of children.CmsList<? extends I_CmsListItem>
Returns the children of this list item.com.google.gwt.dom.client.Element
getDragHelper
(I_CmsDropTarget target) Creates the drag helper element and attaches it into the DOM.int
getItemPosition
(CmsTreeItem item) Returns the given item position.protected static CmsTreeItem
getLastOpenedItem
(CmsTreeItem item, int stopLevel, boolean requiresDropEnabled) Returns the last opened item of a tree fragment.Returns the parent item.Returns the parent drop target ornull
if there is none.getPath()
Returns the path of IDs for the this item.protected static int
getPathLevel
(String path) Method determining the path level by counting the number of '/'.getTree()
Gets the tree to which this tree item belongs, or null if it does not belong to a tree.void
Hides the open/close icons for this tree item and its descendants.void
insertChild
(CmsTreeItem item, int position) Inserts the given item at the given position.protected int
insertPlaceholderAsLastChild
(com.google.gwt.dom.client.Element placeholder) Inserts the placeholder element as last child of the children list.boolean
Checks if dropping is enabled.boolean
isOpen()
Checks if the item is open or closed.protected void
Helper method which is called when the list of children changes.void
Executed on drag cancel.removeChild
(int index) Removes the item identified by the given index from the list.removeChild
(String itemId) Removes an item from the list.removeChild
(CmsTreeItem item) Removes an item from the list.void
Removes the opener widget.int
repositionPlaceholder
(int x, int y, com.google.gwt.dom.client.Element placeholder, CmsDNDHandler.Orientation orientation) Positions the drag and drop placeholder as a sibling or descendant of this element.void
setDropEnabled
(boolean enabled) Enables/disables dropping.void
setLeafStyle
(boolean isLeaf) Sets the tree item style to leaf, hiding the list opener.void
setOpen
(boolean open) Opens or closes this tree item (i.e.void
setOpen
(boolean open, boolean fireEvents) Opens or closes this tree item (i.e.void
setParentItem
(CmsTreeItem parentItem) Sets the parent item.void
setTree
(CmsTree<CmsTreeItem> tree) Sets the tree to which this tree item belongs.void
Shows the open/close icons for this tree item and its descendants.void
visit
(com.google.common.base.Function<CmsTreeItem, Boolean> visitor) Visits all nested tree items with the given visitor function.Methods inherited from class org.opencms.gwt.client.ui.CmsListItem
addCheckBox, addDecoration, addDecorationWidget, addMainWidget, cloneForPlaceholder, getCheckBox, getCursorOffsetDelta, getData, getDecorationWidgets, getDndHelperClass, getDndParentClass, getId, getListItemWidget, getMainWidget, getMoveHandle, getParentList, getPlaceholder, initContent, initContent, initContent, initMoveHandle, initMoveHandle, moveHandleLeft, onDrop, onStartDrag, removeDecorationWidget, setData, setDndHelperClass, setDndParentClass, setId, setSmallView, truncate
Methods inherited from class com.google.gwt.user.client.ui.Composite
claimElement, getWidget, initializeClaimedElement, initWidget, isAttached, onAttach, onBrowserEvent, onDetach, render, render, resolvePotentialElement, setWidget
Methods inherited from class com.google.gwt.user.client.ui.Widget
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, doAttachChildren, doDetachChildren, fireEvent, getHandlerCount, getLayoutData, getParent, isOrWasAttached, onLoad, onUnload, removeFromParent, setLayoutData, sinkEvents, unsinkEvents
Methods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, onEnsureDebugId, removeStyleDependentName, removeStyleName, setElement, setElement, setHeight, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkBitlessEvent, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.opencms.gwt.client.dnd.I_CmsDraggable
getElement
-
Field Details
-
ANIMATION_DURATION
The duration of the animations.- See Also:
-
m_children
The children list. -
m_opener
The element showing the open/close icon.
-
-
Constructor Details
-
CmsTreeItem
public CmsTreeItem(boolean showOpeners, CmsCheckBox checkbox, com.google.gwt.user.client.ui.Widget mainWidget) Creates a new list tree item containing a main widget and a check box.- Parameters:
showOpeners
- if true, show open/close iconscheckbox
- the check boxmainWidget
- the main widget
-
CmsTreeItem
Creates a new list tree item containing a main widget.- Parameters:
showOpeners
- if true, show open/close iconsmainWidget
- the main widget
-
CmsTreeItem
public CmsTreeItem(boolean showOpeners, com.google.gwt.user.client.ui.Widget mainWidget, String icon) Creates a new tree item with a 24px wide icon.- Parameters:
showOpeners
- iftrue
, show open/close iconsmainWidget
- the main widgeticon
- the icon style name
-
CmsTreeItem
Default constructor.- Parameters:
showOpeners
- if true, the opener icons should be shown
-
-
Method Details
-
getLastOpenedItem
protected static CmsTreeItem getLastOpenedItem(CmsTreeItem item, int stopLevel, boolean requiresDropEnabled) Returns the last opened item of a tree fragment.- Parameters:
item
- the tree itemstopLevel
- the level to stop at, set -1 to go to the very last opened itemrequiresDropEnabled
-true
if it is required the returned element to be drop enabled- Returns:
- the last visible item of a tree fragment
-
getPathLevel
Method determining the path level by counting the number of '/'.Example: '/xxx/xxx/' has a path-level of 2.
- Parameters:
path
- the path to test- Returns:
- the path level
-
add
Unsupported operation.- Specified by:
add
in interfaceI_CmsListItem
- Overrides:
add
in classCmsListItem
- Parameters:
w
- the widget to add- See Also:
-
addChild
Adds a child list item.- Parameters:
item
- the child to add- See Also:
-
clear
- See Also:
-
HasWidgets.clear()
-
clearChildren
Removes all children.- See Also:
-
closeAllEmptyChildren
Closes all empty child entries. -
getChild
Returns the child tree item at the given position.- Parameters:
index
- the position- Returns:
- the tree item
- See Also:
-
getChild
Returns the tree item with the given id.- Parameters:
itemId
- the id of the item to retrieve- Returns:
- the tree item
- See Also:
-
getChildCount
Helper method which gets the number of children.- Returns:
- the number of children
- See Also:
-
ComplexPanel.getWidgetCount()
-
getChildren
Returns the children of this list item.- Returns:
- the children list
-
getDragHelper
Description copied from interface:I_CmsDraggable
Creates the drag helper element and attaches it into the DOM.- Specified by:
getDragHelper
in interfaceI_CmsDraggable
- Overrides:
getDragHelper
in classCmsListItem
- Parameters:
target
- the drop target- Returns:
- the drag helper element
- See Also:
-
getItemPosition
Returns the given item position.- Parameters:
item
- the item to get the position for- Returns:
- the item position
-
getParentItem
Returns the parent item.- Returns:
- the parent item
-
getParentTarget
Description copied from interface:I_CmsDraggable
Returns the parent drop target ornull
if there is none.- Specified by:
getParentTarget
in interfaceI_CmsDraggable
- Overrides:
getParentTarget
in classCmsListItem
- Returns:
- the parent drop target
- See Also:
-
getPath
Returns the path of IDs for the this item.- Returns:
- a path of IDs separated by slash
-
getTree
Gets the tree to which this tree item belongs, or null if it does not belong to a tree.- Returns:
- a tree or
null
-
hideOpeners
Hides the open/close icons for this tree item and its descendants. -
insertChild
Inserts the given item at the given position.- Parameters:
item
- the item to insertposition
- the position- See Also:
-
isDropEnabled
Checks if dropping is enabled.- Returns:
true
if dropping is enabled
-
isOpen
Checks if the item is open or closed.- Returns:
true
if open
-
onDragCancel
Description copied from interface:I_CmsDraggable
Executed on drag cancel.- Specified by:
onDragCancel
in interfaceI_CmsDraggable
- Overrides:
onDragCancel
in classCmsListItem
- See Also:
-
removeChild
Removes an item from the list.- Parameters:
item
- the item to remove- Returns:
- the removed item
- See Also:
-
removeChild
Removes the item identified by the given index from the list.- Parameters:
index
- the index of the item to remove- Returns:
- the removed item
- See Also:
-
ComplexPanel.remove(int)
-
removeChild
Removes an item from the list.- Parameters:
itemId
- the id of the item to remove- Returns:
- the removed item
- See Also:
-
removeOpener
Removes the opener widget. -
repositionPlaceholder
public int repositionPlaceholder(int x, int y, com.google.gwt.dom.client.Element placeholder, CmsDNDHandler.Orientation orientation) Positions the drag and drop placeholder as a sibling or descendant of this element.- Parameters:
x
- the cursor client x positiony
- the cursor client y positionplaceholder
- the placeholderorientation
- the drag and drop orientation- Returns:
- the placeholder index
-
setDropEnabled
Enables/disables dropping.- Parameters:
enabled
-true
to enable, orfalse
to disable
-
setLeafStyle
Sets the tree item style to leaf, hiding the list opener.- Parameters:
isLeaf
-true
to set to leaf style
-
setOpen
Opens or closes this tree item (i.e. shows or hides its descendants).- Parameters:
open
- iftrue
, open the tree item, else close it
-
setOpen
Opens or closes this tree item (i.e. shows or hides its descendants).- Parameters:
open
- iftrue
, open the tree item, else close itfireEvents
- true if the open/close events should be fired
-
setParentItem
Sets the parent item.- Parameters:
parentItem
- the parent item to set
-
setTree
Sets the tree to which this tree item belongs.This is automatically called when this tree item or one of its ancestors is inserted into a tree.
- Parameters:
tree
- the tree into which the item has been inserted
-
showOpeners
Shows the open/close icons for this tree item and its descendants. -
visit
Visits all nested tree items with the given visitor function.- Parameters:
visitor
- the visitor
-
adopt
Adopts the given item.- Parameters:
item
- the item to adopt
-
createOpener
Creates the button for opening/closing this item.- Returns:
- a button
-
executeOpen
Executes the open call.- Parameters:
fireEvents
- if true, open/close events will be fired
-
fireClose
Fires the close event. -
fireOpen
Fires the open event on the tree. -
insertPlaceholderAsLastChild
Inserts the placeholder element as last child of the children list. Setting it's path as the current placeholder path and returning the new index.- Parameters:
placeholder
- the placeholder element- Returns:
- the new index
-
onChangeChildren
Helper method which is called when the list of children changes.
-