public class RichTextEditor
extends org.eclipse.swt.widgets.Composite
Browser with enabled Javascript that shows a simple
HTML template containing a ckeditor as rich text editor.
The following style bits are supported:
SWT.RESIZE - specify if the resize function of ckeditor is enabled (mostly used for
embedded usage)SWT.MIN - specify if the configured minimum dimensions should be applied to the
resize function of ckeditorSWT.EMBEDDED - specify if the rich text editor is used in embedded mode (e.g. as a
cell editor of a JFace viewer)SWT.MOZILLA or SWT.WEBKIT can be set to
specify the native browser that should be used for rendering
| Modifier and Type | Class and Description |
|---|---|
(package private) class |
RichTextEditor.FocusInFunction
Callback function that is called via Javascript if the editor gains focus.
|
(package private) class |
RichTextEditor.FocusOutFunction
Callback function that is called via Javascript on blur in the editor part.
|
(package private) class |
RichTextEditor.JavaExecutionFinishedFunction
Callback function that is called via Javascript after a java callback is triggered via custom
toolbar button.
|
(package private) class |
RichTextEditor.JavaExecutionStartedFunction
Callback function that is called via Javascript before a java callback is triggered via
custom toolbar button.
|
(package private) class |
RichTextEditor.KeyPressedFunction
Callback function that is called via Javascript if a keydown event occurs in the editor part.
|
(package private) class |
RichTextEditor.KeyReleasedFunction
Callback function that is called via Javascript if a keyup event occurs in the editor part.
|
(package private) class |
RichTextEditor.ModifyFunction
Callback function that is called via Javascript if a change event occurs in the editor part.
|
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
JAR_UNPACK_LOCATION_PROPERTY
Key of the system property to specify a fixed directory to unpack the ckeditor resources to.
|
protected org.eclipse.swt.graphics.Rectangle |
resizedBounds |
| Constructor and Description |
|---|
RichTextEditor(org.eclipse.swt.widgets.Composite parent)
Creates a
RichTextEditor that wraps a Browser using the style bit
SWT.NONE and the default RichTextEditorConfiguration. |
RichTextEditor(org.eclipse.swt.widgets.Composite parent,
int style)
Creates a
RichTextEditor that wraps a Browser using the given style bit
and the default RichTextEditorConfiguration. |
RichTextEditor(org.eclipse.swt.widgets.Composite parent,
RichTextEditorConfiguration editorConfig)
Creates a
RichTextEditor that wraps a Browser using the style bit
SWT.NONE and the given RichTextEditorConfiguration. |
RichTextEditor(org.eclipse.swt.widgets.Composite parent,
RichTextEditorConfiguration editorConfig,
int style)
Creates a
RichTextEditor that wraps a Browser using the given style bit
and the given RichTextEditorConfiguration. |
RichTextEditor(org.eclipse.swt.widgets.Composite parent,
ToolbarConfiguration toolbarConfig)
Deprecated.
use constructors that take a
RichTextEditorConfiguration |
RichTextEditor(org.eclipse.swt.widgets.Composite parent,
ToolbarConfiguration toolbarConfig,
int style)
Deprecated.
use constructors that take a
RichTextEditorConfiguration |
| Modifier and Type | Method and Description |
|---|---|
void |
addFocusListener(org.eclipse.swt.events.FocusListener listener) |
void |
addJavaCallbackListener(JavaCallbackListener listener)
Add a
JavaCallbackListener that is triggered on executing a Java callback via custom
ToolbarButton. |
void |
addKeyListener(org.eclipse.swt.events.KeyListener listener) |
void |
addModifyListener(org.eclipse.swt.events.ModifyListener listener)
Adds the listener to the collection of listeners who will be notified when the receiver's
text is modified, by sending it one of the messages defined in the
ModifyListener interface. |
void |
addToolbarButton(ToolbarButton button)
Adds the given
ToolbarButton to the toolbar of the editor. |
void |
addToolbarButton(ToolbarButton button,
org.eclipse.swt.browser.BrowserFunction function)
Adds the given
ToolbarButton to the toolbar of the editor. |
void |
dispose() |
java.lang.Object |
evaluateJavascript(java.lang.String script)
Evaluates the specified script in the internal
Browser and returns the result. |
boolean |
executeJavascript(java.lang.String script)
Executes the specified script in the internal
Browser. |
boolean |
forceFocus() |
RichTextEditorConfiguration |
getEditorConfiguration()
This method returns the
RichTextEditorConfiguration that is used to configure this
RichTextEditor. |
protected int |
getMinimumHeight()
Returns the minimum height that should be used for initially open the editor in embedded
mode.
|
protected int |
getMinimumWidth()
Returns the minimum width that should be used for initially open the editor in embedded mode.
|
java.lang.String |
getSelectedHTML()
Returns the current selected text containing the markup tags for styling.
|
java.lang.String |
getSelectedText()
Returns the current selected text without any markup tags.
|
java.lang.String |
getText() |
void |
insertHTML(java.lang.String html)
Inserts HTML code into the currently selected position in the editor in WYSIWYG mode.
|
void |
insertText(java.lang.String text)
Insert text content into the currently selected position in the editor in WYSIWYG mode.
|
boolean |
isEditable()
Returns the editable state.
|
boolean |
isFocusControl() |
boolean |
isHandleFocusChanges() |
void |
notifyFocusGained(org.eclipse.swt.events.FocusEvent event)
Notify the registered
FocusListener that the editor gained focus. |
void |
notifyFocusLost(org.eclipse.swt.events.FocusEvent event)
Notify the registered
FocusListener that the editor lost focus. |
void |
notifyKeyPressed(org.eclipse.swt.events.KeyEvent event)
Notify the registered
KeyListener that a key was pressed. |
void |
notifyKeyReleased(org.eclipse.swt.events.KeyEvent event)
Notify the registered
KeyListener that a key was released. |
void |
notifyModifyListeners(org.eclipse.swt.events.ModifyEvent event)
Notifies all of the receiver's listeners when the receiver's text is modified.
|
void |
removeFocusListener(org.eclipse.swt.events.FocusListener listener) |
void |
removeJavaCallbackListener(JavaCallbackListener listener)
Remove a
JavaCallbackListener that is triggered on executing a Java callback via
custom ToolbarButton. |
void |
removeKeyListener(org.eclipse.swt.events.KeyListener listener) |
void |
removeModifyListener(org.eclipse.swt.events.ModifyListener listener)
Removes the listener from the collection of listeners who will be notified when the
receiver's text is modified.
|
void |
removeToolbarButton(ToolbarButton button)
Removes the given
ToolbarButton from the toolbar of the editor. |
void |
setBounds(int x,
int y,
int width,
int height) |
void |
setBounds(org.eclipse.swt.graphics.Rectangle rect) |
void |
setEditable(boolean editable)
Sets the editable state.
|
boolean |
setFocus() |
void |
setHandleFocusChanges(boolean handleFocusChanges)
Configure whether focus changes should be handled or not.
|
(package private) void |
setInlineContainerBounds(int x,
int y,
int width,
int height)
Used in embedded mode to support manual resizing of the editor.
|
void |
setLanguage(java.util.Locale locale)
Sets the user interface language localization to use.
|
void |
setLanguage(java.util.Locale locale,
boolean update) |
void |
setLanguage(java.lang.String language)
Sets the user interface language localization to use.
|
void |
setLanguage(java.lang.String language,
boolean update) |
void |
setText(java.lang.String text)
Set text to the editing area.
|
void |
setVisible(boolean visible) |
void |
updateEditor()
Update the editor.
|
void |
updateToolbar()
Update the toolbar.
|
changed, checkSubclass, drawBackground, getBackgroundMode, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, layout, setBackgroundMode, setLayout, setLayoutDeferred, setTabListcomputeTrim, getClientArea, getHorizontalBar, getScrollbarsMode, getVerticalBaraddControlListener, addDragDetectListener, addGestureListener, addHelpListener, addMenuDetectListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addMouseWheelListener, addPaintListener, addTouchListener, addTraverseListener, computeSize, computeSize, dragDetect, dragDetect, getAccessible, getBackground, getBackgroundImage, getBorderWidth, getBounds, getCursor, getDragDetect, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getOrientation, getParent, getRegion, getShell, getSize, getTextDirection, getToolTipText, getTouchEnabled, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, print, redraw, redraw, removeControlListener, removeDragDetectListener, removeGestureListener, removeHelpListener, removeMenuDetectListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removeMouseWheelListener, removePaintListener, removeTouchListener, removeTraverseListener, requestLayout, setBackground, setBackgroundImage, setCapture, setCursor, setDragDetect, setEnabled, setFont, setForeground, setLayoutData, setLocation, setLocation, setMenu, setOrientation, setParent, setRedraw, setRegion, setSize, setSize, setTextDirection, setToolTipText, setTouchEnabled, toControl, toControl, toDisplay, toDisplay, traverse, traverse, traverse, updateaddDisposeListener, addListener, checkWidget, getData, getData, getDisplay, getListeners, getStyle, isAutoDirection, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, reskin, setData, setData, toStringprotected org.eclipse.swt.graphics.Rectangle resizedBounds
public static final java.lang.String JAR_UNPACK_LOCATION_PROPERTY
public RichTextEditor(org.eclipse.swt.widgets.Composite parent)
RichTextEditor that wraps a Browser using the style bit
SWT.NONE and the default RichTextEditorConfiguration.parent - the parent composite where this rich text editor should be added to@Deprecated
public RichTextEditor(org.eclipse.swt.widgets.Composite parent,
ToolbarConfiguration toolbarConfig)
RichTextEditorConfigurationRichTextEditor that wraps a Browser using the style bit
SWT.NONE and creates a RichTextEditorConfiguration out of the given
ToolbarConfiguration.parent - the parent composite where this rich text editor should be added totoolbarConfig - the ToolbarConfiguration to
use or null for using the default
ToolbarConfigurationpublic RichTextEditor(org.eclipse.swt.widgets.Composite parent,
RichTextEditorConfiguration editorConfig)
RichTextEditor that wraps a Browser using the style bit
SWT.NONE and the given RichTextEditorConfiguration.parent - the parent composite where this rich text editor should be added toeditorConfig - the RichTextEditorConfiguration to use or null for using the default
RichTextEditorConfigurationpublic RichTextEditor(org.eclipse.swt.widgets.Composite parent,
int style)
RichTextEditor that wraps a Browser using the given style bit
and the default RichTextEditorConfiguration.parent - the parent composite where this rich text editor should be added tostyle - the style of widget to construct, see Browser for further style bit
information@Deprecated
public RichTextEditor(org.eclipse.swt.widgets.Composite parent,
ToolbarConfiguration toolbarConfig,
int style)
RichTextEditorConfigurationRichTextEditor that wraps a Browser using the given style bit and
creates a RichTextEditorConfiguration out of the given ToolbarConfiguration.parent - the parent composite where this rich text editor should be added totoolbarConfig - the ToolbarConfiguration to use or null for using the default
ToolbarConfigurationstyle - the style of widget to construct, see Browser for further style bit
informationBrowserpublic RichTextEditor(org.eclipse.swt.widgets.Composite parent,
RichTextEditorConfiguration editorConfig,
int style)
RichTextEditor that wraps a Browser using the given style bit
and the given RichTextEditorConfiguration.parent - the parent composite where this rich text editor should be added toeditorConfig - the RichTextEditorConfiguration to use or null for using the default
RichTextEditorConfigurationstyle - the style of widget to construct, see Browser for further style bit
informationBrowserpublic void dispose()
dispose in class org.eclipse.swt.widgets.Widgetpublic void setVisible(boolean visible)
setVisible in class org.eclipse.swt.widgets.Controlpublic java.lang.String getText()
public void setText(java.lang.String text)
text - The text to set to the editing area.public void insertText(java.lang.String text)
text - Text to be inserted into the editor.public void insertHTML(java.lang.String html)
html - HTML code to be inserted into the editor.public java.lang.String getSelectedText()
public java.lang.String getSelectedHTML()
Note: It will not contain the parent tag.
public boolean isEditable()
public void updateToolbar()
public void updateEditor()
public void setEditable(boolean editable)
editable - the new editable statepublic RichTextEditorConfiguration getEditorConfiguration()
RichTextEditorConfiguration that is used to configure this
RichTextEditor. It can be used to change some configurations at runtime.
Note: After configuration values have been changed it is necessary to call
updateEditor() so the configurations are applied.
RichTextEditorConfiguration used to configure this
RichTextEditor.public void setLanguage(java.util.Locale locale)
Locale will be used. This method triggers an immediate update of the editor instance.locale - The user interface language localization to use.public void setLanguage(java.util.Locale locale,
boolean update)
locale - The user interface language localization to use.update - true if the editor should be updated immediately, false
if the update should not be executed. In that case updateEditor() needs
to be executed explicitly.public void setLanguage(java.lang.String language)
language - The user interface language localization to use.public void setLanguage(java.lang.String language,
boolean update)
language - The user interface language localization to use.update - true if the editor should be updated immediately, false
if the update should not be executed. In that case updateEditor() needs
to be executed explicitly.public void addToolbarButton(ToolbarButton button)
ToolbarButton to the toolbar of the editor.button - The button to add.RichTextEditorConfiguration.addToolbarButton(ToolbarButton)public void addToolbarButton(ToolbarButton button, org.eclipse.swt.browser.BrowserFunction function)
ToolbarButton to the toolbar of the editor. Uses the given
BrowserFunction as callback for the button.button - The button to add.function - The function to use as callback.RichTextEditorConfiguration.addToolbarButton(ToolbarButton, BrowserFunction)public void removeToolbarButton(ToolbarButton button)
ToolbarButton from the toolbar of the editor.button - The button to remove.RichTextEditorConfiguration.removeToolbarButton(ToolbarButton)public boolean setFocus()
setFocus in class org.eclipse.swt.widgets.Compositepublic boolean forceFocus()
forceFocus in class org.eclipse.swt.widgets.Controlpublic boolean isFocusControl()
isFocusControl in class org.eclipse.swt.widgets.Controlpublic void addFocusListener(org.eclipse.swt.events.FocusListener listener)
addFocusListener in class org.eclipse.swt.widgets.Controlpublic void removeFocusListener(org.eclipse.swt.events.FocusListener listener)
removeFocusListener in class org.eclipse.swt.widgets.Controlpublic void notifyFocusGained(org.eclipse.swt.events.FocusEvent event)
FocusListener that the editor gained focus.event - The event to fire.public void notifyFocusLost(org.eclipse.swt.events.FocusEvent event)
FocusListener that the editor lost focus.event - The event to fire.public void setBounds(org.eclipse.swt.graphics.Rectangle rect)
setBounds in class org.eclipse.swt.widgets.Controlpublic void setBounds(int x,
int y,
int width,
int height)
setBounds in class org.eclipse.swt.widgets.Controlvoid setInlineContainerBounds(int x,
int y,
int width,
int height)
x - the new x coordinate for the receivery - the new y coordinate for the receiverwidth - the new width for the receiverheight - the new height for the receiverprotected int getMinimumHeight()
SWT.MIN. Using the default RichTextEditorConfiguration this is
150 for the toolbar and 50 for showing one row in the editor area.SWT.MINprotected int getMinimumWidth()
SWT.MIN. Using the default RichTextEditorConfiguration this is 370 for
showing the default options in three lines of the toolbar.SWT.MINpublic boolean executeJavascript(java.lang.String script)
Browser. Can be used to execute
Javascript directly in the browser from a listener if necessary.script - the script with javascript commandstrue if the operation was successful and false otherwiseBrowser.execute(String)public java.lang.Object evaluateJavascript(java.lang.String script)
Browser and returns the result. Can be
used to evaluate Javascript directly in the browser from a listener if necessary.script - the script with javascript commandsBrowser.evaluate(String)public boolean isHandleFocusChanges()
true if focus changes are handled, false if notpublic void setHandleFocusChanges(boolean handleFocusChanges)
handleFocusChanges - true if focus changes should be handled, false if notpublic void addKeyListener(org.eclipse.swt.events.KeyListener listener)
addKeyListener in class org.eclipse.swt.widgets.Controlpublic void removeKeyListener(org.eclipse.swt.events.KeyListener listener)
removeKeyListener in class org.eclipse.swt.widgets.Controlpublic void notifyKeyPressed(org.eclipse.swt.events.KeyEvent event)
KeyListener that a key was pressed.event - The event to fire.public void notifyKeyReleased(org.eclipse.swt.events.KeyEvent event)
KeyListener that a key was released.event - The event to fire.public void addModifyListener(org.eclipse.swt.events.ModifyListener listener)
ModifyListener interface.listener - the listener which should be notifiedjava.lang.IllegalArgumentException - org.eclipse.swt.SWTException - ModifyListener,
removeModifyListener(org.eclipse.swt.events.ModifyListener)public void removeModifyListener(org.eclipse.swt.events.ModifyListener listener)
listener - the listener which should no longer be notifiedjava.lang.IllegalArgumentException - org.eclipse.swt.SWTException - ModifyListener,
addModifyListener(org.eclipse.swt.events.ModifyListener)public void notifyModifyListeners(org.eclipse.swt.events.ModifyEvent event)
eventType - the type of event which has occurredevent - the event dataorg.eclipse.swt.SWTException - addModifyListener(ModifyListener),
removeModifyListener(ModifyListener)public void addJavaCallbackListener(JavaCallbackListener listener)
JavaCallbackListener that is triggered on executing a Java callback via custom
ToolbarButton.listener - The JavaCallbackListener to add.public void removeJavaCallbackListener(JavaCallbackListener listener)
JavaCallbackListener that is triggered on executing a Java callback via
custom ToolbarButton.listener - The JavaCallbackListener to remove.