MWF.APPDD=MWF.xApplication.process.DictionaryDesigner;MWF.APPDD.options={multitask:true,executable:false};MWF.xDesktop.requireApp("process.DictionaryDesigner","Dictionary",null,false);MWF.xApplication.process.DictionaryDesigner.Main=new Class({Extends:MWF.xApplication.Common.Main,Implements:[Options,Events],options:{style:"default",name:"process.DictionaryDesigner",icon:"icon.png",title:MWF.APPDD.LP.title,appTitle:MWF.APPDD.LP.title,id:"",width:"1200",height:"600",actions:null,category:null,processData:null},onQueryLoad:function(){this.shortcut=true;if(this.status){this.options.application=this.status.applicationId;this.application=this.status.application||this.status.applicationId;this.options.id=this.status.id;this.setOptions(this.status.options)}if(!this.options.id){this.options.desktopReload=false;this.options.title=this.options.title+"-"+MWF.APPDD.LP.newDictionary}if(!this.actions){this.actions=MWF.Actions.get("x_processplatform_assemble_designer");debugger;this.actions.application=this.application}this.lp=MWF.xApplication.process.DictionaryDesigner.LP;this.addEvent("queryClose",function(t){if(this.explorer){this.explorer.reload()}}.bind(this))},loadApplication:function(t){this.createNode();if(!this.options.isRefresh){this.maxSize(function(){this.openForm()}.bind(this))}else{this.openForm()}if(!this.options.readMode)this.addKeyboardEvents();if(t)t()},addKeyboardEvents:function(){this.addEvent("copy",function(){this.copyModule()}.bind(this));this.addEvent("paste",function(){this.pasteModule()}.bind(this));this.addEvent("cut",function(){this.cutModule()}.bind(this));this.addEvent("keySave",function(t){this.keySave(t)}.bind(this));this.addEvent("keyDelete",function(t){this.keyDelete(t)}.bind(this))},keySave:function(t){if(this.shortcut){if(this.tab.showPage){var i=this.tab.showPage.dictionary;if(i){i.save();t.preventDefault()}}}},keyDelete:function(){if(this.shortcut){if(this.tab.showPage){var t=this.tab.showPage.dictionary;if(t){if(t.currentSelectedItem){var i=t.currentSelectedItem;i.delItem(i.itemTextNode)}}}}},copyModule:function(){if(this.shortcut){if(this.tab.showPage){var t=this.tab.showPage.dictionary;if(t){if(t.currentSelectedItem){var i=t.currentSelectedItem;MWF.clipboard.data={type:"dictionary",data:{key:i.key,value:typeOf(i.value)=="object"?Object.clone(i.value):i.value}}}}}}},cutModule:function(){if(this.shortcut){if(this.tab.showPage){var t=this.tab.showPage.dictionary;if(t){if(t.currentSelectedItem){this.copyModule();var i=t.currentSelectedItem;i.destroy()}}}}},pasteModule:function(){if(this.shortcut){if(MWF.clipboard.data){if(MWF.clipboard.data.type=="dictionary"){if(this.tab.showPage){var t=this.tab.showPage.dictionary;if(t){if(t.currentSelectedItem){var i=t.currentSelectedItem;var e=MWF.clipboard.data.data.key;var o=typeOf(MWF.clipboard.data.data.value)=="object"?Object.clone(MWF.clipboard.data.data.value):MWF.clipboard.data.data.value;var s=i.level;var n=i;var a=null;if(!i.parent){s=1}else{if(i.type!="array"&&i.type!="object"){n=i.parent;a=i}else{if(i.exp){s=i.level+1}else{n=i.parent;a=i}}}var r=n.children.length;if(i.type=="array"){if(a){e=a.key;n.value.splice(a.key,0,o);for(var d=a.key;do.x/2)r=o.x/2;if(r<40)r=40;this.contentNode.setStyle("margin-left",r+1);this.dictionaryListNode.setStyle("width",r)}.bind(this)})},loadDictionaryList:function(){this.actions.listDictionary(this.application.id||this.application,function(t){t.data.each(function(t){this.createListDictionaryItem(t)}.bind(this))}.bind(this),null,false)},createListDictionaryItem:function(t,i){var e=this;var o=new Element("div",{styles:this.css.listDictionaryItem}).inject(this.dictionaryListAreaNode,i?"top":"bottom");var s=new Element("div",{styles:this.css.listDictionaryItemIcon}).inject(o);var n=new Element("div",{styles:this.css.listDictionaryItemText,text:t.name?t.name+" ("+t.alias+")":this.lp.newDictionary}).inject(o);o.store("dictionary",t);o.addEvents({dblclick:function(t){e.loadDictionaryByData(this,t)},mouseover:function(){if(e.currentListDictionaryItem!=this)this.setStyles(e.css.listDictionaryItem_over)},mouseout:function(){if(e.currentListDictionaryItem!=this)this.setStyles(e.css.listDictionaryItem)}})},loadDictionaryByData:function(t,i){var e=t.retrieve("dictionary");var o=true;for(var s=0;so.x/2)r=o.x/2;if(r<40)r=40;this.contentNode.setStyle("margin-right",r+1);this.propertyNode.setStyle("width",r)}.bind(this)})},loadPropertyContentResize:function(){this.propertyContentResize=new Drag(this.propertyContentResizeNode,{snap:1,onStart:function(t,i){var e=Browser.name=="firefox"?i.event.clientX:i.event.x;var o=Browser.name=="firefox"?i.event.clientY:i.event.y;t.store("position",{x:e,y:o});var s=this.propertyDomArea.getSize();t.store("initialHeight",s.y)}.bind(this),onDrag:function(t,i){var e=this.propertyContentNode.getSize();var o=Browser.name=="firefox"?i.event.clientY:i.event.y;var s=t.retrieve("position");var n=o.toFloat()-s.y.toFloat();var a=t.retrieve("initialHeight").toFloat();var r=a+n;if(r<40)r=40;if(r>e.y-40)r=e.y-40;this.propertyDomPercent=r/e.y;this.setPropertyContentResize()}.bind(this)})},setPropertyContentResize:function(){var t=this.propertyContentNode.getSize();var i=this.propertyContentResizeNode.getSize();var e=t.y-i.y;var o=this.propertyDomPercent*e;var s=e-o;this.propertyDomArea.setStyle("height",""+o+"px");this.propertyContentArea.setStyle("height",""+s+"px");if(this.form){if(this.form.currentSelectedModule){if(this.form.currentSelectedModule.property){var n=this.form.currentSelectedModule.property.propertyTab;if(n){var a=n.tabNodeContainer.getSize();n.pages.each(function(t){var i=t.contentNodeArea.getStyle("margin-top").toFloat();var e=t.contentNodeArea.getStyle("margin-bottom").toFloat();var o=s-i-e-a.y.toFloat()-15;t.contentNodeArea.setStyle("height",o)}.bind(this))}}}}},resizeNode:function(){var t=this.node.getSize();this.contentNode.setStyle("height",""+t.y+"px");this.propertyNode.setStyle("height",""+t.y+"px");var i=this.contentToolbarNode.getStyle("margin-top").toFloat();var e=this.contentToolbarNode.getStyle("margin-bottom").toFloat();var o=this.contentToolbarNode.getComputedSize();var s=t.y-o.totalHeight-i-e;this.editContentNode.setStyle("height",""+s+"px");if(this.designNode){var n=this.designNode.getStyle("margin-top").toFloat();var a=this.designNode.getStyle("margin-bottom").toFloat();s=t.y-o.totalHeight-i-e-n-a;this.designNode.setStyle("height",""+s+"px")}titleSize=this.propertyTitleNode.getSize();titleMarginTop=this.propertyTitleNode.getStyle("margin-top").toFloat();titleMarginBottom=this.propertyTitleNode.getStyle("margin-bottom").toFloat();titlePaddingTop=this.propertyTitleNode.getStyle("padding-top").toFloat();titlePaddingBottom=this.propertyTitleNode.getStyle("padding-bottom").toFloat();s=titleSize.y+titleMarginTop+titleMarginBottom+titlePaddingTop+titlePaddingBottom;s=t.y-s;this.propertyContentNode.setStyle("height",""+s+"px");this.propertyResizeBar.setStyle("height",""+s+"px");this.setPropertyContentResize();titleSize=this.dictionaryListTitleNode.getSize();titleMarginTop=this.dictionaryListTitleNode.getStyle("margin-top").toFloat();titleMarginBottom=this.dictionaryListTitleNode.getStyle("margin-bottom").toFloat();titlePaddingTop=this.dictionaryListTitleNode.getStyle("padding-top").toFloat();titlePaddingBottom=this.dictionaryListTitleNode.getStyle("padding-bottom").toFloat();nodeMarginTop=this.dictionaryListAreaSccrollNode.getStyle("margin-top").toFloat();nodeMarginBottom=this.dictionaryListAreaSccrollNode.getStyle("margin-bottom").toFloat();s=titleSize.y+titleMarginTop+titleMarginBottom+titlePaddingTop+titlePaddingBottom+nodeMarginTop+nodeMarginBottom;s=t.y-s;this.dictionaryListAreaSccrollNode.setStyle("height",""+s+"px");this.dictionaryListResizeNode.setStyle("height",""+s+"px")},loadDictionary:function(){debugger;this.getDictionaryData(this.options.id,function(t){this.setTitle(this.options.appTitle+"-"+t.name);this.taskitem.setText(this.options.appTitle+"-"+t.name);this.options.appTitle=this.options.appTitle+"-"+t.name;if(this.options.readMode){this.dictionary=new MWF.xApplication.process.DictionaryDesigner.DictionaryReader(this,t)}else{this.dictionary=new MWF.xApplication.process.DictionaryDesigner.Dictionary(this,t)}this.dictionary.load();if(this.status){if(this.status.openDictionarys){this.status.openDictionarys.each(function(t){this.loadDictionaryData(t,function(t){var i=true;if(this.status.currentId){if(this.status.currentId!=t.id)i=false}if(this.options.readMode){var e=new MWF.xApplication.process.DictionaryDesigner.DictionaryReader(this,t,{showTab:i})}else{var e=new MWF.xApplication.process.DictionaryDesigner.Dictionary(this,t,{showTab:i})}e.load()}.bind(this),true)}.bind(this))}}}.bind(this))},getDictionaryData:function(t,i){if(!this.options.id){this.loadNewDictionaryData(i)}else{this.loadDictionaryData(t,i)}},loadNewDictionaryData:function(t){var i={name:"",id:"",application:this.application.id,alias:"",description:"",data:{}};this.createListDictionaryItem(i,true);if(t)t(i)},loadDictionaryData:function(t,i){debugger;this.actions.getDictionary(t,function(t){if(t){var e=t.data;if(!this.application){this.actions.getApplication(e.application,function(t){this.application={name:t.data.name,id:t.data.id};if(i)i(e)}.bind(this))}else{if(i)i(e)}}}.bind(this))},saveDictionary:function(){if(this.tab.showPage){var t=this.tab.showPage.dictionary;t.save(function(){if(t==this.dictionary){var i=t.data.name;this.setTitle(MWF.APPDD.LP.title+"-"+i);this.options.desktopReload=true;this.options.id=t.data.id}}.bind(this))}},saveDictionaryAs:function(){this.dictionary.saveAs()},dictionaryExplode:function(){this.dictionary.explode()},dictionaryImplode:function(){this.dictionary.implode()},dictionarySearch:function(){this.dictionary.loadSearch()},recordStatus:function(){if(this.tab){var t=[];this.tab.pages.each(function(i){if(i.dictionary.data.id!=this.options.id)t.push(i.dictionary.data.id)}.bind(this));var i=this.tab.showPage.dictionary.data.id;var e={id:this.options.id,application:this.application,applicationId:this.application.id||this.application,openDictionarys:t,currentId:i,options:{action:this.options.action,noCreate:this.options.noCreate,noDelete:this.options.noDelete,noModifyName:this.options.noModifyName,readMode:this.options.readMode}};return e}return{id:this.options.id,application:this.application}}});