MWF.xApplication = MWF.xApplication || {}; MWF.xApplication.service = MWF.xApplication.service || {}; MWF.xApplication.service.InvokeDesigner = MWF.xApplication.service.InvokeDesigner || {}; MWF.SRVID = MWF.xApplication.service.InvokeDesigner; MWF.require("MWF.widget.Common", null, false); MWF.xDesktop.requireApp("service.InvokeDesigner", "lp."+MWF.language, null, false); MWF.require("MWF.widget.JavascriptEditor", null, false); MWF.xApplication.service.InvokeDesigner.Invoke = 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_InvokeDesigner/$Invoke/"; this.cssPath = "../x_component_service_InvokeDesigner/$Invoke/"+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.invokeTab; this.areaNode = new Element("div", {"styles": {"overflow": "hidden", "height": "700px"}}); //this.propertyIncludeNode = this.designer.propertyDomArea; this.propertyNode = this.designer.propertyContentArea; this.isNewInvoke = (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("#MWFInvokeAutoSaveCheck"); if (this.autoSaveCheckNode){ if (this.autoSaveCheckNode.get("checked")){ if (this.isChanged) this.saveSilence(); } } }.bind(this), 60000); }, //createProperty: function(){ // this.invokePropertyNode = new Element("div", {"styles": this.css.invokePropertyNode}).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.newInvoke, (!this.data.isNewInvoke && this.data.id!=this.designer.options.id)); this.page.invoke = this; this.page.addEvent("show", function(){ this.designer.currentPage = this.page; this.designer.invokeListAreaNode.getChildren().each(function(node){ var scrtip = node.retrieve("invoke"); if (scrtip.id==this.data.id){ if (this.designer.currentListInvokeItem){ this.designer.currentListInvokeItem.setStyles(this.designer.css.listInvokeItem); } node.setStyles(this.designer.css.listInvokeItem_current); this.designer.currentListInvokeItem = node; this.lisNode = node; } }.bind(this)); this.designer.currentScript = this; this.setPropertyContent(); //this.setIncludeNode(); if (this.editor){ this.editor.focus(); }else{ this.loadEditor(); } this.setAreaNodeSize(); //if (this.editor.editor){ // this.editor.editor.focus(); //} }.bind(this)); var _self = this; this.page.addEvent("queryClose", function(){ if (_self.autoSaveTimerID) window.clearInterval(_self.autoSaveTimerID); this.showIm(); //this.saveSilence(); if (_self.lisNode) _self.lisNode.setStyles(_self.designer.css.listInvokeItem); }); this.page.tabNode.addEvent("dblclick", this.designer.maxOrReturnEditor.bind(this.designer)); if (this.options.showTab) this.page.showTabIm(); }, loadEditor:function(){ this.editor = new MWF.widget.JavascriptEditor(this.areaNode, {"runtime": "service", "option": {"value": this.data.text}}); 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 += "requestText//请求正文\n"; // defaultText += "request//请求\n"; // defaultText += "effectivePerson//当前用户\n"; // defaultText += "********************/\n"; var lp = this.designer.lp.comment; var url = new URI("../api"); var p =url.get("port"); p = (!p || p===80) ? "" : ":"+p; var h = url.get("host"); url.get("scheme")+"://"+h+p+"/api" var defaultText = "/********************\n"; // defaultText += "this.entityManager; //"+lp.entityManager+"\n"; // defaultText += "this.applications; //"+lp.applications+"\n"; defaultText += "this.requestText//"+lp.requestText+"\n"; // defaultText += "this.request//"+lp.request+"\n"; defaultText += "this.currentPerson//"+lp.currentPerson+"\n"; defaultText += "this.response//"+lp.response+"\n"; // defaultText += "this.organization; //"+lp.organization+"\n"; defaultText += "this.org; //"+lp.org+"\n"; // defaultText += "this.service; //"+lp.service+"\n"; defaultText += "API Document: "+url.get("scheme")+"://"+h+p+"/api"+"\n"; defaultText += "********************/\n"; this.editor.editor.setValue(defaultText); } this.editor.addEditorEvent("change", function(e){ 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.invokeReferenceMenu){ // MWF.require("MWF.widget.ScriptHelp", function(){ // this.invokeReferenceMenu = new MWF.widget.ScriptHelp(null, this.editor.editor, { // "onPostLoad": function(){ // this.showReferenceMenu(); // }.bind(this) // }); // this.invokeReferenceMenu.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