Class 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<java.lang.String>, com.google.gwt.event.shared.HasHandlers, com.google.gwt.user.client.EventListener, com.google.gwt.user.client.TakesValue<java.lang.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<java.lang.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
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected boolean m_active
      A flag which indicates whether the editor is currently active.
      protected java.lang.String m_currentContent
      The current content.
      protected com.google.gwt.core.client.JavaScriptObject m_editor
      The TinyMCE editor instance.
      protected java.lang.String m_id
      The DOM ID of the editable element.
      protected java.lang.String m_originalContent
      The original HTML content of the editable element.
      protected int m_width
      The maximal width of the widget.
      static java.lang.String NO_HTML_EDIT
      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, java.lang.Object options)
      Creates a new instance for the given element.
      CmsTinyMCEWidget​(java.lang.Object options)
      Creates a new instance with the given options.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      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<java.lang.String> handler)  
      protected void checkLibraries()
      Checks whether the necessary Javascript libraries are available by accessing them.
      protected java.lang.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.
      I_CmsHasDisplayDirection.Direction getDisplayingDirection()
      Returns the display direction.
      protected com.google.gwt.dom.client.Element getEditorParentElement()
      Returns the editor parent element.
      protected com.google.gwt.dom.client.Element getElementById​(java.lang.String id)
      Gets an element by its id.
      com.google.gwt.dom.client.Element getMainElement()
      Gets the main editable element.
      protected com.google.gwt.dom.client.Element getToolbarElement()
      Gets the toolbar element.
      java.lang.String getValue()  
      boolean isActive()
      Returns if the widget is active.
      protected boolean isInline()
      Returns if the widget is used in inline mode.
      protected void onAttach()  
      protected void onDetach()  
      protected void propagateFocusEvent()
      Propagates the a focus event.
      protected void propagateMouseEvent​(java.lang.String eventType, com.google.gwt.dom.client.Element eventSource)
      Propagates a native mouse event.
      protected void removeEditor()
      Removes the editor instance.
      void setActive​(boolean active)
      Sets the widget active/inactive.
      protected void setMainElementContent​(java.lang.String html)
      Sets the main content of the element which is inline editable.
      void setName​(java.lang.String name)
      Sets the name of input fields.
      void setValue​(java.lang.String value)  
      void setValue​(java.lang.String value, boolean fireEvents)  
      protected boolean shouldReceiveFocus()
      Checks if the main element contains the current text selection.
      • 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 com.google.gwt.user.client.ui.IsWidget

        asWidget
    • Field Detail

      • m_active

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

        protected java.lang.String m_currentContent
        The current content.
      • m_editor

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

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

        protected java.lang.String m_originalContent
        The original HTML content of the editable element.
      • m_width

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

      • CmsTinyMCEWidget

        public CmsTinyMCEWidget​(com.google.gwt.dom.client.Element element,
                                java.lang.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​(java.lang.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 Detail

      • 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)
      • getMainElement

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

        Returns:
        the editable element
      • getValue

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

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

        public void setValue​(java.lang.String value,
                             boolean fireEvents)
        Specified by:
        setValue in interface com.google.gwt.user.client.ui.HasValue<java.lang.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 java.lang.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​(java.lang.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()
      • propagateMouseEvent

        protected void propagateMouseEvent​(java.lang.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​(java.lang.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