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.

  • Constructor Details

    • CmsAttributeHandler

      public CmsAttributeHandler(I_CmsEntityBackend entityBackEnd, org.opencms.acacia.shared.CmsEntity entity, String attributeName, I_CmsWidgetService widgetService)
      Constructor.

      Parameters:
      entityBackEnd - the entity back end instance
      entity - the entity
      attributeName - the attribute name
      widgetService - the widget service
  • Method Details

    • 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()
      Returns true 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

      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(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, List<String> choicePath)
      Adds a new choice attribute value.

      Parameters:
      reference - the reference value view
      choicePath - the path of the selected (possibly nested) choice attribute, consisting of attribute names
    • changeValue

      public void changeValue(String value, int valueIndex)
      Applies a value change to the entity data as well as to the value view widget.

      Parameters:
      value - the value
      valueIndex - the value index
    • collectSimplePath

      Description copied from interface: I_CmsAttributeHandler
      Returns the simple path.

      Specified by:
      collectSimplePath in interface I_CmsAttributeHandler
      Overrides:
      collectSimplePath in class CmsRootHandler
      Parameters:
      childHandler - the child attribute handler
      Returns:
      the simple path
      See Also:
    • createNestedEntitiesForChoicePath

      public void createNestedEntitiesForChoicePath(org.opencms.acacia.shared.CmsEntity value, List<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 inserted
      choicePath - the path of choice attributes
    • destroy

      public void destroy()
      Destroys the attribute handler instance.

    • getAttributeName

      Returns the attribute name.

      Specified by:
      getAttributeName in interface I_CmsAttributeHandler
      Overrides:
      getAttributeName in class CmsRootHandler
      Returns:
      the attribute name
      See Also:
    • getAttributeType

      public org.opencms.acacia.shared.CmsType getAttributeType()
      Returns the attribute type.

      Returns:
      the attribute type
    • getDNDHandler

      Returns the drag and drop handler.

      Returns:
      the drag and drop handler
    • getEntityId

      public 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 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

      Gets the widget service.

      Returns:
      the widget service
    • handleValueChange

      public void handleValueChange(CmsAttributeValueView reference, String value)
      Handles value changes from the view.

      Parameters:
      reference - the attribute value reference
      value - the value
    • handleValueChange

      public void handleValueChange(int valueIndex, String value)
      Handles value changes from the view.

      Parameters:
      valueIndex - the value index
      value - 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 entity
      index - the position in which to insert the new value
      container - 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 move
      currentPosition - the current position
      targetPosition - the target position
    • moveAttributeValueDown

      Moves the reference value down in the value list.

      Parameters:
      reference - the reference value
    • moveAttributeValueUp

      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

      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 view
      force - 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 index
      force - 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, String message, CmsTabbedPanel<?> tabbedPanel)
      Sets the error message for the given value index.

      Parameters:
      valueIndex - the value index
      message - the error message
      tabbedPanel - the forms tabbed panel if available
    • setHandlerById

      public void setHandlerById(String attributeName, CmsAttributeHandler handler)
      Description copied from interface: I_CmsAttributeHandler
      Sets the handler by id.

      Specified by:
      setHandlerById in interface I_CmsAttributeHandler
      Overrides:
      setHandlerById in class CmsRootHandler
      Parameters:
      attributeName - the attribute name
      handler - the handler
      See Also:
    • setParentHandler

      public void setParentHandler(I_CmsAttributeHandler handler)
      Sets the parent attribute handler.

      Parameters:
      handler - the parent attribute handler
    • setWarningMessage

      public void setWarningMessage(int valueIndex, String message, CmsTabbedPanel<?> tabbedPanel)
      Sets the warning message for the given value index.

      Parameters:
      valueIndex - the value index
      message - the warning message
      tabbedPanel - 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