/*
 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.toolbars.Drawing"]){dojo._hasResource["esri.dijit.editing.toolbars.Drawing"]=true;dojo.provide("esri.dijit.editing.toolbars.Drawing");dojo.require("dijit._CssStateMixin");dojo.require("esri.dijit.editing.toolbars.ToolbarBase");dojo.require("esri.dijit.editing.tools.Editing");dojo.require("esri.dijit.editing.tools.Selection");dojo.require("esri.dijit.editing.tools.AdvancedTools");(function(){var _1=[dojo.moduleUrl("esri.dijit.editing","css/drawingToolbar.css")];var _2=document.getElementsByTagName("head").item(0),_3;for(i=0,il=_1.length;i<il;i++){_3=document.createElement("link");_3.type="text/css";_3.rel="stylesheet";_3.href=_1[i];_2.appendChild(_3);}})();dojo.declare("esri.dijit.editing.toolbars.Drawing",[esri.dijit.editing.toolbars.ToolbarBase,dijit._CssStateMixin],{onShowAttributeInspector:function(){},_activateTool:function(_4,_5){this._settings.editor._activeTool=_4;if(_4!=="EDITING"){this._settings.templatePicker.clearSelection();}if(_4!=="ATTRIBUTES"){this._settings.editor._hideAttributeInspector();}if(_4==="CLEAR"){return;}this.inherited(arguments);},_initializeToolbar:function(){var _6=this._settings.layers;dojo.forEach(_6,function(_7){this._tbConnects.push(dojo.connect(_7,"onSelectionComplete",this,"_updateUI"));},this);},activateEditing:function(_8,_9){this._tools.EDITING._activateTool(_8,_9.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=esri.dijit.editing.Util.LayerHelper.getSelection(this._settings.layers);var _a=this._selectedFeatures.length;if(this._tools.DELETE){this._tools.DELETE.set("disabled",_a<=0);}if(this._tools.CLEAR){this._tools.CLEAR.set("disabled",_a<=0);}if(this._tools.ATTRIBUTES){this._tools.ATTRIBUTES.set("disabled",_a<=0);}if(this._tools.UNION){this._tools.UNION.set("disabled",_a<2);}},_toolFinished:function(_b){if(_b==="ATTRIBUTES"&&(this._selectedFeatures&&this._selectedFeatures.length)){this.onShowAttributeInspector(this._selectedFeatures[0]);}if(_b==="SELECT"||_b==="CUT"||_b==="RESHAPING"||_b==="EDITING"){this._activeTool.deactivate();this._activeTool.setChecked(false);this._activeTool=null;}if(_b==="DELETE"){this.onDelete();}this._updateUI();},_createTools:function(){this._tools.SELECT=new esri.dijit.editing.tools.Selection({settings:this._settings,onClick:dojo.hitch(this,"_activateTool","SELECT",true),onFinished:dojo.hitch(this,"_toolFinished","SELECT")});this.addChild(this._tools.SELECT);this._tools.CLEAR=new esri.dijit.editing.tools.ButtonToolBase(dojo.mixin(esri.dijit.editing.tools.SelectionTools.selectClear,{settings:this._settings,onClick:dojo.hitch(this._settings.editor,"_clearSelection",false)}));this.addChild(this._tools.CLEAR);this._createSeparator();this._tools.ATTRIBUTES=new esri.dijit.editing.tools.ButtonToolBase(dojo.mixin(esri.dijit.editing.tools.EditingTools.attributes,{settings:this._settings,onClick:dojo.hitch(this,"_toolFinished","ATTRIBUTES")}));this.addChild(this._tools.ATTRIBUTES);this._createSeparator();this._tools.EDITING=new esri.dijit.editing.tools.Editing({settings:this._settings,onClick:dojo.hitch(this,"_activateTool","EDITING",true),onApplyEdits:dojo.hitch(this,"onApplyEdits"),onFinished:dojo.hitch(this,"_toolFinished","EDITING")});this.addChild(this._tools.EDITING);this._tools.DELETE=new esri.dijit.editing.tools.ButtonToolBase(dojo.mixin(esri.dijit.editing.tools.EditingTools.del,{settings:this._settings,onClick:dojo.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 esri.dijit.editing.tools.Cut({settings:this._settings,onFinished:dojo.hitch(this,"_toolFinished","CUT"),onClick:dojo.hitch(this,"_activateTool","CUT",true),onApplyEdits:dojo.hitch(this,"onApplyEdits")});this.addChild(this._tools.CUT);}if(this._settings.toolbarOptions.mergeVisible){this._tools.UNION=new esri.dijit.editing.tools.Union({settings:this._settings,onFinished:dojo.hitch(this,"_toolFinished","UNION"),onApplyEdits:dojo.hitch(this,"onApplyEdits")});this.addChild(this._tools.UNION);}if(this._settings.toolbarOptions.reshapeVisible){this._tools.RESHAPING=new esri.dijit.editing.tools.Reshape({settings:this._settings,onClick:dojo.hitch(this,"_activateTool","RESHAPING",true),onFinished:dojo.hitch(this,"_toolFinished","RESHAPING"),onApplyEdits:dojo.hitch(this,"onApplyEdits")});this.addChild(this._tools.RESHAPING);}}if(this._settings.enableUndoRedo){this._createSeparator();this._tools.UNDO=new esri.dijit.editing.tools.ButtonToolBase(dojo.mixin(esri.dijit.editing.tools.EditingTools.undo,{settings:this._settings,onClick:dojo.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 esri.dijit.editing.tools.ButtonToolBase(dojo.mixin(esri.dijit.editing.tools.EditingTools.redo,{settings:this._settings,onClick:dojo.hitch(this,function(){this._tools.UNDO.set("disabled",true);this._tools.REDO.set("disabled",true);this._settings.editor._redo();})}));this.addChild(this._tools.REDO);}}});}