Skip to content
Permalink
Browse files

JENKINS-23530: First cut at allowing a section header.

  • Loading branch information...
olhado committed Jun 23, 2014
1 parent 11a4602 commit 438312e65f6c52c54cf3850be06c7ed058fc2045
@@ -25,60 +25,90 @@

private static final String SEPARATOR_TEMPLATE = "<hr style=\"STYLE_HERE\" />";

public static final String defaultSeparatorStyle = "margin-top:10px; margin-bottom:10px;";
public static final String DEFAULT_SEPARATOR_STYLE = "margin-top:10px; margin-bottom:10px;";

public ParameterSeparatorDescriptor() {
load();
}

@Override
public boolean configure(StaplerRequest req, JSONObject json) throws FormException {
req.bindJSON(this, json.getJSONObject("parameter_separator"));
save();
return true;
}
@Override
public boolean configure(StaplerRequest req, JSONObject json) throws FormException {
req.bindJSON(this, json.getJSONObject("parameter_separator"));
save();
return true;
}

@Override
public String getDisplayName() {
return Messages.ParameterSeparatorDefinition_DisplayName();
}

public String getSeparatorStyle() {
return separatorStyle;
}
public String getSeparatorStyle() {
return separatorStyle;
}

public void setSeparatorStyle(final String s) {
separatorStyle = s;
}
public void setSeparatorStyle(final String s) {
separatorStyle = s;
}

public String getSeparator() {
if (separatorStyle != null && separatorStyle.length() > 0) {
public String getSeparator() {
if (separatorStyle != null && separatorStyle.length() > 0) {
return SEPARATOR_TEMPLATE.replace("STYLE_HERE", separatorStyle);
}
else {
return SEPARATOR_TEMPLATE.replace("STYLE_HERE", defaultSeparatorStyle);
}
}
else {
return SEPARATOR_TEMPLATE.replace("STYLE_HERE", DEFAULT_SEPARATOR_STYLE);
}
}

@Override
public ParameterSeparatorDefinition newInstance(final StaplerRequest request, final JSONObject jObj) {
return new ParameterSeparatorDefinition("", jObj.getString("sectionHeader"), jObj.getString("sectionHeaderStyle"));
}
}

private String sectionHeader = "";

public String getSectionHeader() {
return this.sectionHeader;
}

public void setSectionHeader(final String sh) {
this.sectionHeader = sh;
}

private String sectionHeaderStyle = "";

public String getSectionHeaderStyle() {
return this.sectionHeaderStyle;
}

public void setSectionHeaderStyle(final String shs) {
this.sectionHeaderStyle = shs;
}

@DataBoundConstructor
public ParameterSeparatorDefinition(final String name) {
super("separator-" + UUID.randomUUID().toString());
public ParameterSeparatorDefinition(final String name, final String sectionHeader, final String sectionHeaderStyle) {
super("separator-" + UUID.randomUUID().toString(), "");

this.sectionHeader = sectionHeader;
this.sectionHeaderStyle = sectionHeaderStyle;
}

@Override
public ParameterValue getDefaultParameterValue() {
return new ParameterSeparatorValue(getName(), getName());
// TODO: Should load a default, not hard-code it
return new ParameterSeparatorValue(getName(), "");
}

@Override
public ParameterValue createValue(final StaplerRequest request) {
return new ParameterSeparatorValue(getName(), getName());
String[] requestFields = request.getParameterValues(getName());
return new ParameterSeparatorValue(getName(), "");
}

@Override
public ParameterValue createValue(final StaplerRequest request, final JSONObject jObj) {
return new ParameterSeparatorValue(getName(), getName());
return new ParameterSeparatorValue(getName(), "");
}

public String getSeparator() {
@@ -10,9 +10,10 @@
import hudson.model.StringParameterValue;

public class ParameterSeparatorValue extends StringParameterValue{

@DataBoundConstructor
public ParameterSeparatorValue(final String name, final String value) {
super(name, value);
}

@DataBoundConstructor
public ParameterSeparatorValue(final String name, final String value) {
super(name, value);

}
}
@@ -4,4 +4,10 @@
-->

<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">
<f:entry title="Section Header" field="sectionHeader">
<f:textbox />
</f:entry>
<f:entry title="Section Header Style" field="sectionHeaderStyle">
<f:textbox />
</f:entry>
</j:jelly>
@@ -1,3 +1,8 @@
<!--
Copyright (c) 2014 Mike Chmielewski
See the file license.txt for copying permission.
-->

<j:jelly xmlns:j="jelly:core" xmlns:f="/lib/form">

<f:section title="Parameter Separator" name="parameter_separator">
@@ -8,5 +8,6 @@
xmlns:i="jelly:fmt" xmlns:p="/lib/hudson/project">
<f:entry title="" description="">
${it.separator}
<div style="${it.sectionHeaderStyle}">${it.sectionHeader}</div>
</f:entry>
</j:jelly>

0 comments on commit 438312e

Please sign in to comment.
You can’t perform that action at this time.