Select to view content in your preferred language

UndoManager's Operations

1517
5
06-30-2011 01:47 PM
MarkHoover
Frequent Contributor
As per the API:

add(operation)
Adds an undo operation to the stack and clears the redo stack.
Return value: none
Input Parameters:
<Operation> operation Required An operation to add to the stack.

Code snippets:

  var operation = new esri.dijit.editing.Delete({
    featureLayer: layer,
    deletedGraphics: [feature]
  });
 
  undoManager.add(operation);

I am curious how an Operation is defined.  It is not a part of the API, and considering the wide variety of actions I would like to include, I have generally no idea how to go about defining an Operation to add to my stack, other than the ones included in the API for UndoManager and in the one Sample that uses it.

Has anyone implemented this?  Any insight you could provide would be great.  Our highest priority for this involves drawing graphics on the map, changing the color/scale/rotation/etc. of those graphics, deleting said graphics, etc...
0 Kudos
5 Replies
JianHuang
Deactivated User
Mark,

You can certainly implement your own operations by extending the base class "esri.OperationBase", which requires to implement two methods�?"performUndo" and "performRedo".
Please take a look at the doc:
http://help.arcgis.com/en/webapi/javascript/arcgis/help/jsapi_start.htm#jsapi/operationbase.htm
There is a sample included.
Hope this helps.
0 Kudos
MarkHoover
Frequent Contributor
Excellent, Jian, thanks.  Perhaps UndoManager's add/remove methods should mention this?

Also, the sample provided does not include an example of inheriting from the OperationBase class.  Rather, it uses the provided operations from the Editing realm (Add, Cut, Update, Union, Delete).  Any chance of getting a sample showing an Operation built by inheriting from OperationBase?
0 Kudos
JianHuang
Deactivated User
Mark,

There is a code snippet illustrating how to inherit the base class in the section of "Constructor Detail".
0 Kudos
KellyHutchins
Esri Notable Contributor
0 Kudos
MarkHoover
Frequent Contributor
Jian and Kelly, thanks for the help.  Those were exactly the resources I needed.
0 Kudos