Search in sources :

Example 1 with Resource

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);
}
Also used : ThemeConstants(com.haulmont.cuba.gui.theme.ThemeConstants) Configuration(com.haulmont.cuba.core.global.Configuration) Resource(com.vaadin.server.Resource) FileResource(com.vaadin.server.FileResource) VersionedThemeResource(com.haulmont.cuba.web.toolkit.VersionedThemeResource) WebConfig(com.haulmont.cuba.web.WebConfig) VersionedThemeResource(com.haulmont.cuba.web.toolkit.VersionedThemeResource) Nullable(javax.annotation.Nullable)

Example 2 with Resource

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);
    }
}
Also used : Configuration(com.haulmont.cuba.core.global.Configuration) FileResource(com.vaadin.server.FileResource) Resource(com.vaadin.server.Resource) FileResource(com.vaadin.server.FileResource) VersionedThemeResource(com.haulmont.cuba.web.toolkit.VersionedThemeResource) WebConfig(com.haulmont.cuba.web.WebConfig) VersionedThemeResource(com.haulmont.cuba.web.toolkit.VersionedThemeResource) ThemeConstants(com.haulmont.cuba.gui.theme.ThemeConstants) File(java.io.File)

Example 3 with Resource

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);
    }
}
Also used : BrowserFrame(com.vaadin.ui.BrowserFrame) ExternalResource(com.vaadin.server.ExternalResource) Resource(com.vaadin.server.Resource) ExternalResource(com.vaadin.server.ExternalResource)

Example 4 with Resource

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;
}
Also used : Resource(com.vaadin.server.Resource)

Example 5 with 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);
    }
}
Also used : Resource(com.vaadin.server.Resource)

Aggregations

Resource (com.vaadin.server.Resource)19 ExternalResource (com.vaadin.server.ExternalResource)5 StreamResource (com.vaadin.server.StreamResource)4 Button (com.vaadin.ui.Button)4 ClickEvent (com.vaadin.ui.Button.ClickEvent)3 ReportSave (au.com.vaadinutils.jasper.scheduler.entities.ReportSave)2 ReportSaveParameter (au.com.vaadinutils.jasper.scheduler.entities.ReportSaveParameter)2 ClickEventLogged (au.com.vaadinutils.listener.ClickEventLogged)2 Configuration (com.haulmont.cuba.core.global.Configuration)2 ThemeConstants (com.haulmont.cuba.gui.theme.ThemeConstants)2 WebConfig (com.haulmont.cuba.web.WebConfig)2 VersionedThemeResource (com.haulmont.cuba.web.toolkit.VersionedThemeResource)2 FileResource (com.vaadin.server.FileResource)2 BrowserFrame (com.vaadin.ui.BrowserFrame)2 InputDialog (au.com.vaadinutils.editors.InputDialog)1 Recipient (au.com.vaadinutils.editors.Recipient)1 ExpanderComponent (au.com.vaadinutils.jasper.filter.ExpanderComponent)1 ReportParameter (au.com.vaadinutils.jasper.parameter.ReportParameter)1 JasperReportEmailWindow (au.com.vaadinutils.jasper.scheduler.JasperReportEmailWindow)1 JasperReportSchedulerWindow (au.com.vaadinutils.jasper.scheduler.JasperReportSchedulerWindow)1