/**
*	A LouGIS library by Lounaispaikka.
*	@copyright Lounaispaikka, www.lounaispaikka.fi <CC BY-SA 3.0>
*	@version 2011-12-19T20:48:52+02:00
*/
Ext.namespace("Ext.ux.LouGIS.Panel");
Ext.ux.LouGIS.Panel.Interfaces=Ext.extend(Ext.ux.LouGIS.Panel,{constructor:function(b){this.formType="Interfaces";Ext.ux.LouGIS.Panel.Interfaces.superclass.constructor.call(this,b);this.setTitle(t(""))},loadContent:function(){if(!this.contentLoaded){this.requestFormData();var b=new Ext.form.FieldSet({title:t(""),autoHeight:true,labelWidth:150,anchor:"95%",buttonAlign:"right"});this.add(b);Ext.Ajax.request({url:"/run/dataset/jsonWMSAccessContentAndFields/?datasetId="+this.datasetId,method:"POST",scope:this,
success:function(c){var a=Ext.decode(c.responseText),g=new Ext.data.JsonStore({url:"/run/dataset/jsonWMSAccessOfDataset/",baseParams:{datasetId:this.datasetId},storeId:"accessStore",root:"WMSAccessOfDataset",fields:a.storeFields});c=new Ext.Panel({header:false,border:false,html:a.html});b.add(c);g.load();a.gridColumns[a.gridColumns.length-1].renderer=function(){return'<img src="img/silkicons/silk/cross.png" class="clickableIcon" />'};c=new Ext.grid.ColumnModel(a.gridColumns);var h=new Ext.grid.GridPanel({id:"wmsAccessGrid",
store:g,colModel:c,autoHeight:true,autoWidth:true,autoExpandColumn:"address",viewConfig:{autoFill:true},style:{marginBottom:"10px"},disabled:a.wmsAllowAll}),i=this.datasetId;h.on("cellclick",function(e,d,j){j=e.getColumnModel().getColumnId(j);var l=e.getStore().getAt(d).get("address");j=="remove"&&Ext.Msg.show({title:a.labels.AreYouSure,msg:a.labels.DoYouReally,buttons:Ext.Msg.YESNO,animEl:"elId",icon:Ext.MessageBox.QUESTION,fn:function(m){m=="yes"&&Ext.Ajax.request({url:"/run/dataset/removeAddressFromWMSAccess/",
params:{datasetId:i,address:l},success:function(){g.load()}})}})});c=new Ext.form.Checkbox({fieldLabel:a.labels.AllowAllAddresses,checked:a.wmsAllowAll});i=this.datasetId;c.on("check",function(e,d){e.setDisabled(true);Ext.Ajax.request({url:"/run/dataset/setUnrestrictedWMS/",params:{datasetId:i,status:d},success:function(){h.setDisabled(d);f.setDisabled(d);k.setDisabled(d);e.setDisabled(false)}})});var f=new Ext.form.TextField({fieldLabel:a.labels.AddAddress,anchor:"100%",disabled:a.wmsAllowAll,qtip:a.labels.addAddressQtip}),
k=new Ext.Button({text:a.labels.Add,icon:"/img/silkicons/silk/add.png",disabled:a.wmsAllowAll,cls:"rightAligned",handler:function(e){var d=f.getValue();if(!(d==null||d=="")){f.setReadOnly(true);e.disable();Ext.Ajax.request({url:"/run/dataset/addWMSAccess/",params:{host:d,datasetId:this.datasetId},success:function(){f.setReadOnly(false);e.enable();f.setValue("");g.load()},scope:this})}},scope:this});b.add(c);b.add(h);b.add(f);b.add(k);b.doLayout()}});this.contentLoaded=true}},processButtons:function(b,
c,a){Ext.ux.LouGIS.Panel.JHS158Theme.superclass.processButtons.call(this,b,c,a);a.setText(t(""))},saveContent:function(){Ext.ux.LouGIS.Panel.Interfaces.superclass.saveContent.call(this);notify(t(""),t(""));this.window.id!="datasetEditWindow"&&this.window.close()}});

