Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[JENKINS-23772] Use String for image width rather than ints
  • Loading branch information
kinow committed Sep 14, 2015
1 parent d3512f0 commit a7eb7fd
Show file tree
Hide file tree
Showing 8 changed files with 225 additions and 57 deletions.
Expand Up @@ -9,20 +9,27 @@
public abstract class AbstractArchivedImagesGallery extends ImageGallery {

/*
* serial UID.
* serial version UID.
*/
private static final long serialVersionUID = -1798633376573726389L;
private static final long serialVersionUID = -2264764254582937499L;
/**
* If checked, marks the build as unstable if no archives were found.
*/
private final boolean markBuildAsUnstableIfNoArchivesFound;

public AbstractArchivedImagesGallery(String title, String imageWidth,
@Deprecated
public AbstractArchivedImagesGallery(String title, Integer imageWidth,
Boolean markBuildAsUnstableIfNoArchivesFound) {
super(title, imageWidth);
this.markBuildAsUnstableIfNoArchivesFound = markBuildAsUnstableIfNoArchivesFound;
}

public AbstractArchivedImagesGallery(String title, String imageWidth,
Boolean markBuildAsUnstableIfNoArchivesFound) {
super(title, imageWidth);
this.markBuildAsUnstableIfNoArchivesFound = markBuildAsUnstableIfNoArchivesFound;
}

/**
* @return the markBuildAsUnstableIfNoArchivesFound
*/
Expand Down
40 changes: 29 additions & 11 deletions src/main/java/org/jenkinsci/plugins/imagegallery/ImageGallery.java
Expand Up @@ -23,6 +23,10 @@
*/
package org.jenkinsci.plugins.imagegallery;

import java.io.IOException;
import java.io.Serializable;
import java.util.Collection;

import hudson.DescriptorExtensionList;
import hudson.model.AbstractBuild;
import hudson.model.AbstractProject;
Expand All @@ -33,10 +37,6 @@
import hudson.model.Hudson;
import hudson.model.Node;

import java.io.IOException;
import java.io.Serializable;
import java.util.Collection;


/**
* Image gallery extension point. Multiple image gallery types extend this class.
Expand All @@ -47,23 +47,33 @@
public abstract class ImageGallery implements Serializable, Describable<ImageGallery>, Comparable<ImageGallery> {

/*
* serial UID.
* serial version UID.
*/
private static final long serialVersionUID = -1568321312897565728L;
private static final long serialVersionUID = 3016249288702988364L;
/**
* Title.
*/
private final String title;
/**
* Images width.
*/
private final String imageWidth;
@Deprecated
private Integer imageWidth;

public ImageGallery(String title, String imageWidth) {
private final String imageWidthText;

@Deprecated
public ImageGallery(String title, Integer imageWidth) {
this.title = title;
this.imageWidth = imageWidth;
imageWidthText = Integer.toString(imageWidth);
}


public ImageGallery(String title, String imageWidth) {
this.title = title;
this.imageWidthText = imageWidth;
}

/**
* @return the title
*/
Expand All @@ -74,11 +84,19 @@ public String getTitle() {
/**
* @return the imageWidth
*/
public String getImageWidth() {
@Deprecated
public Integer getImageWidth() {
return imageWidth;
}

/* (non-Javadoc)
/**
* @return the imageWidthText
*/
public String getImageWidthText() {
return imageWidthText;
}

/* (non-Javadoc)
* @see java.lang.Comparable#compareTo(java.lang.Object)
*/
public int compareTo(ImageGallery o) {
Expand Down
Expand Up @@ -23,9 +23,6 @@
*/
package org.jenkinsci.plugins.imagegallery.comparative;

import hudson.FilePath;
import hudson.util.FormValidation;

import java.util.ArrayList;
import java.util.List;

Expand All @@ -36,6 +33,9 @@
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;

import hudson.FilePath;
import hudson.util.FormValidation;


/**
* Base image gallery to compare images in different way.
Expand All @@ -45,11 +45,10 @@
*/
public abstract class ComparativeArchivedImagesGallery extends AbstractArchivedImagesGallery {


/*
* serial UID.
* serial version UID.
*/
private static final long serialVersionUID = 8022990812020649261L;
private static final long serialVersionUID = -1507776620685441240L;

/**
* Title.
Expand All @@ -64,7 +63,13 @@ public abstract class ComparativeArchivedImagesGallery extends AbstractArchivedI
/**
* Images width.
*/
private final String imageInnerWidth;
@Deprecated
private Integer imageInnerWidth;

/**
* Images inner width.
*/
private final String imageInnerWidthText;

/**
* Constructor called from jelly.
Expand All @@ -74,14 +79,32 @@ public abstract class ComparativeArchivedImagesGallery extends AbstractArchivedI
* @param imageInnerWidth
* @param markBuildAsUnstableIfNoArchivesFound
*/
@DataBoundConstructor
public ComparativeArchivedImagesGallery(String title, String baseRootFolder, String imageWidth, String imageInnerWidth,
@Deprecated
public ComparativeArchivedImagesGallery(String title, String baseRootFolder, Integer imageWidth, Integer imageInnerWidth,
boolean markBuildAsUnstableIfNoArchivesFound) {
super(title, imageWidth, markBuildAsUnstableIfNoArchivesFound);
this.title = title;
this.baseRootFolder = baseRootFolder;
this.imageInnerWidth = imageInnerWidth;
imageInnerWidthText = Integer.toString(imageInnerWidth);
}

/**
* Constructor called from jelly.
* @param title
* @param baseRootFolder
* @param imageWidth
* @param imageInnerWidth
* @param markBuildAsUnstableIfNoArchivesFound
*/
@DataBoundConstructor
public ComparativeArchivedImagesGallery(String title, String baseRootFolder, String imageWidth, String imageInnerWidth,
boolean markBuildAsUnstableIfNoArchivesFound) {
super(title, imageWidth, markBuildAsUnstableIfNoArchivesFound);
this.title = title;
this.baseRootFolder = baseRootFolder;
this.imageInnerWidthText = imageInnerWidth;
}

/**
* @return the title
Expand All @@ -100,10 +123,18 @@ public String getBaseRootFolder() {
/**
* @return the imageInnerWidth
*/
public String getImageInnerWidth() {
@Deprecated
public Integer getImageInnerWidth() {
return imageInnerWidth;
}

/**
* @return the imageInnerWidthText
*/
public String getImageInnerWidthText() {
return imageInnerWidthText;
}

public static abstract class ComparativeDescriptorImpl extends ImageGalleryDescriptor {

public FormValidation doCheckImageInnerWidth(StaplerRequest req, StaplerResponse resp, @QueryParameter String imageInnerWidth) throws Exception {
Expand Down
Expand Up @@ -36,10 +36,9 @@
public class ComparativeImagesGalleryBuildAction implements Action, Serializable {

/*
* serial UID.
* serial version UID.
*/
private static final long serialVersionUID = -4788699009385594824L;

private static final long serialVersionUID = -3667733389967779689L;
/**
* The title.
*/
Expand All @@ -51,13 +50,21 @@ public class ComparativeImagesGalleryBuildAction implements Action, Serializable
/**
* The image width.
*/
private final String imageWidth;

@Deprecated
private Integer imageWidth;
/**
* The image width.
*/
private final String imageWidthText;
/**
* The inner image width
*/
private String imageInnerWidth;

@Deprecated
private Integer imageInnerWidth;
/**
* The image inner width.
*/
private final String imageInnerWidthText;
/**
* Constructor with args.
* @param title
Expand All @@ -66,17 +73,39 @@ public class ComparativeImagesGalleryBuildAction implements Action, Serializable
* @param images
* @param imageWidth
*/
public ComparativeImagesGalleryBuildAction(String title, FilePairTree tree, String imageWidth, String imageInnerWidth) {
@Deprecated
public ComparativeImagesGalleryBuildAction(String title, FilePairTree tree, Integer imageWidth, Integer imageInnerWidth) {
this.title = title;
this.tree = tree;
this.imageInnerWidth = imageInnerWidth;
imageWidthText = Integer.toString(imageInnerWidth);
if(imageWidth != null) {
this.imageWidth = imageWidth;
} else {
this.imageWidth = "0";
this.imageWidth = Integer.valueOf(0);
}
imageInnerWidthText = Integer.toString(this.imageWidth);
}


/**
* Constructor with args.
* @param title
* @param imageWidth2
* @param tree
* @param images
* @param imageWidth
*/
public ComparativeImagesGalleryBuildAction(String title, FilePairTree tree, String imageWidth, String imageInnerWidth) {
this.title = title;
this.tree = tree;
this.imageInnerWidthText = imageInnerWidth;
if(imageWidth != null) {
this.imageWidthText = imageWidth;
} else {
this.imageWidthText = "0";
}
}

/**
* @return the title
*/
Expand Down Expand Up @@ -115,14 +144,29 @@ public String getUrlName() {
/**
* @return the imageWidth
*/
public String getImageWidth() {
@Deprecated
public Integer getImageWidth() {
return imageWidth;
}

/**
* @return the imageWidthText
*/
public String getImageWidthText() {
return imageWidthText;
}

/**
* @return the imageInnerWidth
*/
public String getImageInnerWidth() {
@Deprecated
public Integer getImageInnerWidth() {
return imageInnerWidth;
}
/**
* @return the imageInnerWidthText
*/
public String getImageInnerWidthText() {
return imageInnerWidthText;
}
}
Expand Up @@ -46,9 +46,9 @@
public class InFolderComparativeArchivedImagesGallery extends ComparativeArchivedImagesGallery {

/*
* serial UID.
* serial version UID.
*/
private static final long serialVersionUID = 4490034271037852059L;
private static final long serialVersionUID = 5537875107916417554L;

/**
* Constructor called from jelly.
Expand All @@ -59,12 +59,27 @@ public class InFolderComparativeArchivedImagesGallery extends ComparativeArchive
* @param imageInnerWidth Width for the images in the popup display
* @param markBuildAsUnstableIfNoArchivesFound Mark the build as unstable if no archives found
*/
@DataBoundConstructor
public InFolderComparativeArchivedImagesGallery(String title, String baseRootFolder, String imageWidth, String imageInnerWidth,
@Deprecated
public InFolderComparativeArchivedImagesGallery(String title, String baseRootFolder, Integer imageWidth, Integer imageInnerWidth,
boolean markBuildAsUnstableIfNoArchivesFound) {
super(title, baseRootFolder, imageWidth, imageInnerWidth, markBuildAsUnstableIfNoArchivesFound);
}


/**
* Constructor called from jelly.
*
* @param title Title of the image gallery
* @param baseRootFolder Root folder where the images will be retrieve from
* @param imageWidth thumbnail width of each images
* @param imageInnerWidth Width for the images in the popup display
* @param markBuildAsUnstableIfNoArchivesFound Mark the build as unstable if no archives found
*/
@DataBoundConstructor
public InFolderComparativeArchivedImagesGallery(String title, String baseRootFolder, String imageWidth, String imageInnerWidth,
boolean markBuildAsUnstableIfNoArchivesFound) {
super(title, baseRootFolder, imageWidth, imageInnerWidth, markBuildAsUnstableIfNoArchivesFound);
}

@Extension
public static class DescriptorImpl extends ComparativeDescriptorImpl {
@Override
Expand All @@ -90,7 +105,7 @@ public boolean createImageGallery(AbstractBuild<?, ?> build, BuildListener liste
tree.addToBranch(folder, new FilePair(path.getName(), StringUtils.join(artifactsRelativeFile, '/')));
}
String title = Util.replaceMacro(build.getEnvironment(listener).expand(getTitle()), build.getBuildVariableResolver());
build.addAction(new ComparativeImagesGalleryBuildAction(title, tree, getImageWidth(), getImageInnerWidth()));
build.addAction(new ComparativeImagesGalleryBuildAction(title, tree, getImageWidthText(), getImageInnerWidthText()));
} else {
listener.getLogger().append("No files found for image gallery.");
}
Expand Down

0 comments on commit a7eb7fd

Please sign in to comment.