/*
 COPYRIGHT 2009 ESRI

 TRADE SECRETS: ESRI PROPRIETARY AND CONFIDENTIAL
 Unpublished material - all rights reserved under the
 Copyright Laws of the United States and applicable international
 laws, treaties, and conventions.

 For additional information, contact:
 Environmental Systems Research Institute, Inc.
 Attn: Contracts and Legal Services Department
 380 New York Street
 Redlands, California, 92373
 USA

 email: contracts@esri.com
 */

if(!dojo._hasResource["esri.dijit.editing.editOperation"]){dojo._hasResource["esri.dijit.editing.editOperation"]=true;dojo.provide("esri.dijit.editing.editOperation");dojo.require("esri.undoManager");dojo.declare("esri.dijit.editing.Add",esri.OperationBase,{type:"edit",label:"Add Features",constructor:function(_1){_1=_1||{};if(!_1.featureLayer){console.error("In constructor of 'esri.dijit.editing.Add', featureLayer is not provided");return;}this._featureLayer=_1.featureLayer;if(!_1.addedGraphics){console.error("In constructor of 'esri.dijit.editing.Add', no graphics provided");return;}this._addedGraphics=_1.addedGraphics;},performUndo:function(){this._featureLayer.applyEdits(null,null,this._addedGraphics);},performRedo:function(){this._featureLayer.applyEdits(this._addedGraphics,null,null);}});dojo.declare("esri.dijit.editing.Delete",esri.OperationBase,{type:"edit",label:"Delete Features",constructor:function(_2){_2=_2||{};this._add=new esri.dijit.editing.Add({featureLayer:_2.featureLayer,addedGraphics:_2.deletedGraphics});},performUndo:function(){this._add.performRedo();},performRedo:function(){this._add.performUndo();}});dojo.declare("esri.dijit.editing.Update",esri.OperationBase,{type:"edit",label:"Update Features",constructor:function(_3){_3=_3||{};if(!_3.featureLayer){console.error("In constructor of 'esri.dijit.editing.Update', featureLayer not provided");return;}this._featureLayer=_3.featureLayer;if(!_3.preUpdatedGraphics){console.error("In constructor of 'esri.dijit.editing.Update', preUpdatedGraphics not provided");return;}this._preUpdatedGraphicsGeometries=[];this._preUpdatedGraphicsAttributes=[];for(var i=0;i<_3.preUpdatedGraphics.length;i++){this._preUpdatedGraphicsGeometries.push(_3.preUpdatedGraphics[i].geometry.toJson());this._preUpdatedGraphicsAttributes.push(_3.preUpdatedGraphics[i].attributes);}if(!_3.postUpdatedGraphics){console.error("In constructor of 'esri.dijit.editing.Update', postUpdatedGraphics not provided");return;}this._postUpdatedGraphics=_3.postUpdatedGraphics;this._postUpdatedGraphicsGeometries=[];this._postUpdatedGraphicsAttributes=[];for(i=0;i<_3.postUpdatedGraphics.length;i++){this._postUpdatedGraphicsGeometries.push(_3.postUpdatedGraphics[i].geometry.toJson());this._postUpdatedGraphicsAttributes.push(dojo.clone(_3.postUpdatedGraphics[i].attributes));}},performUndo:function(){for(var i=0;i<this._postUpdatedGraphics.length;i++){this._postUpdatedGraphics[i].setGeometry(esri.geometry.fromJson(this._preUpdatedGraphicsGeometries[i]));this._postUpdatedGraphics[i].setAttributes(this._preUpdatedGraphicsAttributes[i]);}this._featureLayer.applyEdits(null,this._postUpdatedGraphics,null);},performRedo:function(){for(var i=0;i<this._postUpdatedGraphics.length;i++){this._postUpdatedGraphics[i].setGeometry(esri.geometry.fromJson(this._postUpdatedGraphicsGeometries[i]));this._postUpdatedGraphics[i].setAttributes(this._postUpdatedGraphicsAttributes[i]);}this._featureLayer.applyEdits(null,this._postUpdatedGraphics,null);}});dojo.declare("esri.dijit.editing.Cut",esri.OperationBase,{type:"edit",label:"Cut Features",constructor:function(_4){_4=_4||{};if(!_4.featureLayer){console.error("In constructor of 'esri.dijit.editing.Cut', featureLayer not provided");return;}this._featureLayer=_4.featureLayer;if(!_4.addedGraphics){console.error("In constructor of 'esri.dijit.editing.Cut', addedGraphics for cut not provided");return;}this._addedGraphics=_4.addedGraphics;if(!_4.preUpdatedGraphics){console.error("In constructor of 'esri.dijit.editing.Cut', preUpdatedGraphics not provided");return;}this._preUpdatedGraphicsGeometries=[];this._preUpdatedGraphicsAttributes=[];for(var i=0;i<_4.preUpdatedGraphics.length;i++){this._preUpdatedGraphicsGeometries.push(_4.preUpdatedGraphics[i].geometry.toJson());this._preUpdatedGraphicsAttributes.push(_4.preUpdatedGraphics[i].attributes);}if(!_4.postUpdatedGraphics){console.error("In constructor of 'esri.dijit.editing.Cut', postUpdatedGraphics not provided");return;}this._postUpdatedGraphics=_4.postUpdatedGraphics;this._postUpdatedGraphicsGeometries=[];this._postUpdatedGraphicsAttributes=[];for(i=0;i<_4.postUpdatedGraphics.length;i++){this._postUpdatedGraphicsGeometries.push(_4.postUpdatedGraphics[i].geometry.toJson());this._postUpdatedGraphicsAttributes.push(dojo.clone(_4.postUpdatedGraphics[i].attributes));}},performUndo:function(){for(var i=0;i<this._postUpdatedGraphics.length;i++){this._postUpdatedGraphics[i].setGeometry(esri.geometry.fromJson(this._preUpdatedGraphicsGeometries[i]));this._postUpdatedGraphics[i].setAttributes(this._preUpdatedGraphicsAttributes[i]);}this._featureLayer.applyEdits(null,this._postUpdatedGraphics,this._addedGraphics);},performRedo:function(){for(var i=0;i<this._postUpdatedGraphics.length;i++){this._postUpdatedGraphics[i].setGeometry(esri.geometry.fromJson(this._postUpdatedGraphicsGeometries[i]));this._postUpdatedGraphics[i].setAttributes(this._postUpdatedGraphicsAttributes[i]);}this._featureLayer.applyEdits(this._addedGraphics,this._postUpdatedGraphics,null);}});dojo.declare("esri.dijit.editing.Union",esri.OperationBase,{type:"edit",label:"Union Features",constructor:function(_5){_5=_5||{};this._cut=new esri.dijit.editing.Cut({featureLayer:_5.featureLayer,addedGraphics:_5.deletedGraphics,preUpdatedGraphics:_5.preUpdatedGraphics,postUpdatedGraphics:_5.postUpdatedGraphics});},performUndo:function(){this._cut.performRedo();},performRedo:function(){this._cut.performUndo();}});}