@Override public Resource parse(String value) { // strip "theme://" from the url, use the rest as the resource // id return new ThemeResource(value.substring(8)); }
/** * @see com.vaadin.server.Resource#getMIMEType() */ @Override public String getMIMEType() { return FileTypeResolver.getMIMEType(getResourceId()); } }
@Override protected void createResource() { resource = new com.vaadin.server.ThemeResource(path); } }
} else if (resource instanceof ThemeResource) { final String uri = ApplicationConstants.THEME_PROTOCOL_PREFIX + ((ThemeResource) resource).getResourceId(); return uri; } else if (resource instanceof FontIcon) {
search.setIcon(new ThemeResource("../../icons/add.png"));
public static ThemeResource getIcon(String icon) { return new ThemeResource(WORK_FOLDER + icon); }
public static Resource themeResource(String fileName) { return new ThemeResource("./../" + THEME_NAME + "/" + fileName); }
// A resource reference to some object Resource res = new ThemeResource("img/reindeer.svg"); // Display the object Embedded object = new Embedded("My SVG", res); object.setMimeType("image/svg+xml"); // Unnecessary layout.addComponent(object);
ThemeResource html = new ThemeResource("static.html"); BrowserFrame frame = new BrowserFrame("Static", html);
@Override public Resource getIconResource(String iconPath) { Preconditions.checkNotEmptyString(iconPath, "Icon path should not be empty"); String icon = iconPath.substring(THEME_PREFIX.length()); return new ThemeResource(icon); }
@Override public Resource getIcon(ThemeIcon annotation) { final String resourceId = annotation.value(); if (resourceId.isEmpty()) { return null; } else { return new ThemeResource(resourceId); } } }
@Override public Resource getIconResource(String iconPath) { Preconditions.checkNotEmptyString(iconPath, "Icon path should not be empty"); return new ThemeResource(iconPath); }
private static Resource getImage(final boolean gravatar) { if (!gravatar) { return new ThemeResource("images/profile-pic-57px.jpg"); } return UserDetailsFormatter.getCurrentUserEmail().map(email -> (Resource) new GravatarResource(email)) .orElse(new ThemeResource("images/profile-pic-57px.jpg")); }
private static Resource getImage(final boolean gravatar) { if (!gravatar) { return new ThemeResource("images/profile-pic-57px.jpg"); } return UserDetailsFormatter.getCurrentUserEmail().map(email -> (Resource) new GravatarResource(email)) .orElse(new ThemeResource("images/profile-pic-57px.jpg")); }
@Override public Resource getIcon(LocalizedThemeIcon annotation) { final String resourceId = i18n.get(annotation.value()); return new ThemeResource(resourceId); } }
Image image = new Image(); image.setSource(new ThemeResource("path/is/relative/to/the/theme/folder.png"));
Button search = new Button("Search"); search.setIcon(new ThemeResource("/$PORLTET-NAME$/icons/add.png"));
private Button createIconButton(String icon) { Button b = new Button(); b.setIcon(new ThemeResource(icon)); b.setStyleName(Reindeer.BUTTON_LINK); return b; } }
resource = new ThemeResource(themeResource); component.setSource(resource); } else {
TabSheet tabsheet= new TabSheet(); // Create an example of tab VerticalLayout tabExample= new VerticalLayout(); tabExample.addComponent(new Embedded(null, new ThemeResource("anyImage.jpg"))); tabExample.setCaption("Example"); tabsheet.addTab(tabExample).setIcon( new ThemeResource("anyIcon.png")); Iterator<Component> componentIterator = tabsheet.getComponentIterator(); while (componentIterator.hasNext()) { Component c = (Component) componentIterator.next(); Tab tab = tabsheet.getTab(c); System.out.println("test: " + tab.getCaption()); }