Example usage for com.vaadin.server ThemeResource ThemeResource

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

Introduction

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

Prototype

public ThemeResource(String resourceId) 

Source Link

Document

Creates a resource.

Usage

From source file:org.vaadin.addons.javaee.buttons.SearchButton.java

License:Apache License

public SearchButton(CanHandleSearchButton canHandle, String title) {
    super(TranslationKeys.BUTTON_SEARCH, title);
    addClickListener(new SearchClickHandler(this, canHandle));
    setIcon(new ThemeResource("icons/silk/find.png"));
}

From source file:org.vaadin.addons.sitekit.viewlet.anonymous.ImageViewlet.java

License:Apache License

@Override
public void attach() {
    super.attach();
    final String logoImageThemeFileName = getViewletDescriptor().getConfiguration();
    final VerticalLayout layout = new VerticalLayout();
    layout.setMargin(false);//from w  ww .jav a  2  s  .c  o  m
    final Embedded embedded = new Embedded(null, new ThemeResource(logoImageThemeFileName));
    embedded.setWidth(32, UNITS_PIXELS);
    embedded.setHeight(32, UNITS_PIXELS);
    layout.addComponent(embedded);
    layout.setComponentAlignment(embedded, Alignment.MIDDLE_CENTER);
    this.setCompositionRoot(layout);
}

From source file:org.vaadin.alump.fancylayouts.demo.PanelDemo.java

License:Apache License

/**
 * Sample content with simple table (disabled as table is so broken in
 * Vaadin 7). To get table work you probably need some special timer.
 * //from www .  j  av a 2 s .  c  om
 * @return
 */
// private ComponentContainer createPanelContentC() {
// VerticalLayout layout = new VerticalLayout();
// layout.setWidth("100%");
// layout.setMargin(true);
// layout.setSpacing(true);
//
// Label label = new Label ("Table is quite broken in Vaadin 7?");
// layout.addComponent(label);
//
// Table table = new Table();
// table.setWidth("400px");
// table.setHeight("500px");
// table.addContainerProperty("Name", String.class, "");
// table.addContainerProperty("Phone Number", String.class, "");
// table.addItem(new Object[] { "Matti Meiklinen", "555 234 2344" },
// "Matti");
// table.addItem(new Object[] { "Donald Duck", "555 332 7782" }, "Donald");
//
// layout.addComponent(table);
//
// return layout;
// }

private ComponentContainer createPanelContentD() {
    CssLayout layout = new CssLayout();
    layout.addStyleName("demo-panel-d");
    layout.setWidth("100%");
    layout.setHeight("100%");

    Image image = new Image();
    image.setSource(new ThemeResource("images/meme.jpg"));
    image.addStyleName("demo-meme");
    layout.addComponent(image);

    return layout;
}

From source file:org.vaadin.alump.offlinebuilder.demo.DemoUI.java

License:Open Source License

@Override
protected void init(VaadinRequest vaadinRequest) {

    OfflineUIExtension offlineExtension = OfflineUIExtension.get(this);

    // As Panel is half legacy component, using OfflineCssLayout to make content scrollable
    OfflineCssLayout panel = new OfflineCssLayout();
    panel.addStyleName("scrollable-wrapper");
    panel.setSizeFull();/*from  w  ww  . ja v  a2  s . c  om*/
    setContent(panel);
    offlineExtension.setOfflineRoot(panel);

    VerticalLayout layout = new OfflineVerticalLayout();
    layout.setMargin(true);
    layout.setSpacing(true);
    layout.addStyleName("main-layout");
    panel.addComponent(layout);

    Label header = new OfflineLabel("OfflineBuilder");
    header.addStyleName("header-label");
    layout.addComponent(header);

    Label info = new OfflineLabel("OfflineBuilder allows to define offline UI without need of writing GWT"
            + " code. Add-on offers offline extended versions of basic Vaadin UI components and layouts. This way"
            + " your server defined UI can be used on offline mode too.");
    info.addStyleName("info-label");
    layout.addComponent(info);

    info = new OfflineLabel(
            "To test offline functionality. Turn on flight mode on your device or just disconnect"
                    + " from your network connection. Offline UI should look identical with online UI.");
    info.addStyleName("info-label");
    layout.addComponent(info);

    Image image = new OfflineImage();
    image.setWidth("300px");
    image.addStyleName("extra-stylename-image");
    image.setSource(new ThemeResource("img/offline.png"));
    image.setDescription("Example image");
    layout.addComponent(image);

    HorizontalLayout buttonLayout = new OfflineHorizontalLayout();
    buttonLayout.setSpacing(true);
    layout.addComponent(buttonLayout);

    OfflineButton pingButton = new OfflineButton("Ping server");
    pingButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            Notification.show("Server says pong!");
        }
    });
    pingButton.setDescription("Button that will be automatically disabled on offline mode");
    buttonLayout.addComponent(pingButton);

    OfflineButton writeButton = new OfflineButton("Store value (TODO)");
    writeButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            Notification.show("No need to store, in online mode.");
        }
    });
    buttonLayout.addComponent(writeButton);

    /*
    OfflineFormLayout formTest = new OfflineFormLayout();
    OfflineCheckBox checkbox = new OfflineCheckBox("Flag me");
    checkbox.setOfflineValueKey("flag");
    formTest.addComponent(checkbox);
    layout.addComponent(formTest);
    */

    Link link = new OfflineLink("Open project's GitHub page",
            new ExternalResource("https://github.com/alump/OfflineBuilder"));
    link.addStyleName("github-link");
    layout.addComponent(link);
}

From source file:org.vaadin.alump.scaleimage.demo.DemoUI.java

License:Apache License

@Override
protected void init(VaadinRequest request) {
    VerticalLayout layout = new VerticalLayout();
    layout.setWidth(100, Unit.PERCENTAGE);
    layout.setMargin(true);//from ww w .  j a  va 2s  . c  o m
    layout.setSpacing(true);
    setContent(layout);

    // Big image that will scale to match with your page width, will
    // show the center of given picture. See SCSS file.
    ScaleImage bigCenterImage = new ScaleImage();
    bigCenterImage.setWidth("100%");
    bigCenterImage.setHeight("200px");
    bigCenterImage.setStyleName("big-center-image");
    bigCenterImage.setSource(new ThemeResource("images/big-center-image.jpg"));
    bigCenterImage.addClickListener(new MouseEvents.ClickListener() {
        @Override
        public void click(MouseEvents.ClickEvent clickEvent) {
            Notification.show("Big center image clicked!");
        }
    });
    layout.addComponent(bigCenterImage);

    // Tile with image, where images will be scaled to match with tile size.
    // tileimage will cover space of tile and indicator image will be at
    // top left corner.
    // Uses absolute left/right/top/down positioning. See SCSS file.
    final CssLayout tile = new CssLayout();
    tile.setStyleName("tile");
    tile.setWidth(100, Unit.PIXELS);
    tile.setHeight(100, Unit.PIXELS);
    layout.addComponent(tile);
    tile.addLayoutClickListener(new LayoutClickListener() {

        @Override
        public void layoutClick(LayoutClickEvent event) {
            int size = (int) Math.round(100.0 + Math.random() * 100.0);
            tile.setWidth(size, Unit.PIXELS);
            tile.setHeight(size, Unit.PIXELS);
        }

    });

    ScaleImage tileImage = new ScaleImage();
    tileImage.setSource(new ThemeResource("images/tile-image.jpg"));
    tileImage.setStyleName("tile-image");
    tile.addComponent(tileImage);
    ScaleImage indicatorImage = new ScaleImage();
    indicatorImage.setSource(new ThemeResource("images/tile-indicator.png"));
    indicatorImage.setStyleName("tile-indicator");
    tile.addComponent(indicatorImage);
    Label tileLabel = new Label("Click tile to scale it.");
    tile.addComponent(tileLabel);

    extendedImage = new ExtendedScaleImage();
    extendedImage.setSource(new ThemeResource("images/tile-indicator.png"));
    extendedImage.setWidth("200px");
    extendedImage.setHeight("400px");
    extendedImage.setStyleName("extended-image");
    layout.addComponent(extendedImage);

    Button moveButton = new Button("Move background", new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            Boolean val = extendedImage.getPosition();
            if (val == null) {
                val = true;
            }

            extendedImage.setPosition(!val.booleanValue());

        }
    });
    layout.addComponent(moveButton);

    // Test how well scale image behaves inside alignment layout

    HorizontalLayout alignLayout = new HorizontalLayout();
    alignLayout.setSpacing(true);
    alignLayout.setWidth("200px");
    layout.addComponent(alignLayout);

    Label label = new Label("Alignment test:");
    label.addStyleName("align-label");
    alignLayout.addComponent(label);
    alignLayout.setExpandRatio(label, 1.0f);
    alignLayout.setComponentAlignment(label, Alignment.MIDDLE_CENTER);

    ScaleImage alignImage = new ScaleImage();
    alignImage.setSource(new ThemeResource("images/tile-image.jpg"));
    alignImage.setWidth("20px");
    alignImage.setHeight("20px");
    alignLayout.addComponent(alignImage);
    alignLayout.setComponentAlignment(alignImage, Alignment.BOTTOM_CENTER);
}

From source file:org.vaadin.anna.gridactionrenderer.GridAction.java

License:Apache License

/**
 * Constructor./*from  www. j a  v  a2  s.  c om*/
 *
 * @param iconPath
 *            path for a ThemeResource icon, required
 * @param description
 *            tooltip text, can be null
 */
public GridAction(String iconPath, String description) {
    super(null);
    assert iconPath != null;

    setIcon(new ThemeResource(iconPath));
    this.description = description;
}

From source file:org.vaadin.notifique.sample.NotifiqueSampleApplicationUI.java

License:Apache License

@Override
public void init(VaadinRequest request) {
    VerticalLayout view = new VerticalLayout();
    stack = new Notifique(false);
    stack.setClickListener(this);
    stack.setHideListener(this);
    stack.setWidth("100%");
    view.addComponent(stack);/*from  w  w  w . j  a va  2  s . co m*/

    HorizontalLayout btns = new HorizontalLayout();
    view.addComponent(btns);

    String[] styles = new String[] { Notifique.Styles.INFO, Notifique.Styles.SUCCESS, Notifique.Styles.WARNING,
            Notifique.Styles.ERROR, Notifique.Styles.MESSAGE, Notifique.Styles.MAGIC_BLACK,
            Notifique.Styles.MAGIC_GRAY, Notifique.Styles.MAGIC_WHITE, Notifique.Styles.BROWSER_FF,
            Notifique.Styles.BROWSER_FF3, Notifique.Styles.BROWSER_IE, Notifique.Styles.BROWSER_CHROME,
            Notifique.Styles.VAADIN_BLACK, Notifique.Styles.VAADIN_BEIGE, Notifique.Styles.VAADIN_RED,
            Notifique.Styles.VAADIN_GREEN, Notifique.Styles.VAADIN_BLUE, Notifique.Styles.VAADIN_ORANGE };
    for (int i = 0; i < styles.length; i++) {
        final String s = styles[i];
        btns.addComponent(new Button("" + s, new Button.ClickListener() {
            private static final long serialVersionUID = 1L;

            public void buttonClick(ClickEvent event) {
                stack.add(themeIcon("email", 32),
                        "This is a message at <b>" + new Date() + "</b>. This is something longer with this.",
                        s);
            }
        }));
    }
    btns.addComponent(new Button("Clear", new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent event) {
            stack.clear();
        }
    }));

    final Resource icon = new ThemeResource("../runo/icons/32/email.png");

    flow = new Notifique(true);
    flow.setFillFromTop(true);
    flow.setClickListener(this);
    flow.setHideListener(this);
    flow.setVisibleCount(4);
    flow.setWidth("200px");
    flow.setHeight("400px");
    view.addComponent(flow);
    view.addComponent(new Button("add", new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent event) {
            flow.add(icon,
                    "This is a message at <b>" + new Date() + "</b>. This is something longer with this.", true,
                    null, false);
        }
    }));

    setContent(view);
}

From source file:org.vaadin.notifique.sample.NotifiqueSampleApplicationUI.java

License:Apache License

/**
 * Get resource for one of the "Runo" theme icons.
 *
 * @param name//from  w  ww  .  j a  v a2 s . c om
 * @param size
 * @return
 */
protected Resource themeIcon(String name, int size) {
    return new ThemeResource("../runo/icons/" + size + "/" + name + ".png");
}

From source file:org.vaadin.spring.sidebar.LocalizedThemeIconProvider.java

License:Apache License

@Override
public Resource getIcon(LocalizedThemeIcon annotation) {
    final String resourceId = i18n.get(annotation.value());
    return new ThemeResource(resourceId);
}

From source file:org.vaadin.spring.sidebar.ThemeIconProvider.java

License:Apache License

@Override
public Resource getIcon(ThemeIcon annotation) {
    final String resourceId = annotation.value();
    if (resourceId.isEmpty()) {
        return null;
    } else {/*from  ww w.  j a v  a 2  s.  c  o  m*/
        return new ThemeResource(resourceId);
    }
}