if (ctx != null) { Icon icon = IconSet.icons .getIconByClassSpec(StringUtils.join(new String[]{iconClassName, iconStyle}, " ")); if (icon != null) { metadata.put("iconQualifiedUrl", icon.getQualifiedUrl(ctx));
/** * 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; }
} catch (NoSuchMethodException e) { icon = action instanceof IconSpec ? IconSet.icons.getIconByClassSpec(((IconSpec) action).getIconClassName()) : null; if (icon == null) { icon = IconSet.icons.getIconByClassSpec(IconSet.toNormalizedIconNameClass(action.getIconFileName())); icon = IconSet.icons.getIconByUrl(action.getIconFileName());
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 it's url. * @param url The icon url. * @return The icon instance, or {@code null} if no such icon. */ public Icon getIconByUrl(GString url) { if (url == null) { return null; } return getIconByUrl(url.toString()); }
/** * 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(String iconClassSpec) { if (iconClassSpec == null) { return null; } Icon icon = iconsByClassSpec.get(iconClassSpec); if (icon == NO_ICON) { return null; } if (icon != null) { return icon; } String normalizedCSSSelector = Icon.toNormalizedCSSSelector(iconClassSpec); icon = getIconByNormalizedCSSSelector(normalizedCSSSelector); if (icon != null) { iconsByClassSpec.put(iconClassSpec, icon); return icon; } else { iconsByClassSpec.put(iconClassSpec, NO_ICON); return null; } }
} catch (NoSuchMethodException e) { icon = action instanceof IconSpec ? IconSet.icons.getIconByClassSpec(((IconSpec) action).getIconClassName()) : null; if (icon == null) { icon = IconSet.icons.getIconByClassSpec(IconSet.toNormalizedIconNameClass(action.getIconFileName())); icon = IconSet.icons.getIconByUrl(action.getIconFileName());
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()); }
/** * 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; }
"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),
/** * Navigate the signature changes in different versions of {@link IconSet}. * * @param spec the spec to look up. * @return the {@link Icon} or {@code null} */ @CheckForNull public static Icon getIconByClassSpec(String spec) { try { Method getIconByClassSpec = IconSet.class.getMethod("getIconByClassSpec", Object.class); return (Icon) getIconByClassSpec.invoke(IconSet.icons, spec); } catch (NoSuchMethodException e) { // ignore } catch (IllegalAccessException e) { // ignore } catch (InvocationTargetException e) { // ignore } return IconSet.icons.getIconByClassSpec(spec); }
"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),
/** * Navigate the signature changes in different versions of {@link IconSet}. * * @param spec the spec to look up. * @return the {@link Icon} or {@code null} */ @CheckForNull public static Icon getIconByClassSpec(String spec) { try { Method getIconByClassSpec = IconSet.class.getMethod("getIconByClassSpec", Object.class); return (Icon) getIconByClassSpec.invoke(IconSet.icons, spec); } catch (NoSuchMethodException e) { // ignore } catch (IllegalAccessException e) { // ignore } catch (InvocationTargetException e) { // ignore } return IconSet.icons.getIconByClassSpec(spec); }
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)); } }
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; }
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; }
@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; }
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); }
/** * {@inheritDoc} */ @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; }