Class RichTextEditorConfiguration
- java.lang.Object
-
- org.eclipse.nebula.widgets.richtext.RichTextEditorConfiguration
-
public class RichTextEditorConfiguration extends java.lang.Object
Configuration class that is used for general configurations of the CKEditor instance.Note: This configuration class replaces the
ToolbarConfiguration
.- Since:
- 1.1
-
-
Field Summary
Fields Modifier and Type Field Description private org.eclipse.swt.browser.Browser
browser
private java.util.Map<java.lang.String,org.eclipse.swt.browser.BrowserFunction>
buttonCallbacks
private java.util.Set<ToolbarButton>
customButtons
static java.lang.String
DEFAULT_LANGUAGE
Key for the default language configuration.static java.lang.String
LANGUAGE
Key for the language configuration.private java.util.Map<java.lang.String,java.lang.Object>
options
static java.lang.String
REMOVE_BUTTONS
Key for toolbar buttons that should not be rendered.static java.lang.String
REMOVE_PLUGINS
Key to configure a list of plugins that must not be loaded.private java.util.Set<java.lang.String>
removedButtons
private boolean
removeFormat
Configure whether to remove format combo box from the toolbar.private boolean
removePasteFromWord
Configure whether to remove the paste from word button from the toolbar.private boolean
removePasteText
Configure whether to remove the paste text button from the toolbar.private boolean
removeStyles
Configure whether to remove the styles combo box from the toolbar.static java.lang.String
RESIZE_DIR
Key to configure the dimensions for which the editor resizing is enabled.static java.lang.String
RESIZE_ENABLED
Key to configure whether to enable the resizing feature.static java.lang.String
RESIZE_MINHEIGHT
Key to configure the minimum editor height, in pixels, when resizing the editor interface by using the resize handle..static java.lang.String
RESIZE_MINWIDTH
Key to configure the minimum editor width, in pixels, when resizing the editor interface by using the resize handle..private static java.net.URL
resourceURL
static java.util.Collection<java.lang.String>
SUPPORTED_LANGUAGES
Collection of languages that are supported by CKEditor.static java.lang.String
TOOLBAR_CAN_COLLAPSE
Key to configure whether the toolbar can be collapsed by the user.static java.lang.String
TOOLBAR_GROUPS
Key for toolbar groups configuration.static java.lang.String
TOOLBAR_STARTUP_EXPANDED
Key to configure whether the toolbar must start expanded when the editor is loaded.
-
Constructor Summary
Constructors Constructor Description RichTextEditorConfiguration()
Creates a new instance for general configurations that are added to the created CKEditor instance at initialization.RichTextEditorConfiguration(ToolbarConfiguration config)
Deprecated.Use the no-arg constructor instead and set the values directly to the createdRichTextEditorConfiguration
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addDefaultToolbarButton(java.lang.String... buttonNames)
Adds the CKEditor default button for the given name to the toolbar.void
addToolbarButton(ToolbarButton button)
Adds a custom button to the CKEditor toolbar.void
addToolbarButton(ToolbarButton button, org.eclipse.swt.browser.BrowserFunction function)
Adds a custom button to the CKEditor toolbar.void
customizeToolbar()
Adds custom buttons to the toolbar of the CKEditor based on the configurations applied in thisRichTextEditorConfiguration
.void
dispose()
Dispose the registeredBrowserFunction
s.java.util.Map<java.lang.String,java.lang.Object>
getAllOptions()
org.eclipse.swt.browser.Browser
getBrowser()
protected java.lang.String
getCustomButtonConfiguration()
java.lang.Object
getOption(java.lang.String key)
Returns a configuration option set in thisRichTextEditorConfiguration
.private java.lang.String
getRemoveButtonConfiguration()
private java.lang.String
getSupportedLanguage(java.util.Locale locale)
This method is used to get the language String that is supported by CKEditor.void
removeDefaultToolbarButton(java.lang.String... buttonNames)
Removes the CKEditor default button for the given name from the toolbar.void
removeToolbarButton(ToolbarButton button)
Removes the givenToolbarButton
from the local list of custom toolbar buttons.void
setBrowser(org.eclipse.swt.browser.Browser browser)
void
setDefaultLanguage(java.lang.String lang)
void
setDefaultLanguage(java.util.Locale locale)
void
setLanguage(java.lang.String lang)
void
setLanguage(java.util.Locale locale)
void
setMinSize(int minWidth, int minHeight)
The minimum editor size, in pixels, when resizing the editor interface by using the resize handle.void
setOption(java.lang.String key, java.lang.Object value)
Adds a new option to the configuration.void
setRemoveFormat(boolean removeFormat)
void
setRemovePasteFromWord(boolean removePasteFromWord)
void
setRemovePasteText(boolean removePasteText)
void
setRemoveStyles(boolean removeStyles)
void
setResizable(boolean resizable)
Whether to enable the resizing feature.void
setResizeDirection(java.lang.String direction)
void
setToolbarCollapsible(boolean toolbarCollapsible)
Configure if the toolbar should be collapsible.void
setToolbarInitialExpanded(boolean toolbarInitialExpanded)
Configure if the toolbar should be initially expanded.
-
-
-
Field Detail
-
DEFAULT_LANGUAGE
public static final java.lang.String DEFAULT_LANGUAGE
Key for the default language configuration.- See Also:
- Constant Field Values
-
LANGUAGE
public static final java.lang.String LANGUAGE
Key for the language configuration.- See Also:
- Constant Field Values
-
TOOLBAR_GROUPS
public static final java.lang.String TOOLBAR_GROUPS
Key for toolbar groups configuration.- See Also:
- Constant Field Values
-
REMOVE_BUTTONS
public static final java.lang.String REMOVE_BUTTONS
Key for toolbar buttons that should not be rendered.- See Also:
- Constant Field Values
-
TOOLBAR_CAN_COLLAPSE
public static final java.lang.String TOOLBAR_CAN_COLLAPSE
Key to configure whether the toolbar can be collapsed by the user.- See Also:
- Constant Field Values
-
TOOLBAR_STARTUP_EXPANDED
public static final java.lang.String TOOLBAR_STARTUP_EXPANDED
Key to configure whether the toolbar must start expanded when the editor is loaded.- See Also:
- Constant Field Values
-
REMOVE_PLUGINS
public static final java.lang.String REMOVE_PLUGINS
Key to configure a list of plugins that must not be loaded.- See Also:
- Constant Field Values
-
RESIZE_ENABLED
public static final java.lang.String RESIZE_ENABLED
Key to configure whether to enable the resizing feature.- See Also:
- Constant Field Values
-
RESIZE_DIR
public static final java.lang.String RESIZE_DIR
Key to configure the dimensions for which the editor resizing is enabled. Possible values are both, vertical, and horizontal.- See Also:
- Constant Field Values
-
RESIZE_MINWIDTH
public static final java.lang.String RESIZE_MINWIDTH
Key to configure the minimum editor width, in pixels, when resizing the editor interface by using the resize handle..- See Also:
- Constant Field Values
-
RESIZE_MINHEIGHT
public static final java.lang.String RESIZE_MINHEIGHT
Key to configure the minimum editor height, in pixels, when resizing the editor interface by using the resize handle..- See Also:
- Constant Field Values
-
SUPPORTED_LANGUAGES
public static final java.util.Collection<java.lang.String> SUPPORTED_LANGUAGES
Collection of languages that are supported by CKEditor.
-
resourceURL
private static java.net.URL resourceURL
-
removePasteText
private boolean removePasteText
Configure whether to remove the paste text button from the toolbar. Default istrue
.
-
removePasteFromWord
private boolean removePasteFromWord
Configure whether to remove the paste from word button from the toolbar. Default istrue
.
-
removeStyles
private boolean removeStyles
Configure whether to remove the styles combo box from the toolbar. Default istrue
.
-
removeFormat
private boolean removeFormat
Configure whether to remove format combo box from the toolbar. Default istrue
.
-
removedButtons
private java.util.Set<java.lang.String> removedButtons
-
browser
private org.eclipse.swt.browser.Browser browser
-
customButtons
private java.util.Set<ToolbarButton> customButtons
-
buttonCallbacks
private java.util.Map<java.lang.String,org.eclipse.swt.browser.BrowserFunction> buttonCallbacks
-
options
private java.util.Map<java.lang.String,java.lang.Object> options
-
-
Constructor Detail
-
RichTextEditorConfiguration
public RichTextEditorConfiguration()
Creates a new instance for general configurations that are added to the created CKEditor instance at initialization.
-
RichTextEditorConfiguration
@Deprecated public RichTextEditorConfiguration(ToolbarConfiguration config)
Deprecated.Use the no-arg constructor instead and set the values directly to the createdRichTextEditorConfiguration
Creates aRichTextEditorConfiguration
that is initialized with the configuration values out of the givenToolbarConfiguration
. This constructor is used for backwards compatibility only in case adopters use the old ToolbarConfiguration. Therefore it is deprecated from the beginning.- Parameters:
config
- TheToolbarConfiguration
that should be used to initialized theRichTextEditorConfiguration
.- Since:
- 1.2
-
-
Method Detail
-
setOption
public void setOption(java.lang.String key, java.lang.Object value)
Adds a new option to the configuration.- Parameters:
key
- The configuration option key.value
- The configuration option value.- See Also:
- CKEDITOR.config
-
getOption
public java.lang.Object getOption(java.lang.String key)
Returns a configuration option set in thisRichTextEditorConfiguration
.- Parameters:
key
- The configuration option key for which the value is requested.- Returns:
- The configuration option value for the given key or
null
in case there is nothing configured for that key.
-
getAllOptions
public java.util.Map<java.lang.String,java.lang.Object> getAllOptions()
- Returns:
- An unmodifiable map that contains all configuration option values.
-
getSupportedLanguage
private java.lang.String getSupportedLanguage(java.util.Locale locale)
This method is used to get the language String that is supported by CKEditor. There are only few languages that support the country code information, e.g. Portuguese Brasil, and for those the special language code needs to be found. Otherwise the language code only is supported.- Parameters:
locale
- The locale for which the language is requested.- Returns:
- The supported language code with country information if supported, or an empty String.
-
setLanguage
public void setLanguage(java.lang.String lang)
- Parameters:
lang
- The user interface language localization to use. If left empty, the editor will automatically be localized to the user language. If the user language is not supported, the language specified in the defaultLanguage configuration setting is used.
-
setLanguage
public void setLanguage(java.util.Locale locale)
- Parameters:
locale
- The user interface language localization to use. If left empty, the editor will automatically be localized to the user language. If the user language is not supported, the language specified in the defaultLanguage configuration setting is used.
-
setDefaultLanguage
public void setDefaultLanguage(java.lang.String lang)
- Parameters:
lang
- The language to be used if the language setting is left empty and it is not possible to localize the editor to the user language.
-
setDefaultLanguage
public void setDefaultLanguage(java.util.Locale locale)
- Parameters:
locale
- The language to be used if the language setting is left empty and it is not possible to localize the editor to the user language.
-
setResizable
public void setResizable(boolean resizable)
Whether to enable the resizing feature. If this feature is disabled, the resize handle will not be visible.- Parameters:
resizable
-true
to enable the resizing feature.
-
setMinSize
public void setMinSize(int minWidth, int minHeight)
The minimum editor size, in pixels, when resizing the editor interface by using the resize handle. Note: It falls back to editor's actual height if it is smaller than the default value.- Parameters:
minWidth
- the minimum editor width, in pixelsminHeight
- the minimum editor height, in pixels
-
setResizeDirection
public void setResizeDirection(java.lang.String direction)
- Parameters:
direction
- The dimensions for which the editor resizing is enabled. Possible values areboth
,vertical
, andhorizontal
.
-
setToolbarCollapsible
public void setToolbarCollapsible(boolean toolbarCollapsible)
Configure if the toolbar should be collapsible. Default isfalse
.- Parameters:
toolbarCollapsible
-true
if the toolbar should be collapsible,false
if not.
-
setToolbarInitialExpanded
public void setToolbarInitialExpanded(boolean toolbarInitialExpanded)
Configure if the toolbar should be initially expanded. Is only interpreted if#toolbarCollapsible
is set totrue
. Default istrue
.- Parameters:
toolbarInitialExpanded
-true
if the toolbar should be initially expanded,false
if not.
-
setRemovePasteText
public void setRemovePasteText(boolean removePasteText)
- Parameters:
removePasteText
-true
to remove the paste text button from the toolbar.
-
setRemovePasteFromWord
public void setRemovePasteFromWord(boolean removePasteFromWord)
- Parameters:
removePasteFromWord
-true
to remove the paste from word button from the toolbar.
-
setRemoveStyles
public void setRemoveStyles(boolean removeStyles)
- Parameters:
removeStyles
-true
to remove the styles combo box from the toolbar.
-
setRemoveFormat
public void setRemoveFormat(boolean removeFormat)
- Parameters:
removeFormat
-true
to remove format combo box from the toolbar.
-
addDefaultToolbarButton
public void addDefaultToolbarButton(java.lang.String... buttonNames)
Adds the CKEditor default button for the given name to the toolbar.Note: This works only for buttons that have been removed using
removeDefaultToolbarButton(String[])
- Parameters:
buttonNames
- The names of the CKEditor default button to add.
-
removeDefaultToolbarButton
public void removeDefaultToolbarButton(java.lang.String... buttonNames)
Removes the CKEditor default button for the given name from the toolbar.- Parameters:
buttonNames
- The names of the CKEditor default button to remove.
-
getRemoveButtonConfiguration
private java.lang.String getRemoveButtonConfiguration()
- Returns:
- The configuration which default buttons should be removed from the toolbar.
-
getCustomButtonConfiguration
protected java.lang.String getCustomButtonConfiguration()
- Returns:
- The configuration for adding custom commands and buttons to the toolbar.
-
addToolbarButton
public void addToolbarButton(ToolbarButton button)
Adds a custom button to the CKEditor toolbar. Internally creates an anonymousBrowserFunction
that executesToolbarButton.execute()
via callback on pressing the button.- Parameters:
button
- The button to add.
-
addToolbarButton
public void addToolbarButton(ToolbarButton button, org.eclipse.swt.browser.BrowserFunction function)
Adds a custom button to the CKEditor toolbar. Executes the givenBrowserFunction
via callback on pressing the button.- Parameters:
button
- The button to add.function
- TheBrowserFunction
that should be called on pressing the button.
-
removeToolbarButton
public void removeToolbarButton(ToolbarButton button)
Removes the givenToolbarButton
from the local list of custom toolbar buttons.- Parameters:
button
- TheToolbarButton
to remove.
-
customizeToolbar
public void customizeToolbar()
Adds custom buttons to the toolbar of the CKEditor based on the configurations applied in thisRichTextEditorConfiguration
.
-
getBrowser
public org.eclipse.swt.browser.Browser getBrowser()
- Returns:
- The
Browser
instance to which thisRichTextEditorConfiguration
is connected to.
-
setBrowser
public void setBrowser(org.eclipse.swt.browser.Browser browser)
- Parameters:
browser
- TheBrowser
instance to which thisRichTextEditorConfiguration
should be connected to.
-
dispose
public void dispose()
Dispose the registeredBrowserFunction
s.
-
-