MWF.xDesktop.requireApp("process.ProcessManager", "package", null, false); //MWF.xDesktop.requireApp("process.ProcessManager", "Actions.RestActions", null, false); MWF.xDesktop.requireApp("process.ProcessManager", "lp."+MWF.language, null, false); MWF.xDesktop.requireApp("Selector", "package", null, false); //MWF.require("MWF.xAction.org.express.RestActions", null,false); MWF.require("MWF.widget.O2Identity", null,false); MWF.xApplication.process.ProcessManager.Main = new Class({ Extends: MWF.xApplication.Common.Main, Implements: [Options, Events], options: { "application": null, "style": "default", "name": "process.ProcessManager", "icon": "icon.png", "width": "1100", "height": "700", "title": MWF.xApplication.process.ProcessManager.LP.title }, onQueryLoad: function(){ this.lp = MWF.xApplication.process.ProcessManager.LP; this.currentContentNode = null; this.restActions = MWF.Actions.get("x_processplatform_assemble_designer"); //this.restActions = new MWF.xApplication.process.ProcessManager.Actions.RestActions(); }, loadApplication: function(callback){ //if (this.status){ // if (!this.options.application){ // if (this.status.application){ // this.restActions.getApplication(this.status.application, function(json){ // if (json.data){ // this.options.application = json.data; // alert("sds"+this.options.application); // }else{ // this.close(); // } // }.bind(this), function(){this.close();}.bind(this), false) // }else{ // this.close(); // } // } //} this.getApplication(function(){ this.setTitle(this.lp.title + "-"+this.options.application.name); this.createNode(); this.loadApplicationContent(); if (callback) callback(); //var clipboardEvent = new ClipboardEvent("copy", {dataType: "text/plain", data:""}); if (window.clipboardData){ this.addKeyboardEvents(); }else{ this.keyCopyItemsFun = this.keyCopyItems.bind(this); this.keyPasteItemsFun = this.keyPasteItems.bind(this); document.addEventListener('copy', this.keyCopyItemsFun); document.addEventListener('paste', this.keyPasteItemsFun); this.addEvent("queryClose", function(){ if (this.keyCopyItemsFun) document.removeEventListener('copy', this.keyCopyItemsFun); if (this.keyPasteItemsFun) document.removeEventListener('paste', this.keyPasteItemsFun); }.bind(this)); } }.bind(this), function(){ this.close(); }.bind(this)); }, addKeyboardEvents: function(){ this.addEvent("copy", function(){ this.keyCopyItems(); }.bind(this)); this.addEvent("paste", function(){ this.keyPasteItems(); }.bind(this)); }, keyCopyItems: function(e){ var app = layout.desktop.currentApp || layout.desktop.app; if (app && app.appId===this.appId){ if (this.formConfigurator){ this.formConfigurator.keyCopy(e); if (e) e.preventDefault(); } if (this.processConfigurator){ this.processConfigurator.keyCopy(e); if (e) e.preventDefault(); } if (this.dataConfigurator){ this.dataConfigurator.keyCopy(e); if (e) e.preventDefault(); } if (this.scriptConfigurator){ this.scriptConfigurator.keyCopy(e); if (e) e.preventDefault(); } } }, keyPasteItems: function(e){ var app = layout.desktop.currentApp || layout.desktop.app; if (app && app.appId===this.appId) { if (this.formConfigurator) { this.formConfigurator.keyPaste(e); } if (this.processConfigurator) { this.processConfigurator.keyPaste(e); } if (this.dataConfigurator) { this.dataConfigurator.keyPaste(e); } if (this.scriptConfigurator) { this.scriptConfigurator.keyPaste(e); } } }, getApplication: function(success, failure){ if (!this.options.application){ if (this.status) { if (this.status.application){ this.restActions.getApplication(this.status.application, function(json){ if (json.data){ this.options.application = json.data; if (success) success(); }else{ if (failure) failure(); } }.bind(this), function(){if (failure) failure();}.bind(this), false) }else{ if (failure) failure(); } }else{ if (failure) failure(); } }else{ if (success) success(); } }, loadApplicationContent: function(){ this.loadStartMenu(); this.loadApplicationLayout(); }, createNode: function(){ this.content.setStyle("overflow", "hidden"); this.node = new Element("div", { "styles": {"width": "100%", "height": "100%", "overflow": "hidden"} }).inject(this.content); }, loadApplicationLayout: function(){ // this.topMenuNode = new Element("div").inject(this.node); // MWF.require("MWF.widget.Toolbar", function(){ // this.toobar = new MWF.widget.Toolbar(this.topMenuNode); // this.toobar.load(); // alert("ok") // }.bind(this)); }, loadStartMenu: function(callback){ this.startMenuNode = new Element("div", { "styles": this.css.startMenuNode }).inject(this.node); this.menu = new MWF.xApplication.process.ProcessManager.Menu(this, this.startMenuNode, { "onPostLoad": function(){ if (this.status){ if (this.status.navi!=null){ this.menu.doAction(this.menu.startNavis[this.status.navi]); }else{ this.menu.doAction(this.menu.startNavis[0]); } }else{ this.menu.doAction(this.menu.startNavis[0]); } }.bind(this) }); this.addEvent("resize", function(){ if (this.menu) this.menu.onResize(); }.bind(this)); }, clearContent: function(){ if (this.processConfiguratorContent){ if (this.processConfigurator){ if (this.processConfigurator.destroy) this.processConfigurator.destroy(); delete this.processConfigurator; } this.processConfiguratorContent.destroy(); this.processConfiguratorContent = null; } if (this.formConfiguratorContent){ if (this.formConfigurator){ if (this.formConfigurator.destroy) this.formConfigurator.destroy(); delete this.formConfigurator; } this.formConfiguratorContent.destroy(); this.formConfiguratorContent = null; } if (this.viewConfiguratorContent){ if (this.viewConfigurator){ if (this.viewConfigurator.destroy) this.viewConfigurator.destroy(); delete this.viewConfigurator; } this.viewConfiguratorContent.destroy(); this.viewConfiguratorContent = null; } if (this.statConfiguratorContent){ if (this.statConfigurator){ if (this.statConfigurator.destroy) this.statConfigurator.destroy(); delete this.statConfigurator; } this.statConfiguratorContent.destroy(); this.statConfiguratorContent = null; } if (this.propertyConfiguratorContent){ if (this.property){ if (this.property.destroy) this.property.destroy(); delete this.property; } this.propertyConfiguratorContent.destroy(); this.propertyConfiguratorContent = null; } if (this.dataConfiguratorContent){ if (this.dataConfigurator){ if (this.dataConfigurator.destroy) this.dataConfigurator.destroy(); delete this.dataConfigurator; } this.dataConfiguratorContent.destroy(); this.dataConfiguratorContent = null; } if (this.scriptConfiguratorContent){ if (this.scriptConfigurator){ if (this.scriptConfigurator.destroy) this.scriptConfigurator.destroy(); delete this.scriptConfigurator; } this.scriptConfiguratorContent.destroy(); this.scriptConfiguratorContent = null; } if (this.fileConfiguratorContent){ if (this.fileConfigurator){ if (this.fileConfigurator.destroy) this.fileConfigurator.destroy(); delete this.fileConfigurator; } this.fileConfiguratorContent.destroy(); this.fileConfiguratorContent = null; } if (this.projectionConfiguratorContent){ if (this.projectionConfigurator){ if (this.projectionConfigurator.destroy) this.projectionConfigurator.destroy(); delete this.projectionConfigurator; } this.projectionConfiguratorContent.destroy(); this.projectionConfiguratorContent = null; } }, applicationProperty: function(){ this.clearContent(); this.propertyConfiguratorContent = new Element("div", { "styles": this.css.rightContentNode }).inject(this.node); this.property = new MWF.xApplication.process.ProcessManager.ApplicationProperty(this, this.propertyConfiguratorContent); this.property.load(); }, projectionConfig: function(){ this.clearContent(); this.projectionConfiguratorContent = new Element("div", { "styles": this.css.rightContentNode }).inject(this.node); this.loadProjectionConfig(); }, loadProjectionConfig: function(){ MWF.xDesktop.requireApp("process.ProcessManager", "ProjectionExplorer", function(){ this.restActions = MWF.Actions.get("x_processplatform_assemble_designer"); this.projectionConfigurator = new MWF.xApplication.process.ProcessManager.ProjectionExplorer(this.projectionConfiguratorContent, this.restActions); this.projectionConfigurator.app = this; this.projectionConfigurator.load(); }.bind(this)); }, processConfig: function(){ this.clearContent(); this.processConfiguratorContent = new Element("div", { "styles": this.css.rightContentNode }).inject(this.node); this.loadProcessConfig(); }, loadProcessConfig: function(){ MWF.xDesktop.requireApp("process.ProcessManager", "ProcessExplorer", function(){ //MWF.xDesktop.requireApp("process.ProcessManager", "Actions.RestActions", function(){ // if (!this.restActions) this.restActions = new MWF.xApplication.process.ProcessManager.Actions.RestActions(); this.restActions = MWF.Actions.get("x_processplatform_assemble_designer"); this.processConfigurator = new MWF.xApplication.process.ProcessManager.ProcessExplorer(this.processConfiguratorContent, this.restActions); this.processConfigurator.app = this; this.processConfigurator.load(); //}.bind(this)); }.bind(this)); }, formConfig: function(){ this.clearContent(); this.formConfiguratorContent = new Element("div", { "styles": this.css.rightContentNode }).inject(this.node); this.loadFormConfig(); }, loadFormConfig: function(){ MWF.xDesktop.requireApp("process.ProcessManager", "FormExplorer", function(){ //MWF.xDesktop.requireApp("process.ProcessManager", "Actions.RestActions", function(){ // if (!this.restActions) this.restActions = new MWF.xApplication.process.ProcessManager.Actions.RestActions(); this.restActions = MWF.Actions.get("x_processplatform_assemble_designer"); this.formConfigurator = new MWF.xApplication.process.ProcessManager.FormExplorer(this.formConfiguratorContent, this.restActions); this.formConfigurator.app = this; this.formConfigurator.load(); //}.bind(this)); }.bind(this)); }, viewConfig: function(){ this.clearContent(); this.viewConfiguratorContent = new Element("div", { "styles": this.css.rightContentNode }).inject(this.node); this.loadViewConfig(); }, loadViewConfig: function(){ MWF.xDesktop.requireApp("process.ProcessManager", "ViewExplorer", function(){ //MWF.xDesktop.requireApp("process.ProcessManager", "Actions.RestActions", function(){ // if (!this.restActions) this.restActions = new MWF.xApplication.process.ProcessManager.Actions.RestActions(); this.restActions = MWF.Actions.get("x_processplatform_assemble_designer"); this.viewConfigurator = new MWF.xApplication.process.ProcessManager.ViewExplorer(this.viewConfiguratorContent, this.restActions); this.viewConfigurator.app = this; this.viewConfigurator.load(); //}.bind(this)); }.bind(this)); }, statConfig: function(){ this.clearContent(); this.statConfiguratorContent = new Element("div", { "styles": this.css.rightContentNode }).inject(this.node); this.loadStatConfig(); }, loadStatConfig: function(){ MWF.xDesktop.requireApp("process.ProcessManager", "StatExplorer", function(){ //MWF.xDesktop.requireApp("process.ProcessManager", "Actions.RestActions", function(){ // if (!this.restActions) this.restActions = new MWF.xApplication.process.ProcessManager.Actions.RestActions(); this.restActions = MWF.Actions.get("x_processplatform_assemble_designer"); this.statConfigurator = new MWF.xApplication.process.ProcessManager.StatExplorer(this.statConfiguratorContent, this.restActions); this.statConfigurator.app = this; this.statConfigurator.load(); //}.bind(this)); }.bind(this)); }, dataConfig: function(){ this.clearContent(); this.dataConfiguratorContent = new Element("div", { "styles": this.css.rightContentNode }).inject(this.node); this.loadDataConfig(); }, loadDataConfig: function(){ MWF.xDesktop.requireApp("process.ProcessManager", "DictionaryExplorer", function(){ //MWF.xDesktop.requireApp("process.ProcessManager", "Actions.RestActions", function(){ // if (!this.restActions) this.restActions = new MWF.xApplication.process.ProcessManager.Actions.RestActions(); this.restActions = MWF.Actions.get("x_processplatform_assemble_designer"); this.dataConfigurator = new MWF.xApplication.process.ProcessManager.DictionaryExplorer(this.dataConfiguratorContent, this.restActions); this.dataConfigurator.app = this; this.dataConfigurator.load(); //}.bind(this)); }.bind(this)); }, scriptConfig: function(){ this.clearContent(); this.scriptConfiguratorContent = new Element("div", { "styles": this.css.rightContentNode }).inject(this.node); this.loadScriptConfig(); }, loadScriptConfig: function(){ MWF.xDesktop.requireApp("process.ProcessManager", "ScriptExplorer", function(){ //MWF.xDesktop.requireApp("process.ProcessManager", "Actions.RestActions", function(){ // if (!this.restActions) this.restActions = new MWF.xApplication.process.ProcessManager.Actions.RestActions(); this.restActions = MWF.Actions.get("x_processplatform_assemble_designer"); this.scriptConfigurator = new MWF.xApplication.process.ProcessManager.ScriptExplorer(this.scriptConfiguratorContent, this.restActions); this.scriptConfigurator.app = this; this.scriptConfigurator.load(); //}.bind(this)); }.bind(this)); }, fileConfig: function(){ this.clearContent(); this.fileConfiguratorContent = new Element("div", { "styles": this.css.rightContentNode }).inject(this.node); this.loadFileConfig(); }, loadFileConfig: function(){ MWF.xDesktop.requireApp("process.ProcessManager", "FileExplorer", function(){ //MWF.xDesktop.requireApp("process.ProcessManager", "Actions.RestActions", function(){ // if (!this.restActions) this.restActions = new MWF.xApplication.process.ProcessManager.Actions.RestActions(); this.restActions = MWF.Actions.get("x_processplatform_assemble_designer"); this.fileConfigurator = new MWF.xApplication.process.ProcessManager.FileExplorer(this.fileConfiguratorContent, this.restActions); this.fileConfigurator.app = this; this.fileConfigurator.load(); //}.bind(this)); }.bind(this)); }, getCategoryCount: function(){ var size = this.processConfiguratorContent.getSize(); categoryCount = parseInt(size.x/182)+5; return categoryCount; }, getProcessCount: function(){ if (this.processConfigurator){ var size = this.processConfigurator.processNode.getSize(); processCount = (parseInt(size.x/401)*parseInt(size.y/101))+10; return processCount; } return 20; }, showContentNode: function(node){ if (this.currentContentNode){ // this.currentContentNode.setStyles({ // "position": "absolute" // }); this.currentContentNode.fade("hide"); node.fade("show"); node.setStyle("display", "node"); this.currentContentNode = null; } node.setStyle("display", "block"); node.fade("show"); this.currentContentNode = node; }, recordStatus: function(){ var idx = null; if (this.menu.currentNavi){ idx = this.menu.startNavis.indexOf(this.menu.currentNavi); } return {"navi": idx, "application": this.options.application.id}; } // onResize: function(){ // if (this.menu) this.menu.onResize(); // } }); MWF.xApplication.process.ProcessManager.Menu = new Class({ Implements: [Options, Events], initialize: function(app, node, options){ this.setOptions(options); this.app = app; this.node = $(node); this.currentNavi = null; this.status = "start"; this.startNavis = []; this.load(); }, load: function(){ var menuUrl = this.app.path+"startMenu.json"; MWF.getJSON(menuUrl, function(json){ json.each(function(navi){ var naviNode = new Element("div", { "styles": this.app.css.startMenuNaviNode }); naviNode.store("naviData", navi); var iconNode = new Element("div", { "styles": this.app.css.startMenuIconNode }).inject(naviNode); iconNode.setStyle("background-image", "url("+this.app.path+this.app.options.style+"/icon/"+navi.icon+")"); var textNode = new Element("div", { "styles": this.app.css.startMenuTextNode, "text": navi.title }); textNode.inject(naviNode); naviNode.inject(this.node); this.startNavis.push(naviNode); this.setStartNaviEvent(naviNode, navi); this.setNodeCenter(this.node); }.bind(this)); this.setStartMenuWidth(); this.fireEvent("postLoad"); }.bind(this)); }, setStartNaviEvent: function(naviNode){ var _self = this; naviNode.addEvents({ "mouseover": function(){ if (_self.currentNavi!=this) this.setStyles(_self.app.css.startMenuNaviNode_over);}, "mouseout": function(){if (_self.currentNavi!=this) this.setStyles(_self.app.css.startMenuNaviNode);}, "mousedown": function(){if (_self.currentNavi!=this) this.setStyles(_self.app.css.startMenuNaviNode_down);}, "mouseup": function(){if (_self.currentNavi!=this) this.setStyles(_self.app.css.startMenuNaviNode_over);}, "click": function(){ //if (_self.currentNavi!=this) _self.doAction.apply(_self, [this]); _self.doAction.apply(_self, [this]); } }); }, doAction: function(naviNode){ var navi = naviNode.retrieve("naviData"); var action = navi.action; if (this.currentNavi) this.currentNavi.setStyles(this.app.css.startMenuNaviNode); naviNode.setStyles(this.app.css.startMenuNaviNode_current); this.currentNavi = naviNode; if (this.app[action]) this.app[action].apply(this.app); if (this.status == "start"){ this.toNormal(); this.status = "normal"; } }, toNormal: function(){ // var size = this.getStartMenuNormalSize(); var css = this.app.css.normalStartMenuNode; //css.height = size.height+"px"; // css.height = "100%"; // css.width = size.width+"px"; //// this.node.setStyles(css); // if (!this.morph){ this.morph = new Fx.Morph(this.node, {duration: 50, link: "chain"}); } // this.morph.start(css).chain(function(){ this.node.setStyles(css); MWF.require("MWF.widget.ScrollBar", function(){ new MWF.widget.ScrollBar(this.node, { "style":"xApp_ProcessManager_StartMenu", "distance": 100, "friction": 4, "axis": {"x": false, "y": true} }); }.bind(this)); // }.bind(this)); // //// this.node.setStyles(css); //// //// this.startNavis.each(function(naviNode){ //// if (this.currentNavi!=naviNode) naviNode.setStyles(this.app.css.startMenuNaviNode); //// }.bind(this)); // // this.node.set("morph", {duration: 50}); // this.node.morph(css); }, setNodeCenter: function(node){ var size = node.getSize(); var contentSize = this.app.node.getSize(); var top = contentSize.y/2 - size.y/2; var left = contentSize.x/2 - size.x/2; if (left<0) left = 0; if (top<0) top = 0; node.setStyles({"left": left, "top": top}); }, getStartMenuNormalSize: function(){ var naviItemNode = this.node.getFirst(); var size = naviItemNode.getComputedSize(); var mt = naviItemNode.getStyle("margin-top").toFloat(); var mb = naviItemNode.getStyle("margin-bottom").toFloat(); var height = size.totalWidth+mt+mb; var ml = naviItemNode.getStyle("margin-left").toFloat(); var mr = naviItemNode.getStyle("margin-right").toFloat(); var width = size.totalWidth+ml+mr; return {"width": width, "height": height*this.startNavis.length}; }, setStartMenuWidth: function(){ var naviItemNode = this.node.getFirst(); var size = naviItemNode.getComputedSize(); var ml = naviItemNode.getStyle("margin-left").toFloat(); var mr = naviItemNode.getStyle("margin-right").toFloat(); var width = size.totalWidth+ml+mr; this.node.setStyle("width", (width*this.startNavis.length)+"px"); }, onResize: function(){ if (this.status == "start"){ this.setNodeCenter(this.node); } } }); MWF.xApplication.process.ProcessManager.ApplicationProperty = new Class({ initialize: function(app, node){ this.app = app; this.node = $(node); this.data = this.app.options.application; }, load: function(){ this.app.restActions.getApplication(this.app.options.application.id, function(json){ this.data = json.data; this.propertyTitleBar = new Element("div", { "styles": this.app.css.propertyTitleBar, "text": this.data.name }).inject(this.node); this.contentNode = new Element("div", { "styles": this.app.css.propertyContentNode }).inject(this.node); this.contentAreaNode = new Element("div", { "styles": this.app.css.propertyContentAreaNode }).inject(this.contentNode); this.setContentHeight(); this.setContentHeightFun = this.setContentHeight.bind(this); this.app.addEvent("resize", this.setContentHeightFun); MWF.require("MWF.widget.ScrollBar", function(){ new MWF.widget.ScrollBar(this.contentNode, {"indent": false}); }.bind(this)); this.baseActionAreaNode = new Element("div", { "styles": this.app.css.baseActionAreaNode }).inject(this.contentAreaNode); this.baseActionNode = new Element("div", { "styles": this.app.css.propertyInforActionNode }).inject(this.baseActionAreaNode); this.baseTextNode = new Element("div", { "styles": this.app.css.baseTextNode, "text": this.app.lp.application.property }).inject(this.baseActionAreaNode); this.createEditBaseNode(); this.createPropertyContentNode(); this.createIconContentNode(); this.createAvailableNode(); this.createControllerListNode(); this.createMaintainerNode(); }.bind(this)); }, setContentHeight: function(){ var size = this.app.content.getSize(); var titleSize = this.propertyTitleBar.getSize(); var y = size.y-titleSize.y; this.contentNode.setStyle("height", ""+y+"px"); }, createIconContentNode: function(){ this.iconContentTitleNode = new Element("div", { "styles": this.app.css.iconContentTitleNode, "text": this.app.lp.application.icon }).inject(this.contentAreaNode); this.iconContentNode = new Element("div", {"styles": {"overflow": "hidden"}}).inject(this.contentAreaNode); var html = "
"+this.app.lp.application.name+" | |
"+this.app.lp.application.alias+" | |
"+this.app.lp.application.description+" | |
"+this.app.lp.application.type+" | |
"+this.app.lp.application.defaultForm+" | |
"+this.app.lp.application.id+" | |
"+this.app.lp.application.icon+" |