use of com.vaadin.server.Resource in project cuba by cuba-platform.
the class WebComponentsHelper method getIcon.
/**
* @deprecated Use {@link com.haulmont.cuba.web.gui.icons.IconResolver} instead.
*/
@Deprecated
@Nullable
public static Resource getIcon(String iconName) {
if (StringUtils.isEmpty(iconName)) {
return null;
}
Configuration configuration = AppBeans.get(Configuration.NAME);
WebConfig webConfig = configuration.getConfig(WebConfig.class);
if (webConfig.getUseFontIcons()) {
String fontIcon;
if (StringUtils.contains(iconName, ":")) {
fontIcon = iconName;
} else {
ThemeConstants themeConstants = App.getInstance().getThemeConstants();
String iconKey = "cuba.web." + StringUtils.replace(iconName, "/", ".");
fontIcon = themeConstants.get(iconKey);
}
try {
Resource resource = getFontIconResource(fontIcon);
if (resource != null) {
return resource;
}
} catch (NoSuchFieldException | IllegalAccessException e) {
LoggerFactory.getLogger(WebComponentsHelper.class).warn("Unable to use font icon {}", fontIcon);
}
}
return new VersionedThemeResource(iconName);
}
use of com.vaadin.server.Resource in project cuba by cuba-platform.
the class WebComponentsHelper method getResource.
public static Resource getResource(String resURL) {
if (StringUtils.isEmpty(resURL))
return null;
if (resURL.startsWith("file:")) {
return new FileResource(new File(resURL.substring("file:".length())));
} else if (resURL.startsWith("jar:")) {
return new ClassResource(resURL.substring("jar:".length()));
} else if (resURL.startsWith("theme:")) {
String resourceId = resURL.substring("theme:".length());
Configuration configuration = AppBeans.get(Configuration.NAME);
WebConfig webConfig = configuration.getConfig(WebConfig.class);
if (webConfig.getUseFontIcons()) {
String fontIcon;
ThemeConstants themeConstants = App.getInstance().getThemeConstants();
String iconKey = "cuba.web." + StringUtils.replace(resourceId, "/", ".");
fontIcon = themeConstants.get(iconKey);
try {
Resource resource = getFontIconResource(fontIcon);
if (resource != null) {
return resource;
}
} catch (NoSuchFieldException | IllegalAccessException e) {
LoggerFactory.getLogger(WebComponentsHelper.class).warn("Unable to use font icon " + fontIcon);
}
}
return new VersionedThemeResource(resourceId);
} else if (resURL.contains("icon:")) {
try {
return getFontIconResource(resURL);
} catch (NoSuchFieldException | IllegalAccessException e) {
LoggerFactory.getLogger(WebComponentsHelper.class).warn("Unable to use font icon " + resURL);
}
return null;
} else {
return new VersionedThemeResource(resURL);
}
}
use of com.vaadin.server.Resource in project ANNIS by korpling.
the class LoginWindow method attach.
@Override
public void attach() {
super.attach();
this.loginURL = (String) VaadinSession.getCurrent().getAttribute(LOGIN_URL_KEY);
Resource loginRes;
if (loginURL == null || loginURL.isEmpty()) {
loginRes = new ExternalResource(Helper.getContext() + "/login");
} else {
loginRes = new ExternalResource(loginURL);
}
BrowserFrame frame = new BrowserFrame("login", loginRes);
frame.setWidth("100%");
frame.setHeight("100%");
setContent(frame);
String loginMaximizedRaw = (String) getSession().getAttribute(LOGIN_MAXIMIZED_KEY);
if (Boolean.parseBoolean(loginMaximizedRaw)) {
setWindowMode(WindowMode.MAXIMIZED);
}
}
use of com.vaadin.server.Resource in project documentation by cuba-platform.
the class IcoMoonIconProvider method getIconResource.
@Override
public Resource getIconResource(String iconPath) {
Resource resource = null;
iconPath = iconPath.split(":")[1];
try {
resource = ((Resource) IcoMoon.class.getDeclaredField(iconPath).get(null));
} catch (IllegalAccessException | NoSuchFieldException e) {
log.warn("There is no icon with name {} in the FontAwesome icon set", iconPath);
}
return resource;
}
use of com.vaadin.server.Resource in project cuba by cuba-platform.
the class WebButton method setIcon.
@Override
public void setIcon(String icon) {
this.icon = icon;
// -icon style is added automatically on the client-side of CubaButton
if (StringUtils.isNotEmpty(icon)) {
Resource iconResource = getIconResource(icon);
component.setIcon(iconResource);
} else {
component.setIcon(null);
}
}
Aggregations