Package org.opencms.acacia.client
Class CmsAttributeHandler
- java.lang.Object
-
- org.opencms.acacia.client.CmsRootHandler
-
- org.opencms.acacia.client.CmsAttributeHandler
-
- All Implemented Interfaces:
I_CmsAttributeHandler
public class CmsAttributeHandler extends CmsRootHandler
The attribute handler. Handles value changes, addition of new values, remove and move operations on values.
-
-
Field Summary
-
Fields inherited from class org.opencms.acacia.client.CmsRootHandler
m_handlers
-
-
Constructor Summary
Constructors Constructor Description CmsAttributeHandler(I_CmsEntityBackend entityBackEnd, org.opencms.acacia.shared.CmsEntity entity, java.lang.String attributeName, I_CmsWidgetService widgetService)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addNewAttributeValue(java.lang.String value)
Adds a new attribute value and adds the required widgets to the editor DOM.void
addNewAttributeValue(CmsAttributeValueView reference)
Adds a new attribute value below the reference view.void
addNewAttributeValue(org.opencms.acacia.shared.CmsEntity value)
Adds a new attribute value and adds the required widgets to the editor DOM.void
addNewAttributeValueToEntity(int referenceIndex)
Adds a new attribute value below the reference index.void
addNewChoiceAttributeValue(CmsAttributeValueView reference, java.util.List<java.lang.String> choicePath)
Adds a new choice attribute value.void
changeValue(java.lang.String value, int valueIndex)
Applies a value change to the entity data as well as to the value view widget.static void
clearErrorStyles(CmsTabbedPanel<?> tabbedPanel)
Clears the error styles on the given tabbed panel.java.lang.String
collectSimplePath(I_CmsAttributeHandler childHandler)
Returns the simple path.void
createNestedEntitiesForChoicePath(org.opencms.acacia.shared.CmsEntity value, java.util.List<java.lang.String> choicePath)
Creates a sequence of nested entities according to a given path of choice attribute names.void
destroy()
Destroys the attribute handler instance.java.lang.String
getAttributeName()
Returns the attribute name.org.opencms.acacia.shared.CmsType
getAttributeType()
Returns the attribute type.CmsDNDHandler
getDNDHandler()
Returns the drag and drop handler.java.lang.String
getEntityId()
Returns the entity id.int
getMaxOccurence()
Gets the maximum occurrence of the attribute.static com.google.gwt.event.logical.shared.ResizeHandler
getResizeHandler()
Returns the global widget resize handler.java.lang.String
getSimplePath(int index)
Returns the simple value path for the given index.I_CmsWidgetService
getWidgetService()
Gets the widget service.void
handleValueChange(int valueIndex, java.lang.String value)
Handles value changes from the view.void
handleValueChange(CmsAttributeValueView reference, java.lang.String value)
Handles value changes from the view.static boolean
hasResizeHandler()
Returnstrue
if a global widget resize handler is present.boolean
hasSingleOptionalValue()
Return true if there is a single remaining value, which is optional.boolean
hasValueView(int valueIndex)
Returns if there is a value view widget registered for the given index.void
insertNewAttributeValue(org.opencms.acacia.shared.CmsEntity value, int index, com.google.gwt.user.client.ui.Panel container)
Adds a new attribute value and adds the required widgets to the editor DOM.boolean
isChoiceHandler()
Returns if this is a choice handler.protected boolean
isSingleValueHandler()
Returns if the attribute handler is handling a single value only.void
moveAttributeValue(CmsAttributeValueView valueView, int currentPosition, int targetPosition)
Moves the give attribute value from one position to another.void
moveAttributeValueDown(CmsAttributeValueView reference)
Moves the reference value down in the value list.void
moveAttributeValueUp(CmsAttributeValueView reference)
Moves the reference value up in the value list.void
registerAttributeValue(CmsAttributeValueView attributeValue)
Registers an attribute value view.void
removeAttributeValue(int valueIndex)
Removes the attribute value from the given index, also manipulating the editor DOM to display the change.void
removeAttributeValue(CmsAttributeValueView reference)
Removes the reference attribute value view.void
removeAttributeValue(CmsAttributeValueView reference, boolean force)
Removes the reference attribute value view.com.google.gwt.user.client.ui.Panel
removeAttributeValueAndReturnPrevParent(int valueIndex, boolean force)
Removes the attribute value (and corresponding widget) with the given index, and returns the parent widget.void
removeAttributeValueFromEntity(int valueIndex)
Removes the attribute value with the given index.void
removeValidationMessages()
Removes validation messages for all views associated with this attribute handler.void
setErrorMessage(int valueIndex, java.lang.String message, CmsTabbedPanel<?> tabbedPanel)
Sets the error message for the given value index.void
setHandlerById(java.lang.String attributeName, CmsAttributeHandler handler)
Sets the handler by id.void
setParentHandler(I_CmsAttributeHandler handler)
Sets the parent attribute handler.static void
setResizeHandler(com.google.gwt.event.logical.shared.ResizeHandler handler)
Sets the global widget resize handler.static void
setScrollElement(com.google.gwt.dom.client.Element scrollElement)
Sets the scroll element.protected void
setSingleValueIndex(int valueIndex)
Sets the single value index.void
setWarningMessage(int valueIndex, java.lang.String message, CmsTabbedPanel<?> tabbedPanel)
Sets the warning message for the given value index.void
updateButtonVisibilty(CmsInlineEntityWidget inlineWidget)
Updates the add, remove and sort button visibility on the given inline widget or all registered attribute value views.void
updateButtonVisisbility()
Updates the add, remove and sort button visibility on all registered attribute value views.-
Methods inherited from class org.opencms.acacia.client.CmsRootHandler
clearHandlers, ensureHandlers, getChildHandler, getChildHandlerBySimpleName, getHandlerById, getHandlerByPath, getHandlersBySimplePath, initHandlers, insertHandlers, removeHandlers, setHandler, visit
-
-
-
-
Constructor Detail
-
CmsAttributeHandler
public CmsAttributeHandler(I_CmsEntityBackend entityBackEnd, org.opencms.acacia.shared.CmsEntity entity, java.lang.String attributeName, I_CmsWidgetService widgetService)
Constructor.- Parameters:
entityBackEnd
- the entity back end instanceentity
- the entityattributeName
- the attribute namewidgetService
- the widget service
-
-
Method Detail
-
clearErrorStyles
public static void clearErrorStyles(CmsTabbedPanel<?> tabbedPanel)
Clears the error styles on the given tabbed panel.- Parameters:
tabbedPanel
- the tabbed panel
-
getResizeHandler
public static com.google.gwt.event.logical.shared.ResizeHandler getResizeHandler()
Returns the global widget resize handler.- Returns:
- the global widget resize handler
-
hasResizeHandler
public static boolean hasResizeHandler()
Returnstrue
if a global widget resize handler is present.- Returns:
true
if a global widget resize handler is present
-
setResizeHandler
public static void setResizeHandler(com.google.gwt.event.logical.shared.ResizeHandler handler)
Sets the global widget resize handler.- Parameters:
handler
- the resize handler
-
setScrollElement
public static void setScrollElement(com.google.gwt.dom.client.Element scrollElement)
Sets the scroll element. To be used for automatic scrolling during drag and drop.- Parameters:
scrollElement
- the scroll element
-
addNewAttributeValue
public void addNewAttributeValue(CmsAttributeValueView reference)
Adds a new attribute value below the reference view.- Parameters:
reference
- the reference value view
-
addNewAttributeValue
public void addNewAttributeValue(org.opencms.acacia.shared.CmsEntity value)
Adds a new attribute value and adds the required widgets to the editor DOM.- Parameters:
value
- the value entity
-
addNewAttributeValue
public void addNewAttributeValue(java.lang.String value)
Adds a new attribute value and adds the required widgets to the editor DOM.- Parameters:
value
- the simple value
-
addNewAttributeValueToEntity
public void addNewAttributeValueToEntity(int referenceIndex)
Adds a new attribute value below the reference index.This will not execute any DOM manipulations.
- Parameters:
referenceIndex
- the reference value index
-
addNewChoiceAttributeValue
public void addNewChoiceAttributeValue(CmsAttributeValueView reference, java.util.List<java.lang.String> choicePath)
Adds a new choice attribute value.- Parameters:
reference
- the reference value viewchoicePath
- the path of the selected (possibly nested) choice attribute, consisting of attribute names
-
changeValue
public void changeValue(java.lang.String value, int valueIndex)
Applies a value change to the entity data as well as to the value view widget.- Parameters:
value
- the valuevalueIndex
- the value index
-
collectSimplePath
public java.lang.String collectSimplePath(I_CmsAttributeHandler childHandler)
Description copied from interface:I_CmsAttributeHandler
Returns the simple path.- Specified by:
collectSimplePath
in interfaceI_CmsAttributeHandler
- Overrides:
collectSimplePath
in classCmsRootHandler
- Parameters:
childHandler
- the child attribute handler- Returns:
- the simple path
- See Also:
CmsRootHandler.collectSimplePath(org.opencms.acacia.client.I_CmsAttributeHandler)
-
createNestedEntitiesForChoicePath
public void createNestedEntitiesForChoicePath(org.opencms.acacia.shared.CmsEntity value, java.util.List<java.lang.String> choicePath)
Creates a sequence of nested entities according to a given path of choice attribute names.- Parameters:
value
- the entity into which the new entities for the given path should be insertedchoicePath
- the path of choice attributes
-
destroy
public void destroy()
Destroys the attribute handler instance.
-
getAttributeName
public java.lang.String getAttributeName()
Returns the attribute name.- Specified by:
getAttributeName
in interfaceI_CmsAttributeHandler
- Overrides:
getAttributeName
in classCmsRootHandler
- Returns:
- the attribute name
- See Also:
I_CmsAttributeHandler.getAttributeName()
-
getAttributeType
public org.opencms.acacia.shared.CmsType getAttributeType()
Returns the attribute type.- Returns:
- the attribute type
-
getDNDHandler
public CmsDNDHandler getDNDHandler()
Returns the drag and drop handler.- Returns:
- the drag and drop handler
-
getEntityId
public java.lang.String getEntityId()
Returns the entity id.- Returns:
- the entity id
-
getMaxOccurence
public int getMaxOccurence()
Gets the maximum occurrence of the attribute.- Returns:
- the maximum occurrence
-
getSimplePath
public java.lang.String getSimplePath(int index)
Returns the simple value path for the given index.This will use the last fragment of the attribute name and concatenate it with the parent path.
If the given index equals -1 no value index will be appended
- Parameters:
index
- the value index- Returns:
- the simple path
-
getWidgetService
public I_CmsWidgetService getWidgetService()
Gets the widget service.- Returns:
- the widget service
-
handleValueChange
public void handleValueChange(CmsAttributeValueView reference, java.lang.String value)
Handles value changes from the view.- Parameters:
reference
- the attribute value referencevalue
- the value
-
handleValueChange
public void handleValueChange(int valueIndex, java.lang.String value)
Handles value changes from the view.- Parameters:
valueIndex
- the value indexvalue
- the value
-
hasSingleOptionalValue
public boolean hasSingleOptionalValue()
Return true if there is a single remaining value, which is optional.- Returns:
- true if this has only one optional value
-
hasValueView
public boolean hasValueView(int valueIndex)
Returns if there is a value view widget registered for the given index.- Parameters:
valueIndex
- the value index- Returns:
true
if there is a value view widget registered for the given index
-
insertNewAttributeValue
public void insertNewAttributeValue(org.opencms.acacia.shared.CmsEntity value, int index, com.google.gwt.user.client.ui.Panel container)
Adds a new attribute value and adds the required widgets to the editor DOM.- Parameters:
value
- the value entityindex
- the position in which to insert the new valuecontainer
- the widget containing the attribute value views
-
isChoiceHandler
public boolean isChoiceHandler()
Returns if this is a choice handler.- Returns:
true
if this is a choice handler
-
moveAttributeValue
public void moveAttributeValue(CmsAttributeValueView valueView, int currentPosition, int targetPosition)
Moves the give attribute value from one position to another.- Parameters:
valueView
- the value to movecurrentPosition
- the current positiontargetPosition
- the target position
-
moveAttributeValueDown
public void moveAttributeValueDown(CmsAttributeValueView reference)
Moves the reference value down in the value list.- Parameters:
reference
- the reference value
-
moveAttributeValueUp
public void moveAttributeValueUp(CmsAttributeValueView reference)
Moves the reference value up in the value list.- Parameters:
reference
- the reference value
-
registerAttributeValue
public void registerAttributeValue(CmsAttributeValueView attributeValue)
Registers an attribute value view.- Parameters:
attributeValue
- the attribute value view
-
removeAttributeValue
public void removeAttributeValue(CmsAttributeValueView reference)
Removes the reference attribute value view.- Parameters:
reference
- the reference view
-
removeAttributeValue
public void removeAttributeValue(CmsAttributeValueView reference, boolean force)
Removes the reference attribute value view.- Parameters:
reference
- the reference viewforce
-true
if the widget should be removed even if it is the last one
-
removeAttributeValue
public void removeAttributeValue(int valueIndex)
Removes the attribute value from the given index, also manipulating the editor DOM to display the change.- Parameters:
valueIndex
- the value index
-
removeAttributeValueAndReturnPrevParent
public com.google.gwt.user.client.ui.Panel removeAttributeValueAndReturnPrevParent(int valueIndex, boolean force)
Removes the attribute value (and corresponding widget) with the given index, and returns the parent widget.- Parameters:
valueIndex
- the value indexforce
-true
if the widget should be removed even if it is the last one- Returns:
- the parent widget
-
removeAttributeValueFromEntity
public void removeAttributeValueFromEntity(int valueIndex)
Removes the attribute value with the given index.This will not execute any DOM manipulations.
- Parameters:
valueIndex
- the index of the attribute value to remove
-
removeValidationMessages
public void removeValidationMessages()
Removes validation messages for all views associated with this attribute handler.
-
setErrorMessage
public void setErrorMessage(int valueIndex, java.lang.String message, CmsTabbedPanel<?> tabbedPanel)
Sets the error message for the given value index.- Parameters:
valueIndex
- the value indexmessage
- the error messagetabbedPanel
- the forms tabbed panel if available
-
setHandlerById
public void setHandlerById(java.lang.String attributeName, CmsAttributeHandler handler)
Description copied from interface:I_CmsAttributeHandler
Sets the handler by id.- Specified by:
setHandlerById
in interfaceI_CmsAttributeHandler
- Overrides:
setHandlerById
in classCmsRootHandler
- Parameters:
attributeName
- the attribute namehandler
- the handler- See Also:
CmsRootHandler.setHandlerById(java.lang.String, org.opencms.acacia.client.CmsAttributeHandler)
-
setParentHandler
public void setParentHandler(I_CmsAttributeHandler handler)
Sets the parent attribute handler.- Parameters:
handler
- the parent attribute handler
-
setWarningMessage
public void setWarningMessage(int valueIndex, java.lang.String message, CmsTabbedPanel<?> tabbedPanel)
Sets the warning message for the given value index.- Parameters:
valueIndex
- the value indexmessage
- the warning messagetabbedPanel
- the forms tabbed panel if available
-
updateButtonVisibilty
public void updateButtonVisibilty(CmsInlineEntityWidget inlineWidget)
Updates the add, remove and sort button visibility on the given inline widget or all registered attribute value views.- Parameters:
inlineWidget
- the inline widget
-
updateButtonVisisbility
public void updateButtonVisisbility()
Updates the add, remove and sort button visibility on all registered attribute value views.
-
isSingleValueHandler
protected boolean isSingleValueHandler()
Returns if the attribute handler is handling a single value only.- Returns:
true
if the attribute handler is handling a single value only
-
setSingleValueIndex
protected void setSingleValueIndex(int valueIndex)
Sets the single value index.- Parameters:
valueIndex
- the value index
-
-