Skip to content

Commit

Permalink
[JENKINS-33645] Improve Folders handling
Browse files Browse the repository at this point in the history
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 c6d466d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 18 deletions.
11 changes: 8 additions & 3 deletions pom.xml
Expand Up @@ -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>
Expand Down Expand Up @@ -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>
Expand Down
40 changes: 25 additions & 15 deletions src/main/java/hudson/model/RadiatorView.java
@@ -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
Expand All @@ -35,6 +34,8 @@ public class RadiatorView extends ListView {

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.
*/
Expand Down Expand Up @@ -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;
Expand All @@ -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) {
Expand Down

0 comments on commit c6d466d

Please sign in to comment.