Package org.opencms.gwt.client.ui
Class CmsListItem
- 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
-
- 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:
CmsCreatableListItem
,CmsMenuListItem
,CmsResultListItem
,CmsToolbarClipboardView.CmsClipboardDeletedItem
,CmsTreeItem
public class CmsListItem extends com.google.gwt.user.client.ui.Composite implements I_CmsListItem
List item which uses a float panel for layout.- Since:
- 8.0.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
CmsListItem.MoveHandle
The move handle.
-
Field Summary
Fields Modifier and Type Field Description protected CmsCheckBox
m_checkbox
The checkbox of this list item, or null if there is no checkbox.protected CmsSimpleDecoratedPanel
m_decoratedPanel
The panel which contains both the decorations (checkbox, etc.) and the main widget.protected java.util.LinkedList<com.google.gwt.user.client.ui.Widget>
m_decorationWidgets
A list of decoration widgets which is used to initializem_decoratedPanel
.protected int
m_decorationWidth
The decoration width which should be used to initializem_decoratedPanel
.protected java.lang.String
m_id
The logical id, it is not the HTML id.protected CmsListItemWidget
m_listItemWidget
The list item widget, if this widget has one.protected com.google.gwt.user.client.ui.Widget
m_mainWidget
The main widget of the list item.protected CmsFlowPanel
m_panel
This widgets panel.protected com.google.gwt.dom.client.Element
m_placeholder
The drag'n drop place holder element.protected com.google.gwt.dom.client.Element
m_provisionalParent
The provisional drag parent.static java.lang.String
MOVE_HANDLE_MARKER_CLASS
The CSS class to mark the move handle.
-
Constructor Summary
Constructors Constructor Description CmsListItem()
Default constructor.CmsListItem(CmsListItemWidget widget)
Default constructor.CmsListItem(CmsCheckBox checkBox, CmsListItemWidget widget)
Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(com.google.gwt.user.client.ui.Widget w)
Adds a widget to this list item.protected void
addCheckBox(CmsCheckBox checkbox)
Adds a check box to this list item.protected void
addDecoration(com.google.gwt.user.client.ui.Widget widget, int width, boolean first)
Helper method for adding a decoration widget and updating the decoration width accordingly.void
addDecorationWidget(com.google.gwt.user.client.ui.Widget widget, int width)
Adds a decoration widget to the list item.protected void
addMainWidget(com.google.gwt.user.client.ui.Widget widget)
Adds the main widget to the list item.protected com.google.gwt.dom.client.Element
cloneForPlaceholder(CmsListItem listItem)
Clones the given item to be used as a place holder.CmsCheckBox
getCheckBox()
Gets the checkbox of this list item.com.google.common.base.Optional<int[]>
getCursorOffsetDelta()
Gets an optional pair of integers which are to be used as an "offset delta" for the drag and drop process.<T> T
getData()
Gets the data belonging to the list item.java.util.List<com.google.gwt.user.client.ui.Widget>
getDecorationWidgets()
Returns the decoration widgets of this list item.java.lang.String
getDndHelperClass()
Gets the class for the DND helper.java.lang.String
getDndParentClass()
Gets the class for the DND parent.com.google.gwt.dom.client.Element
getDragHelper(I_CmsDropTarget target)
Creates the drag helper element and attaches it into the DOM.java.lang.String
getId()
Returns the logical id, it is not the HTML id.CmsListItemWidget
getListItemWidget()
Returns the list item widget of this list item, or null if this item doesn't have a list item widget.com.google.gwt.user.client.ui.Widget
getMainWidget()
Returns the main widget.I_CmsDragHandle
getMoveHandle()
Returns the move handle.CmsList<CmsListItem>
getParentList()
Returns the parent list.I_CmsDropTarget
getParentTarget()
Returns the parent drop target ornull
if there is none.com.google.gwt.dom.client.Element
getPlaceholder(I_CmsDropTarget target)
Creates the drag placeholder element.protected void
initContent()
This internal helper method creates the actual contents of the widget by combining the decorators and the main widget.protected void
initContent(com.google.gwt.user.client.ui.Widget mainWidget)
This method is a convenience method which sets the main widget of this widget, and then callsinitContent()
.protected void
initContent(CmsCheckBox checkbox, com.google.gwt.user.client.ui.Widget mainWidget)
This method is a convenience method which sets the checkbox and main widget of this widget, and then callsinitContent()
.boolean
initMoveHandle(CmsDNDHandler dndHandler)
Initializes the move handle with the given drag and drop handler and adds it to the list item widget.boolean
initMoveHandle(CmsDNDHandler dndHandler, boolean addFirst)
Initializes the move handle with the given drag and drop handler and adds it to the list item widget.protected int
moveHandleLeft(com.google.gwt.dom.client.Element elem)
Gets the left edge of the move handle located in the element.void
onDragCancel()
Executed on drag cancel.void
onDrop(I_CmsDropTarget target)
Executed on drop.void
onStartDrag(I_CmsDropTarget target)
Executed on drag start.protected void
removeDecorationWidget(com.google.gwt.user.client.ui.Widget widget, int width)
Removes a decoration widget.void
setData(java.lang.Object data)
Sets the data for this list item.void
setDndHelperClass(java.lang.String dndHelperClass)
Sets the class for the DND helper.void
setDndParentClass(java.lang.String dndParentClass)
Sets the class for the DND parent.void
setId(java.lang.String id)
Sets the logical id, it is not the HTML id.void
setSmallView(boolean smallView)
Sets the decoration style to fit with the small view of list items.void
truncate(java.lang.String textMetricsPrefix, int widgetWidth)
Truncates long text and sets the original text to the title attribute.-
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
-
MOVE_HANDLE_MARKER_CLASS
public static final java.lang.String MOVE_HANDLE_MARKER_CLASS
The CSS class to mark the move handle.- See Also:
- Constant Field Values
-
m_checkbox
protected CmsCheckBox m_checkbox
The checkbox of this list item, or null if there is no checkbox.
-
m_decoratedPanel
protected CmsSimpleDecoratedPanel m_decoratedPanel
The panel which contains both the decorations (checkbox, etc.) and the main widget.
-
m_decorationWidgets
protected java.util.LinkedList<com.google.gwt.user.client.ui.Widget> m_decorationWidgets
A list of decoration widgets which is used to initializem_decoratedPanel
.
-
m_decorationWidth
protected int m_decorationWidth
The decoration width which should be used to initializem_decoratedPanel
.
-
m_id
protected java.lang.String m_id
The logical id, it is not the HTML id.
-
m_listItemWidget
protected CmsListItemWidget m_listItemWidget
The list item widget, if this widget has one.
-
m_mainWidget
protected com.google.gwt.user.client.ui.Widget m_mainWidget
The main widget of the list item.
-
m_panel
protected CmsFlowPanel m_panel
This widgets panel.
-
m_placeholder
protected com.google.gwt.dom.client.Element m_placeholder
The drag'n drop place holder element.
-
m_provisionalParent
protected com.google.gwt.dom.client.Element m_provisionalParent
The provisional drag parent.
-
-
Constructor Detail
-
CmsListItem
public CmsListItem()
Default constructor.
-
CmsListItem
public CmsListItem(CmsCheckBox checkBox, CmsListItemWidget widget)
Default constructor.- Parameters:
checkBox
- the checkboxwidget
- the widget to use
-
CmsListItem
public CmsListItem(CmsListItemWidget widget)
Default constructor.- Parameters:
widget
- the widget to use
-
-
Method Detail
-
add
public void add(com.google.gwt.user.client.ui.Widget w)
Description copied from interface:I_CmsListItem
Adds a widget to this list item.- Specified by:
add
in interfaceI_CmsListItem
- Parameters:
w
- the widget to add- See Also:
I_CmsListItem.add(com.google.gwt.user.client.ui.Widget)
-
addDecorationWidget
public void addDecorationWidget(com.google.gwt.user.client.ui.Widget widget, int width)
Adds a decoration widget to the list item.- Parameters:
widget
- the widgetwidth
- the widget width
-
getCheckBox
public CmsCheckBox getCheckBox()
Gets the checkbox of this list item.This method will return a checkbox if this list item has one, or null if it doesn't.
- Returns:
- a check box or null
-
getCursorOffsetDelta
public com.google.common.base.Optional<int[]> getCursorOffsetDelta()
Description copied from interface:I_CmsDraggable
Gets an optional pair of integers which are to be used as an "offset delta" for the drag and drop process.- Specified by:
getCursorOffsetDelta
in interfaceI_CmsDraggable
- Returns:
- an optional array containing exactly 2 entries [x,y]
- See Also:
I_CmsDraggable.getCursorOffsetDelta()
-
getData
public <T> T getData()
Gets the data belonging to the list item.- Returns:
- the data belonging to the list item
-
getDecorationWidgets
public java.util.List<com.google.gwt.user.client.ui.Widget> getDecorationWidgets()
Returns the decoration widgets of this list item.- Returns:
- the decoration widgets
-
getDndHelperClass
public java.lang.String getDndHelperClass()
Gets the class for the DND helper.- Returns:
- the class for the DND helper
-
getDndParentClass
public java.lang.String getDndParentClass()
Gets the class for the DND parent.- Returns:
- the class for the DND parent
-
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
- Parameters:
target
- the drop target- Returns:
- the drag helper element
- See Also:
I_CmsDraggable.getDragHelper(I_CmsDropTarget)
-
getId
public java.lang.String getId()
Description copied from interface:I_CmsListItem
Returns the logical id, it is not the HTML id.- Specified by:
getId
in interfaceI_CmsDraggable
- Specified by:
getId
in interfaceI_CmsListItem
- Returns:
- the id
- See Also:
I_CmsListItem.getId()
-
getListItemWidget
public CmsListItemWidget getListItemWidget()
Returns the list item widget of this list item, or null if this item doesn't have a list item widget.- Returns:
- a list item widget or null
-
getMainWidget
public com.google.gwt.user.client.ui.Widget getMainWidget()
Returns the main widget.- Returns:
- the main widget
-
getMoveHandle
public I_CmsDragHandle getMoveHandle()
Returns the move handle.- Returns:
- the move handle
-
getParentList
public CmsList<CmsListItem> getParentList()
Returns the parent list.- Returns:
- the parent list
-
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
- Returns:
- the parent drop target
- See Also:
I_CmsDraggable.getParentTarget()
-
getPlaceholder
public com.google.gwt.dom.client.Element getPlaceholder(I_CmsDropTarget target)
Description copied from interface:I_CmsDraggable
Creates the drag placeholder element.- Specified by:
getPlaceholder
in interfaceI_CmsDraggable
- Parameters:
target
- the drop target- Returns:
- the drag placeholder element
- See Also:
I_CmsDraggable.getPlaceholder(I_CmsDropTarget)
-
initMoveHandle
public boolean initMoveHandle(CmsDNDHandler dndHandler)
Initializes the move handle with the given drag and drop handler and adds it to the list item widget.This method will not work for list items that don't have a list-item-widget.
- Parameters:
dndHandler
- the drag and drop handler- Returns:
true
if initialization was successful
-
initMoveHandle
public boolean initMoveHandle(CmsDNDHandler dndHandler, boolean addFirst)
Initializes the move handle with the given drag and drop handler and adds it to the list item widget.This method will not work for list items that don't have a list-item-widget.
- Parameters:
dndHandler
- the drag and drop handleraddFirst
- if true, adds the move handle as first child- Returns:
true
if initialization was successful
-
onDragCancel
public void onDragCancel()
Description copied from interface:I_CmsDraggable
Executed on drag cancel.- Specified by:
onDragCancel
in interfaceI_CmsDraggable
- See Also:
I_CmsDraggable.onDragCancel()
-
onDrop
public void onDrop(I_CmsDropTarget target)
Description copied from interface:I_CmsDraggable
Executed on drop.- Specified by:
onDrop
in interfaceI_CmsDraggable
- Parameters:
target
- the drop target- See Also:
I_CmsDraggable.onDrop(org.opencms.gwt.client.dnd.I_CmsDropTarget)
-
onStartDrag
public void onStartDrag(I_CmsDropTarget target)
Description copied from interface:I_CmsDraggable
Executed on drag start.- Specified by:
onStartDrag
in interfaceI_CmsDraggable
- Parameters:
target
- the current drop target- See Also:
I_CmsDraggable.onStartDrag(org.opencms.gwt.client.dnd.I_CmsDropTarget)
-
setData
public void setData(java.lang.Object data)
Sets the data for this list item.- Parameters:
data
- the data to set
-
setDndHelperClass
public void setDndHelperClass(java.lang.String dndHelperClass)
Sets the class for the DND helper.- Parameters:
dndHelperClass
- the class for the DND helper
-
setDndParentClass
public void setDndParentClass(java.lang.String dndParentClass)
Sets the class for the DND parent.- Parameters:
dndParentClass
- the class for the DND parent
-
setId
public void setId(java.lang.String id)
Description copied from interface:I_CmsListItem
Sets the logical id, it is not the HTML id.- Specified by:
setId
in interfaceI_CmsListItem
- Parameters:
id
- the id to set- See Also:
I_CmsListItem.setId(java.lang.String)
-
setSmallView
public void setSmallView(boolean smallView)
Sets the decoration style to fit with the small view of list items.- Parameters:
smallView
- true if the decoration has to fit with the small view of list items
-
truncate
public void truncate(java.lang.String textMetricsPrefix, int widgetWidth)
Description copied from interface:I_CmsTruncable
Truncates long text and sets the original text to the title attribute.- Specified by:
truncate
in interfaceI_CmsTruncable
- Parameters:
textMetricsPrefix
- the key identifying the text metrics to usewidgetWidth
- the width to use in pixels- See Also:
I_CmsTruncable.truncate(java.lang.String, int)
-
addCheckBox
protected void addCheckBox(CmsCheckBox checkbox)
Adds a check box to this list item.- Parameters:
checkbox
- the check box
-
addDecoration
protected void addDecoration(com.google.gwt.user.client.ui.Widget widget, int width, boolean first)
Helper method for adding a decoration widget and updating the decoration width accordingly.- Parameters:
widget
- the decoration widget to addwidth
- the intended width of the decoration widgetfirst
- if true, inserts the widget at the front of the decorations, else at the end.
-
addMainWidget
protected void addMainWidget(com.google.gwt.user.client.ui.Widget widget)
Adds the main widget to the list item.In most cases, the widget will be a list item widget. If this is the case, then further calls to
getListItemWidget()
will return the widget which was passed as a parameter to this method. Otherwise, the method will return null.- Parameters:
widget
- the main content widget
-
cloneForPlaceholder
protected com.google.gwt.dom.client.Element cloneForPlaceholder(CmsListItem listItem)
Clones the given item to be used as a place holder.- Parameters:
listItem
- the item to clone- Returns:
- the cloned item
-
initContent
protected void initContent()
This internal helper method creates the actual contents of the widget by combining the decorators and the main widget.
-
initContent
protected void initContent(CmsCheckBox checkbox, com.google.gwt.user.client.ui.Widget mainWidget)
This method is a convenience method which sets the checkbox and main widget of this widget, and then callsinitContent()
.- Parameters:
checkbox
- the checkbox to addmainWidget
- the mainWidget to add
-
initContent
protected void initContent(com.google.gwt.user.client.ui.Widget mainWidget)
This method is a convenience method which sets the main widget of this widget, and then callsinitContent()
.- Parameters:
mainWidget
- the main widget to add
-
moveHandleLeft
protected int moveHandleLeft(com.google.gwt.dom.client.Element elem)
Gets the left edge of the move handle located in the element.- Parameters:
elem
- the element to search in- Returns:
- the left edge of the move handle
-
removeDecorationWidget
protected void removeDecorationWidget(com.google.gwt.user.client.ui.Widget widget, int width)
Removes a decoration widget.- Parameters:
widget
- the widget to removewidth
- the widget width
-
-