Package org.opencms.acacia.client.ui
Class CmsAttributeValueView
- 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.acacia.client.ui.CmsAttributeValueView
-
- All Implemented Interfaces:
com.google.gwt.event.dom.client.HasMouseDownHandlers
,com.google.gwt.event.dom.client.HasMouseOutHandlers
,com.google.gwt.event.dom.client.HasMouseOverHandlers
,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_CmsHasResizeOnShow
public class CmsAttributeValueView extends com.google.gwt.user.client.ui.Composite implements I_CmsDraggable, I_CmsHasResizeOnShow, com.google.gwt.event.dom.client.HasMouseOverHandlers, com.google.gwt.event.dom.client.HasMouseOutHandlers, com.google.gwt.event.dom.client.HasMouseDownHandlers
UI object holding an attribute value.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
CmsAttributeValueView.ChangeHandler
The widget value change handler.protected class
CmsAttributeValueView.LabelHoverHandler
Handles showing and hiding the help bubble on mouse over the title label.protected class
CmsAttributeValueView.MoveHandle
The move handle.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ATTR_HAS_HOVER
Attribute for marking menu bars that are actually menu bars which should open on hovering (rather than just a single button).static java.lang.String
ATTR_KEY
static int
COMPACT_MODE_FIRST_COLUMN
The first column compact view mode.static int
COMPACT_MODE_NESTED
The nested compact view mode.static int
COMPACT_MODE_SECOND_COLUMN
The second column compact view mode.static int
COMPACT_MODE_SINGLE_LINE
The single line compact view mode.static int
COMPACT_MODE_WIDE
The wide compact view mode.protected CmsAttributeChoiceWidget
m_addButton
The add button.protected CmsAttributeChoiceWidget
m_attributeChoice
The attribute choice button.protected com.google.gwt.user.client.ui.FlowPanel
m_buttonBar
The button bar.protected CmsPushButton
m_downButton
The down button.protected com.google.gwt.dom.client.DivElement
m_helpBubble
The help bubble element.protected CmsPushButton
m_helpBubbleClose
The help bubble close button.protected com.google.gwt.dom.client.DivElement
m_helpBubbleText
The help bubble text element.protected com.google.gwt.dom.client.SpanElement
m_messageText
The message text element.protected CmsAttributeValueView.MoveHandle
m_moveButton
The move button.protected CmsPushButton
m_removeButton
The remove button.protected CmsPushButton
m_upButton
The up button.protected com.google.gwt.user.client.ui.FlowPanel
m_widgetHolder
The widget holder elemenet.
-
Constructor Summary
Constructors Constructor Description CmsAttributeValueView(CmsAttributeHandler handler, java.lang.String label, java.lang.String help)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addChoice(I_CmsWidgetService widgetService, CmsChoiceMenuEntryBean menuEntry)
Adds a new choice choice selection menu.com.google.gwt.event.shared.HandlerRegistration
addMouseDownHandler(com.google.gwt.event.dom.client.MouseDownHandler handler)
com.google.gwt.event.shared.HandlerRegistration
addMouseOutHandler(com.google.gwt.event.dom.client.MouseOutHandler handler)
com.google.gwt.event.shared.HandlerRegistration
addMouseOverHandler(com.google.gwt.event.dom.client.MouseOverHandler handler)
protected void
addNewAttributeValue()
Adds a new attribute value.protected void
closeHelpBubble(com.google.gwt.event.dom.client.ClickEvent event)
Handles the click event to close the help bubble.com.google.gwt.user.client.ui.FlowPanel
getButtonBar()
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.com.google.gwt.dom.client.Element
getDragHelper(I_CmsDropTarget target)
Creates the drag helper element and attaches it into the DOM.CmsAttributeHandler
getHandler()
Returns the attribute handler.java.lang.String
getId()
Returns the draggable id.protected java.lang.String
getLabel()
Returns the attribute label.I_CmsDropTarget
getParentTarget()
Returns the parent drop target ornull
if there is none.CmsAttributeValueView
getParentView()
Gets the parent attribute value view, or null if none exists.com.google.gwt.dom.client.Element
getPlaceholder(I_CmsDropTarget target)
Creates the drag placeholder element.int
getValueIndex()
Returns the attribute value index.I_CmsEditWidget
getValueWidget()
Returns the editing widget.boolean
hasValue()
Returns if there is a value set for this attribute.void
hideAllButtons()
Hides the button bar.boolean
isDragEnabled()
Returns if drag and drop is enabled for this attribute.boolean
isSimpleValue()
Returns if this view represents a simple value.protected void
moveAttributeValueDown(com.google.gwt.event.dom.client.ClickEvent event)
Handles the click event to move the attribute value down.protected void
moveAttributeValueUp(com.google.gwt.event.dom.client.ClickEvent event)
Handles the click event to move the attribute value up.protected void
onAttach()
void
onDragCancel()
Executed on drag cancel.void
onDrop(I_CmsDropTarget target)
Executed on drop.protected void
onResize()
Call when content changes.void
onStartDrag(I_CmsDropTarget target)
Executed on drag start.boolean
owns(com.google.gwt.dom.client.Element element)
Checks if the attribute value view's widget "owns" the given element.protected void
removeAttributeValue(com.google.gwt.event.dom.client.ClickEvent event)
Handles the click event to remove the attribute value.void
removeValidationMessage()
Removes any present error message.void
removeValue()
Removes the value.void
resizeOnShow()
Adjusts widget's size once it's visible.protected void
selectChoice(java.util.List<java.lang.String> choicePath)
Selects the attribute choice.void
setActive()
Sets the value widget active and removes the inactive view styling.void
setCollapsed(boolean collapsed)
Enables or disables the "collapsed" style, which is used for choice elements to reduce the nesting level visually.void
setCompactMode(int mode)
Sets the compact view mode.void
setErrorMessage(java.lang.String message)
Shows a validation error message.void
setValueEntity(I_CmsEntityRenderer renderer, org.opencms.acacia.shared.CmsEntity value)
Sets the value entity.void
setValueWidget(I_CmsFormEditWidget widget, java.lang.String value, java.lang.String defaultValue, boolean active)
Sets the value widget.void
setWarningMessage(java.lang.String message)
Shows a validation warning message.void
showButtons()
Shows the button bar.void
toggleFocus(boolean focusOn)
Tells the attribute value view to change its display state between focused/unfocused (this doesn't actually change the focus).void
updateButtonVisibility(boolean hasAddButton, boolean hasRemoveButton, boolean hasSortButtons)
Updates the visibility of the add, remove, up and down buttons.-
Methods inherited from class com.google.gwt.user.client.ui.Composite
claimElement, getWidget, initializeClaimedElement, initWidget, isAttached, 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
-
ATTR_KEY
public static final java.lang.String ATTR_KEY
- See Also:
- Constant Field Values
-
COMPACT_MODE_FIRST_COLUMN
public static final int COMPACT_MODE_FIRST_COLUMN
The first column compact view mode.- See Also:
- Constant Field Values
-
COMPACT_MODE_NESTED
public static final int COMPACT_MODE_NESTED
The nested compact view mode.- See Also:
- Constant Field Values
-
COMPACT_MODE_SECOND_COLUMN
public static final int COMPACT_MODE_SECOND_COLUMN
The second column compact view mode.- See Also:
- Constant Field Values
-
COMPACT_MODE_SINGLE_LINE
public static final int COMPACT_MODE_SINGLE_LINE
The single line compact view mode.- See Also:
- Constant Field Values
-
COMPACT_MODE_WIDE
public static final int COMPACT_MODE_WIDE
The wide compact view mode.- See Also:
- Constant Field Values
-
ATTR_HAS_HOVER
public static final java.lang.String ATTR_HAS_HOVER
Attribute for marking menu bars that are actually menu bars which should open on hovering (rather than just a single button).- See Also:
- Constant Field Values
-
m_addButton
@UiField protected CmsAttributeChoiceWidget m_addButton
The add button.
-
m_attributeChoice
@UiField protected CmsAttributeChoiceWidget m_attributeChoice
The attribute choice button.
-
m_buttonBar
@UiField protected com.google.gwt.user.client.ui.FlowPanel m_buttonBar
The button bar.
-
m_downButton
@UiField protected CmsPushButton m_downButton
The down button.
-
m_helpBubble
@UiField protected com.google.gwt.dom.client.DivElement m_helpBubble
The help bubble element.
-
m_helpBubbleClose
@UiField protected CmsPushButton m_helpBubbleClose
The help bubble close button.
-
m_helpBubbleText
@UiField protected com.google.gwt.dom.client.DivElement m_helpBubbleText
The help bubble text element.
-
m_messageText
@UiField protected com.google.gwt.dom.client.SpanElement m_messageText
The message text element.
-
m_moveButton
@UiField(provided=true) protected CmsAttributeValueView.MoveHandle m_moveButton
The move button.
-
m_removeButton
@UiField protected CmsPushButton m_removeButton
The remove button.
-
m_upButton
@UiField protected CmsPushButton m_upButton
The up button.
-
m_widgetHolder
@UiField protected com.google.gwt.user.client.ui.FlowPanel m_widgetHolder
The widget holder elemenet.
-
-
Constructor Detail
-
CmsAttributeValueView
public CmsAttributeValueView(CmsAttributeHandler handler, java.lang.String label, java.lang.String help)
Constructor.- Parameters:
handler
- the attribute handlerlabel
- the attribute labelhelp
- the attribute help information
-
-
Method Detail
-
addChoice
public void addChoice(I_CmsWidgetService widgetService, CmsChoiceMenuEntryBean menuEntry)
Adds a new choice choice selection menu.- Parameters:
widgetService
- the widget service to use for labelsmenuEntry
- the menu entry bean for the choice
-
addMouseDownHandler
public com.google.gwt.event.shared.HandlerRegistration addMouseDownHandler(com.google.gwt.event.dom.client.MouseDownHandler handler)
- Specified by:
addMouseDownHandler
in interfacecom.google.gwt.event.dom.client.HasMouseDownHandlers
- See Also:
HasMouseDownHandlers.addMouseDownHandler(com.google.gwt.event.dom.client.MouseDownHandler)
-
addMouseOutHandler
public com.google.gwt.event.shared.HandlerRegistration addMouseOutHandler(com.google.gwt.event.dom.client.MouseOutHandler handler)
- Specified by:
addMouseOutHandler
in interfacecom.google.gwt.event.dom.client.HasMouseOutHandlers
- See Also:
HasMouseOutHandlers.addMouseOutHandler(com.google.gwt.event.dom.client.MouseOutHandler)
-
addMouseOverHandler
public com.google.gwt.event.shared.HandlerRegistration addMouseOverHandler(com.google.gwt.event.dom.client.MouseOverHandler handler)
- Specified by:
addMouseOverHandler
in interfacecom.google.gwt.event.dom.client.HasMouseOverHandlers
- See Also:
HasMouseOverHandlers.addMouseOverHandler(com.google.gwt.event.dom.client.MouseOverHandler)
-
getButtonBar
public com.google.gwt.user.client.ui.FlowPanel getButtonBar()
-
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()
-
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(org.opencms.gwt.client.dnd.I_CmsDropTarget)
-
getHandler
public CmsAttributeHandler getHandler()
Returns the attribute handler.- Returns:
- the attribute handler
-
getId
public java.lang.String getId()
Description copied from interface:I_CmsDraggable
Returns the draggable id.- Specified by:
getId
in interfaceI_CmsDraggable
- Returns:
- the id
- See Also:
I_CmsDraggable.getId()
-
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()
-
getParentView
public CmsAttributeValueView getParentView()
Gets the parent attribute value view, or null if none exists.- Returns:
- the parent attribute value view
-
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(org.opencms.gwt.client.dnd.I_CmsDropTarget)
-
getValueIndex
public int getValueIndex()
Returns the attribute value index.- Returns:
- the attribute value index
-
getValueWidget
public I_CmsEditWidget getValueWidget()
Returns the editing widget.- Returns:
- the editing widget or
null
if not available
-
hasValue
public boolean hasValue()
Returns if there is a value set for this attribute.- Returns:
true
if there is a value set for this attribute
-
hideAllButtons
public void hideAllButtons()
Hides the button bar.
-
isDragEnabled
public boolean isDragEnabled()
Returns if drag and drop is enabled for this attribute.- Returns:
true
if drag and drop is enabled for this attribute
-
isSimpleValue
public boolean isSimpleValue()
Returns if this view represents a simple value.- Returns:
true
if this view represents a simple value
-
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)
-
owns
public boolean owns(com.google.gwt.dom.client.Element element)
Checks if the attribute value view's widget "owns" the given element.- Parameters:
element
- the element to check- Returns:
- true if the widget owns the element
-
removeValidationMessage
public void removeValidationMessage()
Removes any present error message.
-
removeValue
public void removeValue()
Removes the value.
-
resizeOnShow
public void resizeOnShow()
Description copied from interface:I_CmsHasResizeOnShow
Adjusts widget's size once it's visible.- Specified by:
resizeOnShow
in interfaceI_CmsHasResizeOnShow
- See Also:
I_CmsHasResizeOnShow.resizeOnShow()
-
setActive
public void setActive()
Sets the value widget active and removes the inactive view styling.
-
setCollapsed
public void setCollapsed(boolean collapsed)
Enables or disables the "collapsed" style, which is used for choice elements to reduce the nesting level visually.- Parameters:
collapsed
- true if the view should be set to 'collapsed'
-
setCompactMode
public void setCompactMode(int mode)
Sets the compact view mode.- Parameters:
mode
- the mode to set
-
setErrorMessage
public void setErrorMessage(java.lang.String message)
Shows a validation error message.- Parameters:
message
- the error message
-
setValueEntity
public void setValueEntity(I_CmsEntityRenderer renderer, org.opencms.acacia.shared.CmsEntity value)
Sets the value entity.- Parameters:
renderer
- the entity renderervalue
- the value entity
-
setValueWidget
public void setValueWidget(I_CmsFormEditWidget widget, java.lang.String value, java.lang.String defaultValue, boolean active)
Sets the value widget.- Parameters:
widget
- the widgetvalue
- the valuedefaultValue
- the default attribute valueactive
-true
if the widget should be activated
-
setWarningMessage
public void setWarningMessage(java.lang.String message)
Shows a validation warning message.- Parameters:
message
- the warning message
-
showButtons
public void showButtons()
Shows the button bar.
-
toggleFocus
public void toggleFocus(boolean focusOn)
Tells the attribute value view to change its display state between focused/unfocused (this doesn't actually change the focus).- Parameters:
focusOn
-true
to change the display state to 'focused'
-
updateButtonVisibility
public void updateButtonVisibility(boolean hasAddButton, boolean hasRemoveButton, boolean hasSortButtons)
Updates the visibility of the add, remove, up and down buttons.- Parameters:
hasAddButton
-true
if the add button should be visiblehasRemoveButton
-true
if the remove button should be visiblehasSortButtons
-true
if the sort buttons should be visible
-
addNewAttributeValue
protected void addNewAttributeValue()
Adds a new attribute value.
-
closeHelpBubble
@UiHandler("m_helpBubbleClose") protected void closeHelpBubble(com.google.gwt.event.dom.client.ClickEvent event)
Handles the click event to close the help bubble.- Parameters:
event
- the click event
-
getLabel
protected java.lang.String getLabel()
Returns the attribute label.- Returns:
- the attribute label
-
moveAttributeValueDown
@UiHandler("m_downButton") protected void moveAttributeValueDown(com.google.gwt.event.dom.client.ClickEvent event)
Handles the click event to move the attribute value down.- Parameters:
event
- the click event
-
moveAttributeValueUp
@UiHandler("m_upButton") protected void moveAttributeValueUp(com.google.gwt.event.dom.client.ClickEvent event)
Handles the click event to move the attribute value up.- Parameters:
event
- the click event
-
onAttach
protected void onAttach()
- Overrides:
onAttach
in classcom.google.gwt.user.client.ui.Composite
- See Also:
Composite.onAttach()
-
onResize
protected void onResize()
Call when content changes.
-
removeAttributeValue
@UiHandler("m_removeButton") protected void removeAttributeValue(com.google.gwt.event.dom.client.ClickEvent event)
Handles the click event to remove the attribute value.- Parameters:
event
- the click event
-
selectChoice
protected void selectChoice(java.util.List<java.lang.String> choicePath)
Selects the attribute choice.- Parameters:
choicePath
- the choice attribute path
-
-