org.opencms.widgets
Class CmsHtmlWidgetOption

java.lang.Object
  extended by org.opencms.widgets.CmsHtmlWidgetOption

public class CmsHtmlWidgetOption
extends java.lang.Object

An option of a HTML type widget.

Options can be defined for each element of the type OpenCmsHtml using the widget HtmlWidget. They have to be placed in the annotation section of a XSD describing an XML content. The configuration attribute in the layout node for the element must contain the activated options as a comma separated String value:

Available options are:

Some things like the button bar items should be defined in the global widget configuration of the file opencms-vfs.xml.

Since:
6.0.1
Version:
$Revision: 1.12 $
Author:
Andreas Zahner

Field Summary
static java.lang.String BUTTONBAR_BLOCK_END
          The button bar end block indicator.
static java.lang.String BUTTONBAR_BLOCK_START
          The button bar start block indicator.
static java.lang.String BUTTONBAR_DEFAULT
          The default editor widget button bar configuration.
static java.util.List<java.lang.String> BUTTONBAR_DEFAULT_LIST
          The default button bar configuration as List.
static java.lang.String BUTTONBAR_SEPARATOR
          The button bar separator.
static java.lang.String DELIMITER_OPTION
          The delimiter to use in the configuration String.
static char DELIMITER_VALUE
          The delimiter to use for separation of option values.
static java.lang.String EDITOR_DEFAULTHEIGHT
          The editor widget default height to use.
static java.lang.String OPTION_ANCHOR
          Option for the "anchor" dialog.
static java.lang.String OPTION_BUTTONBAR
          Option for the "buttonbar" configuration.
static java.lang.String OPTION_CSS
          Option for the css style sheet VFS path to use in the widget area.
static java.lang.String OPTION_EDITORLINK
          Option for the "editor link" dialog (editor specific).
static java.lang.String OPTION_FIND
          Option for the "find" dialog.
static java.lang.String OPTION_FORMATSELECT
          Option for the "formatselect" selector.
static java.lang.String OPTION_FORMATSELECT_OPTIONS
          Option for the "formatselect" options selector.
static java.lang.String OPTION_FULLPAGE
          Option for the "fullpage" editor variant.
static java.lang.String OPTION_HEIGHT
          Option for the "height" configuration.
static java.lang.String OPTION_HIDEBUTTONS
          Option for the "hidebuttons" configuration.
static java.lang.String OPTION_IMAGE
          Option for the "image" dialog.
static java.lang.String OPTION_LINK
          Option for the "link" dialog.
static java.lang.String OPTION_REPLACE
          Option for the "replace" dialog.
static java.lang.String OPTION_SOURCE
          Option for the "source" code mode.
static java.lang.String OPTION_SPELLCHECK
          Option for the "spell check" dialog.
static java.lang.String OPTION_STYLE
          Option for the style select box.
static java.lang.String OPTION_STYLES
          Option for the styles XML VFS path to use in the widget area.
static java.lang.String OPTION_TABLE
          Option for the "table" dialog.
static java.lang.String OPTION_UNLINK
          Option for the "unlink" button.
static java.lang.String[] OPTIONAL_BUTTONS
          The optional buttons that can be additionally added to the button bar.
static java.util.List<java.lang.String> OPTIONAL_BUTTONS_LIST
          The optional buttons that can be additionally added to the button bar as list.
 
Constructor Summary
CmsHtmlWidgetOption()
          Creates a new empty HTML widget object object.
CmsHtmlWidgetOption(java.lang.String configuration)
          Creates a new HTML widget object object, configured by the given configuration String.
 
Method Summary
protected  void addAdditionalButton(java.lang.String buttonName)
          Adds a button to the list of defined additional buttons.
static java.lang.String createConfigurationString(CmsHtmlWidgetOption option)
          Returns a HTML widget configuration String created from the given HTML widget option.
 java.util.List<java.lang.String> getAdditionalButtons()
          Returns the buttons to show additionally as list with button names.
 java.lang.String getButtonBar(java.util.Map<java.lang.String,java.lang.String> buttonNamesLookUp, java.lang.String itemSeparator)
          Returns the specific editor button bar string generated from the configuration.
 java.lang.String getButtonBar(java.util.Map<java.lang.String,java.lang.String> buttonNamesLookUp, java.lang.String itemSeparator, boolean addMissingBlock)
          Returns the specific editor button bar string generated from the configuration.
 java.util.List<java.lang.String> getButtonBarOption()
          Returns the individual button bar configuration option.
 java.lang.String getButtonBarOptionString()
          Returns the individual button bar configuration option string.
 java.util.List<java.lang.String> getButtonBarShownItems()
          Returns the calculated button bar items, including blocks and separators, considering the current widget configuration.
protected  java.lang.String getButtonName(java.lang.String barItem, java.util.Map<java.lang.String,java.lang.String> buttonNamesLookUp)
          Returns the real button name matched with the look up map.
 java.lang.String getConfiguration()
          Returns the original configuration String that was used to initialize the HTML widget options.
 java.lang.String getCssPath()
          Returns the CSS style sheet VFS path to use in the widget area.
 java.lang.String getEditorHeight()
          Returns the widget editor height.
 java.lang.String getFormatSelectOptions()
          Returns the options for the format select box as String.
 java.util.List<java.lang.String> getHiddenButtons()
          Returns the buttons to hide as list with button names.
 java.lang.String getStylesXmlPath()
          Returns the styles XML VFS path to use in the widget area.
 void init(java.lang.String configuration)
          Initializes the widget options from the given configuration String.
 boolean isButtonAdditional(java.lang.String buttonName)
          Returns if the button with the given name should be additionally shown.
 boolean isButtonHidden(java.lang.String buttonName)
          Returns if the button with the given name should be hidden.
 boolean isButtonOptional(java.lang.String buttonName)
          Returns if the button with the given name is optional.
 boolean isFullPage()
          Returns if the editor should be used in full page mode.
protected  void parseOptions(java.lang.String configuration)
          Parses the given configuration String.
 void setAdditionalButtons(java.util.List<java.lang.String> buttons)
          Sets the buttons to show additionally as list with button names.
 void setButtonBarOption(java.util.List<java.lang.String> buttonBar)
          Sets the individual button bar configuration option.
 void setButtonBarOptionString(java.lang.String buttonBar)
          Sets the individual button bar configuration option string.
 void setCssPath(java.lang.String cssPath)
          Sets the CSS style sheet VFS path to use in the widget area.
 void setEditorHeight(java.lang.String editorHeight)
          Sets the widget editor height.
 void setFormatSelectOptions(java.lang.String formatSelectOptions)
          Sets the options for the format select box as String.
 void setFullPage(boolean fullPage)
          Sets if the editor should be used in full page mode.
 void setHiddenButtons(java.util.List<java.lang.String> buttons)
          Sets the buttons to hide as list with button names.
 void setStylesXmlPath(java.lang.String stylesXmlPath)
          Sets the styles XML VFS path to use in the widget area.
 boolean showAnchorDialog()
          Returns true if the anchor dialog button should be available.
 boolean showFormatSelect()
          Returns true if the format selector should be available.
 boolean showGalleryDialog(java.lang.String galleryType)
          Returns true if the specified gallery type dialog button is shown.
 boolean showImageDialog()
          Returns true if the image dialog button should be available.
 boolean showLinkDialog()
          Returns true if the link dialog button should be available.
 boolean showSourceEditor()
          Returns true if the source code button should be available.
 boolean showStylesXml()
          Returns true if the styles selector should be available.
 boolean showTableDialog()
          Returns true if the table dialog button should be available.
 boolean useCss()
          Returns true if the widget editor should use a defined CSS style sheet.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BUTTONBAR_BLOCK_END

public static final java.lang.String BUTTONBAR_BLOCK_END
The button bar end block indicator.

See Also:
Constant Field Values

BUTTONBAR_BLOCK_START

public static final java.lang.String BUTTONBAR_BLOCK_START
The button bar start block indicator.

See Also:
Constant Field Values

BUTTONBAR_DEFAULT

public static final java.lang.String BUTTONBAR_DEFAULT
The default editor widget button bar configuration.

See Also:
Constant Field Values

BUTTONBAR_DEFAULT_LIST

public static final java.util.List<java.lang.String> BUTTONBAR_DEFAULT_LIST
The default button bar configuration as List.


BUTTONBAR_SEPARATOR

public static final java.lang.String BUTTONBAR_SEPARATOR
The button bar separator.

See Also:
Constant Field Values

DELIMITER_OPTION

public static final java.lang.String DELIMITER_OPTION
The delimiter to use in the configuration String.

See Also:
Constant Field Values

DELIMITER_VALUE

public static final char DELIMITER_VALUE
The delimiter to use for separation of option values.

See Also:
Constant Field Values

EDITOR_DEFAULTHEIGHT

public static final java.lang.String EDITOR_DEFAULTHEIGHT
The editor widget default height to use.

See Also:
Constant Field Values

OPTION_ANCHOR

public static final java.lang.String OPTION_ANCHOR
Option for the "anchor" dialog.

See Also:
Constant Field Values

OPTION_BUTTONBAR

public static final java.lang.String OPTION_BUTTONBAR
Option for the "buttonbar" configuration.

See Also:
Constant Field Values

OPTION_CSS

public static final java.lang.String OPTION_CSS
Option for the css style sheet VFS path to use in the widget area.

See Also:
Constant Field Values

OPTION_EDITORLINK

public static final java.lang.String OPTION_EDITORLINK
Option for the "editor link" dialog (editor specific).

See Also:
Constant Field Values

OPTION_FIND

public static final java.lang.String OPTION_FIND
Option for the "find" dialog.

See Also:
Constant Field Values

OPTION_FORMATSELECT

public static final java.lang.String OPTION_FORMATSELECT
Option for the "formatselect" selector.

See Also:
Constant Field Values

OPTION_FORMATSELECT_OPTIONS

public static final java.lang.String OPTION_FORMATSELECT_OPTIONS
Option for the "formatselect" options selector.

See Also:
Constant Field Values

OPTION_FULLPAGE

public static final java.lang.String OPTION_FULLPAGE
Option for the "fullpage" editor variant.

See Also:
Constant Field Values

OPTION_HEIGHT

public static final java.lang.String OPTION_HEIGHT
Option for the "height" configuration.

See Also:
Constant Field Values

OPTION_HIDEBUTTONS

public static final java.lang.String OPTION_HIDEBUTTONS
Option for the "hidebuttons" configuration.

See Also:
Constant Field Values

OPTION_IMAGE

public static final java.lang.String OPTION_IMAGE
Option for the "image" dialog.

See Also:
Constant Field Values

OPTION_LINK

public static final java.lang.String OPTION_LINK
Option for the "link" dialog.

See Also:
Constant Field Values

OPTION_REPLACE

public static final java.lang.String OPTION_REPLACE
Option for the "replace" dialog.

See Also:
Constant Field Values

OPTION_SOURCE

public static final java.lang.String OPTION_SOURCE
Option for the "source" code mode.

See Also:
Constant Field Values

OPTION_SPELLCHECK

public static final java.lang.String OPTION_SPELLCHECK
Option for the "spell check" dialog.

See Also:
Constant Field Values

OPTION_STYLE

public static final java.lang.String OPTION_STYLE
Option for the style select box.

See Also:
Constant Field Values

OPTION_STYLES

public static final java.lang.String OPTION_STYLES
Option for the styles XML VFS path to use in the widget area.

See Also:
Constant Field Values

OPTION_TABLE

public static final java.lang.String OPTION_TABLE
Option for the "table" dialog.

See Also:
Constant Field Values

OPTION_UNLINK

public static final java.lang.String OPTION_UNLINK
Option for the "unlink" button.

See Also:
Constant Field Values

OPTIONAL_BUTTONS

public static final java.lang.String[] OPTIONAL_BUTTONS
The optional buttons that can be additionally added to the button bar.


OPTIONAL_BUTTONS_LIST

public static final java.util.List<java.lang.String> OPTIONAL_BUTTONS_LIST
The optional buttons that can be additionally added to the button bar as list.

Constructor Detail

CmsHtmlWidgetOption

public CmsHtmlWidgetOption()
Creates a new empty HTML widget object object.


CmsHtmlWidgetOption

public CmsHtmlWidgetOption(java.lang.String configuration)
Creates a new HTML widget object object, configured by the given configuration String.

Parameters:
configuration - configuration String to parse
Method Detail

createConfigurationString

public static java.lang.String createConfigurationString(CmsHtmlWidgetOption option)
Returns a HTML widget configuration String created from the given HTML widget option.

Parameters:
option - the HTML widget options to create the configuration String for
Returns:
a select widget configuration String created from the given HTML widget option object

getAdditionalButtons

public java.util.List<java.lang.String> getAdditionalButtons()
Returns the buttons to show additionally as list with button names.

Returns:
the buttons to show additionally as list with button names

getButtonBar

public java.lang.String getButtonBar(java.util.Map<java.lang.String,java.lang.String> buttonNamesLookUp,
                                     java.lang.String itemSeparator)
Returns the specific editor button bar string generated from the configuration.

The lookup map can contain translations for the button names, the separator and the block names. The button bar will be automatically surrounded by block start and end items if they are not explicitly defined.

It may be necessary to write your own method to generate the button bar string for a specific editor widget. In this case, use the method getButtonBarShownItems() to get the calculated list of shown button bar items.

Parameters:
buttonNamesLookUp - the lookup map with translations for the button names, the separator and the block names or null
itemSeparator - the separator for the tool bar items
Returns:
the button bar string generated from the configuration

getButtonBar

public java.lang.String getButtonBar(java.util.Map<java.lang.String,java.lang.String> buttonNamesLookUp,
                                     java.lang.String itemSeparator,
                                     boolean addMissingBlock)
Returns the specific editor button bar string generated from the configuration.

The lookup map can contain translations for the button names, the separator and the block names.

It may be necessary to write your own method to generate the button bar string for a specific editor widget. In this case, use the method getButtonBarShownItems() to get the calculated list of shown button bar items.

Parameters:
buttonNamesLookUp - the lookup map with translations for the button names, the separator and the block names or null
itemSeparator - the separator for the tool bar items
addMissingBlock - flag indicating if the button bar should be automatically surrounded by a block if not explicitly defined
Returns:
the button bar string generated from the configuration

getButtonBarOption

public java.util.List<java.lang.String> getButtonBarOption()
Returns the individual button bar configuration option.

Returns:
the individual button bar configuration option

getButtonBarOptionString

public java.lang.String getButtonBarOptionString()
Returns the individual button bar configuration option string.

Returns:
the individual button bar configuration option string

getButtonBarShownItems

public java.util.List<java.lang.String> getButtonBarShownItems()
Returns the calculated button bar items, including blocks and separators, considering the current widget configuration.

Use this method to get the calculated list of button bar items if getButtonBar(Map, String) can not be used for a specific editor widget.

Returns:
the calculated button bar items

getConfiguration

public java.lang.String getConfiguration()
Returns the original configuration String that was used to initialize the HTML widget options.

Returns:
the original configuration String

getCssPath

public java.lang.String getCssPath()
Returns the CSS style sheet VFS path to use in the widget area.

Returns:
the CSS style sheet VFS path to use in the widget area

getEditorHeight

public java.lang.String getEditorHeight()
Returns the widget editor height.

Returns:
the widget editor height

getFormatSelectOptions

public java.lang.String getFormatSelectOptions()
Returns the options for the format select box as String.

Returns:
the options for the format select box as String

getHiddenButtons

public java.util.List<java.lang.String> getHiddenButtons()
Returns the buttons to hide as list with button names.

Returns:
the buttons to hide as list with button names

getStylesXmlPath

public java.lang.String getStylesXmlPath()
Returns the styles XML VFS path to use in the widget area.

Returns:
the styles XML VFS path to use in the widget area

init

public void init(java.lang.String configuration)
Initializes the widget options from the given configuration String.

Parameters:
configuration - the configuration String

isButtonAdditional

public boolean isButtonAdditional(java.lang.String buttonName)
Returns if the button with the given name should be additionally shown.

Parameters:
buttonName - the button name to check
Returns:
true if the button with the given name should be additionally shown, otherwise false

isButtonHidden

public boolean isButtonHidden(java.lang.String buttonName)
Returns if the button with the given name should be hidden.

Parameters:
buttonName - the button name to check
Returns:
true if the button with the given name should be hidden, otherwise false

isButtonOptional

public boolean isButtonOptional(java.lang.String buttonName)
Returns if the button with the given name is optional.

Parameters:
buttonName - the button name to check
Returns:
true if the button with the given name is optional, otherwise false

isFullPage

public boolean isFullPage()
Returns if the editor should be used in full page mode.

Returns:
true if the editor should be used in full page mode, otherwise false

setAdditionalButtons

public void setAdditionalButtons(java.util.List<java.lang.String> buttons)
Sets the buttons to show additionally as list with button names.

Parameters:
buttons - the buttons to show additionally as list with button names

setButtonBarOption

public void setButtonBarOption(java.util.List<java.lang.String> buttonBar)
Sets the individual button bar configuration option.

Parameters:
buttonBar - the individual button bar configuration option

setButtonBarOptionString

public void setButtonBarOptionString(java.lang.String buttonBar)
Sets the individual button bar configuration option string.

Parameters:
buttonBar - the individual button bar configuration option string

setCssPath

public void setCssPath(java.lang.String cssPath)
Sets the CSS style sheet VFS path to use in the widget area.

Parameters:
cssPath - the CSS style sheet VFS path to use in the widget area

setEditorHeight

public void setEditorHeight(java.lang.String editorHeight)
Sets the widget editor height.

Parameters:
editorHeight - the widget editor height

setFormatSelectOptions

public void setFormatSelectOptions(java.lang.String formatSelectOptions)
Sets the options for the format select box as String.

Parameters:
formatSelectOptions - the options for the format select box as String

setFullPage

public void setFullPage(boolean fullPage)
Sets if the editor should be used in full page mode.

Parameters:
fullPage - true if the editor should be used in full page mode, otherwise false

setHiddenButtons

public void setHiddenButtons(java.util.List<java.lang.String> buttons)
Sets the buttons to hide as list with button names.

Parameters:
buttons - the buttons to hide as list with button names

setStylesXmlPath

public void setStylesXmlPath(java.lang.String stylesXmlPath)
Sets the styles XML VFS path to use in the widget area.

Parameters:
stylesXmlPath - the styles XML VFS path to use in the widget area

showAnchorDialog

public boolean showAnchorDialog()
Returns true if the anchor dialog button should be available.

Returns:
if the anchor dialog button should be available

showFormatSelect

public boolean showFormatSelect()
Returns true if the format selector should be available.

Returns:
if the format selector should be available

showGalleryDialog

public boolean showGalleryDialog(java.lang.String galleryType)
Returns true if the specified gallery type dialog button is shown.

Parameters:
galleryType - the gallery type to check
Returns:
true if the specified gallery type dialog button is shown, otherwise false

showImageDialog

public boolean showImageDialog()
Returns true if the image dialog button should be available.

Returns:
if the image dialog button should be available

showLinkDialog

public boolean showLinkDialog()
Returns true if the link dialog button should be available.

Returns:
if the link dialog button should be available

showSourceEditor

public boolean showSourceEditor()
Returns true if the source code button should be available.

Returns:
if the source code button should be available

showStylesXml

public boolean showStylesXml()
Returns true if the styles selector should be available.

Returns:
if the styles selector should be available

showTableDialog

public boolean showTableDialog()
Returns true if the table dialog button should be available.

Returns:
if the table dialog button should be available

useCss

public boolean useCss()
Returns true if the widget editor should use a defined CSS style sheet.

Returns:
if the widget editor should use a defined CSS style sheet

addAdditionalButton

protected void addAdditionalButton(java.lang.String buttonName)
Adds a button to the list of defined additional buttons.

Parameters:
buttonName - the button name to add

getButtonName

protected java.lang.String getButtonName(java.lang.String barItem,
                                         java.util.Map<java.lang.String,java.lang.String> buttonNamesLookUp)
Returns the real button name matched with the look up map.

If no value is found in the look up map, the button name is returned unchanged.

Parameters:
barItem - the button bar item name to look up
buttonNamesLookUp - the look up map containing the button names and/or separator name to use
Returns:
the translated button name

parseOptions

protected void parseOptions(java.lang.String configuration)
Parses the given configuration String.

Parameters:
configuration - the configuration String to parse