提交 1da88ff4 编写于 作者: NoSubject's avatar NoSubject

新政脚本编辑器monaco

上级 6cddaa67
...@@ -147,6 +147,7 @@ ...@@ -147,6 +147,7 @@
var MSXML = function(){ return new ActiveXObject('Microsoft.XMLHTTP'); }; var MSXML = function(){ return new ActiveXObject('Microsoft.XMLHTTP'); };
return _attempt(XMLHTTP, MSXML2, MSXML); return _attempt(XMLHTTP, MSXML2, MSXML);
})(); })();
this.o2.request = _request;
var _returnBase = function(number, base) { var _returnBase = function(number, base) {
return (number).toString(base).toUpperCase(); return (number).toString(base).toUpperCase();
...@@ -290,13 +291,13 @@ ...@@ -290,13 +291,13 @@
_removeListener(xhr, 'load', _checkCssLoaded); _removeListener(xhr, 'load', _checkCssLoaded);
_removeListener(xhr, 'error', _checkCssErrorLoaded); _removeListener(xhr, 'error', _checkCssErrorLoaded);
if (err) {failure(xhr); return} if (err) {if (failure) failure(xhr); return}
var status = xhr.status; var status = xhr.status;
status = (status == 1223) ? 204 : status; status = (status == 1223) ? 204 : status;
if ((status >= 200 && status < 300)) if ((status >= 200 && status < 300))
success(xhr); if (success) success(xhr);
else if ((status >= 300 && status < 400)) else if ((status >= 300 && status < 400))
failure(xhr); if (failure) failure(xhr);
else else
failure(xhr); failure(xhr);
if (completed) completed(xhr); if (completed) completed(xhr);
...@@ -308,7 +309,7 @@ ...@@ -308,7 +309,7 @@
_addListener(xhr, "readystatechange", _checkCssLoaded); _addListener(xhr, "readystatechange", _checkCssLoaded);
xhr.send(); xhr.send();
}; };
this.o2.xhr_get = _xhr_get;
var _loadSequence = function(ms, cb, op, n, thisLoaded, loadSingle, uuid, fun){ var _loadSequence = function(ms, cb, op, n, thisLoaded, loadSingle, uuid, fun){
loadSingle(ms[n], function(module){ loadSingle(ms[n], function(module){
if (module) thisLoaded.push(module); if (module) thisLoaded.push(module);
...@@ -343,7 +344,7 @@ ...@@ -343,7 +344,7 @@
"mootools": ["/o2_lib/mootools/mootools-1.6.0_all.js"], "mootools": ["/o2_lib/mootools/mootools-1.6.0_all.js"],
"ckeditor": ["/o2_lib/htmleditor/ckeditor4114/ckeditor.js"], "ckeditor": ["/o2_lib/htmleditor/ckeditor4114/ckeditor.js"],
"ckeditor5": ["/o2_lib/htmleditor/ckeditor5-12-1-0/ckeditor.js"], "ckeditor5": ["/o2_lib/htmleditor/ckeditor5-12-1-0/ckeditor.js"],
"raphael": ["/o2_lib/raphael/raphael.js"], "raphael": ["/o2_lib/raphael/raphael_230.js"],
"d3": ["/o2_lib/d3/d3.min.js"], "d3": ["/o2_lib/d3/d3.min.js"],
"ace": ["/o2_lib/ace/src-min-noconflict/ace.js","/o2_lib/ace/src-min-noconflict/ext-language_tools.js"], "ace": ["/o2_lib/ace/src-min-noconflict/ace.js","/o2_lib/ace/src-min-noconflict/ext-language_tools.js"],
"monaco": ["/o2_lib/vs/loader.js"], "monaco": ["/o2_lib/vs/loader.js"],
......
...@@ -4,10 +4,18 @@ o2.widget.MWFRaphael = MWFRaphael = { ...@@ -4,10 +4,18 @@ o2.widget.MWFRaphael = MWFRaphael = {
if (window.Raphael){ if (window.Raphael){
if (callback) callback(); if (callback) callback();
}else{ }else{
COMMON.AjaxModule.load("raphael", function(){ if(!window.Raphael && typeof require === 'function' && define.amd){
this.expandRaphael(); require(["../o2_lib/raphael/raphael.js"], function(r){
if (callback) callback(); window.Raphael = r;
}.bind(this), true, true); this.expandRaphael();
if (callback) callback();
}.bind(this));
}else{
COMMON.AjaxModule.load("raphael", function(){
this.expandRaphael();
if (callback) callback();
}.bind(this), true, true);
}
} }
}, },
expandRaphael: function(){ expandRaphael: function(){
......
...@@ -68,6 +68,7 @@ o2.widget.ScriptArea = new Class({ ...@@ -68,6 +68,7 @@ o2.widget.ScriptArea = new Class({
} }
}, },
maxSize: function(){ maxSize: function(){
debugger;
var obj = this.options.maxObj; var obj = this.options.maxObj;
var coordinates = obj.getCoordinates(obj.getOffsetParent()); var coordinates = obj.getCoordinates(obj.getOffsetParent());
...@@ -80,8 +81,8 @@ o2.widget.ScriptArea = new Class({ ...@@ -80,8 +81,8 @@ o2.widget.ScriptArea = new Class({
"position": "absolute", "position": "absolute",
// "top": coordinates.top, // "top": coordinates.top,
// "left": coordinates.left, // "left": coordinates.left,
"top": "0px", "top": coordinates.top+"px",
"left": "0px", "left": coordinates.left+"px",
"width": coordinates.width, "width": coordinates.width,
"height": coordinates.height-2, "height": coordinates.height-2,
"z-index": 20001 "z-index": 20001
...@@ -97,7 +98,8 @@ o2.widget.ScriptArea = new Class({ ...@@ -97,7 +98,8 @@ o2.widget.ScriptArea = new Class({
returnSize: function(){ returnSize: function(){
var size = this.container.retrieve("size"); var size = this.container.retrieve("size");
this.editor.setOption("lineNumbers", false); //this.editor.setOption("lineNumbers", false);
this.jsEditor.hideLineNumbers();
this.container.inject(this.node); this.container.inject(this.node);
this.container.setStyles({ this.container.setStyles({
"position": "static", "position": "static",
......
...@@ -2,15 +2,20 @@ o2.widget = o2.widget || {}; ...@@ -2,15 +2,20 @@ o2.widget = o2.widget || {};
o2.widget.ace = { o2.widget.ace = {
//"ace": COMMON.contentPath+"/res/framework/ace/src-min/ace.js", //"ace": COMMON.contentPath+"/res/framework/ace/src-min/ace.js",
//"tools": COMMON.contentPath+"/res/framework/ace/src-min/ext-language_tools.js", //"tools": COMMON.contentPath+"/res/framework/ace/src-min/ext-language_tools.js",
"callbackList": [],
"load": function(callback){ "load": function(callback){
if (!window.ace){ if (!window.ace){
var jsLoaded = false; this.callbackList.push(callback);
var cssLoaded = false; if (!this.isLoadding) {
o2.load("ace", {"sequence": true}, function(){ this.isLoadding = true;
//COMMON.AjaxModule.loadDom("ace-tools", function(){ o2.load("ace", {"sequence": true}, function(){
if (callback) callback(); this.isLoadding = false;
//}.bind(this)) while (this.callbackList.length){
}.bind(this)); this.callbackList.shift()();
}
}.bind(this));
}
}else{ }else{
if (callback) callback(); if (callback) callback();
} }
......
...@@ -11,8 +11,8 @@ o2.widget.codemirror = { ...@@ -11,8 +11,8 @@ o2.widget.codemirror = {
"php": COMMON.contentPath+"/res/framework/codemirror/mode/php/php.js" "php": COMMON.contentPath+"/res/framework/codemirror/mode/php/php.js"
}, },
"addon": { "addon": {
}, },
"load": function(callback){ "load": function(callback){
var jsLoaded = false; var jsLoaded = false;
...@@ -42,9 +42,5 @@ o2.widget.codemirror = { ...@@ -42,9 +42,5 @@ o2.widget.codemirror = {
if (callback) callback(); if (callback) callback();
} }
} }
};
};
\ No newline at end of file
o2.widget = o2.widget || {}; o2.widget = o2.widget || {};
o2.widget.monaco = { o2.widget.monaco = {
//"ace": COMMON.contentPath+"/res/framework/ace/src-min/ace.js", "callbackList": [],
//"tools": COMMON.contentPath+"/res/framework/ace/src-min/ext-language_tools.js",
"load": function(callback){ "load": function(callback){
if (!window.monaco){ if (!window.monaco){
o2.load("monaco", {"sequence": true}, function(){ this.callbackList.push(callback);
require.config({ paths: { "vs": "/o2_lib/vs" }}); if (!this.isLoadding){
require(["vs/editor/editor.main"], function() { this.isLoadding = true;
if (callback) callback(); o2.load("monaco", {"sequence": true}, function(){
// var editor = monaco.editor.create(document.getElementById('container'), { require.config({ paths: { "vs": "/o2_lib/vs" }});
// value: [ require(["vs/editor/editor.main"], function() {
// 'function x() {', this.isLoadding = false;
// '\tconsole.log("Hello world!");', while (this.callbackList.length){
// '}' this.callbackList.shift()();
// ].join('\n'), }
// language: 'javascript' //if (callback) callback();
// }); }.bind(this));
}); }.bind(this));
}.bind(this)); }
}else{ }else{
if (callback) callback(); if (callback) callback();
} }
......
此差异已折叠。
...@@ -63,6 +63,15 @@ ...@@ -63,6 +63,15 @@
<option value="vibrant_ink">vibrant_ink</option> <option value="vibrant_ink">vibrant_ink</option>
<option value="xcode">xcode</option> <option value="xcode">xcode</option>
</select></div> </select></div>
<div style="float: right; margin-right: 20px">样式:<select MWFnodetype="monaco-theme">
<option value="vs">Visual Studio</option>
<option value="vs-dark">Visual Studio Dark</option>
<option value="hc-black">High Contrast Dark</option>
</select></div>
<div style="float: right; margin-right: 20px">脚本编辑器:<select MWFnodetype="editor">
<option selected value="ace">ace</option>
<option value="monaco">monaco</option>
</select></div>
</div> </div>
\ No newline at end of file
...@@ -366,17 +366,57 @@ MWF.xApplication.cms.ScriptDesigner.Main = new Class({ ...@@ -366,17 +366,57 @@ MWF.xApplication.cms.ScriptDesigner.Main = new Class({
_self.changeFontSize(this); _self.changeFontSize(this);
}); });
this.editorSelectNode = toolbarNode.getElement("select[MWFnodetype='editor']");
this.editorSelectNode.addEvent("change", function(){
_self.changeEditor(this);
});
this.monacoStyleSelectNode = toolbarNode.getElement("select[MWFnodetype='monaco-theme']");
this.monacoStyleSelectNode.addEvent("change", function(){
_self.changeEditorStyle(this);
});
if (callback) callback(); if (callback) callback();
}.bind(this)); }.bind(this));
}.bind(this)); }.bind(this));
}, },
changeEditor: function(node){
var idx = node.selectedIndex;
var value = node.options[idx].value;
if (!MWF.editorData){
MWF.editorData = {
"javascriptEditor": {
"monaco_theme": "vs",
"theme": "tomorrow",
"fontSize" : "12px"
}
};
}
MWF.editorData.javascriptEditor["editor"] = value;
MWF.UD.putData("editor", MWF.editorData);
this.scriptTab.pages.each(function(page){
var editor = page.script.editor;
if (editor) editor.changeEditor(value);
}.bind(this));
if (value=="ace"){
this.monacoStyleSelectNode.hide();
this.styleSelectNode.show();
}else{
this.monacoStyleSelectNode.show();
this.styleSelectNode.hide();
}
},
changeFontSize: function(node){ changeFontSize: function(node){
var idx = node.selectedIndex; var idx = node.selectedIndex;
var value = node.options[idx].value; var value = node.options[idx].value;
//var editorData = null; //var editorData = null;
this.scriptTab.pages.each(function(page){ this.scriptTab.pages.each(function(page){
//if (!editorData) editorData = page.invoke.editor.editorData; //if (!editorData) editorData = page.invoke.editor.editorData;
var editor = page.script.editor.editor; var editor = page.script.editor;
if (editor) editor.setFontSize(value); if (editor) editor.setFontSize(value);
}.bind(this)); }.bind(this));
//if (!editorData) editorData = MWF.editorData; //if (!editorData) editorData = MWF.editorData;
...@@ -384,6 +424,7 @@ MWF.xApplication.cms.ScriptDesigner.Main = new Class({ ...@@ -384,6 +424,7 @@ MWF.xApplication.cms.ScriptDesigner.Main = new Class({
if (!MWF.editorData){ if (!MWF.editorData){
MWF.editorData = { MWF.editorData = {
"javascriptEditor": { "javascriptEditor": {
"monaco_theme": "vs",
"theme": "tomorrow", "theme": "tomorrow",
"fontSize" : "12px" "fontSize" : "12px"
} }
...@@ -397,26 +438,31 @@ MWF.xApplication.cms.ScriptDesigner.Main = new Class({ ...@@ -397,26 +438,31 @@ MWF.xApplication.cms.ScriptDesigner.Main = new Class({
changeEditorStyle: function(node){ changeEditorStyle: function(node){
var idx = node.selectedIndex; var idx = node.selectedIndex;
var value = node.options[idx].value; var value = node.options[idx].value;
var editorData = null; //var editorData = null;
this.scriptTab.pages.each(function(page){ this.scriptTab.pages.each(function(page){
if (!editorData) editorData = page.script.editor.editorData; //if (!editorData) editorData = page.script.editor.editorData;
var editor = page.script.editor.editor; var editor = page.script.editor;
if (editor) editor.setTheme("ace/theme/"+value); if (editor) editor.setTheme(value);
}.bind(this)); }.bind(this));
//if (!editorData) editorData = MWF.editorData;
//editorData.javascriptEditor.theme = value;
if (!MWF.editorData){ if (!MWF.editorData){
MWF.editorData = { MWF.editorData = {
"javascriptEditor": { "javascriptEditor": {
"monaco_theme": "vs",
"theme": "tomorrow", "theme": "tomorrow",
"fontSize" : "12px" "fontSize" : "12px"
} }
}; };
} }
editorData.javascriptEditor.theme = value; if (MWF.editorData.javascriptEditor.editor === "monaco"){
MWF.editorData.javascriptEditor.monaco_theme = value;
MWF.UD.putData("editor", editorData); }else{
MWF.editorData.javascriptEditor.theme = value;
}
MWF.UD.putData("editor", MWF.editorData);
}, },
getFormToolbarHTML: function(callback){ getFormToolbarHTML: function(callback){
var toolbarUrl = this.path+this.options.style+"/toolbars.html"; var toolbarUrl = this.path+this.options.style+"/toolbars.html";
......
...@@ -159,6 +159,28 @@ MWF.xApplication.cms.ScriptDesigner.Script = new Class({ ...@@ -159,6 +159,28 @@ MWF.xApplication.cms.ScriptDesigner.Script = new Class({
} }
} }
} }
if(this.designer.editorSelectNode) {
var options = this.designer.editorSelectNode.options;
for (var i = 0; i < options.length; i++) {
var option = options[i];
if (option.value == this.editor.options.type) {
option.set("selected", true);
break;
}
}
}
if (this.designer.styleSelectNode && this.designer.monacoStyleSelectNode){
if (this.editor.options.type=="ace"){
this.designer.monacoStyleSelectNode.hide();
this.designer.styleSelectNode.show();
}else{
this.designer.monacoStyleSelectNode.show();
this.designer.styleSelectNode.hide();
}
}
}.bind(this)); }.bind(this));
if (this.options.showTab) this.page.showTabIm(); if (this.options.showTab) this.page.showTabIm();
......
...@@ -25,6 +25,15 @@ ...@@ -25,6 +25,15 @@
<option value="16px">16px</option> <option value="16px">16px</option>
<option value="17px">17px</option> <option value="17px">17px</option>
<option value="18px">18px</option> <option value="18px">18px</option>
<option value="20px">20px</option>
<option value="22px">22px</option>
<option value="24px">24px</option>
<option value="26px">26px</option>
<option value="28px">28px</option>
<option value="30px">30px</option>
<option value="32px">32px</option>
<option value="34px">34px</option>
<option value="36px">36px</option>
</select></div> </select></div>
<div style="float: right; margin-right: 20px">样式:<select MWFnodetype="theme"> <div style="float: right; margin-right: 20px">样式:<select MWFnodetype="theme">
...@@ -63,6 +72,17 @@ ...@@ -63,6 +72,17 @@
<option value="vibrant_ink">vibrant_ink</option> <option value="vibrant_ink">vibrant_ink</option>
<option value="xcode">xcode</option> <option value="xcode">xcode</option>
</select></div> </select></div>
<div style="float: right; margin-right: 20px">样式:<select MWFnodetype="monaco-theme">
<option value="vs">Visual Studio</option>
<option value="vs-dark">Visual Studio Dark</option>
<option value="hc-black">High Contrast Dark</option>
</select></div>
<div style="float: right; margin-right: 20px">脚本编辑器:<select MWFnodetype="editor">
<option selected value="ace">ace</option>
<option value="monaco">monaco</option>
</select></div>
</div> </div>
\ No newline at end of file
...@@ -358,17 +358,57 @@ MWF.xApplication.portal.ScriptDesigner.Main = new Class({ ...@@ -358,17 +358,57 @@ MWF.xApplication.portal.ScriptDesigner.Main = new Class({
_self.changeFontSize(this); _self.changeFontSize(this);
}); });
this.editorSelectNode = toolbarNode.getElement("select[MWFnodetype='editor']");
this.editorSelectNode.addEvent("change", function(){
_self.changeEditor(this);
});
this.monacoStyleSelectNode = toolbarNode.getElement("select[MWFnodetype='monaco-theme']");
this.monacoStyleSelectNode.addEvent("change", function(){
_self.changeEditorStyle(this);
});
if (callback) callback(); if (callback) callback();
}.bind(this)); }.bind(this));
}.bind(this)); }.bind(this));
}, },
changeEditor: function(node){
var idx = node.selectedIndex;
var value = node.options[idx].value;
if (!MWF.editorData){
MWF.editorData = {
"javascriptEditor": {
"monaco_theme": "vs",
"theme": "tomorrow",
"fontSize" : "12px"
}
};
}
MWF.editorData.javascriptEditor["editor"] = value;
MWF.UD.putData("editor", MWF.editorData);
this.scriptTab.pages.each(function(page){
var editor = page.script.editor;
if (editor) editor.changeEditor(value);
}.bind(this));
if (value=="ace"){
this.monacoStyleSelectNode.hide();
this.styleSelectNode.show();
}else{
this.monacoStyleSelectNode.show();
this.styleSelectNode.hide();
}
},
changeFontSize: function(node){ changeFontSize: function(node){
var idx = node.selectedIndex; var idx = node.selectedIndex;
var value = node.options[idx].value; var value = node.options[idx].value;
//var editorData = null; //var editorData = null;
this.scriptTab.pages.each(function(page){ this.scriptTab.pages.each(function(page){
//if (!editorData) editorData = page.invoke.editor.editorData; //if (!editorData) editorData = page.invoke.editor.editorData;
var editor = page.script.editor.editor; var editor = page.script.editor;
if (editor) editor.setFontSize(value); if (editor) editor.setFontSize(value);
}.bind(this)); }.bind(this));
//if (!editorData) editorData = MWF.editorData; //if (!editorData) editorData = MWF.editorData;
...@@ -376,6 +416,7 @@ MWF.xApplication.portal.ScriptDesigner.Main = new Class({ ...@@ -376,6 +416,7 @@ MWF.xApplication.portal.ScriptDesigner.Main = new Class({
if (!MWF.editorData){ if (!MWF.editorData){
MWF.editorData = { MWF.editorData = {
"javascriptEditor": { "javascriptEditor": {
"monaco_theme": "vs",
"theme": "tomorrow", "theme": "tomorrow",
"fontSize" : "12px" "fontSize" : "12px"
} }
...@@ -392,23 +433,28 @@ MWF.xApplication.portal.ScriptDesigner.Main = new Class({ ...@@ -392,23 +433,28 @@ MWF.xApplication.portal.ScriptDesigner.Main = new Class({
//var editorData = null; //var editorData = null;
this.scriptTab.pages.each(function(page){ this.scriptTab.pages.each(function(page){
//if (!editorData) editorData = page.script.editor.editorData; //if (!editorData) editorData = page.script.editor.editorData;
var editor = page.script.editor.editor; var editor = page.script.editor;
if (editor) editor.setTheme("ace/theme/"+value); if (editor) editor.setTheme(value);
}.bind(this)); }.bind(this));
//if (!editorData) editorData = MWF.editorData; //if (!editorData) editorData = MWF.editorData;
//editorData.javascriptEditor.theme = value; //editorData.javascriptEditor.theme = value;
if (!MWF.editorData){ if (!MWF.editorData){
MWF.editorData = { MWF.editorData = {
"javascriptEditor": { "javascriptEditor": {
"monaco_theme": "vs",
"theme": "tomorrow", "theme": "tomorrow",
"fontSize" : "12px" "fontSize" : "12px"
} }
}; };
} }
MWF.editorData.javascriptEditor.theme = value;
MWF.UD.putData("editor", MWF.editorData); if (MWF.editorData.javascriptEditor.editor === "monaco"){
MWF.editorData.javascriptEditor.monaco_theme = value;
}else{
MWF.editorData.javascriptEditor.theme = value;
}
MWF.UD.putData("editor", MWF.editorData);
}, },
getFormToolbarHTML: function(callback){ getFormToolbarHTML: function(callback){
var toolbarUrl = this.path+this.options.style+"/toolbars.html"; var toolbarUrl = this.path+this.options.style+"/toolbars.html";
......
...@@ -141,7 +141,7 @@ MWF.xApplication.portal.ScriptDesigner.Script = new Class({ ...@@ -141,7 +141,7 @@ MWF.xApplication.portal.ScriptDesigner.Script = new Class({
} }
} }
var options = this.designer.fontsizeSelectNode.options; options = this.designer.fontsizeSelectNode.options;
for (var i=0; i<options.length; i++){ for (var i=0; i<options.length; i++){
var option = options[i]; var option = options[i];
if (option.value==this.editor.fontSize){ if (option.value==this.editor.fontSize){
...@@ -149,6 +149,22 @@ MWF.xApplication.portal.ScriptDesigner.Script = new Class({ ...@@ -149,6 +149,22 @@ MWF.xApplication.portal.ScriptDesigner.Script = new Class({
break; break;
} }
} }
options = this.designer.editorSelectNode.options;
for (var i=0; i<options.length; i++){
var option = options[i];
if (option.value==this.editor.options.type){
option.set("selected", true);
break;
}
}
if (this.editor.options.type=="ace"){
this.designer.monacoStyleSelectNode.hide();
this.designer.styleSelectNode.show();
}else{
this.designer.monacoStyleSelectNode.show();
this.designer.styleSelectNode.hide();
}
}.bind(this)); }.bind(this));
if (this.options.showTab) this.page.showTabIm(); if (this.options.showTab) this.page.showTabIm();
......
...@@ -63,6 +63,15 @@ ...@@ -63,6 +63,15 @@
<option value="vibrant_ink">vibrant_ink</option> <option value="vibrant_ink">vibrant_ink</option>
<option value="xcode">xcode</option> <option value="xcode">xcode</option>
</select></div> </select></div>
<div style="float: right; margin-right: 20px">样式:<select MWFnodetype="monaco-theme">
<option value="vs">Visual Studio</option>
<option value="vs-dark">Visual Studio Dark</option>
<option value="hc-black">High Contrast Dark</option>
</select></div>
<div style="float: right; margin-right: 20px">脚本编辑器:<select MWFnodetype="editor">
<option selected value="ace">ace</option>
<option value="monaco">monaco</option>
</select></div>
</div> </div>
\ No newline at end of file
...@@ -370,17 +370,57 @@ MWF.xApplication.process.ScriptDesigner.Main = new Class({ ...@@ -370,17 +370,57 @@ MWF.xApplication.process.ScriptDesigner.Main = new Class({
_self.changeFontSize(this); _self.changeFontSize(this);
}); });
this.editorSelectNode = toolbarNode.getElement("select[MWFnodetype='editor']");
this.editorSelectNode.addEvent("change", function(){
_self.changeEditor(this);
});
this.monacoStyleSelectNode = toolbarNode.getElement("select[MWFnodetype='monaco-theme']");
this.monacoStyleSelectNode.addEvent("change", function(){
_self.changeEditorStyle(this);
});
if (callback) callback(); if (callback) callback();
}.bind(this)); }.bind(this));
}.bind(this)); }.bind(this));
}, },
changeEditor: function(node){
var idx = node.selectedIndex;
var value = node.options[idx].value;
if (!MWF.editorData){
MWF.editorData = {
"javascriptEditor": {
"monaco_theme": "vs",
"theme": "tomorrow",
"fontSize" : "12px"
}
};
}
MWF.editorData.javascriptEditor["editor"] = value;
MWF.UD.putData("editor", MWF.editorData);
this.scriptTab.pages.each(function(page){
var editor = page.script.editor;
if (editor) editor.changeEditor(value);
}.bind(this));
if (value=="ace"){
this.monacoStyleSelectNode.hide();
this.styleSelectNode.show();
}else{
this.monacoStyleSelectNode.show();
this.styleSelectNode.hide();
}
},
changeFontSize: function(node){ changeFontSize: function(node){
var idx = node.selectedIndex; var idx = node.selectedIndex;
var value = node.options[idx].value; var value = node.options[idx].value;
//var editorData = null; //var editorData = null;
this.scriptTab.pages.each(function(page){ this.scriptTab.pages.each(function(page){
//if (!editorData) editorData = page.invoke.editor.editorData; //if (!editorData) editorData = page.invoke.editor.editorData;
var editor = page.script.editor.editor; var editor = page.script.editor;
if (editor) editor.setFontSize(value); if (editor) editor.setFontSize(value);
}.bind(this)); }.bind(this));
//if (!editorData) editorData = MWF.editorData; //if (!editorData) editorData = MWF.editorData;
...@@ -388,6 +428,7 @@ MWF.xApplication.process.ScriptDesigner.Main = new Class({ ...@@ -388,6 +428,7 @@ MWF.xApplication.process.ScriptDesigner.Main = new Class({
if (!MWF.editorData){ if (!MWF.editorData){
MWF.editorData = { MWF.editorData = {
"javascriptEditor": { "javascriptEditor": {
"monaco_theme": "vs",
"theme": "tomorrow", "theme": "tomorrow",
"fontSize" : "12px" "fontSize" : "12px"
} }
...@@ -404,23 +445,28 @@ MWF.xApplication.process.ScriptDesigner.Main = new Class({ ...@@ -404,23 +445,28 @@ MWF.xApplication.process.ScriptDesigner.Main = new Class({
//var editorData = null; //var editorData = null;
this.scriptTab.pages.each(function(page){ this.scriptTab.pages.each(function(page){
//if (!editorData) editorData = page.script.editor.editorData; //if (!editorData) editorData = page.script.editor.editorData;
var editor = page.script.editor.editor; var editor = page.script.editor;
if (editor) editor.setTheme("ace/theme/"+value); if (editor) editor.setTheme(value);
}.bind(this)); }.bind(this));
//if (!editorData) editorData = MWF.editorData; //if (!editorData) editorData = MWF.editorData;
//editorData.javascriptEditor.theme = value; //editorData.javascriptEditor.theme = value;
if (!MWF.editorData){ if (!MWF.editorData){
MWF.editorData = { MWF.editorData = {
"javascriptEditor": { "javascriptEditor": {
"monaco_theme": "vs",
"theme": "tomorrow", "theme": "tomorrow",
"fontSize" : "12px" "fontSize" : "12px"
} }
}; };
} }
MWF.editorData.javascriptEditor.theme = value;
MWF.UD.putData("editor", MWF.editorData); if (MWF.editorData.javascriptEditor.editor === "monaco"){
MWF.editorData.javascriptEditor.monaco_theme = value;
}else{
MWF.editorData.javascriptEditor.theme = value;
}
MWF.UD.putData("editor", MWF.editorData);
}, },
getFormToolbarHTML: function(callback){ getFormToolbarHTML: function(callback){
var toolbarUrl = this.path+this.options.style+"/toolbars.html"; var toolbarUrl = this.path+this.options.style+"/toolbars.html";
......
...@@ -159,6 +159,23 @@ MWF.xApplication.process.ScriptDesigner.Script = new Class({ ...@@ -159,6 +159,23 @@ MWF.xApplication.process.ScriptDesigner.Script = new Class({
break; break;
} }
} }
options = this.designer.editorSelectNode.options;
for (var i=0; i<options.length; i++){
var option = options[i];
if (option.value==this.editor.options.type){
option.set("selected", true);
break;
}
}
if (this.editor.options.type=="ace"){
this.designer.monacoStyleSelectNode.hide();
this.designer.styleSelectNode.show();
}else{
this.designer.monacoStyleSelectNode.show();
this.designer.styleSelectNode.hide();
}
}.bind(this)); }.bind(this));
}, },
......
...@@ -6,6 +6,7 @@ MWF.APPDSMD = MWF.xApplication.query.StatementDesigner; ...@@ -6,6 +6,7 @@ MWF.APPDSMD = MWF.xApplication.query.StatementDesigner;
MWF.xDesktop.requireApp("query.StatementDesigner", "lp."+MWF.language, null, false); MWF.xDesktop.requireApp("query.StatementDesigner", "lp."+MWF.language, null, false);
//MWF.xDesktop.requireApp("query.StatementDesigner", "Property", null, false); //MWF.xDesktop.requireApp("query.StatementDesigner", "Property", null, false);
MWF.xDesktop.requireApp("query.TableDesigner", "Property", null, false); MWF.xDesktop.requireApp("query.TableDesigner", "Property", null, false);
o2.require("o2.widget.JavascriptEditor", null, false);
MWF.xApplication.query.StatementDesigner.Statement = new Class({ MWF.xApplication.query.StatementDesigner.Statement = new Class({
Extends: MWF.widget.Common, Extends: MWF.widget.Common,
...@@ -156,10 +157,11 @@ MWF.xApplication.query.StatementDesigner.Statement = new Class({ ...@@ -156,10 +157,11 @@ MWF.xApplication.query.StatementDesigner.Statement = new Class({
}, },
loadStatementScriptEditor: function(){ loadStatementScriptEditor: function(){
if (! this.scriptEditor){ if (! this.scriptEditor){
debugger;
o2.require("o2.widget.ScriptArea", function(){ o2.require("o2.widget.ScriptArea", function(){
this.scriptEditor = new o2.widget.ScriptArea(this.scriptArea, { this.scriptEditor = new o2.widget.ScriptArea(this.scriptArea, {
"isbind": false, "isbind": false,
"maxObj": this.designer.content, "maxObj": this.designer.designNode,
"title": this.designer.lp.scriptTitle, "title": this.designer.lp.scriptTitle,
"onChange": function(){ "onChange": function(){
this.json.scriptText = this.scriptEditor.toJson().code; this.json.scriptText = this.scriptEditor.toJson().code;
...@@ -209,6 +211,7 @@ MWF.xApplication.query.StatementDesigner.Statement = new Class({ ...@@ -209,6 +211,7 @@ MWF.xApplication.query.StatementDesigner.Statement = new Class({
this.json.data = this.editor.editor.getValue(); this.json.data = this.editor.editor.getValue();
this.editor.addEditorEvent("change", function(){ this.editor.addEditorEvent("change", function(){
debugger;
this.data.data = this.editor.getValue(); this.data.data = this.editor.getValue();
this.checkJpqlType(); this.checkJpqlType();
}.bind(this)); }.bind(this));
......
...@@ -64,5 +64,14 @@ ...@@ -64,5 +64,14 @@
<option value="xcode">xcode</option> <option value="xcode">xcode</option>
</select></div> </select></div>
<div style="float: right; margin-right: 20px">样式:<select MWFnodetype="monaco-theme">
<option value="vs">Visual Studio</option>
<option value="vs-dark">Visual Studio Dark</option>
<option value="hc-black">High Contrast Dark</option>
</select></div>
<div style="float: right; margin-right: 20px">脚本编辑器:<select MWFnodetype="editor">
<option selected value="ace">ace</option>
<option value="monaco">monaco</option>
</select></div>
</div> </div>
\ No newline at end of file
...@@ -96,7 +96,7 @@ MWF.xApplication.service.AgentDesigner.Agent = new Class({ ...@@ -96,7 +96,7 @@ MWF.xApplication.service.AgentDesigner.Agent = new Class({
this.editor = new MWF.widget.JavascriptEditor(this.areaNode); this.editor = new MWF.widget.JavascriptEditor(this.areaNode, {"runtime": "service"});
this.editor.load(function(){ this.editor.load(function(){
if (this.data.text){ if (this.data.text){
this.editor.editor.setValue(this.data.text); this.editor.editor.setValue(this.data.text);
...@@ -165,6 +165,23 @@ MWF.xApplication.service.AgentDesigner.Agent = new Class({ ...@@ -165,6 +165,23 @@ MWF.xApplication.service.AgentDesigner.Agent = new Class({
break; break;
} }
} }
options = this.designer.editorSelectNode.options;
for (var i=0; i<options.length; i++){
var option = options[i];
if (option.value==this.editor.options.type){
option.set("selected", true);
break;
}
}
if (this.editor.options.type=="ace"){
this.designer.monacoStyleSelectNode.hide();
this.designer.styleSelectNode.show();
}else{
this.designer.monacoStyleSelectNode.show();
this.designer.styleSelectNode.hide();
}
}.bind(this)); }.bind(this));
if (this.options.showTab) this.page.showTabIm(); if (this.options.showTab) this.page.showTabIm();
......
...@@ -350,17 +350,57 @@ MWF.xApplication.service.AgentDesigner.Main = new Class({ ...@@ -350,17 +350,57 @@ MWF.xApplication.service.AgentDesigner.Main = new Class({
_self.changeFontSize(this); _self.changeFontSize(this);
}); });
this.editorSelectNode = toolbarNode.getElement("select[MWFnodetype='editor']");
this.editorSelectNode.addEvent("change", function(){
_self.changeEditor(this);
});
this.monacoStyleSelectNode = toolbarNode.getElement("select[MWFnodetype='monaco-theme']");
this.monacoStyleSelectNode.addEvent("change", function(){
_self.changeEditorStyle(this);
});
if (callback) callback(); if (callback) callback();
}.bind(this)); }.bind(this));
}.bind(this)); }.bind(this));
}, },
changeEditor: function(node){
var idx = node.selectedIndex;
var value = node.options[idx].value;
if (!MWF.editorData){
MWF.editorData = {
"javascriptEditor": {
"monaco_theme": "vs",
"theme": "tomorrow",
"fontSize" : "12px"
}
};
}
MWF.editorData.javascriptEditor["editor"] = value;
MWF.UD.putData("editor", MWF.editorData);
this.agentTab.pages.each(function(page){
var editor = page.agent.editor;
if (editor) editor.changeEditor(value);
}.bind(this));
if (value=="ace"){
this.monacoStyleSelectNode.hide();
this.styleSelectNode.show();
}else{
this.monacoStyleSelectNode.show();
this.styleSelectNode.hide();
}
},
changeFontSize: function(node){ changeFontSize: function(node){
var idx = node.selectedIndex; var idx = node.selectedIndex;
var value = node.options[idx].value; var value = node.options[idx].value;
//var editorData = null; //var editorData = null;
this.agentTab.pages.each(function(page){ this.agentTab.pages.each(function(page){
//if (!editorData) editorData = page.invoke.editor.editorData; //if (!editorData) editorData = page.invoke.editor.editorData;
var editor = page.agent.editor.editor; var editor = page.agent.editor;
if (editor) editor.setFontSize(value); if (editor) editor.setFontSize(value);
}.bind(this)); }.bind(this));
//if (!editorData) editorData = MWF.editorData; //if (!editorData) editorData = MWF.editorData;
...@@ -368,6 +408,7 @@ MWF.xApplication.service.AgentDesigner.Main = new Class({ ...@@ -368,6 +408,7 @@ MWF.xApplication.service.AgentDesigner.Main = new Class({
if (!MWF.editorData){ if (!MWF.editorData){
MWF.editorData = { MWF.editorData = {
"javascriptEditor": { "javascriptEditor": {
"monaco_theme": "vs",
"theme": "tomorrow", "theme": "tomorrow",
"fontSize" : "12px" "fontSize" : "12px"
} }
...@@ -383,24 +424,29 @@ MWF.xApplication.service.AgentDesigner.Main = new Class({ ...@@ -383,24 +424,29 @@ MWF.xApplication.service.AgentDesigner.Main = new Class({
var value = node.options[idx].value; var value = node.options[idx].value;
//var editorData = null; //var editorData = null;
this.agentTab.pages.each(function(page){ this.agentTab.pages.each(function(page){
//if (!editorData) editorData = page.agent.editor.editorData; //if (!editorData) editorData = page.script.editor.editorData;
var editor = page.agent.editor.editor; var editor = page.agent.editor;
if (editor) editor.setTheme("ace/theme/"+value); if (editor) editor.setTheme(value);
}.bind(this)); }.bind(this));
//if (!editorData) editorData = MWF.editorData; //if (!editorData) editorData = MWF.editorData;
//editorData.javaagentEditor.theme = value; //editorData.javascriptEditor.theme = value;
if (!MWF.editorData){ if (!MWF.editorData){
MWF.editorData = { MWF.editorData = {
"javascriptEditor": { "javascriptEditor": {
"monaco_theme": "vs",
"theme": "tomorrow", "theme": "tomorrow",
"fontSize" : "12px" "fontSize" : "12px"
} }
}; };
} }
MWF.editorData.javascriptEditor.theme = value;
MWF.UD.putData("editor", MWF.editorData); if (MWF.editorData.javascriptEditor.editor === "monaco"){
MWF.editorData.javascriptEditor.monaco_theme = value;
}else{
MWF.editorData.javascriptEditor.theme = value;
}
MWF.UD.putData("editor", MWF.editorData);
}, },
getFormToolbarHTML: function(callback){ getFormToolbarHTML: function(callback){
var toolbarUrl = this.path+this.options.style+"/toolbars.html"; var toolbarUrl = this.path+this.options.style+"/toolbars.html";
......
...@@ -62,4 +62,14 @@ ...@@ -62,4 +62,14 @@
<option value="xcode">xcode</option> <option value="xcode">xcode</option>
</select></div> </select></div>
<div style="float: right; margin-right: 20px">样式:<select MWFnodetype="monaco-theme">
<option value="vs">Visual Studio</option>
<option value="vs-dark">Visual Studio Dark</option>
<option value="hc-black">High Contrast Dark</option>
</select></div>
<div style="float: right; margin-right: 20px">脚本编辑器:<select MWFnodetype="editor">
<option selected value="ace">ace</option>
<option value="monaco">monaco</option>
</select></div>
</div> </div>
\ No newline at end of file
...@@ -95,7 +95,7 @@ MWF.xApplication.service.InvokeDesigner.Invoke = new Class({ ...@@ -95,7 +95,7 @@ MWF.xApplication.service.InvokeDesigner.Invoke = new Class({
this.editor = new MWF.widget.JavascriptEditor(this.areaNode); this.editor = new MWF.widget.JavascriptEditor(this.areaNode, {"runtime": "service"});
this.editor.load(function(){ this.editor.load(function(){
if (this.data.text){ if (this.data.text){
this.editor.editor.setValue(this.data.text); this.editor.editor.setValue(this.data.text);
...@@ -172,6 +172,22 @@ MWF.xApplication.service.InvokeDesigner.Invoke = new Class({ ...@@ -172,6 +172,22 @@ MWF.xApplication.service.InvokeDesigner.Invoke = new Class({
break; break;
} }
} }
options = this.designer.editorSelectNode.options;
for (var i=0; i<options.length; i++){
var option = options[i];
if (option.value==this.editor.options.type){
option.set("selected", true);
break;
}
}
if (this.editor.options.type=="ace"){
this.designer.monacoStyleSelectNode.hide();
this.designer.styleSelectNode.show();
}else{
this.designer.monacoStyleSelectNode.show();
this.designer.styleSelectNode.hide();
}
}.bind(this)); }.bind(this));
if (this.options.showTab) this.page.showTabIm(); if (this.options.showTab) this.page.showTabIm();
......
...@@ -350,17 +350,58 @@ MWF.xApplication.service.InvokeDesigner.Main = new Class({ ...@@ -350,17 +350,58 @@ MWF.xApplication.service.InvokeDesigner.Main = new Class({
_self.changeFontSize(this); _self.changeFontSize(this);
}); });
this.editorSelectNode = toolbarNode.getElement("select[MWFnodetype='editor']");
this.editorSelectNode.addEvent("change", function(){
_self.changeEditor(this);
});
this.monacoStyleSelectNode = toolbarNode.getElement("select[MWFnodetype='monaco-theme']");
this.monacoStyleSelectNode.addEvent("change", function(){
_self.changeEditorStyle(this);
});
if (callback) callback(); if (callback) callback();
}.bind(this)); }.bind(this));
}.bind(this)); }.bind(this));
}, },
changeEditor: function(node){
var idx = node.selectedIndex;
var value = node.options[idx].value;
if (!MWF.editorData){
MWF.editorData = {
"javascriptEditor": {
"monaco_theme": "vs",
"theme": "tomorrow",
"fontSize" : "12px"
}
};
}
MWF.editorData.javascriptEditor["editor"] = value;
MWF.UD.putData("editor", MWF.editorData);
this.invokeTab.pages.each(function(page){
var editor = page.invoke.editor;
if (editor) editor.changeEditor(value);
}.bind(this));
if (value=="ace"){
this.monacoStyleSelectNode.hide();
this.styleSelectNode.show();
}else{
this.monacoStyleSelectNode.show();
this.styleSelectNode.hide();
}
},
changeFontSize: function(node){ changeFontSize: function(node){
var idx = node.selectedIndex; var idx = node.selectedIndex;
var value = node.options[idx].value; var value = node.options[idx].value;
//var editorData = null; //var editorData = null;
this.invokeTab.pages.each(function(page){ this.invokeTab.pages.each(function(page){
//if (!editorData) editorData = page.invoke.editor.editorData; //if (!editorData) editorData = page.invoke.editor.editorData;
var editor = page.invoke.editor.editor; var editor = page.invoke.editor;
if (editor) editor.setFontSize(value); if (editor) editor.setFontSize(value);
}.bind(this)); }.bind(this));
//if (!editorData) editorData = MWF.editorData; //if (!editorData) editorData = MWF.editorData;
...@@ -368,6 +409,7 @@ MWF.xApplication.service.InvokeDesigner.Main = new Class({ ...@@ -368,6 +409,7 @@ MWF.xApplication.service.InvokeDesigner.Main = new Class({
if (!MWF.editorData){ if (!MWF.editorData){
MWF.editorData = { MWF.editorData = {
"javascriptEditor": { "javascriptEditor": {
"monaco_theme": "vs",
"theme": "tomorrow", "theme": "tomorrow",
"fontSize" : "12px" "fontSize" : "12px"
} }
...@@ -383,24 +425,29 @@ MWF.xApplication.service.InvokeDesigner.Main = new Class({ ...@@ -383,24 +425,29 @@ MWF.xApplication.service.InvokeDesigner.Main = new Class({
var value = node.options[idx].value; var value = node.options[idx].value;
//var editorData = null; //var editorData = null;
this.invokeTab.pages.each(function(page){ this.invokeTab.pages.each(function(page){
//if (!editorData) editorData = page.invoke.editor.editorData; //if (!editorData) editorData = page.script.editor.editorData;
var editor = page.invoke.editor.editor; var editor = page.invoke.editor;
if (editor) editor.setTheme("ace/theme/"+value); if (editor) editor.setTheme(value);
}.bind(this)); }.bind(this));
//if (!editorData) editorData = MWF.editorData; //if (!editorData) editorData = MWF.editorData;
//editorData.javainvokeEditor.theme = value; //editorData.javascriptEditor.theme = value;
if (!MWF.editorData){ if (!MWF.editorData){
MWF.editorData = { MWF.editorData = {
"javascriptEditor": { "javascriptEditor": {
"monaco_theme": "vs",
"theme": "tomorrow", "theme": "tomorrow",
"fontSize" : "12px" "fontSize" : "12px"
} }
}; };
} }
MWF.editorData.javascriptEditor.theme = value;
MWF.UD.putData("editor", MWF.editorData); if (MWF.editorData.javascriptEditor.editor === "monaco"){
MWF.editorData.javascriptEditor.monaco_theme = value;
}else{
MWF.editorData.javascriptEditor.theme = value;
}
MWF.UD.putData("editor", MWF.editorData);
}, },
getFormToolbarHTML: function(callback){ getFormToolbarHTML: function(callback){
var toolbarUrl = this.path+this.options.style+"/toolbars.html"; var toolbarUrl = this.path+this.options.style+"/toolbars.html";
......
var resources = {
"getEntityManagerContainer": function(){ return {}; },
"getContext": function(){ return {}; },
"getApplications": function(){ return {}; },
"getOrganization": function(){
return {
group: function(){ return {}; },
identity: function(){ return {}; },
person: function(){ return {}; },
personAttribute: function(){ return {}; },
role: function(){ return {}; },
unit: function(){ return {}; },
unitAttribute: function(){ return {}; },
unitDuty: function(){ return {}; }
};
},
"getWebservicesClient": function(){ return {}; }
};
var effectivePerson = this.effectivePerson = {};
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册