MWF.xApplication = MWF.xApplication || {}; MWF.xApplication.service = MWF.xApplication.service || {}; MWF.xApplication.service.AgentDesigner = MWF.xApplication.service.AgentDesigner || {}; MWF.SRVAD = MWF.xApplication.service.AgentDesigner; MWF.require("MWF.widget.Common", null, false); MWF.xDesktop.requireApp("service.AgentDesigner", "lp."+MWF.language, null, false); MWF.require("MWF.widget.JavascriptEditor", null, false); MWF.xApplication.service.AgentDesigner.Agent = new Class({ Extends: MWF.widget.Common, Implements: [Options, Events], options: { "style": "default", "showTab": true }, initialize: function(designer, data, options){ this.setOptions(options); this.path = "../x_component_service_AgentDesigner/$Agent/"; this.cssPath = "../x_component_service_AgentDesigner/$Agent/"+this.options.style+"/css.wcss"; this._loadCss(); this.isChanged = false; this.designer = designer; this.data = data; if (!this.data.text) this.data.text = ""; this.node = this.designer.designNode; this.tab = this.designer.agentTab; this.areaNode = new Element("div", {"styles": {"overflow": "hidden", "height": "700px"}}); //this.propertyIncludeNode = this.designer.propertyDomArea; this.propertyNode = this.designer.propertyContentArea; this.isNewAgent = (this.data.id) ? false : true; // this.createProperty(); this.autoSave(); this.designer.addEvent("queryClose", function(){ if (this.autoSaveTimerID) window.clearInterval(this.autoSaveTimerID); }.bind(this)); }, autoSave: function(){ this.autoSaveTimerID = window.setInterval(function(){ if (!this.autoSaveCheckNode) this.autoSaveCheckNode = this.designer.contentToolbarNode.getElement("#MWFAgentAutoSaveCheck"); if (this.autoSaveCheckNode){ if (this.autoSaveCheckNode.get("checked")){ if (this.isChanged) this.saveSilence(); } } }.bind(this), 60000); }, //createProperty: function(){ // this.agentPropertyNode = new Element("div", {"styles": this.css.agentPropertyNode}).inject(this.propertyNode); //}, load : function(){ this.setAreaNodeSize(); this.designer.addEvent("resize", this.setAreaNodeSize.bind(this)); this.page = this.tab.addTab(this.areaNode, this.data.name || this.designer.lp.newAgent, (!this.data.isNewAgent && this.data.id!=this.designer.options.id)); this.page.agent = this; this.page.addEvent("show", function(){ this.designer.agentListAreaNode.getChildren().each(function(node){ var scrtip = node.retrieve("agent"); if (scrtip.id==this.data.id){ if (this.designer.currentListAgentItem){ this.designer.currentListAgentItem.setStyles(this.designer.css.listAgentItem); } node.setStyles(this.designer.css.listAgentItem_current); this.designer.currentListAgentItem = node; this.lisNode = node; } }.bind(this)); this.designer.currentScript = this; this.setPropertyContent(); //this.setIncludeNode(); if (this.editor.editor){ this.editor.editor.focus(); //this.editor.editor.navigateFileStart(); } }.bind(this)); this.page.addEvent("queryClose", function(){ if (this.autoSaveTimerID) window.clearInterval(this.autoSaveTimerID); //this.saveSilence(); if (this.lisNode) this.lisNode.setStyles(this.designer.css.listAgentItem); }.bind(this)); this.page.tabNode.addEvent("dblclick", this.designer.maxOrReturnEditor.bind(this.designer)); this.editor = new MWF.widget.JavascriptEditor(this.areaNode, {"runtime": "service"}); this.editor.load(function(){ if (this.data.text){ this.editor.editor.setValue(this.data.text); }else{ // var defaultText = "/********************\n"; // defaultText += "resources.getEntityManagerContainer(); //实体管理器\n"; // defaultText += "resources.getContext(); //上下文根\n"; // defaultText += "resources.getOrganization(); //组织访问\n"; // defaultText += "resources.getWebservicesClient();//webSerivces客户端\n"; // defaultText += "********************/\n"; var defaultText = "/********************\n"; defaultText += "this.entityManager; //实体管理器\n"; defaultText += "this.applications; //访问系统内服务\n"; defaultText += "this.organization(); //组织访问\n"; defaultText += "this.org(); //组织快速访问方法\n"; defaultText += "this.service(); ///webSerivces客户端\n"; defaultText += "********************/\n"; this.editor.editor.setValue(defaultText); } this.editor.addEditorEvent("change", function(){ if (!this.isChanged){ this.isChanged = true; this.page.textNode.set("text", " * "+this.page.textNode.get("text")); } }.bind(this)); // this.editor.editor.on("change", function(e){ // if (!this.isChanged){ // this.isChanged = true; // this.page.textNode.set("text", " * "+this.page.textNode.get("text")); // } // }.bind(this)); this.editor.addEvent("save", function(){ this.save(); }.bind(this)); this.editor.addEvent("reference", function(editor, e, e1){ if (!this.agentReferenceMenu){ MWF.require("MWF.widget.ScriptHelp", function(){ this.agentReferenceMenu = new MWF.widget.ScriptHelp(null, this.editor.editor, { "onPostLoad": function(){ this.showReferenceMenu(); }.bind(this) }); this.agentReferenceMenu.getEditor = function(){return this.editor.editor;}.bind(this) }.bind(this)); }else{ this.showReferenceMenu(); } }.bind(this)); var options = this.designer.styleSelectNode.options; for (var i=0; i