Skip to content
Permalink
Browse files

[JENKINS-38960 Follow-up] Make the IconSpec API for FolderIcon more …

…reusable
  • Loading branch information...
stephenc committed Oct 18, 2016
1 parent 3573f74 commit 9c718a0f35c3746d66c9786fd957eaeaaab2d2b5
@@ -30,6 +30,7 @@
import hudson.model.StatusIcon;
import jenkins.model.Jenkins;
import org.apache.commons.jelly.JellyContext;
import org.apache.commons.lang.StringUtils;
import org.jenkins.ui.icon.Icon;
import org.jenkins.ui.icon.IconSet;
import org.jenkins.ui.icon.IconSpec;
@@ -62,22 +63,25 @@ public String getIconClassName() {
}

protected String iconClassNameImageOf(String size) {
String spec = null;
if ("16x16".equals(size)) {
spec = "icon-sm";
} else if ("24x24".equals(size)) {
spec = "icon-md";
} else if ("32x32".equals(size)) {
spec = "icon-lg";
} else if ("48x48".equals(size)) {
spec = "icon-xlg";
}
if (spec != null) {
Icon icon = IconSet.icons.getIconByClassSpec("icon-folder " + spec);
if (icon != null) {
JellyContext ctx = new JellyContext();
ctx.setVariable("resURL", Stapler.getCurrentRequest().getContextPath() + Jenkins.RESOURCE_PATH);
return icon.getQualifiedUrl(ctx);
String iconClassName = getIconClassName();
if (StringUtils.isNotBlank(iconClassName)) {
String spec = null;
if ("16x16".equals(size)) {
spec = "icon-sm";
} else if ("24x24".equals(size)) {
spec = "icon-md";
} else if ("32x32".equals(size)) {
spec = "icon-lg";
} else if ("48x48".equals(size)) {
spec = "icon-xlg";
}
if (spec != null) {
Icon icon = IconSet.icons.getIconByClassSpec(iconClassName + " " + spec);
if (icon != null) {
JellyContext ctx = new JellyContext();
ctx.setVariable("resURL", Stapler.getCurrentRequest().getContextPath() + Jenkins.RESOURCE_PATH);
return icon.getQualifiedUrl(ctx);
}
}
}
return null;
@@ -43,6 +43,11 @@
public StockFolderIcon() {
}

@Override
public String getIconClassName() {
return "icon-folder";
}

public String getImageOf(String size) {
String image = iconClassNameImageOf(size);
return image != null

0 comments on commit 9c718a0

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