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; }
if (ctx != null) { Icon icon = IconSet.icons .getIconByClassSpec(StringUtils.join(new String[]{iconClassName, iconStyle}, " ")); if (icon != null) { metadata.put("iconQualifiedUrl", 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)); } }
/** * Get an icon instance from a class specification. * @param iconClassSpec The icon's class spec as defined on the <l:icon class> attribute. * @return The icon instance, or {@code null} if no such icon. */ public Icon getIconByClassSpec(GString iconClassSpec) { if (iconClassSpec == null) { return null; } return getIconByClassSpec(iconClassSpec.toString()); }
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); }
/** * Icon instance. * * @param classSpec The icon class specification. * @param url The icon image url. * @param style The icon style. * @param iconType The icon type. */ public Icon(String classSpec, String url, String style, IconType iconType) { this.classSpec = classSpec; this.normalizedSelector = toNormalizedCSSSelector(classSpec); this.url = toNormalizedIconUrl(url); this.style = style; this.iconType = iconType; }
/** * Normalize the supplied url. * * @param url The url to be normalized. * @return The normalized url. */ public static String toNormalizedIconUrl(String url) { return Icon.toNormalizedIconUrl(url); }
/** * Normalize the supplied string to an Icon size class e.g. "16x16" to "icon-sm". * * @param string The string to be normalized. * @return The normalized icon size class, or the unmodified {@code string} arg * if it was an unrecognised icon size. */ public static String toNormalizedIconSizeClass(String string) { return Icon.toNormalizedIconSizeClass(string); }
public static void initPageVariables(JellyContext context) { StaplerRequest currentRequest = Stapler.getCurrentRequest(); String rootURL = currentRequest.getContextPath(); Functions h = new Functions(); context.setVariable("h", h); // The path starts with a "/" character but does not end with a "/" character. context.setVariable("rootURL", rootURL); /* load static resources from the path dedicated to a specific version. This "/static/VERSION/abc/def.ghi" path is interpreted by stapler to be the same thing as "/abc/def.ghi", but this avoids the stale cache problem when the user upgrades to new Jenkins. Stapler also sets a long future expiration dates for such static resources. see https://wiki.jenkins-ci.org/display/JENKINS/Hyperlinks+in+HTML */ context.setVariable("resURL",rootURL+getResourcePath()); context.setVariable("imagesURL",rootURL+getResourcePath()+"/images"); context.setVariable("userAgent", currentRequest.getHeader("User-Agent")); IconSet.initPageVariables(context); }
/** * Get the qualified icon url. * <p/> * Qualifying the URL involves prefixing it depending on whether the icon is a core or plugin icon. * Core icons are prefixed with the * * @param context The JellyContext. * @return The qualified icon url. */ public String getQualifiedUrl(JellyContext context) { return iconType.toQualifiedUrl(url, context); }
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)); } }
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; }
/** * 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()); }
/** * Get an icon instance from it's url. * @param url The icon url. * @return The icon instance, or {@code null} if no such icon. */ public Icon getIconByUrl(String url) { if (url == null) { return null; } url = Icon.toNormalizedIconUrl(url); return iconsByUrl.get(url); }
/** * Normalize the supplied string to an Icon size class e.g. "16x16" to "icon-sm". * * @param string The string to be normalized. * @return The normalized icon size class, or the unmodified {@code string} arg * if it was an unrecognised icon size. */ public static String toNormalizedIconSizeClass(GString string) { return Icon.toNormalizedIconSizeClass(string.toString()); }
/** * Normalize the supplied url. * * @param url The url to be normalized. * @return The normalized url. */ public static String toNormalizedIconUrl(GString url) { return Icon.toNormalizedIconUrl(url.toString()); }