Skip to content

Commit

Permalink
Merge pull request #7 from ikedam/feature/JENKINS-23561_UseOwnTaglib
Browse files Browse the repository at this point in the history
[JENKINS-23561] [JENKINS-23030] Use customized matrix tag
  • Loading branch information
ikedam committed Jul 5, 2014
2 parents 5d9b818 + a3b2e3d commit 60e111a
Show file tree
Hide file tree
Showing 9 changed files with 698 additions and 108 deletions.
Expand Up @@ -13,7 +13,7 @@ l = namespace(LayoutTagLib)
t = namespace("/lib/hudson")
st = namespace("jelly:stapler")
f = namespace("lib/form")
nsProject = namespace("/lib/hudson/project")
nsProject = namespace("/hudson/plugins/matrix_configuration_parameter/taglib")


MatrixProject project = request.findAncestorObject(MatrixProject.class);
Expand All @@ -23,7 +23,7 @@ if (project == null) //in case project is not a Matrix Project
AxisList axes = project.getAxes();
def paramDef = it;
String nameIt = it.getName();
Layouter layouter = axes == null ? null : new Layouter<Combination>(axes) {
Layouter layouter = new Layouter<Combination>(axes) {
protected Combination getT(Combination c) {
return c;
}
Expand All @@ -43,14 +43,14 @@ private void drawMainBody(MatrixCombinationsParameterDefinition paramDef, Namesp
f.entry(title: nameIt, description: it.getDescription()) {
div(name: "parameter") {
input(type: "hidden", name: "name", value: nameIt)
nsProject.matrix(it: project) {
drawMainBall(paramDef, p.combination, project.axes, nameIt, project, layouter);
nsProject.matrix(it: project, layouter: layouter) {
drawMainBall(paramDef, p, project.axes, nameIt, project, layouter);
}
raw("<span style=\"font-weight:bold\">Select: </span> \n" +
"<a href=\"#\" onclick=\"click2Change(0);\">Successful</a> - \n" +
"<a href=\"#\" onclick=\"click2Change(2);\">Failed</a> - \n" +
"<a href=\"#\" onclick=\"click2Change(1000);\">All</a> - \n" +
"<a href=\"#\" onclick=\"click2Change(-1);\">None</a>")
"<a id=\"shortcut-" + nameIt + "-successful\" href=\"#\" onclick=\"click2Change(0);\">Successful</a> - \n" +
"<a id=\"shortcut-" + nameIt + "-failed\" href=\"#\" onclick=\"click2Change(2);\">Failed</a> - \n" +
"<a id=\"shortcut-" + nameIt + "-all\" href=\"#\" onclick=\"click2Change(1000);\">All</a> - \n" +
"<a id=\"shortcut-" + nameIt + "-none\" href=\"#\" onclick=\"click2Change(-1);\">None</a>")

}//div
}
Expand All @@ -64,7 +64,7 @@ private void drawMainLinksJS(String nameIt) {
"for( i = 0, len = document.parameters.elements.length ; i < len ; i++ )\n" +
"{\n" +
"var element = document.parameters.elements[i];\n" +
"if( element.type == 'checkbox' && element.id == \"checkbox" + nameIt + "\" )\n" +
"if( element.type == 'checkbox' && element.id.lastIndexOf(\"checkbox" + nameIt + "-\", 0) == 0 )\n" +
"{\n" +
"if( element.value == status || status > 999 )\n" +

Expand Down Expand Up @@ -95,7 +95,7 @@ private void drawMainBall(MatrixCombinationsParameterDefinition paramDef, Combin
}
}
checked = combination.evalGroovyExpression(axes, paramDef.defaultCombinationFilter?:project.combinationFilter)
f.checkbox(checked: checked, name: "values",id: "checkbox"+matrixName)
f.checkbox(checked: checked, name: "values",id: String.format("checkbox%s-%s", matrixName, combination.toString('-' as char, '-' as char)))
input(type: "hidden", name: "confs", value: combination.toString())

}
Expand All @@ -107,7 +107,7 @@ private void drawMainBall(MatrixCombinationsParameterDefinition paramDef, Combin
}

checked = combination.evalGroovyExpression(axes, paramDef.defaultCombinationFilter?:project.combinationFilter)
f.checkbox(checked: checked, name: "values",id: "checkbox"+matrixName, value: combination.toIndex((AxisList) axes))
f.checkbox(checked: checked, name: "values",id: String.format("checkbox%s-%s", matrixName, combination.toString('-' as char, '-' as char)), value: combination.toIndex((AxisList) axes))
input(type: "hidden", name: "confs", value: combination.toString())
}

Expand Down
Expand Up @@ -2,6 +2,7 @@ package hudson.plugins.matrix_configuration_parameter.MatrixCombinationsParamete


import hudson.matrix.AxisList
import hudson.matrix.Combination
import hudson.matrix.Layouter
import hudson.matrix.MatrixBuild
import hudson.matrix.MatrixProject
Expand All @@ -12,7 +13,7 @@ l = namespace(LayoutTagLib)
t = namespace("/lib/hudson")
st = namespace("jelly:stapler")
f = namespace("lib/form")
nsProject = namespace("/lib/hudson/project")
nsProject = namespace("/hudson/plugins/matrix_configuration_parameter/taglib")


MatrixProject project = request.findAncestorObject(MatrixProject.class);
Expand All @@ -21,47 +22,47 @@ MatrixBuild build = request.findAncestorObject(MatrixBuild.class);
if (build == null) //in case you are looking at a specific run, MatrixRun Ancestor will replace the MatrixBuild
return;
def valueIt = it;
Layouter layouter = build.getLayouter();
if (layouter==null)
return;

drawParameterBody(f, valueIt, axes, project, layouter);
Layouter layouter = new Layouter<Combination>(axes) {
protected Combination getT(Combination c) {
return c;
}
};

drawParameterBody(f, valueIt, axes, project, build, layouter);


private void drawParameterBody(Namespace f,valueIt,AxisList axes,MatrixProject project,Layouter layouter) {
h2() { raw("Matrix Combinations") }

private void drawParameterBody(Namespace f,valueIt,AxisList axes,MatrixProject project,MatrixBuild build,Layouter layouter) {
f.entry(title: valueIt.getName(), description: it.getDescription()) {
div(name: "parameter") {
input(type: "hidden", name: "name", value: valueIt.getName())
nsProject.matrix(it: build) {
drawTableBall(p, project.axes, valueIt, project, layouter);
nsProject.matrix(it: build, layouter: layouter) {
drawTableBall(p, project.axes, valueIt, project, build, layouter);
}
}//div
}
}

private void drawTableBall(MatrixBuild.RunPtr runPtr,AxisList axes,matrixValue,MatrixProject project,Layouter layouter) {
private void drawTableBall(Combination combination,AxisList axes,matrixValue,MatrixProject project,MatrixBuild build,Layouter layouter) {

run = runPtr.getRun();
result = matrixValue.combinationExists(axes, runPtr.combination);
if (result){
run = build.getRun(combination);
result = matrixValue.combinationExists(axes, combination);
if (run != null && result){
a(href:rootURL+"/"+run.getUrl()){
img(src: "${imagesURL}/24x24/"+run.getBuildStatusUrl());
if (!layouter.x || !layouter.y) {
text(runPtr.combination.toString(layouter.z))
text(combination.toString(layouter.z))
}
}
f.checkbox(checked: "true", name: "values",id: "checkbox"+matrixValue.getName());
input(type: "hidden", name: "confs", value: runPtr.combination.toString());
f.checkbox(checked: "true", name: "values",id: String.format("checkbox%s-%s", matrixValue.getName(), combination.toString('-' as char, '-' as char)));
input(type: "hidden", name: "confs", value: combination.toString());

} else {
img(src: "${imagesURL}/24x24/grey.gif");
if (!layouter.x || !layouter.y) {
text(runPtr.combination.toString(layouter.z))
text(combination.toString(layouter.z))
}
f.checkbox(checked: "false", name: "values",id: "checkbox"+matrixValue.getName());
input(type: "hidden", name: "confs", value: runPtr.combination.toString());
f.checkbox(checked: "false", name: "values",id: String.format("checkbox%s-%s", matrixValue.getName(), combination.toString('-' as char, '-' as char)));
input(type: "hidden", name: "confs", value: combination.toString());
}
}
Expand Up @@ -13,101 +13,55 @@ l = namespace(LayoutTagLib)
t = namespace("/lib/hudson")
st = namespace("jelly:stapler")
f = namespace("lib/form")
nsProject = namespace("/hudson/plugins/matrix_configuration_parameter/taglib")

MatrixProject project = request.findAncestorObject(MatrixProject.class);
AxisList axes = project.getAxes();
MatrixBuild build = request.findAncestorObject(MatrixBuild.class);
if (build == null) //in case you are looking at a specific run, MatrixRun Ancestor will replace the MatrixBuild
return;
MatrixCombinationsParameterValue valueIt = it;
Layouter layouter = build.getLayouter();
if (layouter==null)
return;

drawParameterBody(f, valueIt, axes, project, layouter);
Layouter layouter = new Layouter<Combination>(axes) {
protected Combination getT(Combination c) {
return c;
}
};

drawParameterBody(f, valueIt, axes, project, build, layouter);


private void drawParameterBody(Namespace f,MatrixCombinationsParameterValue valueIt,AxisList axes,MatrixProject project,Layouter layouter) {
h2() { raw("Matrix Combinations") }

private void drawParameterBody(Namespace f,MatrixCombinationsParameterValue valueIt,AxisList axes,MatrixProject project,MatrixBuild build,Layouter layouter) {
f.entry(title: valueIt.getName(), description: it.getDescription()) {
div(name: "parameter") {
input(type: "hidden", name: "name", value: valueIt.getName())
table(border: "1", class: "middle-align center-align", id: "configuration-matrix") {

drawTableHeader(layouter);

drawTableBody(layouter, axes, valueIt, project);


}//table
}//div
}
}

private void drawTableBody(Layouter layouter,AxisList axes,MatrixCombinationsParameterValue valueIt,MatrixProject project) {
for (row in layouter.rows) {
tr() {
int i = 0;
for (y in layouter.y) {
if (row.drawYHeader(i) != null) {
td(rowspan: layouter.height(i), class: "matrix-leftcolumn") { raw(row.drawYHeader(i)) }

}

i++;
nsProject.matrix(it: build, layouter: layouter) {
drawTableBall(p, project.axes, valueIt, project, build, layouter);
}
for (c in row) {
td() {
for (p in c) {
div() {
drawTableBall(p, axes, valueIt, project);
}


}


}

}
}
}//div
}
}

private void drawTableHeader(Layouter layouter) {
int i = 0;
for (x in layouter.x) {
tr(class: "matrix-row") {
if (!layouter.y.isEmpty()) {
td(colspan: +layouter.y.size(), id: "matrix-title") { raw("Configuration Matrix") }
}
for (row in 1..layouter.repeatX(i)) {
for (axis in x.values) {
td(class: "matrix-header", colspan: layouter.width(i)) { raw(axis) }
}
}
}
i++;
}

}//entry

private void drawTableBall(MatrixBuild.RunPtr runPtr,AxisList axes,MatrixCombinationsParameterValue matrixValue,MatrixProject project) {
private void drawTableBall(Combination combination,AxisList axes,MatrixCombinationsParameterValue matrixValue,MatrixProject project,MatrixBuild build,Layouter layouter) {

run = runPtr.getRun();
result = matrixValue.combinationExists(axes, runPtr.combination);
if (result){
run = build.getRun(combination);
result = matrixValue.combinationExists(axes, combination);
if (run != null && result){
a(href:rootURL+"/"+run.getUrl()){
img(src: "${imagesURL}/24x24/"+run.getBuildStatusUrl());
f.checkbox(checked: "true",onclick:"return false;", onkeydown:"return false;", name: "values",id: "checkbox"+matrixValue.getName());
input(type: "hidden", name: "confs", value: runPtr.combination.toString());
if (!layouter.x || !layouter.y) {
text(combination.toString(layouter.z))
}
f.checkbox(checked: "true",onclick:"return false;", onkeydown:"return false;", name: "values",id: String.format("checkbox%s-%s", matrixValue.getName(), combination.toString('-' as char, '-' as char)));
input(type: "hidden", name: "confs", value: combination.toString());
}

} else {
img(src: "${imagesURL}/24x24/grey.gif");
f.checkbox(checked: "false",onclick:"return false;", onkeydown:"return false;", name: "values",id: "checkbox"+matrixValue.getName());
input(type: "hidden", name: "confs", value: runPtr.combination.toString());
if (!layouter.x || !layouter.y) {
text(combination.toString(layouter.z))
}
f.checkbox(checked: "false",onclick:"return false;", onkeydown:"return false;", name: "values",id: String.format("checkbox%s-%s", matrixValue.getName(), combination.toString('-' as char, '-' as char)));
input(type: "hidden", name: "confs", value: combination.toString());
}
}
@@ -0,0 +1,103 @@
<!--
The MIT License
Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi, Yahoo! Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->

<!--
Generate configuration matrix and invoke body with 'p' as the instance of T
(of Layouter<T>)
Used by Matrix* classes
-->
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:i="jelly:fmt" xmlns:p="/lib/hudson/project">
<st:documentation>
Generate configuration matrix and invoke body with 'p' as the instance of T
(of Layouter&lt;T>)

<st:attribute name="autoRefresh">
If specified, the content of the matrix will be automatically updated via AJAX.
(This happens by requesting URL "./ajaxMatrix", so the caller needs "ajaxMatrix.jelly"
to serve this request.)
</st:attribute>
</st:documentation>

<j:set var="layouter" value="${layouter?:it.layouter}"/>
<j:set var="o" value="${layouter}"/>
<div id='matrix'>
<j:choose>
<!-- Optimized case when there's only one dimension to the axis (or zero dimension) -->
<j:when test="${empty(o.x) and empty(o.y)}">
<j:forEach var="p" items="${o.rows[0][0]}">
<d:invokeBody />
<st:nbsp />
</j:forEach>
</j:when>
<j:otherwise>
<table id="configuration-matrix">
<!-- X-axis -->
<j:forEach var="x" items="${o.x}" varStatus="loop">
<tr class="matrix-row">
<!-- space for Y-axis -->
<j:if test="${!empty(o.y)}">
<td id="matrix-title" colspan="${size(o.y)}"><st:nbsp /></td>
</j:if>
<j:forEach begin="1" end="${o.repeatX(loop.index)}">
<j:forEach var="v" items="${x.values}">
<td class="matrix-header" colspan="${o.width(loop.index)}">${v}</td>
</j:forEach>
</j:forEach>
</tr>
</j:forEach>

<!-- Y-axis -->
<j:forEach var="r" items="${o.rows}">
<tr>
<j:forEach var="y" items="${o.y}" varStatus="loop">
<j:if test="${r.drawYHeader(loop.index)!=null}">
<td class="matrix-leftcolumn" rowspan="${o.height(loop.index)}">${r.drawYHeader(loop.index)}</td>
</j:if>
</j:forEach>

<j:forEach var="c" items="${r}">
<td class="matrix-cell">
<j:choose>
<j:forEach var="p" items="${c}">
<div>
<d:invokeBody />
</div>
</j:forEach>
</j:choose>
</td>
</j:forEach>
</tr>
</j:forEach>
</table>
</j:otherwise>
</j:choose>
<j:if test="${ajax==null and attrs.autoRefresh and !h.isAutoRefresh(request)}">
<script defer="defer">
refreshPart('matrix',"./ajaxMatrix");
</script>
</j:if>
</div>
</j:jelly>
Empty file.

0 comments on commit 60e111a

Please sign in to comment.