Class CmsTinyMCEWidget

  • All Implemented Interfaces:
    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.ui.HasVisibility, com.google.gwt.user.client.ui.HasWidgets, com.google.gwt.user.client.ui.HasWidgets.ForIsWidget, com.google.gwt.user.client.ui.IndexedPanel, com.google.gwt.user.client.ui.IndexedPanel.ForIsWidget, com.google.gwt.user.client.ui.InsertPanel, com.google.gwt.user.client.ui.InsertPanel.ForIsWidget, com.google.gwt.user.client.ui.IsWidget, java.lang.Iterable<com.google.gwt.user.client.ui.Widget>, I_CmsHasInit, I_CmsFormWidget

    public final class CmsTinyMCEWidget
    extends com.google.gwt.user.client.ui.FlowPanel
    implements I_CmsFormWidget, com.google.gwt.event.logical.shared.HasResizeHandlers, I_CmsHasInit, com.google.gwt.event.logical.shared.HasValueChangeHandlers<java.lang.String>
    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 com.google.gwt.user.client.ui.HasWidgets

        com.google.gwt.user.client.ui.HasWidgets.ForIsWidget
      • Nested classes/interfaces inherited from interface com.google.gwt.user.client.ui.IndexedPanel

        com.google.gwt.user.client.ui.IndexedPanel.ForIsWidget
      • Nested classes/interfaces inherited from interface com.google.gwt.user.client.ui.InsertPanel

        com.google.gwt.user.client.ui.InsertPanel.ForIsWidget
    • Field Summary

      Fields 
      Modifier and Type Field Description
      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.
      static java.lang.String WIDGET_TYPE
      The widget type id.
      • Fields inherited from class com.google.gwt.user.client.ui.UIObject

        DEBUG_ID_PREFIX
    • Constructor Summary

      Constructors 
      Constructor Description
      CmsTinyMCEWidget​(java.lang.Object options)
      Creates a new instance with the given TinyMCE options.
      CmsTinyMCEWidget​(java.lang.String config)
      Creates a new instance based on configuration data from the server.
    • Method Summary

      All Methods Static 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.
      protected void fireValueChange​(boolean force)
      Fires a change event.
      java.lang.String getApparentValue()
      Returns the "apparent value", i.e.
      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.
      I_CmsFormWidget.FieldType getFieldType()
      Returns the type of data this widget produces.
      java.lang.Object getFormValue()
      Gets the selected/entered value from the widget.
      java.lang.String getFormValueAsString()
      Gets the current value of the widget as a string.
      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()
      Gets the value.
      static void initClass()
      Initializes this class.
      boolean isEnabled()
      Returns true if this widget is enabled.
      protected void onDetach()  
      protected void onLoad()  
      protected void onUnload()  
      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 refocusInlineEditor()
      Sets focus to the editor.
      protected void removeEditor()
      Removes the editor instance.
      void reset()
      Resets the widget to its default state.
      protected void scheduleRefocus()
      Schedules to reset the focus to the main element.
      void setAutoHideParent​(I_CmsAutoHider autoHideParent)
      Call this when auto hiding parents are shown.
      void setEnabled​(boolean enabled)
      Enables or disables the widget.
      void setErrorMessage​(java.lang.String errorMessage)
      Sets the error message for this widget.
      void setFormValueAsString​(java.lang.String value)
      Sets the current value of the widget as a string.
      protected void setMainElementContent​(java.lang.String html)
      Sets the main content of the element which is inline editable.
      protected void setPreviousValue​(java.lang.String previousValue)
      Sets the previous value.
      void setValue​(java.lang.String value, boolean fireEvents)
      Sets the value.
      • Methods inherited from class com.google.gwt.user.client.ui.FlowPanel

        add, clear, insert, insert
      • Methods inherited from class com.google.gwt.user.client.ui.ComplexPanel

        add, add, adjustIndex, checkIndexBoundsForAccess, checkIndexBoundsForInsertion, getChildren, getWidget, getWidgetCount, getWidgetIndex, getWidgetIndex, insert, insert, iterator, remove, remove
      • Methods inherited from class com.google.gwt.user.client.ui.Panel

        add, adopt, doAttachChildren, doDetachChildren, orphan, remove
      • Methods inherited from class com.google.gwt.user.client.ui.Widget

        addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, fireEvent, getHandlerCount, getLayoutData, getParent, isAttached, isOrWasAttached, onAttach, onBrowserEvent, 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.shared.HasHandlers

        fireEvent
      • Methods inherited from interface com.google.gwt.user.client.ui.IndexedPanel

        getWidget, getWidgetCount, getWidgetIndex, remove
      • Methods inherited from interface com.google.gwt.user.client.ui.IndexedPanel.ForIsWidget

        getWidgetIndex
      • Methods inherited from interface com.google.gwt.user.client.ui.InsertPanel.ForIsWidget

        add
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • Field Detail

      • 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​(java.lang.Object options)
        Creates a new instance with the given TinyMCE options. Use this constructor for form based editing.

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

        public CmsTinyMCEWidget​(java.lang.String config)
        Creates a new instance based on configuration data from the server.

        Parameters:
        config - the configuration data
    • Method Detail

      • initClass

        public static void initClass()
        Initializes this class.

      • 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<java.lang.String> handler)
        Specified by:
        addValueChangeHandler in interface com.google.gwt.event.logical.shared.HasValueChangeHandlers<java.lang.String>
        See Also:
        HasValueChangeHandlers.addValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler)
      • getMainElement

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

        Returns:
        the editable element
      • getValue

        public java.lang.String getValue()
        Gets the value.

        Returns:
        the value
      • setValue

        public void setValue​(java.lang.String value,
                             boolean fireEvents)
        Sets the value.

        Parameters:
        value - the value
        fireEvents - true if value change event should be fired
      • 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
      • fireValueChange

        protected void fireValueChange​(boolean force)
        Fires a change event.

        Parameters:
        force - true if the event should be fired even if the value does not differ from the previous one
      • 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
      • onDetach

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

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

        protected void onUnload()
        Overrides:
        onUnload in class com.google.gwt.user.client.ui.Widget
        See Also:
        Widget.onUnload()
      • 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
      • refocusInlineEditor

        protected void refocusInlineEditor()
        Sets focus to the editor. Use only when in line editing.

      • removeEditor

        protected void removeEditor()
        Removes the editor instance.

      • scheduleRefocus

        protected void scheduleRefocus()
        Schedules to reset the focus to the main element.

      • 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
      • setPreviousValue

        protected void setPreviousValue​(java.lang.String previousValue)
        Sets the previous value.

        Parameters:
        previousValue - the previous value to set