Class WTextEdit
public class WTextEdit extends WTextArea
The editor provides interactive editing of XHTML text. By default it provides basic mark-up (font, formatting, color, links, and lists), but additional buttons may be added to the tool bars that add additional formatting options.
The implementation is based on TinyMCE. The widget
may be configured and tailored using the setConfigurationSetting()
and related methods that provide direct access to the
underlying TinyMCE component.
You can use this widget with TinyMCE version 3 or version 4.
The choice is global and set using Configuration#setTinyMCEVersion(int).
CSS
Styling through CSS is not applicable.
Default configuration of a WTextEdit
-
Nested Class Summary
Nested classes/interfaces inherited from class eu.webtoolkit.jwt.WObject
WObject.FormData
-
Field Summary
Fields inherited from class eu.webtoolkit.jwt.WInteractWidget
dragTouchEndSlot_, dragTouchSlot_
-
Constructor Summary
Constructors Constructor Description WTextEdit()
Creates a new text editor.WTextEdit(WContainerWidget parent)
Creates a new text editor.WTextEdit(java.lang.String text)
Creates a new text editor and initialize with given text.WTextEdit(java.lang.String text, WContainerWidget parent)
Creates a new text editor and initialize with given text. -
Method Summary
Modifier and Type Method Description protected int
boxBorder(Orientation orientation)
Returns the widget's built-in border width.protected int
boxPadding(Orientation orientation)
Returns the widget's built-in padding.java.lang.Object
getConfigurationSetting(java.lang.String name)
Returns a TinyMCE configuration setting's value.protected void
getDomChanges(java.util.List<DomElement> result, WApplication app)
Get DOM changes for this widget.java.lang.String
getExtraPlugins()
Returns the extra plugins.java.lang.String
getStyleSheet()
Returns the content stylesheet.java.lang.String
getToolBar(int i)
Returns a tool bar configuration.int
getVersion()
Returns the TinyMCE version.void
propagateSetEnabled(boolean enabled)
Propagates that a widget was enabled or disabled through children.void
remove()
Destructor.JSignal
rendered()
Signal emitted when rendered.void
resize(WLength width, WLength height)
Resizes the widget.void
setConfigurationSetting(java.lang.String name, java.lang.Object value)
Configure a TinyMCE setting.void
setExtraPlugins(java.lang.String plugins)
Loads additional TinyMCE plugins.void
setPlaceholderText(java.lang.CharSequence placeholder)
Sets the placeholder text.void
setReadOnly(boolean readOnly)
Sets the element read-only.void
setStyleSheet(java.lang.String uri)
Sets the stylesheet for displaying the content.void
setText(java.lang.String text)
Sets the content.void
setToolBar(int i, java.lang.String config)
Configures a tool bar.Methods inherited from class eu.webtoolkit.jwt.WTextArea
getColumns, getCursorPosition, getRows, getSelectedText, getSelectionStart, getText, getValueText, hasSelectedText, setColumns, setFormData, setRows, setValueText, textInput
Methods inherited from class eu.webtoolkit.jwt.WFormWidget
changed, enableAjax, getEmptyText, getLabel, getPlaceholderText, getTabIndex, getValidator, isCanReceiveFocus, isReadOnly, refresh, render, selected, setEmptyText, setEnabled, setHidden, setToolTip, setValidator, validate, validated
Methods inherited from class eu.webtoolkit.jwt.WInteractWidget
clicked, doubleClicked, enterPressed, escapePressed, gestureChanged, gestureEnded, gestureStarted, getMouseOverDelay, isEnabled, keyPressed, keyWentDown, keyWentUp, load, mouseDragged, mouseMoved, mouseWentDown, mouseWentOut, mouseWentOver, mouseWentUp, mouseWheel, setDraggable, setDraggable, setDraggable, setDraggable, setMouseOverDelay, setPopup, touchEnded, touchMoved, touchStarted, unsetDraggable
Methods inherited from class eu.webtoolkit.jwt.WWebWidget
addStyleClass, blurred, callJavaScriptMember, childrenChanged, createDomElement, doJavaScript, escapeText, escapeText, escapeText, escapeText, find, findById, focussed, getAttributeValue, getBaseZIndex, getChildren, getClearSides, getDecorationStyle, getFloatSide, getHeight, getHtmlTagName, getId, getJavaScriptMember, getLineHeight, getMargin, getMaximumHeight, getMaximumWidth, getMinimumHeight, getMinimumWidth, getOffset, getPositionScheme, getScrollVisibilityMargin, getStyleClass, getToolTip, getVerticalAlignment, getVerticalAlignmentLength, getWidth, hasFocus, hasStyleClass, isDisabled, isHidden, isHiddenKeepsGeometry, isInline, isLoaded, isPopup, isRendered, isScrollVisibilityEnabled, isScrollVisible, isSetFirstFocus, isThemeStyleEnabled, isVisible, jsStringLiteral, jsStringLiteral, parentResized, parentResized, propagateSetVisible, removeScript, removeStyleClass, scrollVisibilityChanged, setAttributeValue, setBaseZIndex, setCanReceiveFocus, setClearSides, setDecorationStyle, setDeferredToolTip, setDisabled, setFloatSide, setFocus, setHiddenKeepsGeometry, setHtmlTagName, setId, setInline, setJavaScriptMember, setLineHeight, setLoadLaterWhenInvisible, setMargin, setMaximumSize, setMinimumSize, setOffsets, setPositionScheme, setScrollVisibilityEnabled, setScrollVisibilityMargin, setSelectable, setStyleClass, setTabIndex, setThemeStyleEnabled, setVerticalAlignment, updateSignalConnection, voidEventSignal
Methods inherited from class eu.webtoolkit.jwt.WWidget
acceptDrops, acceptDrops, addCssRule, addCssRule, addJSignal, addStyleClass, animateHide, animateShow, createJavaScript, disable, dropEvent, enable, getDropTouch, getJsRef, getParent, hide, htmlText, isExposed, isLayoutSizeAware, layoutSizeChanged, needsRerender, positionAt, positionAt, removeChild, removeStyleClass, render, resize, scheduleRender, scheduleRender, scheduleRender, setClearSides, setDeferredToolTip, setFocus, setHeight, setHidden, setLayoutSizeAware, setMargin, setMargin, setMargin, setMargin, setMargin, setObjectName, setOffsets, setOffsets, setOffsets, setOffsets, setOffsets, setToolTip, setVerticalAlignment, setWidth, show, stopAcceptDrops, toggleStyleClass, toggleStyleClass, tr
Methods inherited from class eu.webtoolkit.jwt.WObject
addChild, getObjectName
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
WTextEdit
Creates a new text editor. -
WTextEdit
public WTextEdit()Creates a new text editor. -
WTextEdit
Creates a new text editor and initialize with given text.The
text
should be valid XHTML. -
WTextEdit
public WTextEdit(java.lang.String text)Creates a new text editor and initialize with given text.
-
-
Method Details
-
remove
public void remove()Destructor.- Overrides:
remove
in classWFormWidget
- See Also:
WContainerWidget.removeWidget(WWidget widget)
-
getVersion
public int getVersion()Returns the TinyMCE version.This returns the configured version of TinyMCE (currently 3 or 4).
-
setText
public void setText(java.lang.String text)Sets the content.The
text
should be valid XHTML.The default value is "".
-
setStyleSheet
public void setStyleSheet(java.lang.String uri)Sets the stylesheet for displaying the content.The content is rendered using the rules defined in this stylesheet. The stylesheet is also used to derive additional styles that are available in the text editor, for example in the "styleselect" button.
Multiple stylesheets may be specified as a comma separated list.
-
getStyleSheet
public java.lang.String getStyleSheet()Returns the content stylesheet.- See Also:
setStyleSheet(String uri)
-
setExtraPlugins
public void setExtraPlugins(java.lang.String plugins)Loads additional TinyMCE plugins.Wt loads by default only the plugin 'safari' (which adds support for the Safari web browser). Use this method to load additional plugins. Multiple plugins may be specified as a comma separated list.
The various plugins are described in the TinyMCE documentation.
Note: Plugins can only be loaded before the initial display of the widget.
-
getExtraPlugins
public java.lang.String getExtraPlugins()Returns the extra plugins.- See Also:
setExtraPlugins(String plugins)
-
setToolBar
public void setToolBar(int i, java.lang.String config)Configures a tool bar.This configures the buttons for the
i'th
tool bar (with 0 <=i
<= 3).TinyMCE 3
The syntax and available buttons is documented in the TinyMCE documentation.
The default config for the first tool bar (
i
= 0) is: "fontselect, |, bold, italic, underline, |, fontsizeselect, |, forecolor, backcolor, |, justifyleft, justifycenter, justifyright, justifyfull, |, anchor, |, numlist, bullist".By default, the other three tool bars are disabled (
config
= "").TinyMCE 4
The syntax and available buttons is documented in the TinyMCEdocumentation.
The default config for the first tool bar (
i
= 0) is: "undo redo | styleselect | bold italic | link".Some buttons are only available after loading extra plugins using
setExtraPlugins()
.Note: The tool bar configuration can only be set before the initial display of the widget.
-
getToolBar
public java.lang.String getToolBar(int i)Returns a tool bar configuration.- See Also:
setToolBar(int i, String config)
-
setConfigurationSetting
public void setConfigurationSetting(java.lang.String name, java.lang.Object value)Configure a TinyMCE setting.A list of possible settings can be found at: http://tinymce.moxiecode.com/wiki.php/Configuration
The widget itself will also define a number of configuration settings and these may be overridden using this method.
-
getConfigurationSetting
public java.lang.Object getConfigurationSetting(java.lang.String name)Returns a TinyMCE configuration setting's value.An empty boost::any is returned when no value could be found for the provided argument.
-
setPlaceholderText
public void setPlaceholderText(java.lang.CharSequence placeholder)Sets the placeholder text.This method is not supported on
WTextEdit
and will thrown an exception instead.- Overrides:
setPlaceholderText
in classWFormWidget
-
setReadOnly
public void setReadOnly(boolean readOnly)Description copied from class:WFormWidget
Sets the element read-only.A read-only form element cannot be edited, but the contents can still be selected.
By default, a form element area is not read-only.
- Overrides:
setReadOnly
in classWFormWidget
- See Also:
WFormWidget.setEnabled(boolean enabled)
-
propagateSetEnabled
public void propagateSetEnabled(boolean enabled)Description copied from class:WWidget
Propagates that a widget was enabled or disabled through children.When enabling or disabling a widget, you usually also want to disable contained children. This method is called by
setDisabled()
to propagate its state to all children.You may want to reimplement this method if they wish to render differently when a widget is disabled. The default implementation will propagate the signal to all children.
- Overrides:
propagateSetEnabled
in classWFormWidget
-
resize
Description copied from class:WWidget
Resizes the widget.Specifies a fixed size for this widget, setting CSS
width
andheight
properties. By default a widget has automatic width and height, which sets a size for the widget following CSS rules.When the widget is not managed by a layout manager, the automatic (natural) size of a widget depends on whether they widget is a block or inline widget:
- a block widget takes by default the width of the parent, and the height that it needs based on its contents
- an inline widget takes the width and height that it needs based on its contents (possibly wrapping over multiple lines). The width and height of an inline widget cannot be changed (by the letter of CSS, although most browsers will react to it in varying ways).
When inserted in a layout manager, the size set will be used as a widget's preferred size, but the widget may be given a different size by the layout manager based on available space and stretch factors. The actual size given by a layout manager may be retrieved by making the widget "layout size aware", using
setLayoutSizeAware()
. If you have defined a"wtResize()"
JavaScript method for the widget, then this method will also be called.The default width and height of a widget is
WLength.Auto
.- Overrides:
resize
in classWWebWidget
- See Also:
WWidget.getWidth()
,WWidget.getHeight()
-
rendered
Signal emitted when rendered.A text edit is instantiated asynchronously as it depends on additional JavaScript libraries and initialization. This signal is emitted when the component is initialized. The underlying TinyMCE editor component is accessible as
WWidget.getJsRef()
+ ".ed". -
getDomChanges
Description copied from class:WWebWidget
Get DOM changes for this widget.This is an internal function, and should not be called directly, or be overridden!
- Overrides:
getDomChanges
in classWWebWidget
-
boxPadding
Description copied from class:WWidget
Returns the widget's built-in padding.This is used by the layout managers to correct for a built-in padding which interferes with setting a widget's width (or height) to 100%.
A layout manager needs to set the width to 100% only for form widgets (
WTextArea
,WLineEdit
,WComboBox
, etc...). Therefore, only for those widgets this needs to return the padding (the default implementation returns 0).For form widgets, the padding depends on the specific browser/platform combination, unless an explicit padding is set for the widget.
When setting an explicit padding for the widget using a style class, you will want to reimplement this method to return this padding in case you want to set the widget inside a layout manager.
- Overrides:
boxPadding
in classWTextArea
- See Also:
WWidget.boxBorder(Orientation orientation)
-
boxBorder
Description copied from class:WWidget
Returns the widget's built-in border width.This is used by the layout managers to correct for a built-in border which interferes with setting a widget's width (or height) to 100%.
A layout manager needs to set the width to 100% only for form widgets (
WTextArea
,WLineEdit
,WComboBox
, etc...). Therefore, only for those widgets this needs to return the border width (the default implementation returns 0).For form widgets, the border width depends on the specific browser/platform combination, unless an explicit border is set for the widget.
When setting an explicit border for the widget using a style class, you will want to reimplement this method to return this border width, in case you want to set the widget inside a layout manager.
- Overrides:
boxBorder
in classWTextArea
- See Also:
WWidget.boxPadding(Orientation orientation)
-