Working with the EditorTask control


In this topic


Customizing the EditorTask control

While the EditorTask control includes a comprehensive set of out-of-the-box capabilities, many Web editing solutions require customizing the behavior of the EditorTask to meet your specific requirements. The EditorTask control has the following options to develop a custom solution:
  • Option 1—Adds custom functionality by handling EditorTask events on a page. This option provides convenient access to standard EditorTask events in a Web application.
  • Option 2—Creates a custom Web control by subclassing the EditorTask and its child controls. This option is more complex and provides comprehensive access to the implementation details (including events) of the EditorTask and its subcomponents. It also enables you to package a Web Application Developer Framework (ADF) editing solution as a redistributable custom EditorTask control. 
With either option, it is important to understand the existing structure of an EditorTask control. At runtime, the EditorTask creates the following visible container controls:
  • Editor—Composite control that contains a VersionIDPanel or a set of editor panels and other controls to edit feature layers. 
  • EditorSettingsPanel—Type of EditorPanel that contains a SnappingPanel and SelectionPanel. 
The class type and naming of these components are important when working with EditorTask events or subclassing them in a custom EditorTask control.
For more information about the EditorTask control, see EditorTask control.

Panel structure and naming

This section shows screen shots of the Editor panel with the class type and unique control ID for notable components packaged with the EditorTask. For each component shown in the screen shots, the class type is listed above the unique control ID, which is shown in quotation marks.
If an editable layer is versioned and more than one version is available for editing, the VersionIDPanel shows in the Editor when the EditorTask is initialized at runtime. See the following screen shot:

The EditorTask has an Editor that represents the primary visible control containing other editing controls. The Editor contains a drop-down list to select an editable layer. The main toolbar contains a set of tools and commands to manage selected features in the active edit layer. A set of commands to manage edit operations can be included depending on the type of layer being edited and the map service in which it is accessed; however, the main toolbar can be customized.
  • When editing a non-versioned feature layer in a pooled service, the main toolbar does not contain an Undo, Redo, or Save button. 
  • When editing non-versioned data in a non-pooled service, the Undo and Redo buttons are not available. 
The Editor also contains the following set of panels to create and modify features and attributes:
  • CreateFeaturePanel—Contains one or more tools to create a feature depending on the active edit layer feature type (also has a toolbar that cannot be customized). 
  • EditExistingFeaturesPanel—Contains tools and commands to modify existing features and has the following toolbars:
    • GeometryToolbar1—Includes items to modify entire features (can be customized).
    • GeometryToolbar2—Includes items to manipulate feature vertices (can be customized).   
  • EditAttributesPanel—Lists the attributes of the current set of selected features. Since only one feature's attributes can be visible, paging is enabled when more than one feature is selected. The visibility and edit ability of attributes can be modified via attribute filtering. Attribute labels and text boxes are generated internally by the EditAttributesPanel and are not available for explicit customization.

    See the following screen shot that shows these Editor panels and associated toolbars:

  • EditorSettingsPanel—The EditorTask also contains an EditorSettingsPanel that can be initialized via the Editor at runtime and compliments actions initiated by Editor panels. The EditorSettingsPanel contains the following panels:
    • SnappingPanel—Provides the ability to change snapping rules and SnapTips display at runtime. 
    • SelectionPanel—Provides the ability to modify selection behavior when using the select tool on the Editor's main toolbar.  

      The SnappingPanel and SelectionPanel are not customizable; however, you can add or remove panels from the EditorSettingsPanel.

      See the following screen shot that shows these Editor panels: 

Customization categories

The EditorTask supports customization in the following distinct, but related categories:
The options for developing a custom EditorTask solution is discussed in this section within the context of each category. For more information, see the Common custom EditorTask sample.
Option 1 uses an out-of-the-box EditorTask control and EditorTask events within the context of the page's and control's life cycle to implement custom capabilities in each category. You can add event handlers during the page's or EditorTask control's life cycle events (for example, init and load).

The following illustration highlights where these categories can be leveraged with option 1:

 
Option 2 shows how to subclass existing EditorTask controls, override members, create custom components, and construct a redistributable EditorTask component. All customization capabilities in option 1 are available with option 2, plus those capabilities that are only available within a subclass solution (for example, protected members). 
Instead of working with the event handler, EditorTask and Editor events are overridden in their respective subclass. 

The following illustration highlights where the implementation of each customization category can occur when extending the EditorTask:

 

EditorTask events

Customizing an out-of-the-box EditorTask control involves working with EditorTask events and event handlers. EditorTask event methods can be overridden in a subclassed EditorTask, but are not explicitly necessary. The following discusses each EditorTask event:
  • EditorPanelsCreated—Triggered after the panels in the Editor are created during the CreateChildControls() method. The created panels are—CreateFeaturePanel, EditExistingFeaturePanel, and EditAttributesPanel. The event argument (EditorPanelsCreatedEventArgs) references a collection of panels. For more information, see the Custom editor panels section in this topic.
  • SettingsPanelsCreated—Triggered after the panels in the EditorSettingsPanel are created during the CreateChildControls() method. The created panels are—SnappingPanel and SelectionPanel. The event argument (EditorPanelsCreatedEventArgs) references a collection of panels and can be used to add, remove, or modify panels. For more information, see the Custom editor panels section in this topic.
  • ToolsCreated—Triggered twice per request, when the toolbar in the Editor control is created and when the toolbars in the EditExistingFeaturePanel are created. The Editor control contains one toolbar with the MainToolbar ID. The EditExistingFeaturePanel contains GeometryToolbar1 and GeometryToolbar2. The CreateFeaturePanel contains a toolbar, but it cannot be customized. Handle this event to remove and modify toolbar items on an existing toolbar, add new toolbar items, remove toolbars, or add new toolbars. Only toolbars and tools in the Editor and EditExistingFeaturePanel can be modified. The event argument (ToolsCreatedEventArgs) references the container, Editor, or EditExistingFeaturePanel via the Parent property. The Toolbars property contains a collection of toolbars in the respective parent. For more information, see the Custom editor toolbars and toolbar items section in this topic.
  • SetVersion—Triggered via a postback or callback when a geodatabase version is selected in the VersionIDPanel. Handle this event to change EditorTask content or behavior based on a specific version. The event argument (SetVersionEventArgs) returns the selected version string.
  • LayerChanged—Unique event because the event handler is exposed on the Editor, not the EditorTask. LayerChanged can be triggered via a postback or callback initiated (by two actions in an Editor) when a geodatabase version is selected in the VersionIDPanel and when a layer is selected on the layer drop-down list at the top of the Editor, after a version has been selected. Handle this event to get a reference to the active editable feature layer and modified EditorTask behavior, or prepare the feature layer for editing. The event argument (IFeatureLayer) provides access to the ArcObjects feature layer and feature class. 

    The following illustration shows the event type, the EditorTask component that triggers the event, and when it is triggered (for example, which method in the component). The CreateChildControls() method for all components is called between the control load, page pre-render upon the initial request, and between page init and page load during every postback and callback. 

  • PreAttributeEdit—Triggered when the value in a text box on the EditAttributesPanel is changed, and the text box loses focus. A callback to the EditAttributesPanel calls the SaveEdit() method (the SaveEdit() method cannot be overridden). The PreAttributeEdit event is triggered before an edit operation is initiated, namely a call to the ArcObjects IWorkspaceEdit.StartEditOperation() method. Handle this event to modify the provided attribute value or update other attributes during the same operation. The event argument (PreAttributeEditEventArgs) provides access to the IFeatureLayer, IFeature, and IField interfaces being edited and the new attribute value. You can also cancel the edit operation at this point by setting the Cancel property to true. The event also maintains the ReturnMessage property to send a message to the client in an alert box.
  • PostAttributeEdit—Triggered when the value in a text box on the EditAttributesPanel is changed and the text box loses focus. A callback to the EditAttributesPanel calls the SaveEdit() method. The PostAttributeEdit event is triggered after an edit operation has occurred, namely after a call to the ArcObjects IWorkspaceEdit.StopEditOperation() method. Handle this event to modify information shown to the user or update other related server-side content. The event argument (PostAttributeEditEventArgs) provides access to the IFeatureLayer, IFeature, IField interfaces and the new value used in the edit operation. You can also verify if the operation was successful and if not, interrogate the exception. The event also maintains the ReturnMessage property to send a message to the client in an alert box.

    See the following illustration that shows the PreAttributeEdit and PostAttributeEdit events:

  • PreCommandExecute—Triggered when clicking a toolbar button in the EditorTask that initiates a callback to the Web application. The implementation code for the command is in a class that inherits from EditorServerCommandAction. A callback to the Toolbar control (can be an EditorToolbar) calls the EditorServerAction() method in the custom command action class. The EditorServerCommandAction class is associated with a Toolbar control via an EditorCommand, a type of toolbar item. 

    The PreCommandExecute event is triggered before the EditorServerAction() method is executed. Handle this event to check edit layer properties or work with other content in the map service. This event is useful if you do not have access to the command source code or need to initiate the same set of actions before any group of commands execute. The event argument (PreCommandExecuteEventArgs) provides access to the ServerAction class (EditorServerCommandAction class), which references several useful properties. The IMap, IMapServer, and server context of the map service associated with the command action are available. 

    The ArcObjects IDataset and Simple Object Access Protocol (SOAP) LayerDescription for the active edit layer are also provided. The ToolbarItemInfo property returns information about the EditorCommand toolbar item. Use the Editor property to get a reference to the Editor control. With the Editor control, you can interact with current edit session properties, such as the active edit layer name, MapFunctionality or MapResource associated with the EditorTask, or add custom CallbackResults to the callback response. You can also cancel the command by setting the Cancel property to true. The event also maintains the ReturnMessage property to send a message to the client in an alert box.
  • PostCommandExecute—Triggered when clicking a button on a toolbar in the EditorTask. The implementation code is in a class that inherits from EditorServerCommandAction. The PostCommandExecute event is triggered after the EditorServerAction() method is executed. Handle this event to perform post command processing on the active edit layer or other content in the map service. The event argument (EditorCommandEventArgs) provides access to the ServerAction class, which references several useful properties. This event argument exposes the same properties as PreCommandExecuteEventArgs minus the Cancel option.

    See the following illustration that shows the PreCommandExecute and PostCommandExecute events:


  • PreToolExecute—Triggered when applying a tool in a Map control associated with the EditorTask. The implementation code for the tool action is in a class that inherits from EditorServerToolAction. A callback to the Map control calls the EditorServerAction() method in the tool action class. The EditorServerToolAction class is associated with a Toolbar control via an EditorTool, a type of toolbar item.  

    The PreToolExecute event is triggered before the EditorServerAction() method is executed. Handle this event to check edit layer properties, modify user provided input geometry, or work with other content in the map service. The event argument (PreToolExecuteEventArgs) provides access to the ServerAction class (EditorServerToolAction class), which references several useful properties. The IMap, IMapServer, and server context of the map service associated with the tool action are available. The ArcObjects IDataset and SOAP LayerDescription for the active edit layer are also provided. The ToolEventArgs provides access to the Map control in which the tool was applied (same Map control that generates a callback response). It also exposes the user provided geometry in screen units. The Geometry property on the event argument returns the ArcObjects geometry type in map units. 

    Use the Editor property to get a reference to the Editor control. With the Editor control, you can interact with current edit session properties, such as retrieving the active edit layer name, MapFunctionality or MapResource associated with the EditorTask, or refresh Editor content. You can also cancel the command by setting the Cancel property to true. The event also maintains the ReturnMessage property to send a message to the client in an alert box.
  • PostToolExecute—Triggered when applying a tool in a Map control associated with the EditorTask. The implementation code for the tool action is in a class that inherits from EditorServerToolAction. A callback to the Map control calls the EditorServerAction() method in the tool action class. The EditorServerToolAction class is associated with a Toolbar control via an EditorTool, a type of toolbar item.  

    The PostToolExecute event is triggered after the EditorServerAction() method is executed. Handle this event to confirm proper execution, initiate further actions, or work with other content in the map service. The event argument (EditorToolEventArgs) provides access to the ServerAction class (EditorServerToolAction class), which references several useful properties. This event argument exposes the same properties as the PreToolExecuteEventArgs minus the Cancel option.

    See the following illustration that shows the PreToolExecute and PostToolExecute events:

Attribute filtering

The EditorTask can be customized to filter attributes available for editing at runtime. The EditorTask has a property, AttributeDisplay, which is a collection of AttributeDisplayInfo objects. The AttributeDisplayInfo class allows you to define how attributes show for a specific layer using the DisplayMode enumeration. 
The following table defines the DisplayMode enumeration:
DisplayMode enumeration
Description
Editable
Attribute is displayed and editable.
ReadOnly
Attribute is shown as read-only (text is unavailable in the text box).
Hidden
Attribute is not shown.
Use the AttributeDisplayInfo class to do the following:
  • Specify how attributes display by default.
  • Define how specific fields show using the Add method.
If you only want to show a few attributes, set the default display mode to "Hidden" (via the constructor or DefaultDisplayMode property), then list the fields you want to display. Conversely, if you have many attributes and only want to hide a few, set DefaultDisplayMode to "Editable" or "ReadOnly," then turn off the fields you want to hide.  
The following code example shows filtering attributes on a layer using AttributeDisplayInfo. For customization option 1 (out-of-the-box EditorTask), filter attributes during the initial Page_Load or add an event handler on the EditorTask OnLoad event. For option 2 (custom EditorTask subclass), override the OnLoad event of the custom EditorTask class and filter attributes when the control is first loaded.  
[C#]
protected void Page_Load(object sender, EventArgs e)
{
    if (!Page.IsPostBack)
        FilterAttributes();
}

private void FilterAttributes()
{
    AttributeDisplayInfo adi = new AttributeDisplayInfo(5,
        AttributeDisplayMode.Hidden);
    adi.Overrides.Add(new AttributeDisplayOverride("STATE_NAME",
        AttributeDisplayMode.ReadOnly));
    adi.Overrides.Add(new AttributeDisplayOverride("STATE_FIPS",
        AttributeDisplayMode.ReadOnly));
    adi.Overrides.Add(new AttributeDisplayOverride("SUB_REGION",
        AttributeDisplayMode.ReadOnly));
    adi.Overrides.Add(new AttributeDisplayOverride("POP1990",
        AttributeDisplayMode.ReadOnly));
    adi.Overrides.Add(new AttributeDisplayOverride("POP1999",
        AttributeDisplayMode.Editable));
    adi.Overrides.Add(new AttributeDisplayOverride("AVG_SALE87",
        AttributeDisplayMode.Editable));
    EditorTask1.AttributeDisplay.AttributeDisplayInfos.Add(adi);
}
Based on the preceding code example, the following screen shots show the "before" and "after" EditorTask with changes in the attribute panel:

Custom editor toolbars and toolbar items

The out-of-the-box EditorTask includes a set of prepackaged toolbars and toolbar items available for use at runtime. It also includes a set of custom components to support EditorTask specific behavior in toolbars, tools, and commands. The prepackaged toolbars and toolbar items can be modified, and new toolbars and toolbar items can be added. In all cases, a toolbar in an EditorTask resides in the Editor or an editor panel. The technique for accessing and modifying these toolbars, and adding new toolbars and toolbar items depends on the custom EditorTask solution (option 1 or 2).    
The Editor and EditExistingFeaturePanel containers in the EditorTask expose toolbars for customization.
  • The Editor contains a toolbar (MainToolbar) to manage selecting features and saving edits. 
  • The EditExistingFeaturePanel contains GeometryToolbar1 and GeometryToolbar2 toolbars. GeometryToolbar1 contains toolbar items to manage complete feature edits. GeometryToolbar2 contains toolbar items to manage feature vertex edits.
If working with the out-of-the-box EditorTask (option 1), handle the ToolsCreated event to gain access to a list of toolbars and their parent. The ToolsCreated event is called twice for every request, once for the Editor and once for the EditExistingFeaturePanel. 
Use the Parent property on the ToolsCreatedEventArgs event argument to retrieve the parent control in which the CreateToolbars() method was called. Use the Toolbars property to return the toolbars in the parent. Existing toolbars and toolbar items can be removed and custom toolbar items can be added to existing toolbars. You can use the Toolbars property to add and reorder toolbars to the current parent container.
If creating a custom EditorTask control (option2), override the CreateToolbars method in the custom Editor and EditExistingFeaturePanel. In either case, call the base.CreateToolbars() method to return the default toolbars. The CreateToolbars() method is called during the execution of the CreateChildControls() method. Existing toolbars and toolbar items can be removed or modified while custom toolbars and toolbar items can be added. Custom toolbars and toolbar items can be added to existing or new editor panels by overriding and implementing the CreateChildControls() method (standard when creating any custom Web control). 
The EditorTask includes a set of custom classes and interfaces to use when creating toolbars and toolbar items for use within an EditorTask. These classes and interfaces wrap existing Web ADF toolbar components to use within the events and operations specifically associated with the EditorTask. Regardless of which customization option you choose, the same set of EditorTask components are available for use. Most of the toolbar and toolbar item components enhanced for use with the EditorTask reside in the ESRI.ArcGIS.ADF.ArcGISServer.Editor.Tools namespace.
  • Custom editor toolbar—All toolbars included with the EditorTask (available in the Editor and EditExistingFeaturePanel) are a type of EditorToolbar. The EditorToolbar class extends the Web ADF toolbar in the following ways: 
    • Sets the toolbar group for all EditorToolbars to the same value, EditorToolbarGroup. 
    • Enables and disables toolbar items depending on the feature type and number of features selected in the active edit layer.  
To take advantage of this capability, a custom tool or command must be a type of EditorTool or EditorCommand. To create a custom toolbar, create a new instance of an EditorToolbar. Set the ToolbarStyle, ID, and most importantly, the buddy control. Set the buddy control to the Map control ID associated with the Editor to allow tools and commands on the toolbar to interact with the Map in which the EditorTask edits data. 
See the following code example:
[C#]
ESRI.ArcGIS.ADF.ArcGISServer.Editor.Tools.EditorToolbar newEditorToolbar = new
    ESRI.ArcGIS.ADF.ArcGISServer.Editor.Tools.EditorToolbar();
newEditorToolbar.ToolbarStyle =
    ESRI.ArcGIS.ADF.Web.UI.WebControls.ToolbarStyle.ImageOnly;
newEditorToolbar.ID = "MyCustomToolbar";
newEditorToolbar.BuddyControlType =
    ESRI.ArcGIS.ADF.Web.UI.WebControls.BuddyControlType.Map;
newEditorToolbar.BuddyControls.Add(new
    ESRI.ArcGIS.ADF.Web.UI.WebControls.BuddyControl(EditorTask1.Editor.MapID));
  • Custom editor tool—A set of editor tools are included for use with the EditorTask. The following table shows the class name and description. The class name is usually different than the editor tool name. For example, the EditExistingFeaturePanel included with the EditorTask contains an EditorTool (CopyPointFeature) whose ServerActionClass references the CopyFeature class.
EditorServerToolAction class name
Description
AddVertex
Adds a vertex to the selected features. Included with GeometryToolbar2 in the EditExistingFeaturePanel.
CopyFeature
Copies the selected features. Included with GeometryToolbar1 in the EditExistingFeaturePanel.
CreateFeature
Creates a feature using the type defined by the active edit layer. The CreateFeaturePanel includes a tool to create features based on the symbol classifications in the active edit layer. The tool is generated internally by the CreateFeaturePanel (does not use the CreateFeature tool).
DeleteVertex
Deletes a vertex in the selected features. Included with GeometryToolbar2 in the EditExistingFeaturePanel.
MoveFeature
Moves the selected features. Included with GeometryToolbar1 in the EditExistingFeaturePanel.
MoveVertex
Moves a vertex in the selected features. Included with GeometryToolbar2 in the EditExistingFeaturePanel.
SelectFeature
Selects features in the active edit layer. Included with MainToolbar in the Editor.
SplitFeature
Splits the selected set of features with a defined line. Included with GeometryToolbar1 in the EditExistingFeaturePanel. Calls IFeatureEdit.SplitWithUpdate().
TrimFeature
Cuts the selected set of features with a defined line. Not included in an out-of-the-box toolbar. Calls ITopologicalOperator3.Cut(). 

When creating a custom tool for the EditorTask, subclass the EditorServerToolAction class and override the EditorServerAction method. The EditorServerToolAction class wraps your custom tool code for explicit use within the ArcObjects editing environment provided by the EditorTask. The EditorServerToolAction class is built on the base class, EditorServerActionBase, which provides access to the current Editor, and the ArcObjects server context, IMapServer, IMap, IDataSet, IFeatureLayer, and ArcGIS Server SOAP LayerDescription for the feature layer being edited. A set of methods are available to support customizing the initialization of the tool, modifying pre and post editing operations, changing error messages, refreshing the Editor, and displaying the EditorTask Asynchronous JavaScript and XML (AJAX) indicator. 

The EditorServerToolAction class hooks into the pre and post tool execute event framework in the EditorTask. To use this event framework, override the EditorServerAction method to include the custom implementation code for your custom editor tool. This method is called from the ServerAction in the EditorServerToolAction class—after the PreToolExecuteEvent and before the PostToolExecuteEvent. 

During the EditorServerAction method implementation, call the StartEditOperation() method before the edit occurs, for example, IFeature.Store(); call StopEditOperation() after the edit occurs; and call AbortEditOperation() after an exception is thrown during the edit process. All edit operation methods enable and disable a workspace for editing. The EditorServerToolAction class provides access to editor tool input, such as the user input geometry and whether snapping is applied. After tool execution, editor toolbars are refreshed (enables and disables the save edits button), edit status is updated (displays a notice if there are unsaved edits), and the EditorTask AJAX indicator is hidden. 

The following code example shows an abbreviated version of the implementation code associated with a custom editor tool designed to clip selected features with a user provided envelope:
[C#]
namespace CustomEditorTask_CSharp
{
    class ClipFeatures: EditorServerToolAction
    {
        private List < int > features = new List < int > ();
        public List < int > Features
        {
            get
            {
                return features;
            }
        }
        protected override void EditorServerAction()
        {
            IEnvelope agsCOMEnvelope = this.Geometry as IEnvelope . . . try
            {
                StartEditOperation();
                . . . agsCOMTopoOp3.Clip(agsCOMEnvelope);
                agsCOMFeature.Store();
                features.Add(agsCOMFeature.OID);
                . . . StopEditOperation();
            }
            catch (Exception e)
            {
                AbortEditOperation(e);
            }
            if (features.Count > 0)
            {
                Refresh(features, true);
            }
        }
    }
}
Wrap the custom editor tool action to use in an EditorToolbar with the EditorTool class. The EditorTool class extends the Web ADF tool and implements the IEditorToolbarItem interface. See the following illustration:



These enhancements enable you to associate the custom tool with the ID of the Map on which the tool operates, determine whether snapping should be applied, define the feature types on which the tool can be used, and set the minimum number of selected features in the current editable layer to enable the tool. 

All parameters are provided in the EditorTool constructor. Additional properties on the editor tool are associated with standard custom tool implementation, such as client action, image bitmap display, and ToolTips. The custom editor tool action is associated with the editor tool via the ServerActionAssembly and ServerActionClass properties. The ServerActionAssembly is the name of the assembly that contains the custom editor tool action class. The ServerActionClass is the fully qualified name of the custom editor tool action class. 

The following code example shows a custom editor tool created and added to a custom editor toolbar. This code example shows a custom EditorTask where image resources are embedded. Call this code during the CreateChildControls() method of the custom editor panel or when overriding CreateToolbars() in an Editor or EditExistingFeaturePanel subclass.
[C#]
EditorTool clip = new EditorTool("Clip", ParentEditor.MapID, false,
    ToolGeometry.Line ToolGeometry.Polygon, 1);
clip.ClientAction = Constants.HTML_DRAG_RECTANGLE;
clip.DefaultImage = this.Page.ClientScript.GetWebResourceUrl(typeof(CustomEditorTask)
    , "CustomEditorTask_CSharp.images.clip.png");
clip.SelectedImage = this.Page.ClientScript.GetWebResourceUrl(typeof
    (CustomEditorTask), "CustomEditorTask_CSharp.images.clip_ON.png");
clip.HoverImage = this.Page.ClientScript.GetWebResourceUrl(typeof(CustomEditorTask),
    "CustomEditorTask_CSharp.images.clip_OVER.png");
clip.ToolTip = "Clip feature(s)";
clip.ServerActionAssembly = "CustomEditorTask_CSharp";
clip.ServerActionClass = "CustomEditorTask_CSharp.ClipFeatures";
newEditorToolbar.ToolbarItems.Add(clip);
  • Custom editor command—A set of editor commands are included to use with the EditorTask. The following table shows the class name and description:
EditorServerCommandAction class name
Description
ClearSelection
Clears selected features in an active edit layer. Included with the MainToolbar in the Editor.
DeleteFeature
Deletes the selected features in the active edit layer. Included with GeometryToolbar1 in the EditExistingFeaturePanel.
MergeFeature
Merges the selected features in the active edit layer. Included with GeometryToolbar1 in the EditExistingFeaturePanel. Calls ITopologicalOperator3.Union()
SetEditState
Handles commands associated with non-pooled and versioned edit operations. The buttons to save, undo, and redo edits included with the MainToolbar
in the Editor use this command class.  
ShowVertex
Shows vertices of the selected feature in the active edit layer. Included with MainToolbar in the Editor.

When creating a custom command for the EditorTask, subclass the EditorServerCommandAction class and override the EditorServerAction method. The EditorServerCommandAction class wraps your custom command code for explicit use within the ArcObjects editing environment provided by the EditorTask. The EditorServerCommandAction class is built on the base class, EditorServerActionBase, which provides access to the current Editor; the ArcObjects server context, IMapServer, IMap, IDataSet, and the IFeatureLayer, and ArcGIS Server SOAP LayerDescription for the feature layer being edited. A set of methods are available to modify pre and post editing operations, change error messages, refresh the Editor, and display the EditorTask AJAX indicator. 

The EditorServerCommandAction class hooks into the pre and post command execute event framework in the EditorTask. To use this event framework, override the EditorServerAction method to include the custom implementation code for your custom editor command. This method is called from the ServerAction in the EditorServerCommandAction class—after the PreCommandExecuteEvent and before the PostCommandExecuteEvent. 

During EditorServerAction method implementation, call the StartEditOperation() method before the edit occurs, for example, IFeature.Store(); call StopEditOperation() after the edit occurs; and call AbortEditOperation() after an exception is thrown during the edit process. All edit operation methods enable and disable a workspace for editing. After command execution, Editor toolbars are refreshed (enables and disables the save edits button), edit status is updated (displays a notice if there are unsaved edits), and the EditorTask AJAX indicator is hidden. 

The following code example shows an abbreviated example of the implementation code associated with a custom editor command designed to convert selected polygons into polylines and store them in a predefined feature class:
[C#]
namespace CustomEditorTask_CSharp
{
    class PolygonToLine: EditorServerCommandAction
    {
        private List < int > features = new List < int > ();
        public List < int > Features
        {
            get
            {
                return features;
            }
        }
        protected override void EditorServerAction()
        {
            . . . try
            {
                StartEditOperation();
                . . . agsCOMNewFeature = DestinationFeatureClass.CreateFeature();
                agsCOMNewFeature.Shape = agsCOMTopoOp3.Boundary;
                agsCOMNewFeature.Store();
                features.Add(agsCOMNewFeature.OID);
                . . . StopEditOperation();
            }
            catch (Exception e)
            {
                AbortEditOperation(e);
            }
            if (features.Count > 0)
            {
                Refresh(features, true);
            }
        }
    }
}
Wrap the custom editor command action to use in an EditorToolbar with the EditorCommand class. The EditorCommand class extends the Web ADF command by implementing the IEditorToolbarItem interface. See the following illustration:



The IEditorToolbarItem interface enables you to define the feature types on which the command can be used and the minimum number of selected features in the current editable layer to enable the command. All parameters are provided in the EditorCommand constructor. Additional properties on the editor tool are associated with standard custom command implementation, such as image bitmap display and ToolTips. The custom editor command action is associated with the editor command via the ServerActionAssembly and ServerActionClass properties. The ServerActionAssembly is the name of the assembly that contains the custom editor command action class. The ServerActionClass is the fully qualified name of the custom editor command action class.  

The following code example shows a custom editor command created and added to a custom editor toolbar. The code example shows a custom EditorTask where image resources are embedded. Call this code during the CreateChildControls() method of the custom editor panel or when overriding CreateToolbars() in an Editor or EditExistingFeaturePanel subclass.
[C#]
EditorCommand ptl = new EditorCommand("PolygonToLine", ToolGeometry.Polygon, 1);
ptl.DefaultImage = this.Page.ClientScript.GetWebResourceUrl(typeof(CustomEditorTask),
    "CustomEditorTask_CSharp.images.polygon2line.png");
ptl.SelectedImage = this.Page.ClientScript.GetWebResourceUrl(typeof(CustomEditorTask)
    , "CustomEditorTask_CSharp.images.polygon2line_ON.png");
ptl.HoverImage = this.Page.ClientScript.GetWebResourceUrl(typeof(CustomEditorTask), 
    "CustomEditorTask_CSharp.images.polygon2line_OVER.png");
ptl.ToolTip = "Convert polygon feature(s) to polylines";
ptl.ServerActionAssembly = "CustomEditorTask_CSharp";
ptl.ServerActionClass = "CustomEditorTask_CSharp.PolygonToLine";
newEditorToolbar.ToolbarItems.Add(ptl);

Custom editor panels

The out-of-the-box EditorTask includes a set of prepackaged editor panels to use at runtime. By default, there are two parent panels included with the EditorTask—Editor and EditorSettingsPanel. Both include a set of subpanels that contain logically grouped functionality. The EditorTask also includes a set of components to support extending existing editor panels and to create editor panels. EditorPanel extends the Web ADF FloatingPanel, and provides access to the parent EditorTask, Editor, and feature layer associated with the active edit layer. TooledEditorPanel extends EditorPanel by defining a collection of toolbar items that can be populated by overriding the CreateToolbars() method. Any subclass of TooledEditorPanel (for example, EditExistingFeaturePanel) triggers the ToolsCreated event on the EditorTask when CreateToolbars() returns.
The technique for accessing and modifying panels depends on the custom EditorTask solution (option 1 or 2). The content of an EditorPanel can contain an editor toolbar and toolbar items
The Editor contains three editor panels by default. Each panel is available via a property on the Editor and contains prepackaged functionality. At a minimum, each panel is a type of EditorPanel. See the following table:
Editor property
Description
NewFeatureCreator
Returns an instance of the CreateFeaturePanel. 
ExistingFeatureEditor
Returns an instance of the EditExistingFeaturePanel. Subclasses TooledEditorPanel.
AttributesEditor
Returns an instance of the EditAttributesPanel.
EditorPanels
Returns a collection of editor panels contained by the Editor. 
The EditorSettingsPanel contains two editor panels by default. Some properties are provided on the EditorSettingsPanel to provide access to these subpanels. See the following table:
EditorSettingsPanel property
Description
SnappingPanel
Returns an instance of the SnappingPanel.
EditorPanels
Returns a collection of the editor panels contained by the EditorSettingsPanel. Includes a reference to the SelectionPanel.
To add, remove, or modify editor panels in the out-of-the-box EditorTask (option 1), handle the EditorPanelsCreated event to access the Editor panels collection; and handle the SettingsPanelsCreated event to access the EditorSettingsPanel panels collection.
To add a panel, create a subclass of EditorPanel or TooledEditorPanel and add it to the collection exposed in the event argument. To add controls to the custom panel, override the CreateChildControls() method. To start with an existing editor panel (for example, EditExistingEditorPanel), subclass the appropriate panel class and override the appropriate members. For example, you can create a custom panel that subclasses the EditExistingEditorPanel class, override the CreateToolbars() method to add custom toolbar items, then add the custom panel to the Editor or EditorSettingsPanel. You can also modify toolbars and toolbar items in the existing EditExistingEditorPanel via the ToolsCreated event.         
The following code example shows a simple custom EditorPanel:
[C#]
public class MyPanel: EditorPanel
{
    public MyPanel(string title, EditorTask task, string ID): base(title, task, ID){}
    protected override void RenderContents(HtmlTextWriter writer)
    {
        writer.Write("This is my custom panel");
    }
}
By adding this class to the App_Code folder of the EditorTask Web application, the custom panel can be added to the out-of-the-box EditorTask with the following EditorPanelsCreated event handler code example:
[C#]
protected void EditorTask1_EditorPanelsCreated(object sender,
    EditorPanelsCreatedEventArgs e)
{
    MyPanel panel = new MyPanel("My Custom Panel", EditorTask1, "myPanelID");
    e.EditorPanels.Insert(0, panel);
}
In the preceding code example, the custom panel was inserted into the first position in the EditorPanel collection (index 0) allowing the custom panel to display above the other standard EditorPanel panels. The following screen shot shows the custom panel that appears at runtime:
Similarly, a custom panel can be added or can replace an existing panel when creating a custom EditorTask control (option 2). You can also subclass the Editor and EditorSettingPanel class and override the CreateEditorPanels() method to define the added panels. The CreateEditorPanels() method is called in the CreateChildControls() method for each class. A call to base.CreateEditorPanels() returns the default panels available in each container (Editor and EditorSettingsPanels). You can modify this collection or replace it. If you replace an existing panel with a custom panel (for example, replace the existing CreateFeaturePanel with a new panel to create features) override the appropriate method shown in the following table:
Editor method
Description
CreateCreateFeaturePanel
Override to create an instance of a create feature panel. Returns a type of EditorPanel.
CreateEditExistingFeaturePanel
Override to create an instance of an edit existing feature panel. Returns a type of EditorPanel.
CreateEditAttributesPanel
Override to create an instance of an edit attributes panel. Returns a type of EditorPanel.
CreateEditorPanels
Override to modify the panels created for the Editor. Returns a list of EditorPanels.

The Editor and EditorSettingsPanel share the technique for overriding CreateEditorPanels() to set the panels in either container. However, the EditorSettingsPanel does not require you to override another method when replacing a SnappingPanel or SelectionPanel. If replacing the existing SnappingPanel with a new panel that subclasses SnappingPanel (not just EditorPanel), override the SnappingPanel property. The property returns a reference to the new panel created in CreateEditorPanels(). See the following table:
EditorSettingsPanel method
Description
CreateEditorPanels
Override to modify the panels created for the EditorSettingsPanel. Returns a list of editor panels.
The following code example shows how to override the CreateEditorPanels() method in a custom EditorSettingsPanel to define the editor panels it contains:
[C#]
public class CustomEditorSettingsPanel: EditorSettingsPanel
{
    protected override List < EditorPanel > CreateEditorPanels()
    {
        List < EditorPanel > panels = new List < EditorPanel > ();
        CustomEditorTask customEditorTask = (CustomEditorTask)this.Task;
        EditorPanel snappingPanel = null;
        if (customEditorTask.UseMapUnitsForSnapping)
        {
            snappingPanel = new CustomSnappingPanel(this.Task);
            snappingPanel.Visible = true;
        }
        else
        {
            snappingPanel = new SnappingPanel(this.Task);
        }
        panels.Add(snappingPanel);
        EditorPanel selectionPanel = new SelectionPanel(this.Task);
        panels.Add(selectionPanel);
        PolygonToLineLayerEditorPanel customPolygonToLinePanel = new
            PolygonToLineLayerEditorPanel("Polygon to Polyline Settings", this.Task,
            "P2PPanel");
        panels.Add(customPolygonToLinePanel);
        return panels;
    }
}
To integrate a custom Editor or EditorSettingsPanel, subclass the EditorTask and override the CreateEditor() or CreateEditorSettingsPanel() method to create and return an instance of the custom Editor or EditorSettingsPanel, respectively. 
The following code example shows the implementation of a CreateEditor() method in a custom EditorTask:
[C#]
public class CustomEditorTask: ESRI.ArcGIS.ADF.ArcGISServer.Editor.EditorTask
{
    protected override ESRI.ArcGIS.ADF.ArcGISServer.Editor.Editor CreateEditor()
    {
        return new CustomEditor(this);
    }
}


See Also:

EditorTask control
Sample: Common custom EditorTask