refactor plugin

This commit is contained in:
fanfuxiaoran 2014-03-24 17:59:06 +08:00
parent 03601007eb
commit c4bae962ab
17 changed files with 238 additions and 256 deletions

View File

@ -5,11 +5,9 @@ import javax.xml.bind.JAXBException;
import org.apache.log4j.Logger;
import org.bench4q.share.helper.ExceptionLog;
import org.bench4q.web.model.BaseResponseModel;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
@ControllerAdvice
public class GlobalExceptionController {

View File

@ -37,12 +37,12 @@ display:none;
padding-right:5px;
}
.div-left{
.left{
float:left;
}
.div-right{
.right{
float:right;
}

View File

@ -1,76 +1,73 @@
.inset{
width:85% ;
height:80%;
align:center;
.inset {
width: 85%;
height: 80%;
align: center;
margin: 5px;
}
.scroll{
.scroll {
overflow-x: hidden;
overflow-y: auto;
overflow-y: auto;
}
a:hover {
color:#ECE9D8;
color: #ECE9D8;
}
.button-div {
margin-top: 50px;
padding-left: 20px;
}
.button-div div {
margin-top: 10px;
}
.behavior_box {
border: 1px inset;
width: 200px;
height: 300px;
margin-right: 0px;
margin-left: 0px;
}
.sample_frame {
margin-bottom: 0px;
border: #3689BB solid thin;
}
.sample_sub_frame {
border: #F0ECE0 solid thin;
margin-top: 5px;
margin-bottom: 5px;
margin-left: 10px;
margin-right: 10px;
}
.listArea {
height: 340px;
margin-bottom: 15px;
outline-style: outset;
color: black;
}
.behavior-box {
height: 400px;
border: solid 1px black;
margin-left: 5px;
}
.behavior_box{
border:1px inset;
width:200px;
height:300px;
margin-right:0px;
margin-left:0px;
#myModal_Behavior {
width: 800px;
left:40%;
}
.sample_frame{
margin-bottom:0px;
border:#3689BB solid thin;
}
.sample_sub_frame{
border:#F0ECE0 solid thin;
margin-top:5px;
margin-bottom:5px;
margin-left:10px;
margin-right:10px;
}
table, th, td,thead,tbody
{
border: 1px solid #FFE37E;
width:40px;
height:18px;
.listArea,#insertPluginAreaPlugins,#pluginMethod p,a {
padding-top: 10px;
padding-left: 20px;
}
#pluginArea{
width:280px;
height:340px;
margin-bottom:15px;
outline-style: outset;
}
#behaviorArea{
width:280px;
height:340px;
margin-bottom:15px;
outline-style: inset;
}
.behavior-box{
width:180px;
height:200px;
border:solid thin #F0ECE0;
margin-left:5px;
outline-style:inset;
}
.pluginChoosedList{
border-bottom:1px solid #F0ECE0 ;
color: #4E9BCB ;
width:220px;
height:32px;
p,a{
color: #4E9BCB;
border-bottom: 1px solid #F0ECE0;
}

View File

@ -1 +0,0 @@
/Thumbs.db

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

View File

@ -37,7 +37,7 @@ body {
<link href='css/uploadify.css' rel='stylesheet'>
<link href='css/buttons.css' rel='stylesheet'>
<link href='bench4q-css/plugin.css' rel='stylesheet'>
<link href='bench4q-css/bench4q.css' rel='stylesheet'>
<!-- The HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
@ -84,158 +84,138 @@ body {
</div>
<div class="row-fluid sortable">
<div class="box span5">
<div>
<div class="box-header well" data-original-title>
<i class="icon-pencil" style="float: left;"></i>
<h2>
<span>Plug-ins</span>
</h2>
<div class="box-icon">
<a href="#" class="btn btn-setting btn-round"><i
class="icon-plus"></i></a> <a href="#" class="btn btn-round"><i
class="icon-list"></i></a> <a href="#"
class="btn btn-minimize btn-round"><i
class="icon-chevron-up"></i></a>
</div>
<div class="box span6">
<div class="box-header well" data-original-title>
<i class="icon-pencil left"></i>
<h2>
<span>Plug-ins</span>
</h2>
<div class="box-icon">
<a href="#" class="btn btn-setting btn-round"><i
class="icon-plus"></i></a> <a href="#" class="btn btn-round"><i
class="icon-list"></i></a> <a href="#"
class="btn btn-minimize btn-round"><i
class="icon-chevron-up"></i></a>
</div>
<div class="box-content">
<div class="operatePlugins center">
<div class="span8" style="float: left;">
<div id="pluginArea"></div>
</div>
<div class="pluginButton">
<p>
<button type="submit" class="btn btn-inverse" id="addPlugin"
onClick="addPlugin();">Add</button>
</p>
</div>
<div class="box-content row-fluid">
<p>
<button type="submit" class="btn btn-inverse"
id="removePlugin" onClick="removePlugin();">Remove</button>
</p>
<p>
<button type="submit" class="btn btn-inverse"
id="removeAllPlugin" onClick="#">Remove all</button>
</p>
</div>
<div id="pluginArea" class="listArea span9"></div>
<div class=" span3 button-div">
<div>
<button type="submit" class="btn btn-inverse" id="addPlugin"
onClick="addPlugin();">Add</button>
</div>
<div>
<button type="submit" class="btn btn-inverse"
id="removePlugin" onClick="removePlugin();">Remove</button>
</div>
<div>
<button type="submit" class="btn btn-inverse"
id="removeAllPlugin" onClick="#">Remove all</button>
</div>
</div>
</div>
</div>
<!--/span-->
<!-- Behavior start -->
<div class="box span5" style="float: left;">
<div>
<div class="box-header well" data-original-title>
<i class="icon-pencil" style="float: left;"></i>
<h2>
<i></i> Behavior
</h2>
<div class="box-icon">
<a href="#" class="btn btn-setting btn-round"><i
class="icon-plus"></i></a> <a href="#" class="btn btn-round"><i
class="icon-list"></i></a> <a href="#"
class="btn btn-minimize btn-round"><i
class="icon-chevron-up"></i></a>
</div>
</div>
<div class="box-content">
<div class="operatePlugins center">
<div class="span8 behavior" style="float: left;">
<div id="behaviorArea">
</div>
</div>
<div class="behaviorButton">
<p>
<button type="submit" class="btn btn-inverse"
id="insertBehavior_Plugin" onClick="insertPlugin();">Insert</button>
</p>
<p>
<button type="submit" class="btn btn-inverse"
id="removeBehavior_Plugin" onClick="removeInsertPlugin();">Remove</button>
</p>
</div>
</div>
<div class="box span6">
<div class="box-header well" data-original-title>
<i class="icon-pencil left"></i>
<h2>
<i></i> Behavior
</h2>
<div class="box-icon">
<a href="#" class="btn btn-setting btn-round"><i
class="icon-plus"></i></a> <a href="#" class="btn btn-round"><i
class="icon-list"></i></a> <a href="#"
class="btn btn-minimize btn-round"><i
class="icon-chevron-up"></i></a>
</div>
</div>
</div>
<div class="box-content row-fluid">
<div id="behaviorArea" class="listArea span9"></div>
<div class="span3 button-div">
<div>
<button type="submit" class="btn btn-inverse"
id="insertBehavior_Plugin" onClick="insertPlugin();">Insert</button>
</div>
<div>
<button type="submit" class="btn btn-inverse"
id="removeBehavior_Plugin" onClick="removeInsertPlugin();">Remove</button>
</div>
</div>
</div>
</div>
<div id="showPluginMethod" class="showPluginMethod">
<!-- 显示方法文档,开始动态生成 ,只显示一个-->
</div>
</div>
<!--/row-->
<!-- content ends -->
</div>
<!--/row-->
<!-- content ends -->
<!--/#content.span10-->
</div>
<!--/#content.span10-->
</div>
<hr>
<div class="modal hide fade span4" id="myModal_Plugin">
<div class="modal-header">
<button type="button" id="myModal-close" class="close"
data-dismiss="modal">×</button>
<h3>Add a new plug-in</h3>
</div>
<div class="modal-body" style="height: 260px;">
<div class="inset scroll" id="choosePlugin">
<!-- 显示plugin列表 -->
<hr>
<div class="modal hide fade " id="myModal_Plugin">
<div class="modal-header">
<button type="button" id="myModal-close" class="close"
data-dismiss="modal">×</button>
<h3>Add a new plug-in</h3>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-inverse"
onClick="pluginFinish();" id="pluginFinish">Finish</button>
<button type="button" class="btn btn-inverse"
onClick="pluginCancel();" id="pluginCancel">Cancel</button>
</div>
</div>
<div class="modal hide fade span6" id="myModal_Behavior">
<div class="modal-header">
<button type="button" id="myModal-close" class="close"
data-dismiss="modal">×</button>
<h3>Choose the behaviors of plug-in.</h3>
</div>
<div class="modal-body" style="height: 320px;">
<div class="inset span4 center">
<div class="span2 behavior-box scroll"
style="height: 200px; width: 220px;">
<div id="pluginMethod"></div>
<div class="modal-body" style="height: 260px;">
<div class="inset scroll" id="choosePlugin">
<!-- 显示plugin列表 -->
</div>
<div class="span2 behavior-box scroll"
style="height: 200px; width: 220px;">
<div id="insertPluginAreaPlugins">
<!-- 显示上个modal中的内容 -->
</div>
<div class="modal-footer">
<button type="button" class="btn btn-inverse"
onClick="pluginFinish();" id="pluginFinish">Finish</button>
<button type="button" class="btn btn-inverse"
onClick="pluginCancel();" id="pluginCancel">Cancel</button>
</div>
</div>
<div class="modal hide fade " id="myModal_Behavior">
<div class="modal-header">
<button type="button" id="myModal-close" class="close"
data-dismiss="modal">×</button>
<h3>Choose the behaviors of plug-in.</h3>
</div>
<div class="modal-body"">
<div class="row-fluid">
<div class="span6 behavior-box scroll" >
<div id="insertPluginAreaPlugins"></div>
</div>
<div class="span6 behavior-box scroll">
<div id="pluginMethod"></div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<div class="modal-footer">
<button type="button" class="btn btn-inverse"
onClick="behaviorFinish();" id="behaviorFinish">Finish</button>
<button type="button" class="btn btn-inverse" onClick="#"
id="behaviorCancel">Cancel</button>
<button type="button" class="btn btn-inverse"
onClick="behaviorFinish();" id="behaviorFinish">Finish</button>
<button type="button" class="btn btn-inverse" onClick="#"
id="behaviorCancel">Cancel</button>
</div>
</div>
<jsp:include page="publiccontrol/footer.jsp"></jsp:include>
</div>
<jsp:include page="publiccontrol/footer.jsp"></jsp:include>
<!--/.fluid-container-->

View File

@ -1,9 +1,11 @@
PluginMethodListModel = function(pluginName, methodList) {
var PluginMethodListModel = function(pluginName, methodList) {
this.pluginName = pluginName;
this.methodList = methodList;
};
var pluginChoosedList = new Array();
var num = 0;
var pluginList = new Array();
var pluginMethodList = new Array();
// var pluginMethodList = new Array();
var index = 0;
$(document).ready(function() {
loadPluginList();
@ -16,7 +18,7 @@ function loadPluginList() {
return;
}
data = data.data;// List<String> pluginList
for (var i = 0; i < data.length; i++) {
for ( var i = 0; i < data.length; i++) {
pluginList.push(data[i]);
}
});
@ -32,7 +34,7 @@ function getMethod(pluglin) {
return;
}
data = data.data;// List<String> methodList
for (var i = 0; i < data.length; i++) {
for ( var i = 0; i < data.length; i++) {
aMethodList.push(data[i]);
}
});
@ -41,51 +43,53 @@ function getMethod(pluglin) {
function addPlugin() {
var html = "";
for (var j = 0; j < pluginList.length; j++) {
var textNode = document.createTextNode(pluginList[j]);
var divNode = document.createElement("div");
var inputNode = document.createElement("input");
var brNode = document.createElement("br");
inputNode.setAttribute("type", "radio");
inputNode.setAttribute("name", "radio");
inputNode.setAttribute("class", "chooseOnePlugin");
inputNode.setAttribute("value", pluginList[j]);
divNode.appendChild(inputNode);
divNode.appendChild(textNode);
divNode.appendChild(brNode);
html += $(divNode).html() + "<br>";
for ( var j = 0; j < pluginList.length; j++) {
html += createLineWithRadio(pluginList[j],"plugin");
}
document.getElementById("choosePlugin").innerHTML = html;
$('#choosePlugin').html(html);
$('#myModal_Plugin').modal('show');
$("input:radio").click(function() {
$(this).attr("checked", "checked");
});
}
function createLineWithRadio(lineText,nameAttr) {
var textNode = document.createTextNode(lineText);
var divNode = document.createElement("div");
var inputNode = document.createElement("input");
var brNode = document.createElement("br");
inputNode.setAttribute("type", "radio");
inputNode.setAttribute("name", nameAttr);
inputNode.setAttribute("class", "chooseOnePlugin");
inputNode.setAttribute("value", lineText);
divNode.appendChild(inputNode);
divNode.appendChild(textNode);
divNode.appendChild(brNode);
return $(divNode).html() + "<br>";
}
// 选中的plug-in list
var pluginChoosedList = new Array();
var num = 0;
function pluginFinish() {
$('#myModal_Plugin').modal('hide');
var data;
var item = $("input[name='radio']:checked").val();
data = item + "_" + num;
pluginChoosedList.push(data);
var pluginName;
var item = $("input[type='radio']:checked").val();
pluginName = item + "_" + num;
pluginChoosedList.push(pluginName);
num++;
document.getElementById("pluginArea").innerHTML += createLine(pluginName);
}
function createLine(pluginName) {
var div = document.createElement("div");
var p = document.createElement("p");
var textNode = document.createTextNode(data);
p.setAttribute("class", "pluginChoosedList");// 样式设计
var textNode = document.createTextNode(pluginName);
p.setAttribute("onClick", "showInsertPlugin(this)");// 引入的plugin
p.setAttribute("style", "cursor:pointer;float:left;");
p.appendChild(textNode);
div.appendChild(p);
document.getElementById("pluginArea").innerHTML += $(div).html();
return $(div).html();
}
function removePlugin() {
pluginChoosedList.pop();
var last = document.getElementById("pluginArea").lastChild;
@ -95,15 +99,15 @@ function removePlugin() {
function insertPlugin() {
document.getElementById("pluginMethod").innerHTML = "";
$('#myModal_Behavior').modal('show');
var table = $('#pluginArea').html();
document.getElementById("insertPluginAreaPlugins").innerHTML = table;
var chooesedPluginHtml = "";
for ( var i = 0; i < pluginChoosedList.length; i++) {
chooesedPluginHtml += createLineWithRadio(pluginChoosedList[i],"plugin");
}
$("#insertPluginAreaPlugins").html(chooesedPluginHtml);
}
function showInsertPlugin(selectNode) {
$('#behaviorFinish').attr('disabled', true);
var textNode = selectNode.firstChild;
var methodData = textNode.nodeValue;
getMethodList(methodData);
function showInsertPlugin(pluginName) {
getMethodList(pluginName);
}
function removeInsertPlugin() {
@ -116,7 +120,6 @@ function getMethodList(methodData) {
var methodList = new Array();
// plug-in.method列表
var plugin_method_List = new Array();
var plugin_method_List_count = 0;
// 得到_前的内容
var type = methodData.split("_");
@ -130,26 +133,31 @@ function getMethodList(methodData) {
return;
}
data = data.data;// List<String> methodList
for (var i = 0; i < data.length; i++) {
for ( var i = 0; i < data.length; i++) {
plugin_method_List.push(methodData + "." + data[i]);// httpPlugin_0.post
plugin_method_List_count++;
methodList.push(data[i]);
methodHtml += createLineWithRadio(methodList[i],"method");
}
for (var j = 0; j < methodList.length; j++) {
var hideTextNode = document.createTextNode(plugin_method_List
.valueOf(j));
var hideNode = document.createElement("p");
hideNode.setAttribute("class", "hide");
hideNode.appendChild(hideTextNode);
methodHtml += "<div id='" + plugin_method_List.valueOf(j)
+ "'><a style='cursor: pointer;' onClick='show(this);'>"
+ methodList[j] + "</a><p class='hide'>"
+ plugin_method_List.valueOf(j) + "</div>";
}
// for ( var j = 0; j < methodList.length; j++) {
// var hideTextNode = document.createTextNode(plugin_method_List
// .valueOf(j));
// var hideNode = document.createElement("p");
// hideNode.setAttribute("class", "hide");
// hideNode.appendChild(hideTextNode);
//
// methodHtml += "<div id='" + plugin_method_List.valueOf(j)
// + "'><a style='cursor: pointer;' onClick='show(this);'>"
// + methodList[j] + "</a><p class='hide'>"
// + plugin_method_List.valueOf(j) + "</div>";
// }
document.getElementById("pluginMethod").innerHTML = methodHtml;
});
}
$('#insertPluginAreaPlugins').click(function() {
var item = $("input[type='radio']:checked").val();
showInsertPlugin(item);
});
function show(selectedNode) {
var node = selectedNode.nextSibling.firstChild;
var behaviorData = node.nodeValue;
@ -177,7 +185,7 @@ function showMethodDocument(selectedNode) {
var div = $("#showPluginMethod").children();
$(div[behaviorIndex]).attr("class", "show");
$(div[behaviorIndex]).show();
for (var i = 0; i < length; i++) {
for ( var i = 0; i < length; i++) {
if (div[i].getAttribute("id") != behaviorIndex) {
$(div[i]).hide();
}
@ -206,10 +214,10 @@ function loadMethodParams(behaviorData, behaviorIndex) {
return;
}
data = data.data;
for (var i = 0; i < data.length; i++) {
for ( var i = 0; i < data.length; i++) {
methodParams.push(data[i]);
}
for (var j = 0; j < methodParams.length; j++) {
for ( var j = 0; j < methodParams.length; j++) {
var methodParamModel = new MethodParamModel(
methodParams[j].name,
methodParams[j].lable,
@ -218,7 +226,7 @@ function loadMethodParams(behaviorData, behaviorIndex) {
methodParams[j].paramType,
methodParams[j].methodParamProperties);
var methodParamProperties = new Array();
for (var q = 0; q < methodParamModel.methodParamProperties.length; q++) {
for ( var q = 0; q < methodParamModel.methodParamProperties.length; q++) {
var methodParamPropertyModel = new MethodParamPropertyModel(
methodParamModel.methodParamProperties[q].key,
methodParamModel.methodParamProperties[q].value);
@ -227,7 +235,7 @@ function loadMethodParams(behaviorData, behaviorIndex) {
}
var type = methodParamModel.paramType;
var size = 0, cols = "", rows = "";
for (var p = 0; p < methodParamProperties.length; p++) {
for ( var p = 0; p < methodParamProperties.length; p++) {
var methodParamProertyModel = methodParamProperties[p];
if (methodParamProertyModel.key == "size") {
size = methodParamProertyModel.value;
@ -400,7 +408,7 @@ function createTable(methodParamModel, cols, behaviorIndex) {
var table_content = cols.split(valueSeperator);
// 创建Table head
var tr = document.createElement("tr");
for (var i = 0; i < table_content.length; i++) {
for ( var i = 0; i < table_content.length; i++) {
var th = document.createElement("th");
var text = document.createTextNode(table_content[i]);
th.appendChild(text);
@ -408,7 +416,7 @@ function createTable(methodParamModel, cols, behaviorIndex) {
}
// 创建一行
var tr_content = document.createElement("tr");
for (var j = 0; j < table_content.length; j++) {
for ( var j = 0; j < table_content.length; j++) {
var td_content = document.createElement("td");
var text_content = document.createElement("input");
text_content.setAttribute("type", "text");
@ -464,7 +472,7 @@ function addCol(selectedNode) {
var tbody = selectedNode.nextSibling.nextSibling.nextSibling.lastChild;
var length = tbody.previousSibling.firstChild.childNodes.length;
var tr = document.createElement("tr");
for (var i = 0; i < length; i++) {
for ( var i = 0; i < length; i++) {
var td = document.createElement("td");
var input = document.createElement("input");
td.appendChild(input);
@ -499,7 +507,7 @@ function createCheckBox(methodParamModel, rows, behaviorIndex) {
div.setAttribute("class", "sample_sub_frame");
p.appendChild(labelNode);
for (var i = 0; i < cb_content.length; i++) {
for ( var i = 0; i < cb_content.length; i++) {
var checkBoxNode = document.createElement("input");
var brInput = document.createElement("br");
checkBoxNode.setAttribute("type", "checkbox");
@ -547,7 +555,7 @@ function uploadBehavior(selectedNode) {
var tableList = "";
var checkList = "";
for (var i = 0; i < length; i++) {
for ( var i = 0; i < length; i++) {
var node = div[i];
alert("node=" + $(node).attr("class"));
if ($(node).attr("class") == "Field sample_frame") {
@ -555,7 +563,7 @@ function uploadBehavior(selectedNode) {
} else if ($(node).attr("class") == "MultiField sample_frame") {
var fieldNode = $(node).find("table").children();
var fieldLength = $(fieldNode).length;
for (var j = 0; j < fieldLength; j++) {
for ( var j = 0; j < fieldLength; j++) {
multiFieldList += $(fieldNode[j]).find("input").val() + ",";
}
} else if ($(node).attr("class") == "Table sample_frame") {
@ -564,8 +572,8 @@ function uploadBehavior(selectedNode) {
var row = table.find("tbody").children().length;
alert("col=" + col + ",row=" + row);
var tbody = $(node).find("tbody");
for (var m = 0; m < row; m++) {
for (var n = 0; n < col; n++) {
for ( var m = 0; m < row; m++) {
for ( var n = 0; n < col; n++) {
var rowNode = $(tbody).children()[m];
var colNode = $(rowNode).children()[n];
var value = $(colNode).find("input").val();