Skip to content
Permalink
Browse files

Merge pull request #7 from daniel-beck/stable

[FIXED JENKINS-20523 JENKINS-20235 JENKINS-20006] for current LTS
  • Loading branch information...
jglick committed Mar 17, 2014
2 parents 4e62463 + 5be10cd commit 9cbac2d026e315f41b7b4b2e51ca6d73b5a0092f
@@ -4,7 +4,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.480.3</version>
<version>1.526</version>
</parent>
<artifactId>cloudbees-folder</artifactId>
<version>4.2.2-SNAPSHOT</version>
@@ -47,6 +47,7 @@
import hudson.model.ItemVisitor;
import hudson.model.Items;
import hudson.model.Job;
import hudson.model.AllView;
import hudson.model.ListView;
import hudson.model.TopLevelItem;
import hudson.model.TopLevelItemDescriptor;
@@ -114,13 +115,14 @@
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import jenkins.model.Jenkins;
import jenkins.model.ModelObjectWithChildren;
import org.kohsuke.stapler.interceptor.RequirePOST;

/**
* {@link Item} that contains other {@link Item}s, without modeling dependency.
*/
public class Folder extends AbstractItem
implements ModifiableTopLevelItemGroup, ViewGroup, TopLevelItem, StaplerOverridable, StaplerFallback {
implements ModifiableTopLevelItemGroup, ViewGroup, TopLevelItem, StaplerOverridable, StaplerFallback, ModelObjectWithChildren {

/**
* @see #getNewPronoun
@@ -268,33 +270,31 @@ private void init() {
for (FolderProperty p : properties) {
p.setOwner(this);
}
if (columns == null) {
columns = new DescribableList<ListViewColumn, Descriptor<ListViewColumn>>(this,
ListViewColumn.createDefaultInitialColumnList());
}
if (filters == null) {
filters = new DescribableList<ViewJobFilter, Descriptor<ViewJobFilter>>(this);
}
if (views == null) {
views = new CopyOnWriteArrayList<View>();
}
if (views.size() == 0) {
ListView lv = new ListView("All", this);
views.add(lv);
try {
lv.getColumns().replaceBy(columns.toList());
lv.getJobFilters().replaceBy(filters.toList());

try { // TODO use setIncludeRegex as of 1.526
Field f = lv.getClass().getDeclaredField("includeRegex");
f.setAccessible(true);
f.set(lv, ".*");
f = lv.getClass().getDeclaredField("includePattern");
f.setAccessible(true);
f.set(lv, Pattern.compile(".*"));
} catch (Throwable e) {
if (columns != null || filters != null) {
// we're loading an ancient config
if (columns == null) {
columns = new DescribableList<ListViewColumn, Descriptor<ListViewColumn>>(this,
ListViewColumn.createDefaultInitialColumnList());
}
if (filters == null) {
filters = new DescribableList<ViewJobFilter, Descriptor<ViewJobFilter>>(this);
}
ListView lv = new ListView("All", this);
views.add(lv);
lv.getColumns().replaceBy(columns.toList());
lv.getJobFilters().replaceBy(filters.toList());
lv.setIncludeRegex(".*");
lv.save();
} else {
AllView v = new AllView("All", this);
views.add(v);
v.save();
}
lv.save();
} catch (IOException e) {
LOGGER.log(Level.WARNING, "Failed to set up the initial view", e);
}
@@ -479,7 +479,8 @@ public FolderIcon getIconColor() {
* Folder is no longer a view by itself.
*/
public DescribableList<ListViewColumn, Descriptor<ListViewColumn>> getColumns() {
return columns;
return new DescribableList<ListViewColumn, Descriptor<ListViewColumn>>(this,
ListViewColumn.createDefaultInitialColumnList());
}

/**
@@ -653,6 +654,14 @@ public FormValidation doCheckJobName(@QueryParameter String value) {
}
}

public ContextMenu doChildrenContextMenu(StaplerRequest request, StaplerResponse response) {
ContextMenu menu = new ContextMenu();
for (View view : getViews()) {
menu.add(view.getAbsoluteUrl(),view.getDisplayName());
}
return menu;
}

/**
* Copies an existing {@link TopLevelItem} to into this folder with a new name.
*/
@@ -701,6 +710,10 @@ public void doConfigSubmit(StaplerRequest req, StaplerResponse rsp)
description = json.getString("description");
displayName = Util.fixEmpty(json.optString("displayNameOrNull"));

if (json.has("primaryView")) {
setPrimaryView(viewGroupMixIn.getView(json.getString("primaryView")));
}

properties.rebuild(req, json, getDescriptor().getPropertyDescriptors());
for (FolderProperty p : properties) // TODO: push this to the subtype of property descriptors
{
@@ -42,6 +42,23 @@ THE SOFTWARE.
<f:textarea codemirror-mode="${app.markupFormatter.codeMirrorMode}" codemirror-config="${app.markupFormatter.codeMirrorConfig}" previewEndpoint="/markupFormatter/previewDescription" />
</f:entry>

<j:if test="${it.views.size()>1}">
<f:entry title="${%Default View}" field="defaultView">
<select class="setting-input" name="primaryView">
<j:forEach var="v" items="${it.views}">
<j:choose>
<j:when test="${it.primaryView==v}">
<option value="${v.viewName}" selected="selected">${v.viewName}</option>
</j:when>
<j:otherwise>
<option value="${v.viewName}">${v.viewName}</option>
</j:otherwise>
</j:choose>
</j:forEach>
</select>
</f:entry>
</j:if>

<!-- TODO tried to hide unless ${it.icon.descriptor.all().size() > 1} using f:invisibleEntry but this did not seem to work: -->
<f:dropdownDescriptorSelector title="${%Icon}" field="icon"/>

0 comments on commit 9cbac2d

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