Class CmsEditorBase

java.lang.Object
org.opencms.acacia.client.CmsEditorBase
All Implemented Interfaces:
I_CmsInlineHtmlUpdateHandler
Direct Known Subclasses:
CmsContentEditor

public class CmsEditorBase extends Object implements I_CmsInlineHtmlUpdateHandler
The content editor base.

  • Field Details

  • Constructor Details

    • CmsEditorBase

      public CmsEditorBase(org.opencms.acacia.shared.rpc.I_CmsContentServiceAsync service, I_CmsWidgetService widgetService)
      Constructor.

      Parameters:
      service - the content service
      widgetService - the widget service to use
  • Method Details

    • getMessageForKey

      public static String getMessageForKey(String key, Object... args)
      Returns the formated message.

      Parameters:
      key - the message key
      args - the parameters to insert into the placeholders
      Returns:
      the formated message
    • hasDictionary

      public static boolean hasDictionary()
      Returns if the messages dictionary is set.

      Returns:
      true if the messages dictionary is set
    • markForInlineFocus

      public static void markForInlineFocus(com.google.gwt.dom.client.Element element)
      Marks the given element to receive focus once the inline editing is initialized.

      Parameters:
      element - the element to mark
    • setDictionary

      public static void setDictionary(com.google.gwt.i18n.client.Dictionary dictionary)
      Sets the m_dictionary.

      Parameters:
      dictionary - the m_dictionary to set
    • shouldFocusOnInlineEdit

      public static boolean shouldFocusOnInlineEdit(com.google.gwt.dom.client.Element element)
      Checks whether the given element is marked to receive focus once the inline editing is initialized.

      Parameters:
      element - the element to check
      Returns:
      true if the given element is marked to receive focus once the inline editing is initialized
    • addEntityChangeHandler

      public void addEntityChangeHandler(String entityId, com.google.gwt.event.logical.shared.ValueChangeHandler<org.opencms.acacia.shared.CmsEntity> handler)
      Adds the value change handler to the entity with the given id.

      Parameters:
      entityId - the entity id
      handler - the change handler
    • addValidationChangeHandler

      public com.google.gwt.event.shared.HandlerRegistration addValidationChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler<CmsValidationContext> handler)
      Adds a validation change handler.

      Parameters:
      handler - the validation change handler
      Returns:
      the handler registration
    • destroyForm

      public void destroyForm(boolean clearEntities)
      Destroys the form and related resources. Also clears all entities from the entity back-end

      Parameters:
      clearEntities - true to also clear all entities
    • getCurrentEntity

      public org.opencms.acacia.shared.CmsEntity getCurrentEntity()
      Returns the currently edited entity.

      Returns:
      the currently edited entity
    • getFormTabs

      Returns editor form tabs or null in case no tabs are used.

      Returns:
      the editor form tabs
    • getService

      public org.opencms.acacia.shared.rpc.I_CmsContentServiceAsync getService()
      Returns the content service instance.

      Returns:
      the content service
    • loadContentDefinition

      public void loadContentDefinition(String entityId, com.google.gwt.user.client.Command callback)
      Loads the content definition for the given entity and executes the callback on success.

      Parameters:
      entityId - the entity id
      callback - the callback
    • registerContentDefinition

      public void registerContentDefinition(org.opencms.acacia.shared.CmsContentDefinition definition)
      Registers the types and entities of the given content definition.

      Parameters:
      definition - the content definition
    • reinitWidgets

      public void reinitWidgets(I_CmsInlineFormParent formParent)
      Description copied from interface: I_CmsInlineHtmlUpdateHandler
      Reinitializes the editing widget inside the form parent.

      Specified by:
      reinitWidgets in interface I_CmsInlineHtmlUpdateHandler
      Parameters:
      formParent - the form parent
      See Also:
    • renderEntityForm

      public void renderEntityForm(String entityId, List<org.opencms.acacia.shared.CmsTabInfo> tabInfos, com.google.gwt.user.client.ui.Panel context, com.google.gwt.dom.client.Element scrollParent)
      Renders the entity form within the given context.

      Parameters:
      entityId - the entity id
      tabInfos - the tab informations
      context - the context element
      scrollParent - the scroll element to be used for automatic scrolling during drag and drop
    • renderEntityForm

      public void renderEntityForm(String entityId, com.google.gwt.user.client.ui.Panel context, com.google.gwt.dom.client.Element scrollParent)
      Renders the entity form within the given context.

      Parameters:
      entityId - the entity id
      context - the context element
      scrollParent - the scroll element to be used for automatic scrolling during drag and drop
    • renderInlineEntity

      public void renderInlineEntity(String entityId, I_CmsInlineFormParent formParent)
      Renders the entity form within the given context.

      Parameters:
      entityId - the entity id
      formParent - the form parent widget
    • rerenderForm

      public void rerenderForm(org.opencms.acacia.shared.CmsEntity newContent)
      Re-renders the form with the given entity data.

      Parameters:
      newContent - the entity data
    • saveEntities

      public void saveEntities(List<org.opencms.acacia.shared.CmsEntity> entities, boolean clearOnSuccess, com.google.gwt.user.client.Command callback)
      Saves the given entities.

      Parameters:
      entities - the entities to save
      clearOnSuccess - true to clear the entity back-end instance on success
      callback - the call back command
    • saveEntities

      public void saveEntities(Set<String> entityIds, boolean clearOnSuccess, com.google.gwt.user.client.Command callback)
      Saves the given entity.

      Parameters:
      entityIds - the entity ids
      clearOnSuccess - true to clear all entities from entity back-end on success
      callback - the callback executed on success
    • saveEntity

      public void saveEntity(org.opencms.acacia.shared.CmsEntity entity, boolean clearOnSuccess, com.google.gwt.user.client.Command callback)
      Saves the given entity.

      Parameters:
      entity - the entity
      clearOnSuccess - true to clear all entities from entity back-end on success
      callback - the callback executed on success
    • saveEntity

      public void saveEntity(String entityId, boolean clearOnSuccess, com.google.gwt.user.client.Command callback)
      Saves the given entity.

      Parameters:
      entityId - the entity id
      clearOnSuccess - true to clear all entities from entity back-end on success
      callback - the callback executed on success
    • saveEntity

      public void saveEntity(String entityId, com.google.gwt.user.client.Command callback)
      Saves the given entity.

      Parameters:
      entityId - the entity id
      callback - the callback executed on success
    • updateHtml

      public void updateHtml(I_CmsInlineFormParent formParent, com.google.gwt.user.client.Command onSuccess)
      Description copied from interface: I_CmsInlineHtmlUpdateHandler
      Updates the HTML inside the form parent according to the currently edited entiy data.

      Specified by:
      updateHtml in interface I_CmsInlineHtmlUpdateHandler
      Parameters:
      formParent - the form parent
      onSuccess - the callback to execute on success
      See Also:
    • addOverlayClickHandler

      protected com.google.gwt.event.shared.HandlerRegistration addOverlayClickHandler(com.google.gwt.event.dom.client.ClickHandler handler)
      Adds a click handler to the edit overlay.

      Parameters:
      handler - the click handler
      Returns:
      the click handler registration
    • clearEditor

      protected void clearEditor()
      Clears the editor.

    • getContextUri

      protected String getContextUri()
      Returns the context URI.

      Needed when updating the HTML due to content data changes.

      Override to supply the required info.

      Returns:
      the context URI
    • getHtmlContextInfo

      Returns the in-line HTML context info.

      Needed when updating the HTML due to content data changes.

      Override to supply the required info.

      Returns:
      the HTML context info
    • getRootAttributeHandler

      Returns the root attribute handler.

      Returns:
      the root attribute handler
    • getValidationHandler

      Returns the validation handler.

      Returns:
      the validation handler
    • getWidgetService

      Returns the widget service.

      Returns:
      the widget service
    • initEditOverlay

      protected void initEditOverlay(com.google.gwt.dom.client.Element element)
      Initializes the edit overlay to be positioned around the given element.

      Parameters:
      element - the element
    • onRpcError

      protected void onRpcError(Throwable caught)
      Handles RPC errors.

      Override this for better error handling

      Parameters:
      caught - the error caught from the RPC
    • removeEditOverlays

      protected void removeEditOverlays()
      Removes the edit overlay from the DOM.

    • updateOverlayPosition

      protected void updateOverlayPosition()
      Updates the edit overlay position.