Skip to content
Permalink
Browse files

[JENKINS-33645] Improve Folders handling

Now, folders are recursively processed instead of being ignored.

That makes it now far simpler to add a whole folder's content than
before.

As a Pipeline Multibranch is actually also implementing `AbstractFolder`
interface, this fix also makes selecting all the branches of a Pipeline
MB in one go easier.
  • Loading branch information
batmat committed Nov 5, 2016
1 parent 08d1f94 commit c6d466d0816e125bd606c079cd6b16652a3a4484
Showing with 33 additions and 18 deletions.
  1. +8 −3 pom.xml
  2. +25 −15 src/main/java/hudson/model/RadiatorView.java
11 pom.xml
@@ -29,8 +29,8 @@
<connection>scm:git:git://github.com/jenkinsci/radiatorview-plugin.git</connection>
<developerConnection>scm:git:git@github.com:jenkinsci/radiatorview-plugin.git</developerConnection>
<url>https://github.com/jenkinsci/radiatorview-plugin</url>
<tag>HEAD</tag>
</scm>
<tag>HEAD</tag>
</scm>
<developers>
<developer>
<id>batmat</id>
@@ -65,11 +65,16 @@
</build>

<dependencies>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>cloudbees-folder</artifactId>
<version>5.13</version>
</dependency>
<dependency>
<groupId>org.jvnet.hudson.plugins</groupId>
<artifactId>claim</artifactId>
<version>1.7</version>
<optional>true</optional>
<optional>false</optional>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
@@ -1,28 +1,27 @@
package hudson.model;

import com.cloudbees.hudson.plugins.folder.AbstractFolder;
import hudson.Extension;
import hudson.Util;
import hudson.model.Descriptor.FormException;
import hudson.util.FormValidation;
import jenkins.model.Jenkins;
import org.apache.commons.lang.StringUtils;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.DataBoundSetter;
import org.kohsuke.stapler.QueryParameter;
import org.kohsuke.stapler.StaplerRequest;

import javax.servlet.ServletException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.TreeSet;
import java.util.logging.Logger;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;

import javax.servlet.ServletException;

import jenkins.model.Jenkins;
import org.apache.commons.lang.StringUtils;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.DataBoundSetter;
import org.kohsuke.stapler.QueryParameter;
import org.kohsuke.stapler.StaplerRequest;

/**
* A configurable Radiator-Style job view suitable for use in extreme feedback
* systems - ideal for running on a spare PC in the office. Many thanks to
@@ -35,6 +34,8 @@

private static final int DEFAULT_CAPTION_SIZE = 36;

private static final Logger LOGGER = Logger.getLogger(RadiatorView.class.getName());

/**
* Entries to be shown in the view.
*/
@@ -113,7 +114,7 @@ public ViewEntryColors getColors() {
}

public ProjectViewEntry getContents() {
ProjectViewEntry contents = new ProjectViewEntry();
ProjectViewEntry content = new ProjectViewEntry();

placeInQueue = new HashMap<hudson.model.Queue.Item, Integer>();
int j = 1;
@@ -122,13 +123,22 @@ public ProjectViewEntry getContents() {
placeInQueue.put(i, j++);
}

for (TopLevelItem item : super.getItems()) {
if(item instanceof Job && !isDisabled(item)) {
LOGGER.fine("Collecting items for view " + getViewName());
addItems(getItems(), content);
return content;
}

private void addItems(Collection<TopLevelItem> items, ProjectViewEntry content) {
for (TopLevelItem item : items) {
LOGGER.fine(item.getName() + " (" + item.getClass() + ")");
if (item instanceof AbstractFolder) {
addItems(((AbstractFolder) item).getItems(), content);
}
if (item instanceof Job && !isDisabled(item)) {
IViewEntry entry = new JobViewEntry(this, (Job<?, ?>) item);
contents.addBuild(entry);
content.addBuild(entry);
}
}
return contents;
}

private boolean isDisabled(TopLevelItem item) {

0 comments on commit c6d466d

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