/*
 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
 */
//>>built
define("esri/dijit/editing/toolbars/Drawing",["dojo/_base/declare","dojo/_base/lang","dojo/_base/array","dojo/_base/connect","dojo/has","dijit/_CssStateMixin","esri/dijit/editing/Util","esri/dijit/editing/toolbars/ToolbarBase","esri/dijit/editing/tools/ButtonToolBase","esri/dijit/editing/tools/Cut","esri/dijit/editing/tools/Union","esri/dijit/editing/tools/Reshape","esri/dijit/editing/tools/Editing","esri/dijit/editing/tools/EditingTools","esri/dijit/editing/tools/Selection","esri/dijit/editing/tools/SelectionTools","esri/kernel"],function(_1,_2,_3,_4,_5,_6,_7,_8,_9,_a,_b,_c,_d,_e,_f,_10,_11){var _12=_1([_8,_6],{declaredClass:"esri.dijit.editing.toolbars.Drawing",onShowAttributeInspector:function(){},_activateTool:function(_13,_14){this._settings.editor._activeTool=_13;if(_13!=="EDITING"){this._settings.templatePicker.clearSelection();}if(_13!=="ATTRIBUTES"){this._settings.editor._hideAttributeInspector();}if(_13==="CLEAR"){return;}this.inherited(arguments);},_initializeToolbar:function(){var _15=this._settings.layers;_3.forEach(_15,function(_16){this._tbConnects.push(_4.connect(_16,"onSelectionComplete",this,"_updateUI"));},this);},activateEditing:function(_17,_18){this._tools.EDITING._activateTool(_17,_18.geometryType);this._activeTool=this._tools.EDITING;this._activeTool.setChecked(true);},_updateUI:function(){if(this._settings.undoManager){this._tools.UNDO.set("disabled",this._settings.undoManager.canUndo===false);this._tools.REDO.set("disabled",this._settings.undoManager.canRedo===false);}this._selectedFeatures=_7.getSelection(this._settings.layers);var _19=this._selectedFeatures.length;if(this._tools.DELETE){this._tools.DELETE.set("disabled",_19<=0);}if(this._tools.CLEAR){this._tools.CLEAR.set("disabled",_19<=0);}if(this._tools.ATTRIBUTES){this._tools.ATTRIBUTES.set("disabled",_19<=0);}if(this._tools.UNION){this._tools.UNION.set("disabled",_19<2);}},_toolFinished:function(_1a){if(_1a==="ATTRIBUTES"&&(this._selectedFeatures&&this._selectedFeatures.length)){this.onShowAttributeInspector(this._selectedFeatures[0]);}if(_1a==="SELECT"||_1a==="CUT"||_1a==="RESHAPING"||_1a==="EDITING"){this._activeTool.deactivate();this._activeTool.setChecked(false);this._activeTool=null;}if(_1a==="DELETE"){this.onDelete();}this._updateUI();},_createTools:function(){this._tools.SELECT=new _f({settings:this._settings,onClick:_2.hitch(this,"_activateTool","SELECT",true),onFinished:_2.hitch(this,"_toolFinished","SELECT")});this.addChild(this._tools.SELECT);this._tools.CLEAR=new _9(_2.mixin(_10.selectClear,{settings:this._settings,onClick:_2.hitch(this._settings.editor,"_clearSelection",false)}));this.addChild(this._tools.CLEAR);this._createSeparator();this._tools.ATTRIBUTES=new _9(_2.mixin(_e.attributes,{settings:this._settings,onClick:_2.hitch(this,"_toolFinished","ATTRIBUTES")}));this.addChild(this._tools.ATTRIBUTES);this._createSeparator();this._tools.EDITING=new _d({settings:this._settings,onClick:_2.hitch(this,"_activateTool","EDITING",true),onApplyEdits:_2.hitch(this,"onApplyEdits"),onFinished:_2.hitch(this,"_toolFinished","EDITING")});this.addChild(this._tools.EDITING);this._tools.DELETE=new _9(_2.mixin(_e.del,{settings:this._settings,onClick:_2.hitch(this,"_toolFinished","DELETE")}));this.addChild(this._tools.DELETE);if(this._settings.toolbarOptions){if(this._settings.toolbarOptions.cutVisible||this._settings.toolbarOptions.mergeVisible||this._settings.toolbarOptions.reshapeVisible){this._createSeparator();}if(this._settings.toolbarOptions.cutVisible){this._tools.CUT=new _a({settings:this._settings,onFinished:_2.hitch(this,"_toolFinished","CUT"),onClick:_2.hitch(this,"_activateTool","CUT",true),onApplyEdits:_2.hitch(this,"onApplyEdits")});this.addChild(this._tools.CUT);}if(this._settings.toolbarOptions.mergeVisible){this._tools.UNION=new _b({settings:this._settings,onFinished:_2.hitch(this,"_toolFinished","UNION"),onApplyEdits:_2.hitch(this,"onApplyEdits")});this.addChild(this._tools.UNION);}if(this._settings.toolbarOptions.reshapeVisible){this._tools.RESHAPING=new _c({settings:this._settings,onClick:_2.hitch(this,"_activateTool","RESHAPING",true),onFinished:_2.hitch(this,"_toolFinished","RESHAPING"),onApplyEdits:_2.hitch(this,"onApplyEdits")});this.addChild(this._tools.RESHAPING);}}if(this._settings.enableUndoRedo){this._createSeparator();this._tools.UNDO=new _9(_2.mixin(_e.undo,{settings:this._settings,onClick:_2.hitch(this,function(){this._tools.UNDO.set("disabled",true);this._tools.REDO.set("disabled",true);this._settings.editor._undo();})}));this.addChild(this._tools.UNDO);this._tools.REDO=new _9(_2.mixin(_e.redo,{settings:this._settings,onClick:_2.hitch(this,function(){this._tools.UNDO.set("disabled",true);this._tools.REDO.set("disabled",true);this._settings.editor._redo();})}));this.addChild(this._tools.REDO);}}});if(_5("extend-esri")){_2.setObject("dijit.editing.toolbars.Drawing",_12,_11);}return _12;});