public String getSuffix() { return "." + name(); }
/** * @since 7.4 */ public final boolean equals(String type) { if (name().equalsIgnoreCase(type)) { return true; } return false; }
protected ro.isdc.wro.model.resource.ResourceType toWroResourceType(String type) { if (StringUtils.isBlank(type)) { return null; } if (ResourceType.js.name().equals(type.toLowerCase())) { return ro.isdc.wro.model.resource.ResourceType.JS; } if (ResourceType.css.name().equals(type.toLowerCase())) { return ro.isdc.wro.model.resource.ResourceType.CSS; } return null; }
public List<String> getResources() { List<String> res = new ArrayList<String>(); // BBB if (styles != null) { for (String style : styles) { if (style == null) { continue; } if (style.endsWith(ResourceType.css.name())) { res.add(style); } else { res.add(style + "." + ResourceType.css.name()); } } } if (resources != null) { res.addAll(resources); } return res; }
public static final ResourceType parse(String type) { for (ResourceType item : values()) { if (item.name().equals(type)) { return item; } } return ResourceType.unknown; }
public static final boolean matches(String type, Resource r) { if (StringUtils.isBlank(type) || ResourceType.any.name().equals(type.toLowerCase())) { return true; } String rt = r.getType(); if (StringUtils.isBlank(rt)) { return true; } if (type.toLowerCase().equals(rt.toLowerCase())) { return true; } return false; }
public final boolean matches(Resource r) { if (ResourceType.any == this) { return true; } if (r == null || r.getType() == null) { return true; } if (this.name().toLowerCase().equals(r.getType().toLowerCase())) { return true; } return false; }
protected List<Resource> retrieveResources(WebResourceManager wrm, String bundle, ResourceType type) { return wrm.getResources(new ResourceContextImpl(), bundle, type.name()); }
protected ResourceDescriptor getResourceFromStyle(SimpleStyle style) { // turn style into a resource ResourceDescriptor resource = new ResourceDescriptor(); resource.setPath(style.getSrc()); String name = style.getName(); if (name.endsWith(ResourceType.css.name())) { resource.setName(name); } else { resource.setName(name + "." + ResourceType.css.name()); } resource.setProcessors(Collections.singletonList("flavor")); return resource; }
protected void includePageResource(FaceletContext ctx, UIComponent parent, String name, ResourceType type, String flavor, String target, String includeTimestamp, FaceletHandler nextHandler) throws IOException { String componentType = UIOutput.COMPONENT_TYPE; List<TagAttribute> attrs = new ArrayList<TagAttribute>(); attrs.add(getTagAttribute("name", name)); attrs.add(getTagAttribute("type", type.name())); if (!StringUtils.isBlank(target)) { attrs.add(getTagAttribute("target", target)); } if (!StringUtils.isBlank(flavor)) { attrs.add(getTagAttribute("flavor", flavor)); } if (!StringUtils.isBlank(includeTimestamp)) { attrs.add(getTagAttribute("includeTimestamp", includeTimestamp)); } TagAttributesImpl attributes = new TagAttributesImpl(attrs.toArray(new TagAttribute[] {})); ComponentConfig cconfig = TagConfigFactory.createComponentConfig(config, tagId, attributes, nextHandler, componentType, PageResourceRenderer.RENDERER_TYPE); new ComponentHandler(cconfig).apply(ctx, parent); }
protected void includeResourceBundle(FaceletContext ctx, UIComponent parent, String name, ResourceType type, String flavor, String target, String includeTimestamp, FaceletHandler nextHandler) throws IOException { String componentType = UIOutput.COMPONENT_TYPE; List<TagAttribute> attrs = new ArrayList<TagAttribute>(); attrs.add(getTagAttribute("name", name)); attrs.add(getTagAttribute("type", type.name())); if (!StringUtils.isBlank(target)) { attrs.add(getTagAttribute("target", target)); } if (!StringUtils.isBlank(flavor)) { attrs.add(getTagAttribute("flavor", flavor)); } if (!StringUtils.isBlank(includeTimestamp)) { attrs.add(getTagAttribute("includeTimestamp", includeTimestamp)); } TagAttributesImpl attributes = new TagAttributesImpl(attrs.toArray(new TagAttribute[] {})); ComponentConfig cconfig = TagConfigFactory.createComponentConfig(config, tagId, attributes, nextHandler, componentType, ResourceBundleRenderer.RENDERER_TYPE); new ComponentHandler(cconfig).apply(ctx, parent); }
@Override public WroModel create() { WroModel model = new WroModel(); WebResourceManager service = Framework.getService(WebResourceManager.class); ResourceContextImpl rcontext = new ResourceContextImpl(); List<ResourceBundle> bundles = service.getResourceBundles(); for (ResourceBundle bundle : bundles) { String groupName = bundle.getName(); Group group = new Group(groupName); List<Resource> resources = service.getResources(rcontext, groupName, ResourceType.any.name()); if (resources != null) { for (Resource resource : resources) { ro.isdc.wro.model.resource.Resource wr = toWroResource(groupName, resource); if (wr != null) { group.addResource(wr); } } } model.addGroup(group); } return model; }
@Override public WroModel create() { WroModel model = new WroModel(); ThemeStylingService ts = Framework.getService(ThemeStylingService.class); WebResourceManager ws = Framework.getService(WebResourceManager.class); ResourceContextImpl rcontext = new ResourceContextImpl(); List<PageDescriptor> pages = ts.getPages(); for (PageDescriptor page : pages) { String groupName = page.getName(); Group group = new Group(groupName); List<String> bundleNames = page.getResourceBundles(); for (String bundleName : bundleNames) { List<Resource> resources = ws.getResources(rcontext, bundleName, ResourceType.any.name()); if (resources != null) { for (Resource resource : resources) { ro.isdc.wro.model.resource.Resource wr = toWroResource(bundleName, resource); if (wr != null) { group.addResource(wr); } } } } model.addGroup(group); } return model; }