Skip to content

Commit

Permalink
[FIXED JENKINS-23030] Use Combination for Layouter instead of built-i…
Browse files Browse the repository at this point in the history
…n Layouter. This avoids NPE when MatrixCombination is not available.
  • Loading branch information
ikedam committed Jun 29, 2014
1 parent 21950f6 commit a3b2e3d
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 38 deletions.
Expand Up @@ -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,8 +43,8 @@ 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 id=\"shortcut-" + nameIt + "-successful\" href=\"#\" onclick=\"click2Change(0);\">Successful</a> - \n" +
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 @@ -21,45 +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;
Layouter layouter = new Layouter<Combination>(axes) {
protected Combination getT(Combination c) {
return c;
}
};

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



private void drawParameterBody(Namespace f,valueIt,AxisList axes,MatrixProject project,Layouter layouter) {
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: String.format("checkbox%s-%s", matrixValue.getName(), runPtr.combination.toString('-' as char, '-' as char)));
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: String.format("checkbox%s-%s", matrixValue.getName(), runPtr.combination.toString('-' as char, '-' as char)));
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 @@ -21,45 +21,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;
MatrixCombinationsParameterValue valueIt = it;
Layouter layouter = build.getLayouter();
if (layouter==null)
return;
Layouter layouter = new Layouter<Combination>(axes) {
protected Combination getT(Combination c) {
return c;
}
};

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



private void drawParameterBody(Namespace f,MatrixCombinationsParameterValue valueIt,AxisList axes,MatrixProject project,Layouter layouter) {
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())
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,MatrixCombinationsParameterValue matrixValue,MatrixProject project,Layouter layouter) {
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());
if (!layouter.x || !layouter.y) {
text(runPtr.combination.toString(layouter.z))
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(), runPtr.combination.toString('-' as char, '-' as char)));
input(type: "hidden", name: "confs", value: runPtr.combination.toString());
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");
if (!layouter.x || !layouter.y) {
text(runPtr.combination.toString(layouter.z))
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(), runPtr.combination.toString('-' as char, '-' as char)));
input(type: "hidden", name: "confs", value: runPtr.combination.toString());
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());
}
}
Expand Up @@ -41,7 +41,8 @@ THE SOFTWARE.
</st:attribute>
</st:documentation>

<j:set var="o" value="${it.layouter}"/>
<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) -->
Expand Down

0 comments on commit a3b2e3d

Please sign in to comment.