/*
 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.toolbars.edit"]){dojo._hasResource["esri.toolbars.edit"]=true;dojo.provide("esri.toolbars.edit");dojo.require("esri.toolbars._toolbar");dojo.require("esri.toolbars._GraphicMover");dojo.require("esri.toolbars._VertexEditor");dojo.require("esri.toolbars._Box");(function(){var _1=document.createElement("link");_1.type="text/css";_1.rel="stylesheet";_1.href=dojo.moduleUrl("esri","toolbars/css/edit.css").toString();document.getElementsByTagName("head").item(0).appendChild(_1);}());dojo.declare("esri.toolbars.Edit",esri.toolbars._Toolbar,{constructor:function(_2,_3){this._map=_2;this._tool=0;this._scratchGL=_2.graphics;var _4=esri.isTouchEnabled;this._defaultOptions=dojo.mixin({vertexSymbol:new esri.symbol.SimpleMarkerSymbol(esri.symbol.SimpleMarkerSymbol.STYLE_CIRCLE,_4?20:12,new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID,new dojo.Color([0,0,0,0.5]),1),new dojo.Color([128,128,128])),ghostVertexSymbol:new esri.symbol.SimpleMarkerSymbol(esri.symbol.SimpleMarkerSymbol.STYLE_CIRCLE,_4?18:10,new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID,new dojo.Color([0,0,0,0.5]),1),new dojo.Color([255,255,255,0.75])),ghostLineSymbol:new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_DOT,new dojo.Color([128,128,128]),2),allowDeleteVertices:true,allowAddVertices:true,rotateHandleOffset:_4?24:16,boxLineSymbol:new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_DASH,new dojo.Color([64,64,64]),1),boxHandleSymbol:new esri.symbol.SimpleMarkerSymbol(esri.symbol.SimpleMarkerSymbol.STYLE_SQUARE,_4?16:9,new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID,new dojo.Color([0,0,0,0.5]),1),new dojo.Color([255,255,255,0.75]))},_3||{});},activate:function(_5,_6,_7){this.deactivate();this._graphic=_6;this._options=dojo.mixin(dojo.mixin({},this._defaultOptions),_7||{});var _8=esri.toolbars.Edit.MOVE,_9=esri.toolbars.Edit.EDIT_VERTICES;var _a=esri.toolbars.Edit.SCALE,_b=esri.toolbars.Edit.ROTATE;var _c=false,_d=false,_e=false;if((_5&_8)===_8){_c=this._enableMove(_6);}var _f=((_5&_a)===_a),_10=((_5&_b)===_b);if(_f||_10){_e=this._enableBoxEditing(_6,_f,_10);}if((_5&_9)===_9){_d=this._enableVertexEditing(_6);}if(!(_c||_d||_e)){throw new Error("[esri.toolbars.Edit::activate] "+esri.bundle.toolbars.edit.invalidType);}this._tool=_5;var map=this._map;if(this._tool){this._mapPanEndHandle=dojo.connect(map,"onPanEnd",this,this._mapPanEndHandler);this._mapExtChgHandle=dojo.connect(map,"onExtentChange",this,this._mapExtentChangeHandler);this.onActivate(this._tool,_6);}if(map.snappingManager&&(_c||_d)){map.snappingManager._startSelectionLayerQuery();}},deactivate:function(){var _11=this._tool,_12=this._graphic;if(!_11){return;}var _13=!!this._modified;this._clear();dojo.disconnect(this._mapPanEndHandle);dojo.disconnect(this._mapExtChgHandle);this._graphic=null;this.onDeactivate(_11,_12,{isModified:_13});if(this._map.snappingManager){this._map.snappingManager._stopSelectionLayerQuery();}},refresh:function(){this._refreshMoveables(true);},getCurrentState:function(){return {tool:this._tool,graphic:this._graphic,isModified:!!this._modified};},onActivate:function(_14,_15){},onDeactivate:function(_16,_17,_18){},onGraphicMoveStart:function(_19){},onGraphicFirstMove:function(_1a){this._modified=true;},onGraphicMove:function(_1b,_1c){},onGraphicMoveStop:function(_1d,_1e){},onGraphicClick:function(_1f,_20){},onVertexMoveStart:function(_21,_22){},onVertexFirstMove:function(_23,_24){this._modified=true;},onVertexMove:function(_25,_26,_27){},onVertexMoveStop:function(_28,_29,_2a){},onVertexAdd:function(_2b,_2c){this._modified=true;},onVertexClick:function(_2d,_2e){},onVertexMouseOver:function(_2f,_30){},onVertexMouseOut:function(_31,_32){},onVertexDelete:function(_33,_34){this._modified=true;},onScaleStart:function(_35){},onScaleFirstMove:function(_36){this._modified=true;},onScale:function(_37,_38){},onScaleStop:function(_39,_3a){},onRotateStart:function(_3b){},onRotateFirstMove:function(_3c){this._modified=true;},onRotate:function(_3d,_3e){},onRotateStop:function(_3f,_40){},_enableMove:function(_41){var map=this._map,_42=_41.geometry.type;switch(_42){case "point":case "polyline":case "polygon":this._graphicMover=new esri.toolbars._GraphicMover(_41,map,this);return true;case "multipoint":break;}return false;},_enableVertexEditing:function(_43){var map=this._map,_44=_43.geometry.type;switch(_44){case "point":break;case "multipoint":case "polyline":case "polygon":this._vertexEditor=esri.toolbars._GraphicVertexEditor.create(_43,map,this);return true;}return false;},_enableBoxEditing:function(_45,_46,_47){var map=this._map,_48=_45.geometry.type;switch(_48){case "point":case "multipoint":break;case "polyline":case "polygon":this._boxEditor=new esri.toolbars._Box(_45,map,this,_46,_47);return true;}return false;},_disableMove:function(){var _49=this._graphicMover;if(_49){_49.destroy();this._graphicMover=null;}},_disableVertexEditing:function(){var _4a=this._vertexEditor;if(_4a){_4a.destroy();this._vertexEditor=null;}},_disableBoxEditing:function(){var box=this._boxEditor;if(box){box.destroy();this._boxEditor=null;}},_clear:function(){this._disableMove();this._disableVertexEditing();this._disableBoxEditing();this._tool=0;this._modified=false;},_mapPanEndHandler:function(){this._refreshMoveables();},_mapExtentChangeHandler:function(e,d,_4b){if(_4b){this._refreshMoveables();}},_refreshMoveables:function(_4c){var _4d=dojo.filter([this._graphicMover,this._vertexEditor,this._boxEditor],esri._isDefined);dojo.forEach(_4d,function(mov){mov.refresh(_4c);});},_beginOperation:function(_4e){dojo.forEach(this._getAffectedTools(_4e),function(_4f){_4f.suspend();});},_endOperation:function(_50){dojo.forEach(this._getAffectedTools(_50),function(_51){_51.resume();});},_getAffectedTools:function(_52){var _53=[];switch(_52){case "MOVE":_53=[this._vertexEditor,this._boxEditor];break;case "VERTICES":_53=[this._boxEditor];break;case "BOX":_53=[this._vertexEditor];break;}_53=dojo.filter(_53,esri._isDefined);return _53;}});dojo.mixin(esri.toolbars.Edit,{MOVE:1,EDIT_VERTICES:2,SCALE:4,ROTATE:8});}