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.Panel
-
- com.google.gwt.user.client.ui.ComplexPanel
-
- com.google.gwt.user.client.ui.FlowPanel
-
- org.opencms.gwt.client.ui.input.tinymce.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 org.opencms.gwt.client.ui.input.I_CmsFormWidget
I_CmsFormWidget.FieldType
-
-
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.
-
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()
Returnstrue
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.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.user.client.ui.IndexedPanel
getWidget, getWidgetCount, getWidgetIndex, remove
-
-
-
-
Field Detail
-
NO_HTML_EDIT
public static final java.lang.String NO_HTML_EDIT
Use as option to disallow any HTML or formatting the content.- See Also:
- Constant Field Values
-
WIDGET_TYPE
public static final java.lang.String WIDGET_TYPE
The widget type id.- See Also:
- Constant Field Values
-
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 interfacecom.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 interfacecom.google.gwt.event.logical.shared.HasValueChangeHandlers<java.lang.String>
- See Also:
HasValueChangeHandlers.addValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler)
-
getApparentValue
public java.lang.String getApparentValue()
Description copied from interface:I_CmsFormWidget
Returns the "apparent value", i.e. either the real value if available, or else the ghost value if available, or null otherwise.- Specified by:
getApparentValue
in interfaceI_CmsFormWidget
- Returns:
- the apparent value
- See Also:
I_CmsFormWidget.getApparentValue()
-
getFieldType
public I_CmsFormWidget.FieldType getFieldType()
Description copied from interface:I_CmsFormWidget
Returns the type of data this widget produces.- Specified by:
getFieldType
in interfaceI_CmsFormWidget
- Returns:
- the data type
- See Also:
I_CmsFormWidget.getFieldType()
-
getFormValue
public java.lang.Object getFormValue()
Description copied from interface:I_CmsFormWidget
Gets the selected/entered value from the widget.- Specified by:
getFormValue
in interfaceI_CmsFormWidget
- Returns:
- the value
- See Also:
I_CmsFormWidget.getFormValue()
-
getFormValueAsString
public java.lang.String getFormValueAsString()
Description copied from interface:I_CmsFormWidget
Gets the current value of the widget as a string.- Specified by:
getFormValueAsString
in interfaceI_CmsFormWidget
- Returns:
- the current value of the widget
- See Also:
I_CmsFormWidget.getFormValueAsString()
-
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
-
isEnabled
public boolean isEnabled()
Description copied from interface:I_CmsFormWidget
Returnstrue
if this widget is enabled.- Specified by:
isEnabled
in interfaceI_CmsFormWidget
- Returns:
true
if this widget is enabled- See Also:
I_CmsFormWidget.isEnabled()
-
reset
public void reset()
Description copied from interface:I_CmsFormWidget
Resets the widget to its default state.- Specified by:
reset
in interfaceI_CmsFormWidget
- See Also:
I_CmsFormWidget.reset()
-
setAutoHideParent
public void setAutoHideParent(I_CmsAutoHider autoHideParent)
Description copied from interface:I_CmsFormWidget
Call this when auto hiding parents are shown.- Specified by:
setAutoHideParent
in interfaceI_CmsFormWidget
- Parameters:
autoHideParent
- the auto hide parent- See Also:
I_CmsFormWidget.setAutoHideParent(org.opencms.gwt.client.ui.I_CmsAutoHider)
-
setEnabled
public void setEnabled(boolean enabled)
Description copied from interface:I_CmsFormWidget
Enables or disables the widget.- Specified by:
setEnabled
in interfaceI_CmsFormWidget
- Parameters:
enabled
- if true, the widget will be enabled, else disabled- See Also:
Partial support: This only works before the actual TinyMCE instance is loaded.
-
setErrorMessage
public void setErrorMessage(java.lang.String errorMessage)
Description copied from interface:I_CmsFormWidget
Sets the error message for this widget.If the error message is null, no error message will be displayed.
- Specified by:
setErrorMessage
in interfaceI_CmsFormWidget
- Parameters:
errorMessage
- an error message or null- See Also:
I_CmsFormWidget.setErrorMessage(java.lang.String)
-
setFormValueAsString
public void setFormValueAsString(java.lang.String value)
Description copied from interface:I_CmsFormWidget
Sets the current value of the widget as a string.- Specified by:
setFormValueAsString
in interfaceI_CmsFormWidget
- Parameters:
value
- the new value of the widget- See Also:
I_CmsFormWidget.setFormValueAsString(java.lang.String)
-
setValue
public void setValue(java.lang.String value, boolean fireEvents)
Sets the value.- Parameters:
value
- the valuefireEvents
- 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 classcom.google.gwt.user.client.ui.Widget
- See Also:
Widget.onDetach()
-
onLoad
protected void onLoad()
- Overrides:
onLoad
in classcom.google.gwt.user.client.ui.Widget
- See Also:
Widget.onLoad()
-
onUnload
protected void onUnload()
- Overrides:
onUnload
in classcom.google.gwt.user.client.ui.Widget
- See Also:
Widget.onUnload()
-
propagateFocusEvent
protected void propagateFocusEvent()
Propagates the a focus event.
-
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 typeeventSource
- 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
-
-