Ext.ns("Sonia.panel");
Sonia.panel.CodeEditorPanel=Ext.extend(Ext.Panel,{modeMappingTable:[],editor:null,editorId:null,editorTheme:"ace/theme/textmate",editorMode:"ace/mode/groovy",initComponent:function(){this.modeMappingTable["ace/mode/ecmascript"]="ace/mode/javascript";this.editorId="ace-"+Ext.id();var config={html:'<div style="width: 100%; height: 100%;" id="'+this.editorId+'"></div>',layout:"fit",autoScroll:true,listeners:{afterrender:{fn:this.loadBodyContent,scope:this}}};Ext.apply(this,Ext.apply(this.initialConfig,config));
Sonia.panel.CodeEditorPanel.superclass.initComponent.apply(this,arguments)},loadBodyContent:function(){main.loadScript(restUrl+"plugins/script/static/ace/ace.js",this.renderEditor,this)},setMode:function(mode){var m=this.modeMappingTable[mode];if(!m)m=mode;this.editorMode=m;this.editor.getSession().setMode(m)},renderEditor:function(){this.editor=ace.edit(this.editorId);this.editor.setTheme(this.editorTheme);this.editor.getSession().setMode(this.editorMode)},getValue:function(){return this.editor.getValue()},
setValue:function(value){this.editor.setValue(value)}});Ext.reg("codeEditorPanel",Sonia.panel.CodeEditorPanel);