org.opencms.workplace.editors
Class CmsEditorDisplayOptions

java.lang.Object
  extended by org.opencms.workplace.editors.CmsEditorDisplayOptions

public class CmsEditorDisplayOptions
extends java.lang.Object

Provides methods to determine the display options of a workplace editor for the current user.

On the editor JSP, do the following:

Define your editor display options in property files located in the VFS folder /system/workplace/editors/configuration/.

Set navigation position property values on the configuration files and use the permission system to determine which groups and users should use which configuration file.

The configuration with the most enabled options should be the first in navigation, followed by configurations with less enabled options, because the first file readable for the current user will be used for configuration.

If no configuration file can be found for the current user, all display options will be disabled by default.

Since:
6.0.0
Version:
$Revision: 1.18 $
Author:
Andreas Zahner

Field Summary
static java.lang.String FOLDER_EDITORCONFIGURATION
          The name of the configuration folder.
static java.lang.String NO_MAPPING_FOR_USER
          Mapping entry name that is used if no mapping is available for the user.
static int SIZE_CONFIGURATIONFILES
          Maximum size of the stored editor configurations.
static int SIZE_USERENTRIES
          Maximum size of the user editor configuration mappings.
 
Constructor Summary
CmsEditorDisplayOptions()
          Constructor that initializes the editor display options for the workplace.
 
Method Summary
 void clearCache()
          Clears the cached user configuration data, casing a reload off all configurations.
 java.util.Properties getDisplayOptions(CmsJspActionElement jsp)
          Reads the editor configuration file valid for the current user and caches the result in a Map.
 java.util.Properties getDisplayOptions(CmsObject cms)
          Reads the editor configuration file valid for the current user and caches the result in a Map.
 java.lang.String getOptionValue(java.lang.String key, java.lang.String defaultValue, java.util.Properties displayOptions)
          Returns the value for the given key from the display options.
 boolean showElement(java.lang.String key, java.util.Properties displayOptions)
          Determines if the given element should be shown in the editor.
 boolean showElement(java.lang.String key, java.lang.String defaultValue, java.util.Properties displayOptions)
          Determines if the given element should be shown in the editor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FOLDER_EDITORCONFIGURATION

public static final java.lang.String FOLDER_EDITORCONFIGURATION
The name of the configuration folder.

See Also:
Constant Field Values

NO_MAPPING_FOR_USER

public static final java.lang.String NO_MAPPING_FOR_USER
Mapping entry name that is used if no mapping is available for the user.

See Also:
Constant Field Values

SIZE_CONFIGURATIONFILES

public static final int SIZE_CONFIGURATIONFILES
Maximum size of the stored editor configurations.

See Also:
Constant Field Values

SIZE_USERENTRIES

public static final int SIZE_USERENTRIES
Maximum size of the user editor configuration mappings.

See Also:
Constant Field Values
Constructor Detail

CmsEditorDisplayOptions

public CmsEditorDisplayOptions()
Constructor that initializes the editor display options for the workplace.

Method Detail

clearCache

public void clearCache()
Clears the cached user configuration data, casing a reload off all configurations.


getDisplayOptions

public java.util.Properties getDisplayOptions(CmsJspActionElement jsp)
Reads the editor configuration file valid for the current user and caches the result in a Map.

The configuration settings of the found file are stored in a Map holding the loaded configuration with the configuration file name as key.

The configuration file name to use for the current user is stored in another Map with the user name as key.

Parameters:
jsp - the JSP action element to access the VFS and current user information
Returns:
the display options to use for the current user or null if no display options were found

getDisplayOptions

public java.util.Properties getDisplayOptions(CmsObject cms)
Reads the editor configuration file valid for the current user and caches the result in a Map.

The configuration settings of the found file are stored in a Map holding the loaded configuration with the configuration file name as key.

The configuration file name to use for the current user is stored in another Map with the user name as key.

Parameters:
cms - the CmsObject to access the VFS and current user information
Returns:
the display options to use for the current user or null if no display options were found

getOptionValue

public java.lang.String getOptionValue(java.lang.String key,
                                       java.lang.String defaultValue,
                                       java.util.Properties displayOptions)
Returns the value for the given key from the display options.

Parameters:
key - he element key name which should be read
defaultValue - the default value to use in case the property is not found
displayOptions - the display options for the current user
Returns:
the value for the given key from the display options

showElement

public boolean showElement(java.lang.String key,
                           java.util.Properties displayOptions)
Determines if the given element should be shown in the editor.

Parameters:
key - the element key name which should be displayed
displayOptions - the display options for the current user
Returns:
true if the element should be shown, otherwise false

showElement

public boolean showElement(java.lang.String key,
                           java.lang.String defaultValue,
                           java.util.Properties displayOptions)
Determines if the given element should be shown in the editor.

Parameters:
key - the element key name which should be displayed
defaultValue - the default value to use in case the property is not found, should be a boolean value as String
displayOptions - the display options for the current user
Returns:
true if the element should be shown, otherwise false