/*
	Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
	Available via Academic Free License >= 2.1 OR the modified BSD license.
	see: http://dojotoolkit.org/license for details
*/


window[esri._dojoScopeName||"dojo"]._xdResourceLoaded(function(_1,_2,_3){return {depends:[["provide","dojox.data.StoreExplorer"],["require","dojox.grid.DataGrid"],["require","dojox.data.ItemExplorer"],["require","dijit.layout.BorderContainer"],["require","dijit.layout.ContentPane"]],defineResource:function(_4,_5,_6){if(!_4._hasResource["dojox.data.StoreExplorer"]){_4._hasResource["dojox.data.StoreExplorer"]=true;_4.provide("dojox.data.StoreExplorer");_4.require("dojox.grid.DataGrid");_4.require("dojox.data.ItemExplorer");_4.require("dijit.layout.BorderContainer");_4.require("dijit.layout.ContentPane");_4.declare("dojox.data.StoreExplorer",_5.layout.BorderContainer,{constructor:function(_7){_4.mixin(this,_7);},store:null,columnWidth:"",stringQueries:false,showAllColumns:false,postCreate:function(){var _8=this;this.inherited(arguments);var _9=new _5.layout.ContentPane({region:"top"}).placeAt(this);function _a(_b,_c){var _d=new _5.form.Button({label:_b});_9.containerNode.appendChild(_d.domNode);_d.onClick=_c;return _d;};var _e=_9.containerNode.appendChild(document.createElement("span"));_e.innerHTML="Enter query: &nbsp;";_e.id="queryText";var _f=_9.containerNode.appendChild(document.createElement("input"));_f.type="text";_f.id="queryTextBox";_a("Query",function(){var _10=_f.value;_8.setQuery(_8.stringQueries?_10:_4.fromJson(_10));});_9.containerNode.appendChild(document.createElement("span")).innerHTML="&nbsp;&nbsp;&nbsp;";var _11=_a("Create New",_4.hitch(this,"createNew"));var _12=_a("Delete",function(){var _13=_14.selection.getSelected();for(var i=0;i<_13.length;i++){_8.store.deleteItem(_13[i]);}});this.setItemName=function(_15){_11.attr("label","<img style='width:12px; height:12px' src='"+_4.moduleUrl("dijit.themes.tundra.images","dndCopy.png")+"' /> Create New "+_15);_12.attr("label","Delete "+_15);};_a("Save",function(){_8.store.save({onError:function(_16){alert(_16);}});_8.tree.refreshItem();});_a("Revert",function(){_8.store.revert();});_a("Add Column",function(){var _17=prompt("Enter column name:","property");if(_17){_8.gridLayout.push({field:_17,name:_17,formatter:_4.hitch(_8,"_formatCell"),editable:true});_8.grid.attr("structure",_8.gridLayout);}});var _18=new _5.layout.ContentPane({region:"center"}).placeAt(this);var _14=this.grid=new _6.grid.DataGrid({store:this.store});_18.attr("content",_14);_14.canEdit=function(_19,_1a){var _1b=this._copyAttr(_1a,_19.field);return !(_1b&&typeof _1b=="object")||_1b instanceof Date;};var _1c=new _5.layout.ContentPane({region:"trailing",splitter:true,style:"width: 300px"}).placeAt(this);var _1d=this.tree=new _6.data.ItemExplorer({store:this.store});_1c.attr("content",_1d);_4.connect(_14,"onCellClick",function(){var _1e=_14.selection.getSelected()[0];_1d.setItem(_1e);});this.gridOnFetchComplete=_14._onFetchComplete;this.setStore(this.store);},setQuery:function(_1f,_20){this.grid.setQuery(_1f,_20);},_formatCell:function(_21){if(this.store.isItem(_21)){return this.store.getLabel(_21)||this.store.getIdentity(_21);}return _21;},setStore:function(_22){this.store=_22;var _23=this;var _24=this.grid;_24._pending_requests[0]=false;function _25(_26){return _23._formatCell(_26);};var _27=this.gridOnFetchComplete;_24._onFetchComplete=function(_28,req){var _29=_23.gridLayout=[];var _2a,key,_2b,i,j,k,_2c=_22.getIdentityAttributes();for(i=0;i<_2c.length;i++){key=_2c[i];_29.push({field:key,name:key,_score:100,formatter:_25,editable:false});}for(i=0;_2b=_28[i++];){var _2d=_22.getAttributes(_2b);for(k=0;key=_2d[k++];){var _2e=false;for(j=0;_2a=_29[j++];){if(_2a.field==key){_2a._score++;_2e=true;break;}}if(!_2e){_29.push({field:key,name:key,_score:1,formatter:_25,styles:"white-space:nowrap; ",editable:true});}}}_29=_29.sort(function(a,b){return b._score-a._score;});if(!_23.showAllColumns){for(j=0;_2a=_29[j];j++){if(_2a._score<_28.length/40*j){_29.splice(j,_29.length-j);break;}}}for(j=0;_2a=_29[j++];){_2a.width=_23.columnWidth||Math.round(100/_29.length)+"%";}_24._onFetchComplete=_27;_24.attr("structure",_29);var _2f=_27.apply(this,arguments);};_24.setStore(_22);this.queryOptions={cache:true};this.tree.setStore(_22);},createNew:function(){var _30=prompt("Enter any properties (in JSON literal form) to put in the new item (passed to the newItem constructor):","{ }");if(_30){try{this.store.newItem(_4.fromJson(_30));}catch(e){alert(e);}}}});}}};});