Example usage for com.vaadin.server ClassResource ClassResource

List of usage examples for com.vaadin.server ClassResource ClassResource

Introduction

In this page you can find the example usage for com.vaadin.server ClassResource ClassResource.

Prototype

public ClassResource(String resourceName) 

Source Link

Document

Creates a new application resource instance.

Usage

From source file:org.jdal.vaadin.ui.FormUtils.java

License:Apache License

/**
 * Gets resource from url using the following prefix
 * <ul>/*from w ww . j  a  v  a 2  s  .c om*/
 * <li> classpath: for searching the classpath.</li>
 * <li> theme: for searching in current theme </li>
 * <li> url: to use a url </li>
 * </ul>
 * @param url resource url
 * @return the resource.
 */
public static Resource getResource(String url) {
    Resource resource;

    if (url.startsWith(CLASSPATH_PREFIX))
        resource = new ClassResource(StringUtils.substringAfter(url, CLASSPATH_PREFIX));
    else if (url.startsWith(THEME_PREFIX))
        resource = new ThemeResource(StringUtils.substringAfter(url, THEME_PREFIX));
    else if (url.startsWith(URL_PREFIX))
        resource = new ExternalResource(StringUtils.substringAfter(url, URL_PREFIX));
    else if (url.contains(":"))
        resource = new ExternalResource(url);
    else
        resource = new ThemeResource(url);

    return resource;
}

From source file:org.jumpmind.metl.ui.views.design.EditFlowPalette.java

License:Open Source License

protected ClassResource getImageResourceForComponentType(String type) {
    return new ClassResource(UiUtils.getImageResourceNameForComponentType(type, context));
}

From source file:org.peergreen.vaadin.diagram.Diagram.java

License:Apache License

public Diagram() {
    // Drop handler
    this.dropHandler = new DiagramDropHandler(this);
    markAsDirty();//w  w w  .j  a v a2 s  .  c o m
    // register server RPC
    registerRpc(new IDiagramServerRpc() {

        @Override
        public void selected(final String uuid) {
            fireSelected(uuid);
        }

        @Override
        public void deleted(final String uuid) {
            fireDeleted(uuid);
        }

        @Override
        public void createConnector(final String sourceUuid, final String targetUuid) {
            fireConnectorCreation(sourceUuid, targetUuid);
        }

        @Override
        public void dropTarget(final String uuid, final String data) {
            fireDropped(uuid, data);
        }

        @Override
        public void log(final String message) {
            fireLog(message);
        }

    });
    addSharedResource(Compartment.DEFAULT_ICON_TYPE, new ClassResource("ovf-icon.png"));
}

From source file:org.rapidpm.jumpstart.vaadin.ui.basics.RapidTopPanel.java

License:Apache License

@PostConstruct
private void createIconsLayout() {
    iconsLayout.setWidth("100%");
    iconsLayout.setMargin(new MarginInfo(false, false, false, false));

    if (propertyService.hasKey("app.logo")) {
        final String resourceName = propertyService.resolve("app.logo");
        final Image iconLeft = new Image(null, new ClassResource(resourceName));
        final Image iconRight = new Image(null, new ClassResource(resourceName));

        iconsLayout.addComponent(iconLeft);
        iconsLayout.setComponentAlignment(iconLeft, Alignment.TOP_LEFT);

        if (propertyService.hasKey("app.version")) {
            final Label versionLabel = new Label(propertyService.resolve("app.version"));
            versionLabel.setSizeUndefined();
            iconsLayout.addComponent(versionLabel);
            iconsLayout.setComponentAlignment(versionLabel, Alignment.MIDDLE_CENTER);
            iconsLayout.setExpandRatio(versionLabel, 1.0f);
        }/*w w w  .j a  va2s . c o m*/

        iconsLayout.addComponent(iconRight);
        iconsLayout.setComponentAlignment(iconRight, Alignment.TOP_RIGHT);
    }
}