org.opencms.workplace.editors.directedit
Class A_CmsDirectEditProvider

java.lang.Object
  extended byorg.opencms.workplace.editors.directedit.A_CmsDirectEditProvider
All Implemented Interfaces:
java.lang.Cloneable, I_CmsConfigurationParameterHandler, I_CmsDirectEditProvider
Direct Known Subclasses:
CmsDirectEditDefaultProvider, CmsDirectEditJspIncludeProvider

public abstract class A_CmsDirectEditProvider
extends java.lang.Object
implements I_CmsDirectEditProvider

Basic functions for direct edit providers.

Since:
6.2.3
Version:
$Revision: 1.5 $
Author:
Alexander Kandzior

Field Summary
protected static java.lang.String INCLUDE_FILE_DEFAULT
          Default direct edit include file URI for post 6.2.3 direct edit providers.
protected  CmsObject m_cms
          The current users OpenCms context.
protected  java.util.Map m_configurationParameters
          The parameters form the configuration.
protected  int m_editButtonStyle
          The editor button style to use.
protected  java.lang.String m_fileName
          Value of the "fileName" parameter.
protected  CmsMessages m_messages
          Used to access the editor messages.
protected  CmsDirectEditMode m_mode
          Indicates which direct edit mode is used.
protected  java.util.Random m_rnd
          Used to generate the edit id's.
 
Fields inherited from interface org.opencms.workplace.editors.directedit.I_CmsDirectEditProvider
ATTRIBUTE_DIRECT_EDIT_PROVIDER, ATTRIBUTE_DIRECT_EDIT_PROVIDER_PARAMS
 
Fields inherited from interface org.opencms.configuration.I_CmsConfigurationParameterHandler
ADD_PARAMETER_METHOD, INIT_CONFIGURATION_METHOD
 
Constructor Summary
A_CmsDirectEditProvider()
           
 
Method Summary
 void addConfigurationParameter(java.lang.String paramName, java.lang.String paramValue)
          Adds a configuration parameter to this parameter configurable class instance.
 java.util.Map getConfiguration()
          Returns the configuration of this parameter configurable class instance, or null if the class does not need to be configured.
protected  java.lang.String getLink(java.lang.String target)
          Returns the given link resolved according to the OpenCms context and export rules.
protected  java.lang.String getNextDirectEditId()
          Returns the next random edit id.
 CmsDirectEditResourceInfo getResourceInfo(java.lang.String resourceName)
          Calculates the direct edit resource information for the given VFS resource.
 void init(CmsObject cms, CmsDirectEditMode mode, java.lang.String fileName)
          Initialize method for a new instance of the direct edit provider.
 void initConfiguration()
          Initializes a configuration after all parameters have been added.
 boolean isManual(CmsDirectEditMode mode)
          Returns true if this provider (currently) operates in manual mode.
protected  void print(javax.servlet.jsp.PageContext context, java.lang.String content)
          Prints the given content string to the given page context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.opencms.workplace.editors.directedit.I_CmsDirectEditProvider
insertDirectEditEnd, insertDirectEditIncludes, insertDirectEditStart, newInstance
 

Field Detail

INCLUDE_FILE_DEFAULT

protected static final java.lang.String INCLUDE_FILE_DEFAULT
Default direct edit include file URI for post 6.2.3 direct edit providers.

See Also:
Constant Field Values

m_cms

protected CmsObject m_cms
The current users OpenCms context.


m_configurationParameters

protected java.util.Map m_configurationParameters
The parameters form the configuration.


m_editButtonStyle

protected int m_editButtonStyle
The editor button style to use.


m_fileName

protected java.lang.String m_fileName
Value of the "fileName" parameter.


m_messages

protected CmsMessages m_messages
Used to access the editor messages.


m_mode

protected CmsDirectEditMode m_mode
Indicates which direct edit mode is used.


m_rnd

protected java.util.Random m_rnd
Used to generate the edit id's.

Constructor Detail

A_CmsDirectEditProvider

public A_CmsDirectEditProvider()
Method Detail

addConfigurationParameter

public void addConfigurationParameter(java.lang.String paramName,
                                      java.lang.String paramValue)
Description copied from interface: I_CmsConfigurationParameterHandler
Adds a configuration parameter to this parameter configurable class instance.

Specified by:
addConfigurationParameter in interface I_CmsConfigurationParameterHandler
Parameters:
paramName - the name of the parameter
paramValue - the value for the parameter
See Also:
I_CmsConfigurationParameterHandler.addConfigurationParameter(java.lang.String, java.lang.String)

getConfiguration

public java.util.Map getConfiguration()
Description copied from interface: I_CmsConfigurationParameterHandler
Returns the configuration of this parameter configurable class instance, or null if the class does not need to be configured.

All elements in the configuration are key, value String pairs, set using the I_CmsConfigurationParameterHandler.addConfigurationParameter(String, String) method during initialization of the loader.

Implementations will (should) not to return a direct reference to the internal configuration but just a copy of it, to avoid unwanted external manipulation.

Specified by:
getConfiguration in interface I_CmsConfigurationParameterHandler
Returns:
the configuration of this resource loader, or null
See Also:
I_CmsConfigurationParameterHandler.getConfiguration()

getResourceInfo

public CmsDirectEditResourceInfo getResourceInfo(java.lang.String resourceName)
Calculates the direct edit resource information for the given VFS resource.

This includes the direct edit permissions. If the permissions are not CmsDirectEditPermissions.INACTIVE, then the resource and lock information is also included in the result.

Parameters:
resourceName - the name of the VFS resource to get the direct edit info for
Returns:
the direct edit resource information for the given VFS resource

init

public void init(CmsObject cms,
                 CmsDirectEditMode mode,
                 java.lang.String fileName)
Description copied from interface: I_CmsDirectEditProvider
Initialize method for a new instance of the direct edit provider.

Specified by:
init in interface I_CmsDirectEditProvider
Parameters:
cms - the current users OpenCms context
mode - the direct edit mode to use
fileName - link to a file that contains the direct edit HTML elements (optional)
See Also:
I_CmsDirectEditProvider.init(org.opencms.file.CmsObject, org.opencms.workplace.editors.directedit.CmsDirectEditMode, java.lang.String)

initConfiguration

public void initConfiguration()
                       throws CmsConfigurationException
Description copied from interface: I_CmsConfigurationParameterHandler
Initializes a configuration after all parameters have been added.

Specified by:
initConfiguration in interface I_CmsConfigurationParameterHandler
Throws:
CmsConfigurationException - if something goes wrong
See Also:
I_CmsConfigurationParameterHandler.initConfiguration()

isManual

public boolean isManual(CmsDirectEditMode mode)
Description copied from interface: I_CmsDirectEditProvider
Returns true if this provider (currently) operates in manual mode.

In manual mode the direct edit HTML is inserted with <cms:enditable mode="manual" /> tags. Otherwise the direct edit HTML is automatically inserted in the current page.

Some providers may not be able to operate in manual mode. These will always return false.

Specified by:
isManual in interface I_CmsDirectEditProvider
Parameters:
mode - the mode of the current direct edit element
Returns:
true if this provider (currently) operates in manual mode
See Also:
I_CmsDirectEditProvider.isManual(org.opencms.workplace.editors.directedit.CmsDirectEditMode)

getLink

protected java.lang.String getLink(java.lang.String target)
Returns the given link resolved according to the OpenCms context and export rules.

Parameters:
target - the link target to resolve
Returns:
the given link resolved according to the OpenCms context and export rules

getNextDirectEditId

protected java.lang.String getNextDirectEditId()
Returns the next random edit id.

Random edit id's are used because to separate multiple direct edit buttons on one page.

Returns:
the next random edit id

print

protected void print(javax.servlet.jsp.PageContext context,
                     java.lang.String content)
              throws javax.servlet.jsp.JspException
Prints the given content string to the given page context.

Does not print anything if the content is null.

Parameters:
context - the JSP page context to print the content to
content - the content to print
Throws:
javax.servlet.jsp.JspException - in case the content could not be written to the page conext