Class CmsTinyMCEWidget

java.lang.Object
com.google.gwt.user.client.ui.UIObject
com.google.gwt.user.client.ui.Widget
com.google.gwt.user.client.ui.FocusWidget
org.opencms.acacia.client.widgets.A_CmsEditWidget
org.opencms.acacia.client.widgets.CmsTinyMCEWidget
All Implemented Interfaces:
com.google.gwt.event.dom.client.HasAllDragAndDropHandlers, com.google.gwt.event.dom.client.HasAllFocusHandlers, com.google.gwt.event.dom.client.HasAllGestureHandlers, com.google.gwt.event.dom.client.HasAllKeyHandlers, com.google.gwt.event.dom.client.HasAllMouseHandlers, com.google.gwt.event.dom.client.HasAllTouchHandlers, com.google.gwt.event.dom.client.HasBlurHandlers, com.google.gwt.event.dom.client.HasClickHandlers, com.google.gwt.event.dom.client.HasDoubleClickHandlers, com.google.gwt.event.dom.client.HasDragEndHandlers, com.google.gwt.event.dom.client.HasDragEnterHandlers, com.google.gwt.event.dom.client.HasDragHandlers, com.google.gwt.event.dom.client.HasDragLeaveHandlers, com.google.gwt.event.dom.client.HasDragOverHandlers, com.google.gwt.event.dom.client.HasDragStartHandlers, com.google.gwt.event.dom.client.HasDropHandlers, com.google.gwt.event.dom.client.HasFocusHandlers, com.google.gwt.event.dom.client.HasGestureChangeHandlers, com.google.gwt.event.dom.client.HasGestureEndHandlers, com.google.gwt.event.dom.client.HasGestureStartHandlers, com.google.gwt.event.dom.client.HasKeyDownHandlers, com.google.gwt.event.dom.client.HasKeyPressHandlers, com.google.gwt.event.dom.client.HasKeyUpHandlers, com.google.gwt.event.dom.client.HasMouseDownHandlers, com.google.gwt.event.dom.client.HasMouseMoveHandlers, com.google.gwt.event.dom.client.HasMouseOutHandlers, com.google.gwt.event.dom.client.HasMouseOverHandlers, com.google.gwt.event.dom.client.HasMouseUpHandlers, com.google.gwt.event.dom.client.HasMouseWheelHandlers, com.google.gwt.event.dom.client.HasTouchCancelHandlers, com.google.gwt.event.dom.client.HasTouchEndHandlers, com.google.gwt.event.dom.client.HasTouchMoveHandlers, com.google.gwt.event.dom.client.HasTouchStartHandlers, com.google.gwt.event.logical.shared.HasAttachHandlers, com.google.gwt.event.logical.shared.HasResizeHandlers, com.google.gwt.event.logical.shared.HasValueChangeHandlers<String>, com.google.gwt.event.shared.HasHandlers, com.google.gwt.user.client.EventListener, com.google.gwt.user.client.TakesValue<String>, com.google.gwt.user.client.ui.Focusable, com.google.gwt.user.client.ui.HasEnabled, com.google.gwt.user.client.ui.HasFocus, com.google.gwt.user.client.ui.HasValue<String>, com.google.gwt.user.client.ui.HasVisibility, com.google.gwt.user.client.ui.IsWidget, com.google.gwt.user.client.ui.SourcesClickEvents, com.google.gwt.user.client.ui.SourcesFocusEvents, com.google.gwt.user.client.ui.SourcesKeyboardEvents, com.google.gwt.user.client.ui.SourcesMouseEvents, I_CmsEditWidget, I_CmsHasDisplayDirection

public final class CmsTinyMCEWidget extends A_CmsEditWidget implements com.google.gwt.event.logical.shared.HasResizeHandlers, I_CmsHasDisplayDirection
This class is used to start TinyMCE for editing the content of an element.

After constructing the instance, the actual editor is opened using the init() method, and destroyed with the close() method. While the editor is opened, the edited contents can be accessed using the methods of the HasValue interface.

  • Nested Class Summary

    Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject

    com.google.gwt.user.client.ui.UIObject.DebugIdImpl, com.google.gwt.user.client.ui.UIObject.DebugIdImplEnabled

    Nested classes/interfaces inherited from interface org.opencms.acacia.client.widgets.I_CmsHasDisplayDirection

    I_CmsHasDisplayDirection.Direction
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected boolean
    A flag which indicates whether the editor is currently active.
    protected String
    The current content.
    protected com.google.gwt.core.client.JavaScriptObject
    The TinyMCE editor instance.
    protected String
    The DOM ID of the editable element.
    protected String
    The original HTML content of the editable element.
    protected int
    The maximal width of the widget.
    static final String
    Use as option to disallow any HTML or formatting the content.

    Fields inherited from class com.google.gwt.user.client.ui.UIObject

    DEBUG_ID_PREFIX
  • Constructor Summary

    Constructors
    Constructor
    Description
    CmsTinyMCEWidget(com.google.gwt.dom.client.Element element, Object options)
    Creates a new instance for the given element.
    Creates a new instance with the given options.
  • Method Summary

    Modifier and Type
    Method
    Description
    com.google.gwt.event.shared.HandlerRegistration
    addResizeHandler(com.google.gwt.event.logical.shared.ResizeHandler handler)
     
    com.google.gwt.event.shared.HandlerRegistration
    addValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler<String> handler)
     
    protected void
    Checks whether the necessary Javascript libraries are available by accessing them.
    protected String
    ensureId(com.google.gwt.dom.client.Element element)
    Gives an element an id if it doesn't already have an id, and then returns the element's id.
    Returns the display direction.
    protected com.google.gwt.dom.client.Element
    Returns the editor parent element.
    protected com.google.gwt.dom.client.Element
    Gets an element by its id.
    com.google.gwt.dom.client.Element
    Gets the main editable element.
    protected com.google.gwt.dom.client.Element
    Gets the toolbar element.
     
    boolean
    Returns if the widget is active.
    protected boolean
    Returns if the widget is used in inline mode.
    protected void
     
    protected void
     
    protected void
    Propagates the a focus event.
    protected void
    propagateMouseEvent(String eventType, com.google.gwt.dom.client.Element eventSource)
    Propagates a native mouse event.
    protected void
    Removes the editor instance.
    void
    setActive(boolean active)
    Sets the widget active/inactive.
    protected void
    Sets the main content of the element which is inline editable.
    void
    Sets the name of input fields.
    void
    setTypografLocale(String typografLocale)
    Sets the Typograf locale for inline editing mode.
    void
     
    void
    setValue(String value, boolean fireEvents)
     
    protected boolean
    Checks if the main element contains the current text selection.

    Methods inherited from class org.opencms.acacia.client.widgets.A_CmsEditWidget

    fireValueChange, getPreviousValue, onAttachWidget, owns, setPreviousValue

    Methods inherited from class com.google.gwt.user.client.ui.FocusWidget

    addBlurHandler, addClickHandler, addClickListener, addDoubleClickHandler, addDragEndHandler, addDragEnterHandler, addDragHandler, addDragLeaveHandler, addDragOverHandler, addDragStartHandler, addDropHandler, addFocusHandler, addFocusListener, addGestureChangeHandler, addGestureEndHandler, addGestureStartHandler, addKeyboardListener, addKeyDownHandler, addKeyPressHandler, addKeyUpHandler, addMouseDownHandler, addMouseListener, addMouseMoveHandler, addMouseOutHandler, addMouseOverHandler, addMouseUpHandler, addMouseWheelHandler, addMouseWheelListener, addTouchCancelHandler, addTouchEndHandler, addTouchMoveHandler, addTouchStartHandler, getFocusImpl, getTabIndex, isEnabled, removeClickListener, removeFocusListener, removeKeyboardListener, removeMouseListener, removeMouseWheelListener, setAccessKey, setEnabled, setFocus, setTabIndex

    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, isAttached, isOrWasAttached, onBrowserEvent, 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, resolvePotentialElement, 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 com.google.gwt.event.dom.client.HasFocusHandlers

    addFocusHandler

    Methods inherited from interface com.google.gwt.event.shared.HasHandlers

    fireEvent

    Methods inherited from interface org.opencms.acacia.client.widgets.I_CmsEditWidget

    shouldSetDefaultWhenDisabled

    Methods inherited from interface com.google.gwt.user.client.ui.IsWidget

    asWidget
  • Field Details

    • NO_HTML_EDIT

      public static final String NO_HTML_EDIT
      Use as option to disallow any HTML or formatting the content.
      See Also:
    • m_active

      protected boolean m_active
      A flag which indicates whether the editor is currently active.
    • m_currentContent

      The current content.
    • m_editor

      protected com.google.gwt.core.client.JavaScriptObject m_editor
      The TinyMCE editor instance.
    • m_id

      protected String m_id
      The DOM ID of the editable element.
    • m_originalContent

      The original HTML content of the editable element.
    • m_width

      protected int m_width
      The maximal width of the widget.
  • Constructor Details

    • CmsTinyMCEWidget

      public CmsTinyMCEWidget(com.google.gwt.dom.client.Element element, Object options)
      Creates a new instance for the given element. Use this constructor for in line editing.

      Parameters:
      element - the DOM element
      options - the tinyMCE editor options to extend the default settings
    • CmsTinyMCEWidget

      public CmsTinyMCEWidget(Object options)
      Creates a new instance with the given options. Use this constructor for form based editing.

      Parameters:
      options - the tinyMCE editor options to extend the default settings
  • Method Details

    • addResizeHandler

      public com.google.gwt.event.shared.HandlerRegistration addResizeHandler(com.google.gwt.event.logical.shared.ResizeHandler handler)
      Specified by:
      addResizeHandler in interface com.google.gwt.event.logical.shared.HasResizeHandlers
      See Also:
      • HasResizeHandlers.addResizeHandler(com.google.gwt.event.logical.shared.ResizeHandler)
    • addValueChangeHandler

      public com.google.gwt.event.shared.HandlerRegistration addValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler<String> handler)
      Specified by:
      addValueChangeHandler in interface com.google.gwt.event.logical.shared.HasValueChangeHandlers<String>
      Specified by:
      addValueChangeHandler in interface I_CmsEditWidget
      Specified by:
      addValueChangeHandler in class A_CmsEditWidget
      See Also:
    • getDisplayingDirection

      Description copied from interface: I_CmsHasDisplayDirection
      Returns the display direction.

      Specified by:
      getDisplayingDirection in interface I_CmsHasDisplayDirection
      Returns:
      the display direction
      See Also:
    • getMainElement

      public com.google.gwt.dom.client.Element getMainElement()
      Gets the main editable element.

      Returns:
      the editable element
    • getValue

      public String getValue()
      Specified by:
      getValue in interface com.google.gwt.user.client.ui.HasValue<String>
      Specified by:
      getValue in interface com.google.gwt.user.client.TakesValue<String>
      Overrides:
      getValue in class A_CmsEditWidget
      See Also:
      • HasValue.getValue()
    • isActive

      public boolean isActive()
      Description copied from interface: I_CmsEditWidget
      Returns if the widget is active.

      Specified by:
      isActive in interface I_CmsEditWidget
      Returns:
      true if the widget is active
      See Also:
    • setActive

      public void setActive(boolean active)
      Description copied from interface: I_CmsEditWidget
      Sets the widget active/inactive.

      Specified by:
      setActive in interface I_CmsEditWidget
      Parameters:
      active - true to activate the widget
      See Also:
    • setName

      public void setName(String name)
      Description copied from interface: I_CmsEditWidget
      Sets the name of input fields.

      Specified by:
      setName in interface I_CmsEditWidget
      Parameters:
      name - of the input field
      See Also:
    • setTypografLocale

      public void setTypografLocale(String typografLocale)
      Sets the Typograf locale for inline editing mode.
    • setValue

      public void setValue(String value)
      Specified by:
      setValue in interface com.google.gwt.user.client.ui.HasValue<String>
      Specified by:
      setValue in interface com.google.gwt.user.client.TakesValue<String>
      See Also:
      • HasValue.setValue(java.lang.Object)
    • setValue

      public void setValue(String value, boolean fireEvents)
      Specified by:
      setValue in interface com.google.gwt.user.client.ui.HasValue<String>
      Specified by:
      setValue in interface I_CmsEditWidget
      See Also:
      • HasValue.setValue(java.lang.Object, boolean)
    • checkLibraries

      protected void checkLibraries()
      Checks whether the necessary Javascript libraries are available by accessing them.
    • ensureId

      protected String ensureId(com.google.gwt.dom.client.Element element)
      Gives an element an id if it doesn't already have an id, and then returns the element's id.

      Parameters:
      element - the element for which we want to add the id
      Returns:
      the id
    • getEditorParentElement

      protected com.google.gwt.dom.client.Element getEditorParentElement()
      Returns the editor parent element.

      Returns:
      the editor parent element
    • getElementById

      protected com.google.gwt.dom.client.Element getElementById(String id)
      Gets an element by its id.

      Parameters:
      id - the id
      Returns:
      the element with the given id
    • getToolbarElement

      protected com.google.gwt.dom.client.Element getToolbarElement()
      Gets the toolbar element.

      Returns:
      the toolbar element
    • isInline

      protected boolean isInline()
      Returns if the widget is used in inline mode.

      Returns:
      true if the widget is used in inline mode
    • onAttach

      protected void onAttach()
      Overrides:
      onAttach in class com.google.gwt.user.client.ui.FocusWidget
      See Also:
      • FocusWidget.onAttach()
    • onDetach

      protected void onDetach()
      Overrides:
      onDetach in class com.google.gwt.user.client.ui.Widget
      See Also:
      • Widget.onDetach()
    • propagateFocusEvent

      protected void propagateFocusEvent()
      Propagates the a focus event.

    • propagateMouseEvent

      protected void propagateMouseEvent(String eventType, com.google.gwt.dom.client.Element eventSource)
      Propagates a native mouse event.

      Parameters:
      eventType - the mouse event type
      eventSource - the event source
    • removeEditor

      protected void removeEditor()
      Removes the editor instance.

    • setMainElementContent

      protected void setMainElementContent(String html)
      Sets the main content of the element which is inline editable.

      Parameters:
      html - the new content html
    • shouldReceiveFocus

      protected boolean shouldReceiveFocus()
      Checks if the main element contains the current text selection.

      Returns:
      true if the main element contains the current text selection