.getIconByClassSpec(StringUtils.join(new String[]{iconClassName, iconStyle}, " ")); if (icon != null) { metadata.put("iconQualifiedUrl", icon.getQualifiedUrl(ctx));
BallColor(String image, Localizable description, Color baseColor) { this.iconName = Icon.toNormalizedIconName(image); this.iconClassName = Icon.toNormalizedIconNameClass(image); this.baseColor = baseColor; // name() is not usable in the constructor, so I have to repeat the name twice // in the constants definition. this.image = image+ (image.endsWith("_anime")?".gif":".png"); this.description = description; }
/** * Get the Item's Icon class specification e.g. 'icon-notepad'. * <p> * Note: do <strong>NOT</strong> include icon size specifications (such as 'icon-sm'). * * @return The Icon class specification e.g. 'icon-notepad'. */ @Override public String getIconClassName() { // Oh the fun of somebody adding a legacy way of referencing images into 2.0 code String pattern = getIconFilePathPattern(); if (pattern != null) { // here we go with the dance of the IconSet's String path = pattern.replace(":size", "24x24"); // we'll strip the icon-md to get the class name if (path.indexOf('/') == -1) { // this one is easy... too easy... also will never happen return IconSet.toNormalizedIconNameClass(path); } if (Jenkins.RESOURCE_PATH.length() > 0 && path.startsWith(Jenkins.RESOURCE_PATH)) { // will to live falling path = path.substring(Jenkins.RESOURCE_PATH.length()); } Icon icon = IconSet.icons.getIconByUrl(path); if (icon != null) { return icon.getClassSpec().replaceAll("\\s*icon-md\\s*", " ").replaceAll("\\s+", " "); } } return null; }
switch (type) { case CORE: { return Functions.getResourcePath() + "/images/" + icon.getUrl(); return Functions.getResourcePath() + "/plugin/" + icon.getUrl(); return icon.getQualifiedUrl(ctx);
private void registerIcons() { IconSet.icons.addIcon(new Icon("icon-docker-logo icon-sm", "docker-commons/images/16x16/docker.png", Icon.ICON_SMALL_STYLE, IconType.PLUGIN)); IconSet.icons.addIcon(new Icon("icon-docker-logo icon-md", "docker-commons/images/24x24/docker.png", Icon.ICON_MEDIUM_STYLE, IconType.PLUGIN)); IconSet.icons.addIcon(new Icon("icon-docker-logo icon-lg", "docker-commons/images/32x32/docker.png", Icon.ICON_LARGE_STYLE, IconType.PLUGIN)); IconSet.icons.addIcon(new Icon("icon-docker-logo icon-xlg", "docker-commons/images/48x48/docker.png", Icon.ICON_XLARGE_STYLE, IconType.PLUGIN)); } }
public IconSet addIcon(Icon icon) { iconsByCSSSelector.put(icon.getNormalizedSelector(), icon); iconsByUrl.put(icon.getUrl(), icon); return this; }
/** * Normalize the supplied string to an Icon name class e.g. "blue_anime" to "icon-blue-anime". * * @param string The string to be normalized. * @return The normalized icon name class. */ public static String toNormalizedIconNameClass(String string) { return Icon.toNormalizedIconNameClass(string); }
/** * Normalize the supplied string to an Icon name class e.g. "blue_anime" to "icon-blue-anime". * * @param string The string to be normalized. * @return The normalized icon name class. */ public static String toNormalizedIconNameClass(String string) { if (string == null) { return null; } return "icon-" + toNormalizedIconName(string); }
switch (type) { case CORE: { return Functions.getResourcePath() + "/images/" + icon.getUrl(); return Functions.getResourcePath() + "/plugin/" + icon.getUrl(); return icon.getQualifiedUrl(ctx);
private void registerIcons() { IconSet.icons.addIcon(new Icon("icon-docker-logo icon-sm", "docker-commons/images/16x16/docker.png", Icon.ICON_SMALL_STYLE, IconType.PLUGIN)); IconSet.icons.addIcon(new Icon("icon-docker-logo icon-md", "docker-commons/images/24x24/docker.png", Icon.ICON_MEDIUM_STYLE, IconType.PLUGIN)); IconSet.icons.addIcon(new Icon("icon-docker-logo icon-lg", "docker-commons/images/32x32/docker.png", Icon.ICON_LARGE_STYLE, IconType.PLUGIN)); IconSet.icons.addIcon(new Icon("icon-docker-logo icon-xlg", "docker-commons/images/48x48/docker.png", Icon.ICON_XLARGE_STYLE, IconType.PLUGIN)); } }
/** * Normalize the supplied string to an Icon name class e.g. "blue_anime" to "icon-blue-anime". * * @param string The string to be normalized. * @return The normalized icon name class. */ public static String toNormalizedIconNameClass(GString string) { return Icon.toNormalizedIconNameClass(string.toString()); }
protected String iconClassNameImageOf(String size) { 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; }
"folder-store", }) { IconSet.icons.addIcon(new Icon( String.format("icon-credentials-%s icon-sm", name), String.format("credentials/images/16x16/%s.png", name), Icon.ICON_SMALL_STYLE, IconType.PLUGIN) ); IconSet.icons.addIcon(new Icon( String.format("icon-credentials-%s icon-md", name), String.format("credentials/images/24x24/%s.png", name), Icon.ICON_MEDIUM_STYLE, IconType.PLUGIN) ); IconSet.icons.addIcon(new Icon( String.format("icon-credentials-%s icon-lg", name), String.format("credentials/images/32x32/%s.png", name), Icon.ICON_LARGE_STYLE, IconType.PLUGIN) ); IconSet.icons.addIcon(new Icon( String.format("icon-credentials-%s icon-xlg", name), String.format("credentials/images/48x48/%s.png", name),
BallColor(String image, Localizable description, Color baseColor) { this.iconName = Icon.toNormalizedIconName(image); this.iconClassName = Icon.toNormalizedIconNameClass(image); this.baseColor = baseColor; // name() is not usable in the constructor, so I have to repeat the name twice // in the constants definition. this.image = image+ (image.endsWith("_anime")?".gif":".png"); this.description = description; }
/** * Get the Item's Icon class specification e.g. 'icon-notepad'. * <p> * Note: do <strong>NOT</strong> include icon size specifications (such as 'icon-sm'). * * @return The Icon class specification e.g. 'icon-notepad'. */ @Override public String getIconClassName() { // Oh the fun of somebody adding a legacy way of referencing images into 2.0 code String pattern = getIconFilePathPattern(); if (pattern != null) { // here we go with the dance of the IconSet's String path = pattern.replace(":size", "24x24"); // we'll strip the icon-md to get the class name if (path.indexOf('/') == -1) { // this one is easy... too easy... also will never happen return IconSet.toNormalizedIconNameClass(path); } if (Jenkins.RESOURCE_PATH.length() > 0 && path.startsWith(Jenkins.RESOURCE_PATH)) { // will to live falling path = path.substring(Jenkins.RESOURCE_PATH.length()); } Icon icon = IconSet.icons.getIconByUrl(path); if (icon != null) { return icon.getClassSpec().replaceAll("\\s*icon-md\\s*", " ").replaceAll("\\s+", " "); } } return null; }
protected String iconClassNameImageOf(String size) { 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; }
"folder-store", }) { IconSet.icons.addIcon(new Icon( String.format("icon-credentials-%s icon-sm", name), String.format("credentials/images/16x16/%s.png", name), Icon.ICON_SMALL_STYLE, IconType.PLUGIN) ); IconSet.icons.addIcon(new Icon( String.format("icon-credentials-%s icon-md", name), String.format("credentials/images/24x24/%s.png", name), Icon.ICON_MEDIUM_STYLE, IconType.PLUGIN) ); IconSet.icons.addIcon(new Icon( String.format("icon-credentials-%s icon-lg", name), String.format("credentials/images/32x32/%s.png", name), Icon.ICON_LARGE_STYLE, IconType.PLUGIN) ); IconSet.icons.addIcon(new Icon( String.format("icon-credentials-%s icon-xlg", name), String.format("credentials/images/48x48/%s.png", name),
@Override public String getIconFileName() { String iconClassName = getIconClassName(); if (iconClassName != null) { Icon icon = IconSet.icons.getIconByClassSpec(iconClassName + " icon-md"); if (icon != null) { JellyContext ctx = new JellyContext(); ctx.setVariable("resURL", Stapler.getCurrentRequest().getContextPath() + Jenkins.RESOURCE_PATH); return icon.getQualifiedUrl(ctx); } } return null; }
private static void addIcon(String name) { for (Size size : Size.values()) { icons.addIcon(new Icon(classSpec(name, size), ICON_PATH + size.dimensions + "/" + name + ".png", size.style)); } }
public static String iconFileName(String name, Size size) { Icon icon = icons.getIconByClassSpec(classSpec(name, size)); if (icon == null) { return null; } JellyContext ctx = new JellyContext(); ctx.setVariable("resURL", Stapler.getCurrentRequest().getContextPath() + Jenkins.RESOURCE_PATH); return icon.getQualifiedUrl(ctx); }