Class CmsAttributeHandler

    • 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 instance
        entity - the entity
        attributeName - the attribute name
        widgetService - 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()
        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

        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 view
        choicePath - 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 value
        valueIndex - the value index
      • 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 inserted
        choicePath - the path of choice attributes
      • destroy

        public void destroy()
        Destroys the attribute handler instance.

      • getAttributeType

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

        Returns:
        the attribute type
      • 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
      • handleValueChange

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

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

        public void handleValueChange​(int valueIndex,
                                      java.lang.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
      • 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,
                                    java.lang.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
      • 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 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