
Ext.USE_NATIVE_JSON=true;(function(){Ext.preg("gx_wmssource",gxp.plugins.WMSSource);Ext.preg("gx_olsource",gxp.plugins.OLSource);Ext.preg("gx_googlesource",gxp.plugins.GoogleSource);Ext.preg("gx_bingsource",gxp.plugins.BingSource);Ext.preg("gx_osmsource",gxp.plugins.OSMSource);})();
var GeoExplorer=Ext.extend(gxp.Viewer,{mapPanel:null,toggleGroup:"toolGroup",constructor:function(config){
this.mapItems=[
{xtype:"gxp_scaleoverlay"},
{xtype:"gx_zoomslider",vertical:true,height:100,plugins:new GeoExt.ZoomSliderTip({template:locale.labels.geoexplorer.zoomSliderText})}
];
config.viewerTools=[
{leaf:true,text:locale.tips.printTool,ptype:"gxp_print",iconCls:"gxp-icon-print",customParams:{outputFilename:'map-print'},printService:config.printService,checked:true},
{leaf:true,text:locale.tips.navTool,checked:true,iconCls:"gxp-icon-pan",ptype:"gxp_navigation",toggleGroup:this.toggleGroup,actionTarget:{target:"paneltbar",index:2}},
{leaf:true,text:locale.tips.infoTool,checked:true,iconCls:"gxp-icon-getfeatureinfo",ptype:"gxp_gridwmsgetfeatureinfo",toggleGroup:this.toggleGroup,actionTarget:{target:"paneltbar",index:3}},
{leaf:true,text:locale.tips.measureTool,checked:true,iconCls:"gxp-icon-measure-length",ptype:"gxp_measure",toggleGroup:this.toggleGroup,actionTarget:{target:"paneltbar",index:5}},
{leaf:true,text:locale.tips.zoomInTool+" / "+locale.tips.zoomOutTool,checked:true,iconCls:"gxp-icon-zoom-in",ptype:"gxp_zoom",actionTarget:{target:"paneltbar",index:6}},
{leaf:true,text:locale.tips.previousTool+" / "+locale.tips.nextTool,checked:true,iconCls:"gxp-icon-zoom-previous",ptype:"gxp_navigationhistory",actionTarget:{target:"paneltbar",index:7}},
{leaf:true,text:locale.tips.zoomToExtentTool,checked:true,iconCls:gxp.plugins.ZoomToExtent.prototype.iconCls,ptype:"gxp_zoomtoextent",actionTarget:{target:"paneltbar",index:9}},
{leaf:true,text:locale.tips.legendTool,checked:true,iconCls:"gxp-icon-legend",ptype:"gxp_legend",actionTarget:{target:"paneltbar",index:10}}
];
GeoExplorer.superclass.constructor.apply(this,arguments);},destroy:function(){this.mapPanel.destroy();this.portal.destroy();this.toolbar.destroy();this.toolbar=null;},initTools:function(){this.tools={};if(this.initialConfig.tools&&this.initialConfig.tools.length>0){var tool;for(var i=0,len=this.initialConfig.tools.length;i<len;i++){if(this.initialConfig.tools[i]){tool=Ext.ComponentMgr.createPlugin(this.initialConfig.tools[i],this.defaultToolType);}
tool.init(this);}}},initPortal:function(){var westPanel=new Ext.TabPanel({border:false,id:'westPanel',activeTab:0,region:"west",width:350,minWidth:20,split:true,collapsible:true,collapsed:true,header:true,items:[
{autoScroll:true,tbar:[],border:false,id:'tree',title:locale.labels.geoexplorer.layersText}//,
/*{xtype:"container",layout:"fit",border:false,id:'legend',title:locale.labels.geoexplorer.legendText},*/
//{xtype:"container",cls:'toolsLeftPanel',border:false,id:'geoTools',title:locale.labels.geoexplorer.toolsText,items:[{xtype:'panel',id:'panel1',title:locale.labels.geoexplorer.searchText,collapsible:true,items:[{xtype:'button',id:'panelbutton1',iconCls:'aquaIcon',text:locale.labels.geoexplorer.aquaSearch,listeners:{click:function(n){openChooserOcean();}}}]},{xtype:'panel',id:'leftEditPanel',hidden:app.preparedTools&&app.preparedTools.filter(function(el){return el=="gxp_featureeditorpanel"}).length==0,title:locale.labels.geoexplorer.featureEditingToolsText,collapsible:true,items:[{xtype:'button',id:'panelCreateFeatureButton',iconCls:'gxp-icon-addfeature',text:locale.labels.geoexplorer.newFeatureText,disabled:true,listeners:{click:function(n){if(!Ext.getCmp("createFeatureButton").disabled){Ext.getCmp("createFeatureButton").toggle();}else{Ext.Msg.alert(locale.messages.notification,locale.messages.unableToEditLayer);}}}},{xtype:'button',id:'panelEditFeatureButton',iconCls:'gxp-icon-editfeature',text:locale.labels.geoexplorer.editFeatureText,disabled:true,listeners:{click:function(n){if(!Ext.getCmp("editFeatureButton").disabled){Ext.getCmp("editFeatureButton").toggle();}else{Ext.Msg.alert(locale.messages.notification,locale.messages.unableToEditLayer);}}}}]},{xtype:'panel',id:'panel5',title:locale.labels.geoexplorer.measureText,hidden:app.preparedTools&&app.preparedTools.filter(function(el){return el=="gxp_measure"}).length==0,collapsible:true,items:[{xtype:'button',id:'panelbutton7',text:locale.labels.geoexplorer.lengthMeasureText,iconCls:'gxp-icon-measure-length',listeners:{click:function(n){Ext.getCmp("distanceMeasureButton").setChecked(!Ext.getCmp("distanceMeasureButton").checked);}}},{xtype:'button',id:'panelbutton8',iconCls:'gxp-icon-measure-area',text:locale.labels.geoexplorer.areaMeasureText,listeners:{click:function(n){Ext.getCmp("areaMeasureButton").setChecked(!Ext.getCmp("areaMeasureButton").checked);}}}]},{xtype:'panel',id:'panel6',title:locale.labels.geoexplorer.printPanelHeaderText,hidden:app.preparedTools&&app.preparedTools.filter(function(el){return el=="gxp_print"}).length==0,collapsible:true,items:[]},{xtype:'panel',id:'panel7',hidden:app.preparedTools&&app.preparedTools.filter(function(el){return el=="gxp_prickertool"}).length==0,title:locale.labels.geoexplorer.chartPanelHeaderText,collapsible:true,items:[{xtype:'button',id:'panelbutton10',iconCls:'chartIcon',text:locale.labels.geoexplorer.buildChartText,listeners:{click:function(n){Ext.getCmp("prickerButton").toggle();}}}]}]}
/*,{id:"rubricatorTree",title:locale.labels.geoexplorer.rubricatorText,autoScroll:true,layout:{type:'vbox',align:'stretch'},border:false}*/
]});app.tools["featuremanager"].on("layerchange",function(mgr,rec,schema){/*Ext.getCmp("panelCreateFeatureButton").setDisabled(!schema);Ext.getCmp("panelEditFeatureButton").setDisabled(!schema);*/},this);var featureGridWindow=new Ext.Window({title:locale.labels.geoexplorer.queryResultText,layout:{type:'hbox',pack:'start',align:'stretch'},defaults:{flex:1},width:400,height:300,featureGridPanel:"featureGridPanel",id:"featureGridWindow",closable:false,listeners:{render:function(){this.addTool({id:'unpin',scope:this,handler:function(){
var c=Ext.getCmp(this.featureGridPanel)
this.items.each(function(a){c.add(a)})
c.show()
c.doLayout()
c.expand()
c.ownerCt.doLayout()
this.hide()}})
this.addTool({id:'close',scope:this,handler:function(){this.hide()}})}}});var featureGridPanel=new Ext.Panel({title:locale.labels.geoexplorer.queryResultText,layout:{type:'hbox',pack:'start',align:'stretch'},defaults:{flex:1},id:"featureGridPanel",hidden:true,region:"south",height:180,split:true,collapsible:true,featureGridWindow:"featureGridWindow",listeners:{render:function(){this.addTool({id:'pin',scope:this,handler:function(){var c=Ext.getCmp(this.featureGridWindow)
this.items.each(function(a){c.add(a)})
c.show()
c.doLayout()
this.hide()
this.ownerCt.doLayout()}})
this.addTool({id:'close',scope:this,handler:function(){var c=Ext.getCmp(this.featureGridWindow)
this.items.each(function(a){c.add(a)})
c.doLayout()
this.hide()
this.ownerCt.doLayout()}})}}});this.toolbar=new Ext.Toolbar({disabled:true,id:'paneltbar',items:this.createTools()});this.on("ready",function(){var disabled=this.toolbar.items.filterBy(function(item){return item.initialConfig&&item.initialConfig.disabled;});this.toolbar.enable();disabled.each(function(item){item.disable();});});var googleEarthPanel=new gxp.GoogleEarthPanel({mapPanel:this.mapPanel,listeners:{beforeadd:function(record){return record.get("group")!=="background";}}});var preGoogleDisabled=[];googleEarthPanel.on("show",function(){preGoogleDisabled.length=0;this.toolbar.items.each(function(item){if(item.disabled){preGoogleDisabled.push(item);}})
this.toolbar.disable();for(var key in this.tools){var tool=this.tools[key];if(tool.outputTarget==="map"){tool.removeOutput();}}
var layersContainer=Ext.getCmp("tree");var layersToolbar=layersContainer&&layersContainer.getTopToolbar();if(layersToolbar){layersToolbar.items.each(function(item){if(item.disabled){preGoogleDisabled.push(item);}});layersToolbar.disable();}},this);googleEarthPanel.on("hide",function(){this.toolbar.enable();var layersContainer=Ext.getCmp("tree");var layersToolbar=layersContainer&&layersContainer.getTopToolbar();if(layersToolbar){layersToolbar.enable();}
for(var i=0,ii=preGoogleDisabled.length;i<ii;++i){preGoogleDisabled[i].disable();}},this);this.mapPanelContainer=new Ext.Panel({layout:"card",id:"centerLayoutItem",region:"center",defaults:{border:false},items:[this.mapPanel,googleEarthPanel],activeItem:0});this.portalItems=[{region:"center",layout:"border",id:"centerRenderer",tbar:this.toolbar,items:[this.mapPanelContainer,westPanel,featureGridPanel]}];GeoExplorer.superclass.initPortal.apply(this,arguments);},createTools:function(){var tools=["-"];return tools;}});GeoExplorer.Composer=Ext.extend(GeoExplorer,{constructor:function(config){var authUrl='',authMethod='',authParams={}
if(config.authWay=='ov'){authUrl='login'
authMethod='POST'
authParams={username:config.username,password:config.password}}else if(config.authWay=='josso'){authUrl=config.proxy+encodeURIComponent(config.authUrl+'usernamePasswordLogin.do?josso_cmd=login&josso_back_to=&josso_username='+config.username+'&josso_password='+config.password)
authMethod='GET'
config.jossoAuthUrl=config.authUrl+'usernamePasswordLogin.do?josso_cmd=login&josso_back_to=&josso_username='+config.username+'&josso_password='+config.password}
config.jossoInfoUrl=config.authUrl+'/info.do'
if(config.authWay!==false){GPOpenLayers.Request[authMethod]({url:authUrl,data:GPOpenLayers.Util.getParameterString(authParams),headers:{"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"},callback:function(request){if(request.status==200){this.authorizedRoles=["ROLE_ADMINISTRATOR"];Ext4.Array.each(this.tools,function(tool){if(tool.needsAuthorization===true){tool.enable();}})}else{this.authorizedRoles=[];Ext4.Array.each(this.tools,function(tool){if(tool.needsAuthorization===true){tool.disable();}})}
this.fireEvent('authorizationchange')},scope:this,proxy:config.proxy})}else{this.authorizedRoles=["ROLE_ADMINISTRATOR"];}
getCookie=function(name){var matches=document.cookie.match(new RegExp("(?:^|; )"+name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g,'\\$1')+"=([^;]*)"))
return matches?decodeURIComponent(matches[1]):undefined};config.currentUser=window.JOSSO_USER||"";
config.tools=[
{"ptype":"gxp_mouseposgxptool","controlOptions":{displayProjection:new GPOpenLayers.Projection("EPSG:4326"),numDigits:3,displayClass:"mousePos",prefix:"X: ",separator:", Y:"},"outputTarget":"map"},
{ptype:"gxp_layertree",groups:window.JOSSO_USER!="null"?{/*editable:locale.labels.composer.editable*/}:{},outputConfig:{id:"layertree"},outputTarget:"tree"},
/*{ptype:"gxp_legend",outputTarget:'legend',outputConfig:{autoScroll:true}}/*,{ptype:"gxp_rubricatortree",id:"gxp_rubricatortree_ctl",outputTarget:"rubricatorTree"},*/
{id:"gxp_addlayers_ctl",ptype:"gxp_addlayers",actionTarget:"tree.tbar",upload:true},{id:"gxp_animationManager_ctl",ptype:"gxp_animationManager"},
{id:"gxp_animationGrid_ctl",ptype:"gxp_animationGrid"},
{id:"gxp_profileGrid_ctl",ptype:"gxp_profileGrid"},
{id:"gxp_chartManager_ctl",ptype:"gxp_chartManager"},
{id:"gxp_chartEditor_ctl",ptype:"gxp_chartEditor"},
{id:"gxp_chartSource_ctl",ptype:"gxp_chartsource"},
{id:"gxp_removelayer_ctl",ptype:"gxp_removelayer",actionTarget:["tree.tbar","layertree.contextMenu"]},
{ptype:"gxp_layerproperties",actionTarget:["tree.tbar","layertree.contextMenu"],featureManager:"featuremanager"},
{ptype:"gxp_zoomtolayerextent",actionTarget:{target:"layertree.contextMenu",index:0}},
{id:"gxp_wmsgetweatherinfo_ctl",ptype:"gxp_gridwmsgetfeatureinfo",toggleGroup:this.toggleGroup,actionTarget:{target:"paneltbar",index:10}},
{id:"gxp_wmsgetfeatureinfo_ctl",ptype:"gxp_gridwmsgetweatherinfo",toggleGroup:this.toggleGroup,actionTarget:{target:"paneltbar",index:11}},
{ptype:"gxp_navigation",toggleGroup:this.toggleGroup,actionTarget:{target:"paneltbar",index:12}},
{ptype:"gxp_zoom",actionTarget:{target:"paneltbar",index:14}},
{ptype:"gxp_navigationhistory",actionTarget:{target:"paneltbar",index:15}},
{ptype:"gxp_zoomtoextent",actionTarget:{target:"paneltbar",index:16}},
{leaf:true,text:locale.labels.geoexplorer.showLegendText,checked:true,iconCls:"gxp-icon-legend",ptype:"gxp_legend",actionTarget:{target:"paneltbar",index:17}},
{ptype:"gxp_measure",toggleGroup:this.toggleGroup,actionTarget:{target:"paneltbar",index:37}},
{ptype:"gxp_print",customParams:{outputFilename:'map-print'},printService:config.printService,actionTarget:["paneltbar","panel6"]},
{ptype:"gxp_prickertool",actionTarget:"paneltbar",layers:config.prickerLayers,aliaseUrl:config.prickerAliaseUrl,getInfoUrl:config.prickerGetInfoUrl,saveChartUrl:config.prickerSaveChartUrl,actionTarget:{target:"paneltbar",index:38},toggleGroup:this.toggleGroup},
{ptype:"gxp_featuremanager",id:"featuremanager",maxFeatures:100,paging:false,actionTarget:{target:"paneltbar",index:18}},{ptype:"gxp_logger",actionTarget:{target:"paneltbar",index:17}},{ptype:"gxp_featureeditorpanel",featureManager:"featuremanager",outputConfig:{panIn:false},toggleGroup:this.toggleGroup,actionTarget:{target:"paneltbar",index:19},createFeatureActionTip:locale.tips.createFeatureActionTip,editFeatureActionTip:locale.tips.editFeatureActionTip,bodyAttribute:'message',usernameAttribute:'author',featureManagerToolTip:locale.tips.featureManagerToolTip,toolWinText:locale.labels.composer.editableTitle,autoLoadFeature:true},'-',{ptype:'gispro_viewmenu',actionTarget:{target:"paneltbar",index:2},graticulOptions:{displayInLayerSwitcher:false},ovLayer:config.ovLayer},{ptype:"gxp_queryform",featureManager:"featuremanager",featureGrid:"featureGrid",actionTarget:{target:"paneltbar",index:15}},{ptype:"gxp_featuregrid",featureManager:"featuremanager",outputConfig:{id:"featureGrid"},outputTarget:"featureGridWindow"}];var staticTools=["gxp_mouseposgxptool","gxp_layertree","gxp_featuregrid","gxp_featuremanager","gxp_rubricatortree","gxp_addlayers","gxp_removelayer","gxp_layerproperties","gxp_zoomtolayerextent","gispro_viewmenu","gxp_profileGrid"];config.preparedTools&&(config.tools=config.tools.filter(function(el){return config.preparedTools.filter(function(prel){return el.ptype==prel}).length>0||staticTools.filter(function(prel){return el.ptype==prel}).length>0}));GeoExplorer.Composer.superclass.constructor.apply(this,arguments);},destroy:function(){this.loginButton=null;GeoExplorer.Composer.superclass.destroy.apply(this,arguments);},createTools:function(){var tools=GeoExplorer.Composer.superclass.createTools.apply(this,arguments);tools.unshift({xtype:"gxp_googlegeocodercombo",id:"googSearchCombo",width:200,listeners:{select:function(combo,record){var bounds=record.get("viewport").transform(new GPOpenLayers.Projection("EPSG:4326"),this.mapPanel.map.getProjectionObject());this.mapPanel.map.zoomToExtent(bounds,true);},afterRender:function(c){c.getEl().dom.setAttribute('ext:qtip',locale.labels.composer.geocode)},scope:this},actionTarget:{target:"paneltbar",index:10}});tools.unshift({xtype:"label",text:locale.labels.composer.search+":",style:"background-image:url(/portal-core/themes/esimo-central/images/icons/icon-magnifier-small.png); padding-right:4px; padding-left:16px; background-repeat:no-repeat; background-position:left;",listeners:{afterRender:function(c){c.getEl().dom.setAttribute('ext:qtip',locale.labels.composer.geocode)}},actionTarget:{target:"paneltbar",index:9}});tools.unshift({xtype:'tbspacer',width:5,actionTarget:{target:"paneltbar",index:8}});var wait=new Ext.BoxComponent({id:'waitIndicator',autoEl:{tag:'img',src:OVROOT+'theme/app/img/silk/loading.gif',},scope:this,actionTarget:{target:"paneltbar",index:7}});tools.unshift(wait);var profileLoadPb=new Ext.ProgressBar({id:'profileLoadPb',text:locale.labels.composer.profileLoading+'...',hidden:true,width:300});profileLoadPb.hide();tools.unshift(profileLoadPb);var aboutButton=new Ext.Button({text:'Помощь',tooltip:locale.tips.helpBtnTip,iconCls:"icon-question",id:"helpButton",handler:function(){var win=new Ext.Window({title:locale.labels.helpWindow.title,layout:'fit',width:700,height:400,closeAction:'hide',maximizable:true,items:[{layout:'border',defaults:{collapsible:true,split:true,},items:[{xtype:'treepanel',listeners:{click:function(a,b,c){if(a.attributes.url)Ext.getCmp('helpIframe').body.dom.innerHTML='<iframe style="border: none;" height="100%" width="100%" src="'+OVROOT+a.attributes.url+'"></iframe>'}},rootVisible:false,region:'west',width:175,minSize:100,maxSize:250,useArrows:true,autoScroll:true,animate:true,containerScroll:true,border:false,root:new Ext.tree.AsyncTreeNode({children:HelpInfo}),},{collapsible:false,region:'center',margins:'5 0 0 0',id:'helpIframe'}]}]});win.show();},scope:this});tools.unshift("->");tools.unshift(aboutButton);tools.unshift('->');
/*tools.unshift({text:locale.labels.composer.layer,menu:new Ext.menu.Menu({items:[{text:locale.labels.composer.addLayer,handler:function(){return app.tools.gxp_addlayers_ctl.showCapabilitiesGrid();}},{text:locale.labels.composer.removeLayer,handler:function(a,b,c){app.tools.gxp_removelayer_ctl.tryRemoveCurrent();}},{text:locale.labels.composer.layerProperties,handler:function(){if(!Ext.getCmp("layerPropertiesButton").disabled){Ext.getCmp("layerPropertiesButton").handler.call(Ext.getCmp("layerPropertiesButton").scope);}else{Ext.Msg.alert(locale.messages.warning,locale.messages.propertiesUnavailableError);}}}]})});*/
tools.unshift('');
var saveAsProfile=function(owner){if(window.JOSSO_USER=="null"){Ext.Msg.alert(locale.messages.profileSaveErrorTitle,locale.messages.profileSaveError);gxp.plugins.Logger.log(locale.log.unauthorizedProfileSaveAttemptText,gxp.plugins.Logger.prototype.LOG_LEVEL_NETWORK_LOCAL_ERRORS);return;}
var getLayers=function(){var arr=app.mapPanel.layers.getRange().filter(function(el){return el&&el.get('layer')&&el.get('layer').displayInLayerSwitcher&&el.get('group')!="background"&&el.get('group')!="editable"&&el.get('source')});var layers=[]
arr.forEach(function(el){var ld={id:el.ov_id,source:el.get('source'),opacity:el.get('layer').opacity,visible:el.get('layer').visibility};if(ld.source!="rss"&&ld.source!="arcgis93"&&ld.source!="animation")ld.source="wms";if(ld.source=="arcgis93")ld.source="arcgis";if(ld.source=="wms"){ld.id=el.id;ld.url=el.get('layer').url;ld.layername=el.get('layer').params.LAYERS;ld.stylename=el.get('layer').params.STYLES;}
layers.push(ld);});return layers;}
var getState=function(){var properties=[{key:"extent",value:app.mapPanel.map.getExtent().toString()},{key:"projection",value:app.mapPanel.map.getProjection()},{key:"basemap",value:app.map.layers.filter(function(el){return el.group=="background"&&el.title==$('input[name="background_checkbox"]:checked').next().children().first()[0].innerHTML})[0].name},{key:"layers",value:JSON.stringify(getLayers())},{key:"tools",value:JSON.stringify((function(){var tools=[];for(var i in app.tools){tools.push(app.tools[i].ptype)};return tools})())}];var prop=[];properties.every(function(el){prop.push(el.key+"="+el.value);return true;});return{name:Ext.getCmp('saveProfileNameField').getValue(),name_en:Ext.getCmp('saveProfileNameEnField').getValue(),obj:"gis.map",owner:owner,prop:prop.join(";")};}
var w=new Ext.Window({title:locale.labels.composer.profileSaveWindowTitle,width:350,autoHeight:true,bodyStyle:"padding:10px",items:[{xtype:'fieldset',flex:1,labelAlign:'top',anchor:'100%',border:0,items:[{fieldLabel:locale.labels.composer.profileSaveNameLabel,xtype:'textfield',id:'saveProfileNameField',width:100,anchor:"100%"},{fieldLabel:locale.labels.composer.profileSaveNameEnLabel,xtype:'textfield',id:'saveProfileNameEnField',width:100,anchor:"100%"}]}],buttons:[{text:locale.labels.composer.saveBtn,handler:function(){var mask=new Ext.LoadMask(w.getEl(),{msg:locale.messages.pleaseWait});mask.show();
//сохранение профиля
var profileStr = OpenLayers.Util.getParameterString(getState());
profileStr = profileStr.split('%3FSERVICE%3DWMS%26').join('').split('%3Fservice%3Dwms%26').join('');
GPOpenLayers.Request.issue({method:"POST",url:/*app.proxy+*/app.restUrl+"/add.json",async:true,data:profileStr,callback:function(request)
{mask.hide();try{var desc=JSON.parse(request.responseText);if(desc.description.profileId)
Ext.Msg.alert(locale.messages.profileSaveMsgTitle,locale.messages.profileSaveSuccessMessage.replace("{profileId}",desc.description.profileId)+'<br/> Ссылка на сохраненный профиль: http://'+window.location.hostname+window.location.pathname+'?profileId='+desc.description.profileId);else
Ext.Msg.alert(locale.messages.profileSaveMsgTitle,locale.messages.profileSaveErrorMessage);}catch(e){Ext.Msg.alert(locale.messages.profileSaveMsgTitle,locale.messages.profileSaveErrorMessage);}
w.close();}})}},{text:locale.labels.composer.cancelBtn,handler:function(){w.close();}}]}).show();}
tools.unshift({text:locale.labels.composer.profiles,menu:new Ext.menu.Menu({id:'mapMenu',items:[{text:locale.labels.composer.saveMap+"...",hidden:window.JOSSO_USER=="null",handler:function(){saveAsProfile(window.JOSSO_USER);}},{text:locale.labels.composer.saveCommonMap+"...",hidden:!window.IS_ADMIN,handler:function(){saveAsProfile("commonprofile");}},{text:locale.labels.composer.profiles,handler:function(){app.tools.gxp_profileGrid_ctl.showProfileGrid()}},{text:locale.labels.composer.print,hidden:true,handler:function(){}}]})});return tools;}});Ext.namespace("GeoExplorer");GeoExplorer.Viewer=Ext.extend(GeoExplorer,{applyConfig:function(config){var allTools=config.viewerTools||this.viewerTools;var tools=[{ptype:'gispro_viewmenu',actionTarget:{target:"paneltbar",index:2},graticulOptions:{displayInLayerSwitcher:false},ovLayer:config.ovLayer}];var toolConfig;for(var i=0,len=allTools.length;i<len;i++){var tool=allTools[i];if(tool.checked===true){toolConfig={ptype:tool.ptype,toggleGroup:tool.toggleGroup,actionTarget:tool.actionTarget};if(tool.ptype==="gxp_googleearth"){var jj=config.tools?config.tools.length:0;var composerConfig;for(var j=0;j<jj;++j){composerConfig=config.tools[j];if(composerConfig.ptype===tool.ptype){toolConfig.apiKey=composerConfig.apiKey;toolConfig.apiKeys=composerConfig.apiKeys;break;}}}
tools.push(toolConfig);}}
config.tools=tools;GeoExplorer.Viewer.superclass.applyConfig.call(this,config);},initPortal:function(){this.toolbar=new Ext.Toolbar({disabled:true,id:"paneltbar",items:this.createTools()});this.on("ready",function(){this.toolbar.enable();},this);this.mapPanelContainer=new Ext.Panel({layout:"card",region:"center",defaults:{border:false},items:[this.mapPanel,new gxp.GoogleEarthPanel({mapPanel:this.mapPanel,listeners:{beforeadd:function(record){return record.get("group")!=="background";}}})],activeItem:0});this.portalItems=[{region:"center",layout:"border",tbar:this.toolbar,items:[this.mapPanelContainer]}];GeoExplorer.superclass.initPortal.apply(this,arguments);},createTools:function(){var tools=GeoExplorer.Viewer.superclass.createTools.apply(this,arguments);var layerChooser=new Ext.Button({tooltip:'Layer Switcher',iconCls:'icon-layer-switcher',menu:new gxp.menu.LayerMenu({layers:this.mapPanel.layers})});tools.unshift("-");tools.unshift(layerChooser);var aboutButton=new Ext.Button({text:'Помощь',tooltip:this.aboutText,iconCls:"icon-question",handler:this.displayAppInfo,scope:this});tools.push("->");tools.push(aboutButton);return tools;}});﻿
GeoExt.Lang.add("ru",{"GeoExplorer.prototype":{zoomSliderText:"<div>Масштаб: {zoom}</div><div>Масштаб: 1:{scale}</div>",loadConfigErrorText:"Ошибка чтения сохраненной конфигурации: <br />",loadConfigErrorDefaultText:"Ошибка сервера.",xhrTroubleText:"Ошибка связи: Статус ",layersText:"Слои",titleText:"Заголовок",zoomLevelText:"Масштаб",saveErrorText:"Ошибка сохранения: ",bookmarkText:"URL карты",permakinkText:'Постоянная ссылка',appInfoText:"OceanViewer",aboutText:"О OceanViewer",mapInfoText:"Описание карты",descriptionText:"Описание",contactText:"Контакты",aboutThisMapText:"Об этой карте"},"GeoExplorer.Composer.prototype":{exportMapText:"Сохранить представление",saveMapText:"Сохранить карту",toolsTitle:"Выберите инструменты на панель представления:",previewText:"Предпросмотр",backText:"Назад",nextText:"Далее",loginText:"Вход",loginErrorText:"Неверный пароль или имя пользователя.",userFieldText:"Пользователь",passwordFieldText:"Пароль",helpTip:'Помощь'}});Ext.namespace("gxp.plugins");gxp.plugins.GraticuleGxpTool=Ext.extend(gxp.plugins.Tool,{ptype:"gxp_graticulegxptool",config:null,graticuleControl:null,map:null,readyAlready:false,activated:true,constructor:function(config){gxp.plugins.GraticuleGxpTool.superclass.constructor.apply(this,arguments);this.config=config;},init:function(target){var ths=this;gxp.plugins.GraticuleGxpTool.superclass.init.apply(ths,arguments);if(target.mapPanel.map.layers[0].mergeNewParams)
target.mapPanel.map.layers[0].mergeNewParams();ths.map=target.mapPanel.map;ths.graticuleControl=new GPOpenLayers.Control.Graticule(ths.config.controlOptions);ths.map.addControl(ths.graticuleControl);ths.readyAlready=true;},toggle:function(){if(this.activated){this.activated=false;this.graticuleControl.deactivate();}else{this.activated=true;this.graticuleControl.activate();}},destroy:function(){this.graticuleControl.destroy();this.graticuleControl=null;this.map=null;gxp.plugins.GraticuleGxpTool.superclass.destroy.apply(this,arguments);},bringUp:function(){var lastNormalLayer=this.map.layers.length-1;for(;lastNormalLayer>=0;lastNormalLayer--){if(this.map.layers[lastNormalLayer].CLASS_NAME!="GPOpenLayers.Layer.GeoRSS"){break;}}
this.map.setLayerIndex(this.graticuleControl.gratLayer,lastNormalLayer);}});Ext.preg(gxp.plugins.GraticuleGxpTool.prototype.ptype,gxp.plugins.GraticuleGxpTool);Ext.namespace("gxp.plugins");gxp.plugins.MousePosGxpTool=Ext.extend(gxp.plugins.Tool,{ptype:"gxp_mouseposgxptool",config:null,mousePosControl:null,map:null,constructor:function(config){gxp.plugins.MousePosGxpTool.superclass.constructor.apply(this,arguments);this.config=config;this.mousePosControl=new GPOpenLayers.Control.MousePosition(this.config.controlOptions);},init:function(target){this.map=target.mapPanel.map;this.map.addControl(this.mousePosControl);gxp.plugins.MousePosGxpTool.superclass.init.apply(this,arguments);},destroy:function(){this.mousePosControl.destroy();this.mousePosControl=null;this.map=null;gxp.plugins.MousePosGxpTool.superclass.destroy.apply(this,arguments);}});Ext.preg(gxp.plugins.MousePosGxpTool.prototype.ptype,gxp.plugins.MousePosGxpTool);var servicesSetting;Ext.namespace("gxp");var isAlreadyInUse=function(t){var count=0;;app.mapPanel.layers.each(function(record,index){if(record.get("title").indexOf(t)+1){count++;}});return count?t+"("+count+")":t;}
gxp.ServicesSetting=Ext.extend(Ext.Window,{title:locale.labels.addLayers.windowTitle,closeAction:'hide',modal:true,maximizable:true,height:600,width:750,newObject:false,buttonAlign:'left',buttons:[{disabled:false,width:150,text:locale.labels.addLayers.addToMap,id:'addButton',handler:function(){if(false/*window.JOSSO_USER=="null"*/){Ext.Msg.alert(locale.messages.error,locale.messages.accessDeniedText);gxp.plugins.Logger.log(locale.log.addLayerAccessError,gxp.plugins.Logger.prototype.LOG_LEVEL_NETWORK_LOCAL_ERRORS);return;}
if(servicesSetting.tabs.activeTab.id==='wmsPanel')
servicesSetting.wmsPanel.addRecord2Map();else if(servicesSetting.tabs.activeTab.id==='rssPanel')
servicesSetting.rssPanel.addRecord2Map();else if(servicesSetting.tabs.activeTab.id==='arcgisPanel')
servicesSetting.arcgisPanel.addRecord2Map();else if(servicesSetting.tabs.activeTab.id==='animationPanel')
Ext.getCmp('animationPanel').addRecord2Map();else if(servicesSetting.tabs.activeTab.id==='customPanel')
Ext.getCmp('customPanel').addRecord2Map();}},'->',{disabled:false,id:'closeButton',text:locale.labels.addLayers.close,handler:function(){servicesSetting.hide();}}],initComponent:function(){this.wmsLayersStore=new Ext.data.Store({autoLoad:false,remoteSort:false,idCustom:'',proxy:new Ext.data.HttpProxy({url:''}),reader:new Ext.data.XmlReader({record:'Layer',id:'Layer'},['Title','Name']),listeners:{loadexception:function(o,arg,nul,e){}}});this.customLayersStore=new Ext.data.Store({autoLoad:false,idCustom:'',proxy:new Ext.data.HttpProxy({url:''}),reader:new Ext.data.XmlReader({record:'Layer',id:'Layer'},['Title','Name']),listeners:{loadexception:function(o,arg,nul,e){}}});this.iconStore=new Ext.data.SimpleStore({fields:['color','url'],data:[[locale.labels.addLayers.colors.blue,'script/images/marker-blue.gif'],[locale.labels.addLayers.colors.brown,'script/images/marker-brown.gif'],[locale.labels.addLayers.colors.yellow,'script/images/marker-gold.png'],[locale.labels.addLayers.colors.green,'script/images/marker-green.png'],[locale.labels.addLayers.colors.purple,'script/images/marker-purple.gif'],[locale.labels.addLayers.colors.red,'script/images/marker-red.png']]});this.iconSelector=new Ext.form.ComboBox({fieldLabel:locale.labels.addLayers.icon,emptyText:locale.labels.addLayers.rssIconEmptyText,displayField:'color',valueField:'url',editable:true,disabled:false,triggerAction:'all',mode:'local',store:this.iconStore,anchor:"100%",labelStyle:'font-size:12px;font-weight: normal; color:#909090'});var arcgisDS=new Ext.data.JsonStore({root:'servers',fields:['id','title','url','format','owner','access']});arcgisDS.loadData(arcgisStore.reader.jsonData);this.notSelected=function(){Ext.Msg.alert(locale.messages.addToMap,locale.messages.nothingSelected);};this.wmsPanel=new Ext.Panel({id:'wmsPanel',title:locale.labels.addLayers.wmsPanelTitle,heigth:750,layout:{type:'vbox',align:'stretch'},getSelectedRow:function(store,data)
{var row=-1;if(store.getCount()>0)
{for(var i=0;i<store.getCount();i++)
{if((store.data.items[i].data.title===data.title)&&(store.data.items[i].data.url===data.url))
{row=i;break;};};};return row;},clear:function()
{Ext.getCmp("serverNameField").setValue('');Ext.getCmp("serverURLField").setValue('');Ext.getCmp("serverRestURLField").setValue('');if((Ext.getCmp("wmsGrid").store.getCount()>0)&&Ext.getCmp("wmsGrid").getSelectionModel().getSelected())
{Ext.getCmp("wmsGrid").getSelectionModel().deselectRow(this.getSelectedRow(Ext.getCmp("wmsGrid").store,Ext.getCmp("wmsGrid").getSelectionModel().getSelected().data));}
this.clearGridLayers();},getLayerSources:function()
{var id;for(var rec in app.layerSources)
{if(app.layerSources[rec].baseParams&&(app.layerSources[rec].baseParams.SERVICE==='WMS')&&(app.layerSources[rec].baseParams.REQUEST==='GetCapabilities')&&(app.layerSources[rec].ptype==='gxp_wmscsource')&&(app.layerSources[rec].title===Ext.getCmp("serverNameField").getValue())&&(app.layerSources[rec].url===Ext.getCmp("serverURLField").getValue())&&(app.layerSources[rec].rest_url===Ext.getCmp("serverRestURLField").getValue()))
{id=rec;break;}}
return id;},showLayerSources:function(id)
{servicesSetting.wmsLayersStore.idCustom=id;servicesSetting.wmsLayersStore.loadData(app.layerSources[id].store.data);Ext.getCmp("wmsLayers").getView().refresh();Ext.getCmp('wmsLayersCount').getEl().update(locale.labels.addLayers.layersCount+': '+servicesSetting.wmsLayersStore.data.length);},clearGridLayers:function()
{Ext.getCmp('wmsLayersCount').getEl().update('&nbsp;');if(Ext.getCmp("wmsLayers").getSelectionModel().getSelected())
{Ext.getCmp("wmsLayers").getSelectionModel().deselectRow(this.getSelectedRow(Ext.getCmp("wmsLayers").store,Ext.getCmp("wmsLayers").getSelectionModel().getSelected().data));}
servicesSetting.wmsLayersStore.proxy=new Ext.data.HttpProxy({url:''});servicesSetting.wmsLayersStore.data=[];Ext.getCmp("wmsLayers").getView().refresh();},rowSelect:function(record)
{Ext.getCmp("serverNameField").setValue(record.data.server_name);Ext.getCmp("serverURLField").setValue(record.data.url);Ext.getCmp("serverRestURLField").setValue(record.data.rest_url);servicesSetting.newObject=false;this.clearGridLayers();var id=this.getLayerSources();if(id)
this.showLayerSources(id);},addRecord2Map:function()
{if(!Ext.getCmp("wmsLayers").getSelectionModel().getSelections())
{servicesSetting.notSelected();}
else{var key=servicesSetting.wmsLayersStore.idCustom;var source=app.layerSources[key];Ext.getCmp("wmsLayers").getSelectionModel().getSelections().forEach(function(rec){var record=source.createLayerRecord({name:rec.data.name,title:isAlreadyInUse(rec.data.title),source:key});if(record)
app.mapPanel.layers.add([record]);});}},items:[{flex:1,border:false,layout:{type:'hbox',align:'stretch'},items:[{flex:1,layout:'fit',items:{xtype:'grid',id:'wmsGrid',autoExpandColumn:"server_name",border:false,ds:wmsStore,columns:[{id:'server_name',header:locale.labels.addLayers.nameLabel,flex:1,sortable:true,dataIndex:'server_name',renderer:function(value,metaData,record,colIndex,store,view){metaData.attr='ext:qtip="'+value+'"';return value;}}],sm:new Ext.grid.RowSelectionModel({listeners:{rowselect:function(sm,row,rec){servicesSetting.wmsPanel.rowSelect(rec);}}}),listeners:{viewready:function(grid){grid.getSelectionModel().selectRow(0);}}}},{xtype:'fieldset',height:280,flex:1,labelAlign:'top',anchor:'100%',bodyStyle:'padding: 10px 10px 5px 10px;',id:"wmsPanelFields",style:{"margin-left":"10px","margin-right":"0","background":"transparent","border":"none"},items:[{xtype:'textfield',fieldLabel:locale.labels.addLayers.nameLabel,name:'server_name',id:'serverNameField',anchor:"100%",labelStyle:'font-size:12px;font-weight: normal; color:#909090'},{xtype:'textfield',fieldLabel:'URL',name:'url',id:'serverURLField',anchor:"100%",labelStyle:'font-size:12px;font-weight: normal; color:#909090'},{xtype:'textfield',fieldLabel:'REST URL',name:'rest_url',id:'serverRestURLField',anchor:"100%",labelStyle:'font-size:12px;font-weight: normal; color:#909090'},{id:'wmsLayersCount',xtype:'label',html:'&nbsp;',style:'font-size:11px;font-weight: normal; font-style: italic;color:#8080ff'},{xtype:'label',html:'&nbsp;',style:'font-size:20px;font-weight: bold'},{xtype:'button',width:100,text:locale.labels.addLayers.addSourceBtn,style:'font-size:14px;font-weight: bold;color:#ffff00',handler:function(){if(Ext.getCmp("serverURLField").getValue()){var mask=new Ext.LoadMask(Ext.getCmp("wmsLayers").getEl(),{msg:locale.labels.addLayers.loading+"..."});mask.show();var wmsCapabilities=Ext.getCmp("serverURLField")+'?request=GetCapabilities';var id=servicesSetting.wmsPanel.getLayerSources();if(id){servicesSetting.wmsPanel.showLayerSources(id);}else{var conf={url:Ext.getCmp("serverURLField").getValue(),restUrl:Ext.getCmp("serverRestURLField").getValue(),title:Ext.getCmp("serverNameField").getValue(),version:'1.3.0'}
app.addLayerSource({config:conf,callback:function(id){mask.hide();servicesSetting.wmsLayersStore.idCustom=id;servicesSetting.wmsLayersStore.data=app.layerSources[id].store.data;Ext.getCmp("wmsLayers").getView().refresh();Ext.getCmp('wmsLayersCount').getEl().update(locale.labels.addLayers.layersCount+': '+servicesSetting.wmsLayersStore.data.length);},fallback:function(source,msg){mask.hide();Ext.Msg.alert(locale.messages.error,locales.messages.getlayersError);},scope:this});}}}}]},]},{xtype:'label',colspan:2,text:locale.labels.addLayers.layersList,style:'padding: 5px 5px 5px 3px;font-size:12px;font-weight: bold;color:#909090'},{id:'wmsLayers',xtype:'grid',colspan:2,style:'padding: 5px 5x 5px 5px',border:true,height:206,autoExpandColumn:"title",ds:this.wmsLayersStore,columns:[{header:locale.labels.addLayers.headerLabel,id:'header',width:340,sortable:true,dataIndex:'title',renderer:function(value,metaData,record,colIndex,store,view){metaData.attr='ext:qtip="'+value+'"';return value;}},{header:locale.labels.addLayers.nameLabel,id:'title',width:340,sortable:true,dataIndex:'name'}]}]});this.arcgisPanel=new Ext.Panel({id:'arcgisPanel',title:locale.labels.addLayers.arcgisPanelTitle,width:750,border:false,layout:'column',getSelectedRow:function(store,data)
{var row=-1;if(store.getCount()>0)
{for(var i=0;i<store.getCount();i++)
{if((store.data.items[i].data.title===data.title)&&(store.data.items[i].data.url===data.url))
{row=i;break;};};};return row;},clear:function()
{Ext.getCmp("arcgisPanel").items.items[1].items.items[0].setValue('');Ext.getCmp("arcgisPanel").items.items[1].items.items[1].setValue('');Ext.getCmp("arcgisPanel").items.items[1].items.items[2].setValue('');if((Ext.getCmp("arcgisGrid").store.getCount()>0)&&Ext.getCmp("arcgisGrid").getSelectionModel().getSelected())
{Ext.getCmp("arcgisGrid").getSelectionModel().deselectRow(this.getSelectedRow(Ext.getCmp("arcgisGrid").store,Ext.getCmp("arcgisGrid").getSelectionModel().getSelected().data));}},rowSelect:function(record)
{Ext.getCmp("arcgisPanel").items.items[1].items.items[0].setValue(record.data.title);Ext.getCmp("arcgisPanel").items.items[1].items.items[1].setValue(record.data.url);Ext.getCmp("arcgisPanel").items.items[1].items.items[2].setValue(record.data.format);servicesSetting.newObject=false;},addRecord2Map:function()
{var source=app.layerSources['arcgis93'];if(!source)
source=new gxp.plugins.ArcGIS93Source();var url=Ext.getCmp("arcgisPanelURL").getValue();var layerStore=app.mapPanel.layers;Ext.getCmp("arcgisGrid").getSelectionModel().getSelections().forEach(function(r){var curl=url+'?layers=show:'+r.get("id");var layer=source.createLayer(isAlreadyInUse(r.get("title")),curl);record=source.createRecord(r.get("id"),layer);if(record){record.ov_id=r.get("id");layerStore.add([record]);}});},items:[{width:560,height:485,layout:'fit',items:{xtype:'grid',id:'arcgisGrid',border:false,autoExpandColumn:'title',ds:arcgisDS,columns:[{id:'title',header:locale.labels.addLayers.nameLabel,flex:1,sortable:true,dataIndex:'title'}],sm:new Ext.grid.RowSelectionModel({listeners:{rowselect:function(sm,row,rec){servicesSetting.arcgisPanel.rowSelect(rec);}}}),listeners:{viewready:function(grid){grid.getSelectionModel().selectRow(0);}}}},{xtype:'fieldset',height:505,columnWidth:1.0,labelAlign:'top',anchor:'100%',bodyStyle:'padding: 10px 10px 5px 10px;border-color: #f86c6c;',style:{"margin-left":"10px","margin-right":"0"},items:[{xtype:'textfield',id:'arcgisPanelTitle',fieldLabel:locale.labels.addLayers.nameLabel,name:'name',anchor:"100%",labelStyle:'font-size:12px;font-weight: normal; color:#909090'},{xtype:'textfield',id:'arcgisPanelURL',fieldLabel:'URL',name:'url',anchor:"100%",labelStyle:'font-size:12px;font-weight: normal; color:#909090'},{xtype:'textfield',fieldLabel:locale.labels.addLayers.formatLabel,name:'format',anchor:"100%",labelStyle:'font-size:12px;font-weight: normal; color:#909090'}]}]});this.rssPanel=new Ext.Panel({id:'rssPanel',title:locale.labels.addLayers.rssPanelTitle,width:750,border:false,layout:'column',getSelectedRow:function(store,data)
{var row=-1;if(store.getCount()>0)
{for(var i=0;i<store.getCount();i++)
{if((store.data.items[i].data.title===data.title)&&(store.data.items[i].data.url===data.url))
{row=i;break;};};};return row;},clear:function()
{Ext.getCmp("rssPanel").items.items[1].items.items[0].setValue('');Ext.getCmp("rssPanel").items.items[1].items.items[1].setValue('');Ext.getCmp("rssPanel").items.items[1].items.items[2].setValue('');if((Ext.getCmp("rssGrid").store.getCount()>0)&&Ext.getCmp("rssGrid").getSelectionModel().getSelected())
{Ext.getCmp("rssGrid").getSelectionModel().deselectRow(this.getSelectedRow(Ext.getCmp("rssGrid").store,Ext.getCmp("rssGrid").getSelectionModel().getSelected().data));}},rowSelect:function(record)
{Ext.getCmp("rssPanel").items.items[1].items.items[0].setValue(record.data.title);Ext.getCmp("rssPanel").items.items[1].items.items[1].setValue(record.data.url);Ext.getCmp("rssPanel").items.items[1].items.items[2].setValue(record.data.icon);servicesSetting.newObject=false;},extractFileName:function(url)
{var fname;var parts=url.split("/");if(parts)
fname=parts[parts.length-1];else
fname='Unreachable';if(fname.indexOf(".")>0)
fname=fname.substring(0,fname.indexOf("."));return fname;},addRecord2Map:function()
{var source=app.layerSources['rss'];if(!source)
source=new gxp.plugins.RssSource();var layerStore=app.mapPanel.layers;var _this=this;Ext.getCmp('rssGrid').getSelectionModel().getSelections().forEach(function(rec){record=source.createRecord(isAlreadyInUse(rec.get("title")),rec.get("name"),rec.get("url"),rec.get("x_axis"),rec.get("layers"));var val=_this.extractFileName(rec.get("url"));var record=source.createRecord(val);if(record&&record.get('name')&&record.get('name')!='Unreachable'){record.ov_id=rec.get("id");layerStore.add([record]);}else{console.log('Unable to add RSS layer');console.log(record);}});},items:[{width:560,height:485,layout:'fit',items:{xtype:'grid',id:'rssGrid',autoExpandColumn:'title',border:false,ds:rssStore,columns:[{id:'title',header:locale.labels.addLayers.nameLabel,flex:1,sortable:true,dataIndex:'title'}],sm:new Ext.grid.RowSelectionModel({listeners:{rowselect:function(sm,row,rec){servicesSetting.rssPanel.rowSelect(rec);}}}),listeners:{viewready:function(g){g.getSelectionModel().selectRow(0);}}}},{xtype:'fieldset',height:505,columnWidth:1.0,labelAlign:'top',anchor:'100%',bodyStyle:'padding: 10px 10px 5px 10px;border-color: #f86c6c;',style:{"margin-left":"10px","margin-right":"0"},items:[{xtype:'textfield',id:'rssPanelTitle',fieldLabel:locale.labels.addLayers.nameLabel,name:'title',anchor:"100%",labelStyle:'font-size:12px;font-weight: normal; color:#909090'},{xtype:'textfield',id:'rssPanelURL',fieldLabel:'URL',name:'url',anchor:"100%",labelStyle:'font-size:12px;font-weight: normal; color:#909090'},this.iconSelector]}]});this.customPanel=new Ext.Panel({id:'customPanel',title:locale.labels.addLayers.customPanelTitle,heigth:750,layout:{type:'vbox',align:'stretch'},clear:function()
{Ext.getCmp("serverNameField").setValue('');Ext.getCmp("serverURLField").setValue('');Ext.getCmp("serverRestURLField").setValue('');if((Ext.getCmp("customGrid").store.getCount()>0)&&Ext.getCmp("customGrid").getSelectionModel().getSelected())
{Ext.getCmp("customGrid").getSelectionModel().deselectRow(this.getSelectedRow(Ext.getCmp("customGrid").store,Ext.getCmp("customGrid").getSelectionModel().getSelected().data));}
this.clearGridLayers();},getLayerSources:function()
{var id;for(var rec in app.layerSources)
{if(app.layerSources[rec].baseParams&&(app.layerSources[rec].baseParams.SERVICE==='custom')&&(app.layerSources[rec].baseParams.REQUEST==='GetCapabilities')&&(app.layerSources[rec].ptype==='gxp_customcsource')&&(app.layerSources[rec].title===Ext.getCmp("customServerNameField").getValue())&&(app.layerSources[rec].url===Ext.getCmp("customServerURLField").getValue())&&(app.layerSources[rec].rest_url===Ext.getCmp("customServerRestURLField").getValue()))
{id=rec;break;}}
return id;},showLayerSources:function(id)
{servicesSetting.customLayersStore.idCustom=id;servicesSetting.customLayersStore.data=app.layerSources[id].store.data;Ext.getCmp("customLayers").getView().refresh();Ext.getCmp('customLayersCount').getEl().update(locale.labels.addLayers.layersCount+': '+servicesSetting.customLayersStore.data.length);},clearGridLayers:function()
{Ext.getCmp('customLayersCount').getEl().update('&nbsp;');if(Ext.getCmp("customLayers").getSelectionModel().getSelected())
{Ext.getCmp("customLayers").getSelectionModel().deselectRow(this.getSelectedRow(Ext.getCmp("customLayers").store,Ext.getCmp("customLayers").getSelectionModel().getSelected().data));}
servicesSetting.customLayersStore.proxy=new Ext.data.HttpProxy({url:''});servicesSetting.customLayersStore.data=[];Ext.getCmp("customLayers").getView().refresh();},addRecord2Map:function()
{if(!Ext.getCmp("customLayers").getSelectionModel().getSelected())
{servicesSetting.notSelected();}
else{var key=servicesSetting.customLayersStore.idCustom;var source=app.layerSources[key];Ext.getCmp('customLayers').getSelectionModel().getSelections().forEach(function(rec){var record=source.createLayerRecord({name:rec.data.name,title:isAlreadyInUse(rec.data.title),source:key});if(record)
app.mapPanel.layers.add([record]);});}},items:[{width:750,border:false,layout:{type:'column',align:'stretch'},bodyStyle:'background-color: #efefef',items:[{xtype:'fieldset',height:280,columnWidth:1.0,labelAlign:'top',anchor:'100%',bodyStyle:'padding: 10px 10px 5px 10px; background-color: #efefef',id:"customPanelFields",style:{"margin-left":"10px","margin-right":"0"},items:[{xtype:'textfield',fieldLabel:locale.labels.addLayers.nameLabel,name:'customServer_name',id:'customServerNameField',anchor:"100%",labelStyle:'font-size:12px;font-weight: normal; color:#909090'},{xtype:'textfield',fieldLabel:'URL',name:'customUrl',id:'customServerURLField',anchor:"100%",labelStyle:'font-size:12px;font-weight: normal; color:#909090'},{xtype:'textfield',fieldLabel:'REST URL',name:'custom_rest_url',id:'customServerRestURLField',anchor:"100%",labelStyle:'font-size:12px;font-weight: normal; color:#909090'},{id:'customLayersCount',xtype:'label',html:'&nbsp;',style:'font-size:11px;font-weight: normal; font-style: italic;color:#8080ff'},{xtype:'label',html:'&nbsp;',style:'font-size:20px;font-weight: bold'},{xtype:'button',width:100,text:locale.labels.addLayers.addSourceBtn,style:'font-size:14px;font-weight: bold;color:#ffff00',handler:function(){if(Ext.getCmp("customServerURLField").getValue()){var mask=new Ext.LoadMask(Ext.getCmp("customLayers").getEl(),{msg:locale.labels.addLayers.loading+'...'});mask.show();var customCapabilities=Ext.getCmp("customServerURLField")+'?request=GetCapabilities';var id=servicesSetting.customPanel.getLayerSources();if(id){servicesSetting.customPanel.showLayerSources(id);}else{var conf={url:Ext.getCmp("customServerURLField").getValue(),restUrl:Ext.getCmp("customServerRestURLField").getValue(),title:Ext.getCmp("customServerNameField").getValue(),version:'1.3.0'}
app.addLayerSource({config:conf,callback:function(id){mask.hide();servicesSetting.customLayersStore.idCustom=id;servicesSetting.customLayersStore.data=app.layerSources[id].store.data;Ext.getCmp("customLayers").getView().refresh();Ext.getCmp('customLayersCount').getEl().update(locale.labels.addLayers.layersCount+': '+servicesSetting.customLayersStore.data.length);},fallback:function(source,msg){mask.hide();Ext.Msg.alert(locale.messages.error,locales.messages.getlayersError);},scope:this});}}}}]},]},{xtype:'label',colspan:2,text:locale.labels.addLayers.layersList,style:'padding: 5px 5px 5px 3px;font-size:12px;font-weight: bold;color:#909090'},{id:'customLayers',xtype:'grid',colspan:2,style:'padding: 5px 5x 5px 5px',border:true,height:206,autoExpandColumn:"title",ds:this.customLayersStore,columns:[{header:locale.labels.addLayers.headerLabel,id:'header',width:340,sortable:true,dataIndex:'title',renderer:function(value,metaData,record,colIndex,store,view){metaData.attr='ext:qtip="'+value+'"';return value;}},{header:locale.labels.addLayers.nameLabel,id:'title',width:340,sortable:true,dataIndex:'name'}]}]});this.tabs=new Ext.TabPanel({deferredRender:false,flex:1,layoutOnTabChange:true,activeTab:0,height:540,plain:true,defaults:{bodyStyle:'padding: 10px; background-color: #efefef',hideMode:'offsets'},items:[this.wmsPanel,this.arcgisPanel,this.rssPanel,{title:locale.labels.addLayers.animationPanelTitle,id:'animationPanel',autoScroll:true,layout:'fit',items:[{xtype:'grid',height:485,id:'animationGrid',store:animationStore,autoScroll:true,autoExpandColumn:"title",colModel:new Ext.grid.ColumnModel([{header:"Id",dataIndex:"anim_id",sortable:true},{id:"title",flex:1,header:locale.labels.addLayers.nameLabel,dataIndex:"title",sortable:true}])}],addRecord2Map:function(){var source=app.layerSources['animation'];if(!source)
source=new gxp.plugins.AnimationSource();var layerStore=app.mapPanel.layers;Ext.getCmp('animationGrid').getSelectionModel().getSelections().forEach(function(rec){record=source.createRecord(isAlreadyInUse(rec.get("title")),rec.get("name"),rec.get("url"),rec.get("x_axis"),rec.get("layers"));if(record){record.ov_id=rec.get("anim_id");layerStore.add([record]);}})}},this.customPanel],listeners:{'tabchange':function(tabPanel,tab){if(tab.id==='wmsPanel'){servicesSetting.newObject=true;servicesSetting.wmsPanel.clear();}else if(tab.id==='rssPanel'){servicesSetting.rssPanel.clear();}}}});this.items=this.tabs;Ext.getCmp('wmsLayers').on('dblclick',function(evt){servicesSetting.wmsPanel.addRecord2Map();});gxp.ServicesSetting.superclass.initComponent.call(this);}});