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
public class CmsTreeItem extends CmsListItem
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 beopened
,closed
orleaf
.- Since:
- 8.0.0
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.opencms.gwt.client.ui.CmsListItem
CmsListItem.MoveHandle
-
-
Field Summary
Fields Modifier and Type Field Description static int
ANIMATION_DURATION
The duration of the animations.protected CmsList<CmsTreeItem>
m_children
The children list.protected CmsToggleButton
m_opener
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
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
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, java.lang.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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
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
clearChildren()
Removes all children.void
closeAllEmptyChildren()
Closes all empty child entries.protected CmsToggleButton
createOpener()
Creates the button for opening/closing this item.protected void
executeOpen(boolean fireEvents)
Executes the open call.protected void
fireClose()
Fires the close event.protected void
fireOpen()
Fires the open event on the tree.CmsTreeItem
getChild(int index)
Returns the child tree item at the given position.CmsTreeItem
getChild(java.lang.String itemId)
Returns the tree item with the given id.int
getChildCount()
Helper method which gets the number of children.CmsList<? extends I_CmsListItem>
getChildren()
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.CmsTreeItem
getParentItem()
Returns the parent item.I_CmsDropTarget
getParentTarget()
Returns the parent drop target ornull
if there is none.java.lang.String
getPath()
Returns the path of IDs for the this item.protected static int
getPathLevel(java.lang.String path)
Method determining the path level by counting the number of '/'.CmsTree<CmsTreeItem>
getTree()
Gets the tree to which this tree item belongs, or null if it does not belong to a tree.void
hideOpeners()
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
isDropEnabled()
Checks if dropping is enabled.boolean
isOpen()
Checks if the item is open or closed.protected void
onChangeChildren()
Helper method which is called when the list of children changes.void
onDragCancel()
Executed on drag cancel.CmsTreeItem
removeChild(int index)
Removes the item identified by the given index from the list.CmsTreeItem
removeChild(java.lang.String itemId)
Removes an item from the list.CmsTreeItem
removeChild(CmsTreeItem item)
Removes an item from the list.void
removeOpener()
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
showOpeners()
Shows the open/close icons for this tree item and its descendants.void
visit(com.google.common.base.Function<CmsTreeItem,java.lang.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 Detail
-
ANIMATION_DURATION
public static final int ANIMATION_DURATION
The duration of the animations.- See Also:
- Constant Field Values
-
m_children
protected CmsList<CmsTreeItem> m_children
The children list.
-
m_opener
protected CmsToggleButton m_opener
The element showing the open/close icon.
-
-
Constructor Detail
-
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
public CmsTreeItem(boolean showOpeners, com.google.gwt.user.client.ui.Widget mainWidget)
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, java.lang.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
protected CmsTreeItem(boolean showOpeners)
Default constructor.- Parameters:
showOpeners
- if true, the opener icons should be shown
-
-
Method Detail
-
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
protected static int getPathLevel(java.lang.String path)
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
public void add(com.google.gwt.user.client.ui.Widget w)
Unsupported operation.- Specified by:
add
in interfaceI_CmsListItem
- Overrides:
add
in classCmsListItem
- Parameters:
w
- the widget to add- See Also:
CmsListItem.add(com.google.gwt.user.client.ui.Widget)
-
addChild
public void addChild(CmsTreeItem item)
Adds a child list item.- Parameters:
item
- the child to add- See Also:
CmsList.addItem(org.opencms.gwt.client.ui.I_CmsListItem)
-
clear
public void clear()
- See Also:
HasWidgets.clear()
-
clearChildren
public void clearChildren()
Removes all children.- See Also:
CmsList.clearList()
-
closeAllEmptyChildren
public void closeAllEmptyChildren()
Closes all empty child entries.
-
getChild
public CmsTreeItem getChild(int index)
Returns the child tree item at the given position.- Parameters:
index
- the position- Returns:
- the tree item
- See Also:
CmsList.getItem(int)
-
getChild
public CmsTreeItem getChild(java.lang.String itemId)
Returns the tree item with the given id.- Parameters:
itemId
- the id of the item to retrieve- Returns:
- the tree item
- See Also:
CmsList.getItem(String)
-
getChildCount
public int getChildCount()
Helper method which gets the number of children.- Returns:
- the number of children
- See Also:
ComplexPanel.getWidgetCount()
-
getChildren
public CmsList<? extends I_CmsListItem> getChildren()
Returns the children of this list item.- Returns:
- the children list
-
getDragHelper
public com.google.gwt.dom.client.Element getDragHelper(I_CmsDropTarget target)
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:
I_CmsDraggable.getDragHelper(I_CmsDropTarget)
-
getItemPosition
public int getItemPosition(CmsTreeItem item)
Returns the given item position.- Parameters:
item
- the item to get the position for- Returns:
- the item position
-
getParentItem
public CmsTreeItem getParentItem()
Returns the parent item.- Returns:
- the parent item
-
getParentTarget
public I_CmsDropTarget 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:
CmsListItem.getParentTarget()
-
getPath
public java.lang.String getPath()
Returns the path of IDs for the this item.- Returns:
- a path of IDs separated by slash
-
getTree
public CmsTree<CmsTreeItem> 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
public void hideOpeners()
Hides the open/close icons for this tree item and its descendants.
-
insertChild
public void insertChild(CmsTreeItem item, int position)
Inserts the given item at the given position.- Parameters:
item
- the item to insertposition
- the position- See Also:
CmsList.insertItem(org.opencms.gwt.client.ui.I_CmsListItem, int)
-
isDropEnabled
public boolean isDropEnabled()
Checks if dropping is enabled.- Returns:
true
if dropping is enabled
-
isOpen
public boolean isOpen()
Checks if the item is open or closed.- Returns:
true
if open
-
onDragCancel
public void onDragCancel()
Description copied from interface:I_CmsDraggable
Executed on drag cancel.- Specified by:
onDragCancel
in interfaceI_CmsDraggable
- Overrides:
onDragCancel
in classCmsListItem
- See Also:
I_CmsDraggable.onDragCancel()
-
removeChild
public CmsTreeItem removeChild(CmsTreeItem item)
Removes an item from the list.- Parameters:
item
- the item to remove- Returns:
- the removed item
- See Also:
CmsList.removeItem(org.opencms.gwt.client.ui.I_CmsListItem)
-
removeChild
public CmsTreeItem removeChild(int index)
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
public CmsTreeItem removeChild(java.lang.String itemId)
Removes an item from the list.- Parameters:
itemId
- the id of the item to remove- Returns:
- the removed item
- See Also:
CmsList.removeItem(String)
-
removeOpener
public void 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
public void setDropEnabled(boolean enabled)
Enables/disables dropping.- Parameters:
enabled
-true
to enable, orfalse
to disable
-
setLeafStyle
public void setLeafStyle(boolean isLeaf)
Sets the tree item style to leaf, hiding the list opener.- Parameters:
isLeaf
-true
to set to leaf style
-
setOpen
public void setOpen(boolean open)
Opens or closes this tree item (i.e. shows or hides its descendants).- Parameters:
open
- iftrue
, open the tree item, else close it
-
setOpen
public void setOpen(boolean open, boolean fireEvents)
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
public void setParentItem(CmsTreeItem parentItem)
Sets the parent item.- Parameters:
parentItem
- the parent item to set
-
setTree
public void setTree(CmsTree<CmsTreeItem> tree)
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
public void showOpeners()
Shows the open/close icons for this tree item and its descendants.
-
visit
public void visit(com.google.common.base.Function<CmsTreeItem,java.lang.Boolean> visitor)
Visits all nested tree items with the given visitor function.- Parameters:
visitor
- the visitor
-
adopt
protected void adopt(CmsTreeItem item)
Adopts the given item.- Parameters:
item
- the item to adopt
-
createOpener
protected CmsToggleButton createOpener()
Creates the button for opening/closing this item.- Returns:
- a button
-
executeOpen
protected void executeOpen(boolean fireEvents)
Executes the open call.- Parameters:
fireEvents
- if true, open/close events will be fired
-
fireClose
protected void fireClose()
Fires the close event.
-
fireOpen
protected void fireOpen()
Fires the open event on the tree.
-
insertPlaceholderAsLastChild
protected int insertPlaceholderAsLastChild(com.google.gwt.dom.client.Element placeholder)
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
protected void onChangeChildren()
Helper method which is called when the list of children changes.
-
-