code.jsp
4.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<%@ page import="com.api.integration.util.FileUtil" %>
<%@ page import="com.api.integration.util.JavaCompiler" %>
<%@ page import="weaver.interfaces.workflow.action.jc.util.FileHelper" %>
<%@ page import="java.io.File" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%--
Created by IntelliJ IDEA.
User: SJZ
Date: 2017/11/16
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ include file="/systeminfo/init_wev8.jsp" %>
<%@ taglib uri="/WEB-INF/weaver.tld" prefix="wea" %>
<%
String fileName = Util.null2String(request.getParameter("fileName"));
String resid = Util.null2String(request.getParameter("resid"));
String javacode = null;
if (!fileName.isEmpty() && !resid.isEmpty()) {
String filePath = JavaCompiler.getJavaSrcPath(resid,fileName);
File file = new File(filePath);
if(file.isFile()) {
javacode = FileUtil.read(filePath);
}
}
if(javacode == null){
//加载action模板
String filepath = GCONST.getRootPath() + "/integration/resource/template/EsbOnline.tpl";
String name = new SimpleDateFormat("yyyyMMddhhmmss").format(new Date());
javacode = FileHelper.loadFile(filepath, "UTF-8");
javacode = javacode.replace("$packageName", "package_" + name);
javacode = javacode.replace("$className", "class_" + name);
}
%>
<html>
<script src="/integration/js/codemirror/lib/codemirror_wev8.js"></script>
<script src="/integration/js/codemirror/mode/clike/clike_wev8.js"></script>
<link rel="stylesheet" href="/integration/js/codemirror/lib/codemirror_wev8.css"/>
<link rel="stylesheet" href="/integration/js/codemirror/theme/eclipse_wev8.css"/>
<body>
<div class="zDialog_div_content" style="height:580px;overflow-y:auto;">
<FORM id="addFrmMain" name="addFrmMain" method=post>
<input type="hidden" name="fileName" value="<%=fileName%>">
<input type="hidden" name="resid" value="<%=resid%>">
<wea:layout>
<wea:group context='JavaCode'
attributes="{'samePair':'SetInfo','groupOperDisplay':'none','itemAreaDisplay':'block'}">
<wea:item attributes="{'colspan':'2','isTableList':'true'}">
<div>
<textarea id="javaCode" name="javaCode"><%=javacode %></textarea>
</div>
</wea:item>
</wea:group>
</wea:layout>
</FORM>
</div>
</body>
</html>
<script language="javascript">
var editor;
jQuery(document).ready(function () {
editor = CodeMirror.fromTextArea(document.getElementById("javaCode"), {
lineNumbers: true,
theme: "eclipse",
indentUnit: 4,
mode: "text/x-java"
});
});
function forbiddenPage() {
$("<div class=\"datagrid-mask\" style=\"position:fixed;z-index:2;opacity:0.4;filter:alpha(opacity=40);BACKGROUND-COLOR:#fff;\"></div>").css({
display: "block",
width: "100%",
height: "100%",
top: 0,
left: 0
}).appendTo("body");
$("<div class=\"datagrid-mask-msg\" style=\"background:#fff;position:fixed;z-index:3;padding: 10px;padding-top: 6px;padding-bottom: 6px;border: 1px solid;\"></div>").html("<%=SystemEnv.getHtmlLabelName(25666,user.getLanguage())%>").appendTo("body").css({
display: "block",
left: ($(document.body).outerWidth(true) - 190) / 2,
top: ($(window).height() - 45) / 2
});
}
function releasePage() {
$(".datagrid-mask,.datagrid-mask-msg").hide();
}
/**
* 表单数据提交
*/
function submitData(diag, func) {
forbiddenPage();
try {
var url = "/api/integration/esb/service/compile";
$("#javaCode").text(editor.getValue());
$.ajax({
type: "post",
url: url,
data: $("#addFrmMain").serialize(),
success: function (data) {
data = jQuery.parseJSON(data);
//code == 100表示保存成功,其它都是失败。
if ("100" == data.code) {
func(data["data"]);
releasePage();
if (diag) {
diag.close();
}
} else {
if(data["description"]){
top.Dialog.alert(data.description, releasePage, 500, 300);
} else {
top.Dialog.alert("<%=SystemEnv.getHtmlLabelName(132169,user.getLanguage())%>");
}
}
},
error: function (jqXHR) {
top.Dialog.alert(jqXHR.statusText, releasePage);
}
});
} catch (e) {
console.log(e);
}
}
</script>