com.esri.adf.web.data.tasks
Class TaskToolDescriptor

java.lang.Object
  extended by java.beans.FeatureDescriptor
      extended by com.esri.adf.web.data.tasks.ButtonDescriptor
          extended by com.esri.adf.web.data.tasks.TaskToolDescriptor
All Implemented Interfaces:
TaskToolDescriptorModel, Serializable

public class TaskToolDescriptor
extends ButtonDescriptor
implements TaskToolDescriptorModel

The TaskToolDescriptor class provides metadata for the task tools.

The tool methods executed on the server take MapEvent as its argument. Since tools also have a corresponding client-side behavior, the clientAction is an important property which specifies the JavaScript method to be executed on the client for this tool.

This is the out of box implementation of the TaskToolDescriptorModel interface and supports the rendering of tool buttons as text-only buttons, image-only buttons and image-and-text buttons.

See Also:
Serialized Form

Field Summary
protected  String clientAction
          The name of the JavaScript method to be executed on the client for this tool
protected  String cursor
          The cursor to be displayed on the map control when this tool is active.
protected  String lineColor
          The color of the line drawn when this tool is used on the map control.
protected  int lineWidth
          The width of the line drawn when this tool is used on the map control.
protected  Method toolActionMethod
          The server-side method that processes this tool.
 
Fields inherited from class com.esri.adf.web.data.tasks.ButtonDescriptor
defaultImage, disabled, disabledImage, hoverImage, IMAGE_RENDERER_TYPE, IMAGEANDTEXT_RENDERER_TYPE, justBeenDisabled, rendererType, selectedImage, showLoadingImage, style, styleClass, TEXT_RENDERER_TYPE, toolTip, VALIDATE_ALL_PARAMS, VALIDATE_NONE_PARAMS
 
Fields inherited from interface com.esri.adf.web.data.tasks.TaskToolDescriptorModel
TOOL_NAME
 
Constructor Summary
TaskToolDescriptor(Class taskClass, String toolActionMethodName, String displayName, String clientAction)
          Creates a new TaskToolDescriptor for the given server-side toolActionMethodName and JavaScript clientAction method with a text button renderer.
 
Method Summary
 ToolItem createToolItem(String taskControlId)
           Creates a ToolItem object for this tool.
 Element generateXML(Object task)
           Generates the XML content for this tool.
 Map<String,Object> getAttributes()
          Returns the name-value attributes of this tool
 String getClientAction()
          Returns the name of the JavaScript method to be executed on the client for this tool
 String getCursor()
          Returns the cursor to be displayed on the map control when this tool is active.
 String getLineColor()
          Returns the color of the line drawn when this tool is used on the map control.
 int getLineWidth()
          Returns the width of the line drawn when this tool is used on the map control
 String getName()
           Returns the name of the tool method.
 Method getToolActionMethod()
          Returns the server-side method that processes the tool
 Object processToolAction(Object task, MapEvent event)
          Calls the tool method on the specified task by passing it the MapEvent object.
 void setAttributes(Map<String,?> attributes)
          Sets the name-value attributes of this tool
 void setClientAction(String clientAction)
          Sets the name of the JavaScript method to be executed on the client for this tool
 void setCursor(String cursor)
          Sets the cursor to be displayed on the map control when this tool is active.
 void setLineColor(String lineColor)
          Sets the color of the line drawn when this tool is used on the map control.
 void setLineWidth(int lineWidth)
          Sets the width of the line drawn when this tool is used on the map control
 String toString()
           
 
Methods inherited from class com.esri.adf.web.data.tasks.ButtonDescriptor
generateButtonXML, getDefaultImage, getDisabledImage, getHoverImage, getParamsToValidate, getRendererType, getSelectedImage, getStyle, getStyleClass, getToolTip, isDisabled, isShowLoadingImage, setDefaultImage, setDisabled, setDisabledImage, setHoverImage, setParamsToValidate, setRendererType, setSelectedImage, setShowLoadingImage, setStyle, setStyleClass, setToolTip
 
Methods inherited from class java.beans.FeatureDescriptor
attributeNames, getDisplayName, getShortDescription, getValue, isExpert, isHidden, isPreferred, setDisplayName, setExpert, setHidden, setName, setPreferred, setShortDescription, setValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.esri.adf.web.data.tasks.TaskToolDescriptorModel
getDisplayName, getRendererType, isHidden
 

Field Detail

toolActionMethod

protected transient Method toolActionMethod
The server-side method that processes this tool.


clientAction

protected String clientAction
The name of the JavaScript method to be executed on the client for this tool


cursor

protected String cursor
The cursor to be displayed on the map control when this tool is active. e.g. cross hair


lineColor

protected String lineColor
The color of the line drawn when this tool is used on the map control. The color is a hex. string e.g. #12A3FE The default color is #FF0000


lineWidth

protected int lineWidth
The width of the line drawn when this tool is used on the map control. The default width is 2 px.

Constructor Detail

TaskToolDescriptor

public TaskToolDescriptor(Class taskClass,
                          String toolActionMethodName,
                          String displayName,
                          String clientAction)
Creates a new TaskToolDescriptor for the given server-side toolActionMethodName and JavaScript clientAction method with a text button renderer.

Parameters:
taskClass - the task Class
toolActionMethodName - the name of the server-side tool method
displayName - the display text for the tool button
clientAction - the name of the client-side JavaScript method
Method Detail

createToolItem

public ToolItem createToolItem(String taskControlId)
Description copied from interface: TaskToolDescriptorModel

Creates a ToolItem object for this tool.

This method is called by the task control and the ToolItem created by this method is eventually used to generate the markup / UI for the tool.

Specified by:
createToolItem in interface TaskToolDescriptorModel
Parameters:
taskControlId - the ID of the task control which contains this tool
Returns:
a ToolItem object for this tool

getName

public String getName()
Description copied from interface: TaskToolDescriptorModel

Returns the name of the tool method.

Note that action methods take MapEvent as its argument.

Specified by:
getName in interface TaskToolDescriptorModel
Overrides:
getName in class FeatureDescriptor
Returns:
the name of the tool method

getToolActionMethod

public Method getToolActionMethod()
Returns the server-side method that processes the tool

Returns:
the server-side method that processes the tool

processToolAction

public Object processToolAction(Object task,
                                MapEvent event)
Description copied from interface: TaskToolDescriptorModel
Calls the tool method on the specified task by passing it the MapEvent object.

Specified by:
processToolAction in interface TaskToolDescriptorModel
Parameters:
task - the task object on which the tool method will be invoked
event - the MapEvent method which will be passed as an argument to the tool method
Returns:
the value returned by the tool method

generateXML

public Element generateXML(Object task)
Description copied from interface: TaskToolDescriptorModel

Generates the XML content for this tool. This XML is then transformed by the XSL used by the task control to generate the appropriate markup.

Note that if you implement this method and generate custom XML, you'll also need to provide the XSL that transforms this XML into the appropriate markup. The XSL file that the task control should use can be specified by using the xslFile attribute of the task tag.

Specified by:
generateXML in interface TaskToolDescriptorModel
Parameters:
task - the task object
Returns:
the generated XML Element

getAttributes

public Map<String,Object> getAttributes()
Returns the name-value attributes of this tool

Returns:
the name-value attributes of this tool

getClientAction

public String getClientAction()
Returns the name of the JavaScript method to be executed on the client for this tool

Returns:
the name of the JavaScript method to be executed on the client for this tool

getCursor

public String getCursor()
Returns the cursor to be displayed on the map control when this tool is active. e.g. cross hair

Returns:
the cursor to be displayed on the map control when this tool is active. e.g. cross hair

getLineWidth

public int getLineWidth()
Returns the width of the line drawn when this tool is used on the map control

Returns:
the width of the line drawn when this tool is used on the map control

getLineColor

public String getLineColor()
Returns the color of the line drawn when this tool is used on the map control. The color is a hex. string e.g. #12A3FE

Returns:
the color of the line drawn when this tool is used on the map control

setAttributes

public void setAttributes(Map<String,?> attributes)
Sets the name-value attributes of this tool

Parameters:
attributes - the name-value attributes of this tool

setClientAction

public void setClientAction(String clientAction)
Sets the name of the JavaScript method to be executed on the client for this tool

Parameters:
clientAction - the name of the JavaScript method to be executed on the client for this tool

setCursor

public void setCursor(String cursor)
Sets the cursor to be displayed on the map control when this tool is active. e.g. crosshair

Parameters:
cursor - the cursor to be displayed on the map control when this tool is active. e.g. crosshair

setLineWidth

public void setLineWidth(int lineWidth)
Sets the width of the line drawn when this tool is used on the map control

Parameters:
lineWidth - the width of the line drawn when this tool is used on the map control

setLineColor

public void setLineColor(String lineColor)
Sets the color of the line drawn when this tool is used on the map control. The color is a hex. string e.g. #12A3FE

Parameters:
lineColor - the color of the line drawn when this tool is used on the map control

toString

public String toString()
Overrides:
toString in class Object