org.opencms.workplace.tools
Class A_CmsToolHandler

java.lang.Object
  extended by org.opencms.workplace.tools.A_CmsToolHandler
All Implemented Interfaces:
I_CmsToolHandler
Direct Known Subclasses:
CmsDefaultToolHandler, CmsInvisibleToolHandler, CmsOnlyAdminToolHandler, CmsToolRootHandler

public abstract class A_CmsToolHandler
extends java.lang.Object
implements I_CmsToolHandler

Helper class to build easily other admin tool handlers.

Since:
6.0.0
Version:
$Revision: 1.31 $
Author:
Michael Moossen

Field Summary
static java.lang.String ARG_PARAM_NAME
          Property for the parameters argument.
static java.lang.String ARG_PATH_NAME
          Property for the path argument.
static java.lang.String ARGS_PROPERTY_DEFINITION
          Property definition for the arguments.
static java.lang.String ARGUMENT_SEPARATOR
          Argument separator.
static java.lang.String DEFAULT_DISABLED_HELPTEXT
          Default disabled help text constant.
static java.lang.String VALUE_SEPARATOR
          Argument name and value separator.
 
Constructor Summary
A_CmsToolHandler()
           
 
Method Summary
 java.lang.String getConfirmationMessage()
          Returns the confirmation Message.
 java.lang.String getDisabledHelpText()
          Returns the help text if disabled.
 java.lang.String getGroup()
          Returns the group.
 java.lang.String getHelpText()
          Returns the help text.
 java.lang.String getIconPath()
          Returns the path to the icon.
 java.lang.String getLink()
          Returns the link to the tool.
 java.lang.String getName()
          Returns the displayed name.
 java.util.Map getParameters(CmsWorkplace wp)
          Returns the evaluated map of parameters.
 java.lang.String getPath()
          Returns the tool path to install the tool in.
 float getPosition()
          Returns the relative position in the group.
 java.lang.String getShortName()
          Returns the name for the menu or navbar.
 java.lang.String getSmallIconPath()
          Returns the path to an optional small(16x16) icon.
 boolean isEnabled(CmsWorkplace wp)
          Returns the state of the admin tool for a given workplace context.
 boolean isVisible(CmsWorkplace wp)
          Returns the visibility flag for a given workplace context.
 void setConfirmationMessage(java.lang.String confirmationMessage)
          Sets the confirmation Message.
 void setDisabledHelpText(java.lang.String disabledHelpText)
          Sets the help text if disabled.
 void setGroup(java.lang.String group)
          Sets the group.
 void setHelpText(java.lang.String helpText)
          Sets the help text.
 void setIconPath(java.lang.String iconPath)
          Sets the icon path.
protected  void setLink(CmsObject cms, java.lang.String resourcePath)
          Sets the link for the given resource.
 void setLink(java.lang.String link)
          Sets the link.
 void setName(java.lang.String name)
          Sets the name.
protected  void setParameters(CmsObject cms, java.lang.String resourcePath)
          Sets the needed properties from the ARGS_PROPERTY_DEFINITION property of the given resource.
 void setParameterString(java.lang.String paramString)
          Sets the parameter string.
 void setPath(java.lang.String path)
          Sets the path.
 void setPosition(float position)
          Sets the position.
 void setShortName(java.lang.String shortName)
          Sets the short name.
 void setSmallIconPath(java.lang.String smallIconPath)
          Sets the small icon path.
 boolean setup(CmsObject cms, CmsToolRootHandler root, java.lang.String resourcePath)
          Default implementation.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.opencms.workplace.tools.I_CmsToolHandler
isEnabled, isVisible
 

Field Detail

ARG_PARAM_NAME

public static final java.lang.String ARG_PARAM_NAME
Property for the parameters argument.

See Also:
Constant Field Values

ARG_PATH_NAME

public static final java.lang.String ARG_PATH_NAME
Property for the path argument.

See Also:
Constant Field Values

ARGS_PROPERTY_DEFINITION

public static final java.lang.String ARGS_PROPERTY_DEFINITION
Property definition for the arguments.

See Also:
Constant Field Values

ARGUMENT_SEPARATOR

public static final java.lang.String ARGUMENT_SEPARATOR
Argument separator.

See Also:
Constant Field Values

DEFAULT_DISABLED_HELPTEXT

public static final java.lang.String DEFAULT_DISABLED_HELPTEXT
Default disabled help text constant.

See Also:
Constant Field Values

VALUE_SEPARATOR

public static final java.lang.String VALUE_SEPARATOR
Argument name and value separator.

See Also:
Constant Field Values
Constructor Detail

A_CmsToolHandler

public A_CmsToolHandler()
Method Detail

getConfirmationMessage

public java.lang.String getConfirmationMessage()
Returns the confirmation Message.

Specified by:
getConfirmationMessage in interface I_CmsToolHandler
Returns:
the confirmation Message

getDisabledHelpText

public java.lang.String getDisabledHelpText()
Description copied from interface: I_CmsToolHandler
Returns the help text if disabled.

Specified by:
getDisabledHelpText in interface I_CmsToolHandler
Returns:
the help text if disabled
See Also:
I_CmsToolHandler.getDisabledHelpText()

getGroup

public java.lang.String getGroup()
Description copied from interface: I_CmsToolHandler
Returns the group.

Specified by:
getGroup in interface I_CmsToolHandler
Returns:
the group
See Also:
I_CmsToolHandler.getGroup()

getHelpText

public java.lang.String getHelpText()
Description copied from interface: I_CmsToolHandler
Returns the help text.

Specified by:
getHelpText in interface I_CmsToolHandler
Returns:
the help text
See Also:
I_CmsToolHandler.getHelpText()

getIconPath

public java.lang.String getIconPath()
Description copied from interface: I_CmsToolHandler
Returns the path to the icon.

Specified by:
getIconPath in interface I_CmsToolHandler
Returns:
the path to the icon
See Also:
I_CmsToolHandler.getIconPath()

getLink

public java.lang.String getLink()
Description copied from interface: I_CmsToolHandler
Returns the link to the tool.

Specified by:
getLink in interface I_CmsToolHandler
Returns:
the link
See Also:
I_CmsToolHandler.getLink()

getName

public java.lang.String getName()
Description copied from interface: I_CmsToolHandler
Returns the displayed name.

Specified by:
getName in interface I_CmsToolHandler
Returns:
the name
See Also:
I_CmsToolHandler.getName()

getParameters

public java.util.Map getParameters(CmsWorkplace wp)
Description copied from interface: I_CmsToolHandler
Returns the evaluated map of parameters.

Specified by:
getParameters in interface I_CmsToolHandler
Parameters:
wp - the workplace context
Returns:
the parameters map
See Also:
I_CmsToolHandler.getParameters(org.opencms.workplace.CmsWorkplace)

getPath

public java.lang.String getPath()
Description copied from interface: I_CmsToolHandler
Returns the tool path to install the tool in.

Specified by:
getPath in interface I_CmsToolHandler
Returns:
the path
See Also:
I_CmsToolHandler.getPath()

getPosition

public float getPosition()
Description copied from interface: I_CmsToolHandler
Returns the relative position in the group.

Specified by:
getPosition in interface I_CmsToolHandler
Returns:
the position
See Also:
I_CmsToolHandler.getPosition()

getShortName

public java.lang.String getShortName()
Description copied from interface: I_CmsToolHandler
Returns the name for the menu or navbar.

Specified by:
getShortName in interface I_CmsToolHandler
Returns:
the short name
See Also:
I_CmsToolHandler.getShortName()

getSmallIconPath

public java.lang.String getSmallIconPath()
Description copied from interface: I_CmsToolHandler
Returns the path to an optional small(16x16) icon.

Specified by:
getSmallIconPath in interface I_CmsToolHandler
Returns:
the path to an optional small(16x16) icon
See Also:
I_CmsToolHandler.getSmallIconPath()

isEnabled

public boolean isEnabled(CmsWorkplace wp)
Description copied from interface: I_CmsToolHandler
Returns the state of the admin tool for a given workplace context.

Specified by:
isEnabled in interface I_CmsToolHandler
Parameters:
wp - the workplace context
Returns:
true if enabled
See Also:
I_CmsToolHandler.isEnabled(org.opencms.workplace.CmsWorkplace)

isVisible

public boolean isVisible(CmsWorkplace wp)
Description copied from interface: I_CmsToolHandler
Returns the visibility flag for a given workplace context.

Specified by:
isVisible in interface I_CmsToolHandler
Parameters:
wp - the workplace context
Returns:
true if visible
See Also:
I_CmsToolHandler.isVisible(org.opencms.workplace.CmsWorkplace)

setConfirmationMessage

public void setConfirmationMessage(java.lang.String confirmationMessage)
Sets the confirmation Message.

Parameters:
confirmationMessage - the confirmation Message to set

setDisabledHelpText

public void setDisabledHelpText(java.lang.String disabledHelpText)
Sets the help text if disabled.

Parameters:
disabledHelpText - the help text to set

setGroup

public void setGroup(java.lang.String group)
Sets the group.

Parameters:
group - the group to set

setHelpText

public void setHelpText(java.lang.String helpText)
Sets the help text.

Parameters:
helpText - the help text to set

setIconPath

public void setIconPath(java.lang.String iconPath)
Sets the icon path.

Parameters:
iconPath - the icon path to set

setLink

public void setLink(java.lang.String link)
Sets the link.

Parameters:
link - the link to set

setName

public void setName(java.lang.String name)
Sets the name.

Parameters:
name - the name to set

setParameterString

public void setParameterString(java.lang.String paramString)
Sets the parameter string.

Parameters:
paramString - the parameter string to set

setPath

public void setPath(java.lang.String path)
Sets the path.

Parameters:
path - the path to set

setPosition

public void setPosition(float position)
Sets the position.

Parameters:
position - the position to set

setShortName

public void setShortName(java.lang.String shortName)
Sets the short name.

Parameters:
shortName - the short name to set

setSmallIconPath

public void setSmallIconPath(java.lang.String smallIconPath)
Sets the small icon path.

Parameters:
smallIconPath - the samll icon path to set

setup

public boolean setup(CmsObject cms,
                     CmsToolRootHandler root,
                     java.lang.String resourcePath)
Default implementation.

It takes the icon path from CmsPropertyDefinition.PROPERTY_NAVIMAGE property, or uses a default icon if undefined, the name is taken from the CmsPropertyDefinition.PROPERTY_NAVTEXT property, or uses the CmsPropertyDefinition.PROPERTY_TITLE property if undefined, or an default text, if still undefined. if you want 2 different names, one for the big icon tools and one for the menu/navbar entries, use a VALUE_SEPARATOR to separate them in the property. (if you do so, the first one is for big icons and the second one for menu/navbar entries). the help text is taken from the CmsPropertyDefinition.PROPERTY_DESCRIPTION property or a default text if undefined, if you want to customize a help text while disabled, use a VALUE_SEPARATOR as a separator in the same property.

The group is taken from the CmsPropertyDefinition.PROPERTY_NAVINFO property, the position from the CmsPropertyDefinition.PROPERTY_NAVPOS and the install path is given by the folder structure if the ARGS_PROPERTY_DEFINITION property does not include path information.

For the icon path you can specify 2 paths separated by a VALUE_SEPARATOR, the first one will be used as a group icon (32x32), and the second as an menu icon (16x16). The paths are relative to the /system/workplace/resources/ folder. If the tool is disabled, the names of the icons are composed as ${name}_disabled.${ext}

The confirmation message is taken from the ARGS_PROPERTY_DEFINITION with key #ARG_CONFIRMATION_NAME

Specified by:
setup in interface I_CmsToolHandler
Parameters:
cms - the admin context (at opencms-workplace (re-)initialization time)
root - the root context
resourcePath - the resource path of the file/folder to use as admin tool
Returns:
false if something goes wrong
See Also:
I_CmsToolHandler.setup(org.opencms.file.CmsObject, CmsToolRootHandler, java.lang.String)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()

setLink

protected void setLink(CmsObject cms,
                       java.lang.String resourcePath)
Sets the link for the given resource.

Use the resourcePath as link if it is not a folder. If it is a folder, try to use the folder default file property value as link. if not use the CmsToolManager.VIEW_JSPPAGE_LOCATION.

Parameters:
cms - the cms context
resourcePath - the path to the resource to set the link for

setParameters

protected void setParameters(CmsObject cms,
                             java.lang.String resourcePath)
Sets the needed properties from the ARGS_PROPERTY_DEFINITION property of the given resource.

Parameters:
cms - the cms context
resourcePath - the path to the resource to read the property from