From 3417dc04ccee454deb387f003a53dfb6697444b0 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Thu, 31 Mar 2011 18:18:38 -0700 Subject: [PATCH] - modified to use for better reuse&consistency. - support invisible JobProperty --- core/src/main/java/hudson/model/Job.java | 22 ++++++++----------- .../main/java/hudson/model/JobProperty.java | 9 +++++++- .../hudson/model/Job/configure.jelly | 12 +--------- .../resources/lib/form/descriptorList.jelly | 5 ++++- 4 files changed, 22 insertions(+), 26 deletions(-) diff --git a/core/src/main/java/hudson/model/Job.java b/core/src/main/java/hudson/model/Job.java index 5c1a9aa012..2a02712d6a 100644 --- a/core/src/main/java/hudson/model/Job.java +++ b/core/src/main/java/hudson/model/Job.java @@ -26,6 +26,7 @@ package hudson.model; import static javax.servlet.http.HttpServletResponse.SC_BAD_REQUEST; import static javax.servlet.http.HttpServletResponse.SC_NO_CONTENT; +import com.google.common.collect.Iterables; import com.infradna.tool.bridge_method_injector.WithBridgeMethods; import hudson.ExtensionPoint; import hudson.PermalinkList; @@ -46,6 +47,7 @@ import hudson.util.ChartUtil; import hudson.util.ColorPalette; import hudson.util.CopyOnWriteList; import hudson.util.DataSetBuilder; +import hudson.util.DescribableList; import hudson.util.IOException2; import hudson.util.RunList; import hudson.util.ShiftedCategoryAxis; @@ -936,25 +938,19 @@ public abstract class Job, RunT extends Run, JobPropertyDescriptor> t = new DescribableList, JobPropertyDescriptor>(NOOP,getAllProperties()); + t.rebuild(req,json.optJSONObject("properties"),JobPropertyDescriptor.getPropertyDescriptors(Job.this.getClass())); + properties.clear(); + for (JobProperty p : t) { + p.setOwner(this); + properties.add(p); } submit(req, rsp); diff --git a/core/src/main/java/hudson/model/JobProperty.java b/core/src/main/java/hudson/model/JobProperty.java index 3d0292315f..f22835ce51 100644 --- a/core/src/main/java/hudson/model/JobProperty.java +++ b/core/src/main/java/hudson/model/JobProperty.java @@ -26,6 +26,7 @@ package hudson.model; import hudson.ExtensionPoint; import hudson.Launcher; import hudson.Plugin; +import hudson.model.Descriptor.FormException; import hudson.model.queue.SubTask; import hudson.tasks.BuildStep; import hudson.tasks.Builder; @@ -36,6 +37,8 @@ import java.io.IOException; import java.util.Collection; import java.util.Collections; +import net.sf.json.JSONObject; +import org.kohsuke.stapler.StaplerRequest; import org.kohsuke.stapler.export.ExportedBean; /** @@ -69,7 +72,7 @@ import org.kohsuke.stapler.export.ExportedBean; * @since 1.72 */ @ExportedBean -public abstract class JobProperty> implements Describable>, BuildStep, ExtensionPoint { +public abstract class JobProperty> implements ReconfigurableDescribable>, BuildStep, ExtensionPoint { /** * The {@link Job} object that owns this property. * This value will be set by the Hudson code. @@ -169,6 +172,10 @@ public abstract class JobProperty> implements Describable reconfigure(StaplerRequest req, JSONObject form) throws FormException { + return form==null ? null : getDescriptor().newInstance(req,form); + } + /** * Contributes {@link SubTask}s to {@link AbstractProject#getSubTasks()} * diff --git a/core/src/main/resources/hudson/model/Job/configure.jelly b/core/src/main/resources/hudson/model/Job/configure.jelly index cdef885d32..67d67d77a3 100644 --- a/core/src/main/resources/hudson/model/Job/configure.jelly +++ b/core/src/main/resources/hudson/model/Job/configure.jelly @@ -53,17 +53,7 @@ THE SOFTWARE. - - - - - - - - - - - + diff --git a/core/src/main/resources/lib/form/descriptorList.jelly b/core/src/main/resources/lib/form/descriptorList.jelly index 5edae295bd..3a3d1b7457 100644 --- a/core/src/main/resources/lib/form/descriptorList.jelly +++ b/core/src/main/resources/lib/form/descriptorList.jelly @@ -50,6 +50,9 @@ THE SOFTWARE. the type for which descriptors will be configured. default to ${it.class} + + If specified, instead of a sequence of <f:optionalBlock>s, draw a sequence of <rowSet>s. + @@ -73,7 +76,7 @@ THE SOFTWARE. + title="${attrs.forceRowSet!=null?null:d.displayName}" checked="${instances.get(d)!=null}"> -- GitLab