Example usage for com.vaadin.ui CssLayout addComponent

List of usage examples for com.vaadin.ui CssLayout addComponent

Introduction

In this page you can find the example usage for com.vaadin.ui CssLayout addComponent.

Prototype

@Override
public void addComponent(Component c) 

Source Link

Document

Add a component into this container.

Usage

From source file:org.opennms.features.vaadin.surveillanceviews.ui.SurveillanceView.java

License:Open Source License

/**
 * Set the view to be displayed by this component.
 *
 * @param view the view to be displayed//w  ww. j  a va2s.  co  m
 */
public void setView(View view) {
    /**
     * set the field
     */
    m_view = view;

    /**
     * check whether refreshing is enabled
     */
    m_refreshEnabled = (m_view.getRefreshSeconds() > 0);
    m_countdown = m_view.getRefreshSeconds();

    /**
     * alter the table header
     */
    m_surveillanceViewTableHeader.setCaptionText("Surveillance view: " + m_view.getName());
    m_surveillanceViewTableHeader.select(m_view.getName());
    m_surveillanceViewTableHeader.getNativeSelect().setEnabled(m_enabled);

    /**
     * remove old components
     */
    removeAllComponents();

    /**
     * create the layout
     */
    upperLayout = new VerticalLayout();
    upperLayout.setId("surveillance-window");
    upperLayout.setSpacing(false);

    /**
     * create surveillance view table...
     */
    m_surveillanceViewTable = new SurveillanceViewTable(m_view, m_surveillanceViewService, m_dashboard,
            m_enabled);

    /**
     * ...and add the header and the table itself
     */

    upperLayout.addComponent(new Label("<div id=\"surveillanceview\"/>", ContentMode.HTML));
    upperLayout.addComponent(m_surveillanceViewTableHeader);
    upperLayout.addComponent(m_surveillanceViewTable);

    if (!m_dashboard) {
        addComponent(upperLayout);
    } else {
        /**
         * if dashboard should be displayed add the detail tables and components
         */

        CssLayout leftCssLayout = new CssLayout() {
            @Override
            protected String getCss(Component c) {
                return "padding-bottom: 6px;";
            }
        };

        leftCssLayout.setPrimaryStyleName("col-md-11");
        leftCssLayout.setId("dashboard-content");

        CssLayout rightCssLayout = new CssLayout();
        rightCssLayout.setPrimaryStyleName("col-md-1");

        lowerLayout = new VerticalLayout();
        lowerLayout.setSpacing(true);

        /**
         * create the tables and components
         */
        SurveillanceViewAlarmTable surveillanceViewAlarmTable = new SurveillanceViewAlarmTable(
                m_surveillanceViewService, m_enabled);
        SurveillanceViewNotificationTable surveillanceViewNotificationTable = new SurveillanceViewNotificationTable(
                m_surveillanceViewService, m_enabled);
        SurveillanceViewNodeRtcTable surveillanceViewNodeRtcTable = new SurveillanceViewNodeRtcTable(
                m_surveillanceViewService, m_enabled);
        SurveillanceViewGraphComponent surveillanceViewGraphComponent = new SurveillanceViewGraphComponent(
                m_surveillanceViewService, m_enabled);

        /**
         * add them to the layout
         */
        surveillanceViewAlarmTable.setId("alarms");
        lowerLayout.addComponent(surveillanceViewAlarmTable);

        surveillanceViewNotificationTable.setId("notifications");
        lowerLayout.addComponent(surveillanceViewNotificationTable);

        surveillanceViewNodeRtcTable.setId("outages");
        lowerLayout.addComponent(surveillanceViewNodeRtcTable);

        surveillanceViewGraphComponent.setId("resourcegraphs");
        lowerLayout.addComponent(surveillanceViewGraphComponent);

        /**
         * associate the detail tables and components with the surveillance view table
         */
        m_surveillanceViewTable.addDetailsTable(surveillanceViewAlarmTable);
        m_surveillanceViewTable.addDetailsTable(surveillanceViewNotificationTable);
        m_surveillanceViewTable.addDetailsTable(surveillanceViewNodeRtcTable);
        m_surveillanceViewTable.addDetailsTable(surveillanceViewGraphComponent);

        /**
         * add the layout to this component
         */
        addComponent(lowerLayout);

        leftCssLayout.addComponent(upperLayout);
        leftCssLayout.addComponent(lowerLayout);

        CssLayout resultsSidebar = new CssLayout();
        resultsSidebar
                .setPrimaryStyleName("resource-graphs-sidebar hidden-print hidden-xs hidden-sm sidebar-fixed");
        resultsSidebar.setId("results-sidebar");

        resultsSidebar.addComponent(new Label("<ul class=\"nav nav-stacked\">\n" + "                <li>\n"
                + "                    <a href=\"#surveillanceview\" data-target=\"#surveillanceview\">Surveillance View</a>\n"
                + "                </li>\n" + "                <li>\n"
                + "                    <a href=\"#alarms\" data-target=\"#alarms\">Alarms</a>\n"
                + "                </li>\n" + "                <li>\n"
                + "                    <a href=\"#notifications\" data-target=\"#notifications\">Notifications</a>\n"
                + "                </li>\n" + "                <li>\n"
                + "                    <a href=\"#outages\" data-target=\"#outages\">Outages</a>\n"
                + "                </li>\n" + "                <li>\n"
                + "                    <a href=\"#resourcegraphs\" data-target=\"#resourcegraphs\">Resource Graphs</a>\n"
                + "                </li>\n" + "            </ul>" + "<script type=\"text/javascript\">\n"
                + "            $('body').scrollspy({ target: '#results-sidebar' });\n" + "</script>\n",
                ContentMode.HTML));

        rightCssLayout.addComponent(resultsSidebar);

        addComponent(leftCssLayout);
        addComponent(rightCssLayout);
    }

}

From source file:org.semanticsoft.vaaclipse.p2.install.ui.impl.ContainerP2Views.java

License:Open Source License

@Override
public void initUI() {
    // TODO Auto-generated method stub

    mainLayout.removeAllComponents();/*w ww  .j a  v a2s . co  m*/
    mainLayout.addComponent((Component) listUI.get(0).getUIComponent());

    selectedBasicUI = listUI.get(0);
    final CssLayout cssLayout = new CssLayout();

    cssLayout.addComponent(buttonPrevies);
    cssLayout.addComponent(buttonNext);
    buttonNext.setEnabled(true);
    buttonInstall.setEnabled(false);
    buttonPrevies.setEnabled(false);

    cssLayout.addComponent(buttonInstall);

    buttonInstall.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            // TODO Auto-generated method stub

            boolean validate = listUI.get(maxViews - 1).validate();

            if (validate) {
                installService.installNewSoftware(listUI.get(maxViews - 1).getRepositories());

                HasComponents parent = buttonNext.getParent();
                while (!(parent instanceof Window)) {

                    parent = parent.getParent();
                }

                Window w = (Window) parent;
                w.close();
                Notification.show("Software installed");
            }

        }
    });

    Button.ClickListener listenerButton = new Button.ClickListener() {

        int index = 0;
        IBasicUI iBasicUIWas = null;
        IBasicUI iBasicUI = null;

        @Override
        public void buttonClick(ClickEvent event) {
            // TODO Auto-generated method stub

            if (event.getButton() == buttonNext) {

                boolean validate = listUI.get(index).validate();

                if (index < maxViews - 1 && validate) {
                    mainLayout.removeAllComponents();
                    index++;
                    iBasicUIWas = iBasicUI;
                    if (iBasicUI == null) {
                        iBasicUIWas = listUI.get(0);
                    }
                    iBasicUI = listUI.get(index);

                    iBasicUI.addRepositories(iBasicUIWas.getRepositories());
                    mainLayout.addComponent((Component) iBasicUI.getUIComponent());
                    handleButtons();
                }
            } else if (event.getButton() == buttonPrevies) {

                if (index > -1) {

                    if (index > 0)
                        mainLayout.removeAllComponents();
                    index--;
                    if (iBasicUI == null) {
                        iBasicUIWas = listUI.get(0);
                    }
                    iBasicUIWas = iBasicUI;
                    iBasicUI = listUI.get(index);

                    iBasicUI.addRepositories(iBasicUIWas.getRepositories());
                    mainLayout.addComponent((Component) iBasicUI.getUIComponent());
                    handleButtons();
                }
            }

            mainLayout.addComponent(cssLayout);
        }

        private void handleButtons() {
            if (index == 0) {
                buttonPrevies.setEnabled(false);
                buttonInstall.setEnabled(false);
            } else if (index == maxViews - 1) {
                buttonNext.setEnabled(false);
                buttonInstall.setEnabled(true);

            }

            if (index > 0) {
                buttonPrevies.setEnabled(true);

            }
            if (index < maxViews - 1) {
                buttonNext.setEnabled(true);

            }
        }
    };
    buttonNext.addClickListener(listenerButton);
    buttonPrevies.addClickListener(listenerButton);
    mainLayout.addComponent(cssLayout);
}

From source file:org.semanticsoft.vaaclipse.p2.sites.ui.impl.SitesView.java

License:Open Source License

@Override
public void initUI() {
    // TODO Auto-generated method stub

    CssLayout buttonLayout = new CssLayout();

    Button buttonAdd = new Button("Add");
    buttonAdd.addClickListener(new ClickListener() {

        @Override/*from  w w w . j a  v  a  2 s  .c o m*/
        public void buttonClick(ClickEvent event) {
            // TODO Auto-generated method stub

            addSite();
        }
    });
    buttonLayout.addComponent(buttonAdd);
    Button buttonRemove = new Button("Remove");
    buttonRemove.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            // TODO Auto-generated method stub

            if (!isSelected()) {

                Notification.show("Must select at least one");
                return;
            }

            Collection<URI> value = getSelected();
            for (URI u : value) {

                removeSite(u.toString());

            }

            loadSites();
        }
    });
    buttonLayout.addComponent(buttonRemove);
    Button buttonEdit = new Button("Edit");
    buttonEdit.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            // TODO Auto-generated method stub
            modificSite();
        }
    });
    buttonLayout.addComponent(buttonEdit);
    VerticalLayout verticalLayoutButton = new VerticalLayout();

    CheckBox enableChek = new CheckBox("Enable");
    verticalLayoutButton.addComponent(enableChek);

    enableChek.addValueChangeListener(new ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            // TODO Auto-generated method stub
            if (!isSelected()) {

                Notification.show("Must select at least one");
                return;
            }
            Boolean value = (Boolean) event.getProperty().getValue();

            Collection<URI> selected = getSelected();
            for (URI uri : selected) {

                sitesManager.setRepositoryEnabled(agent, uri, value);
            }

            loadSites();
        }
    });
    Button reloadButton = new Button("Reload");
    reloadButton.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            // TODO Auto-generated method stub

            loadSites();
        }
    });
    verticalLayoutButton.addComponent(reloadButton);
    Button importButton = new Button("Import");
    verticalLayoutButton.addComponent(importButton);
    Button exportButton = new Button("Export");
    verticalLayoutButton.addComponent(exportButton);

    treeTable = new TreeTable("List of avaible software sites");
    treeTable.addContainerProperty("Name", String.class, "");
    treeTable.addContainerProperty("Location", String.class, "");
    treeTable.addContainerProperty("Enable", String.class, "");
    treeTable.setPageLength(5);
    treeTable.setWidth("40em");
    treeTable.setSelectable(true);
    treeTable.setImmediate(true);
    treeTable.setMultiSelect(true);

    HorizontalLayout simpleContainer = new HorizontalLayout();
    simpleContainer.addComponent(treeTable);
    simpleContainer.addComponent(verticalLayoutButton);

    mainLayout.addComponent(buttonLayout);
    mainLayout.addComponent(simpleContainer);

}

From source file:org.semanticsoft.vaaclipse.presentation.renderers.PartRenderer.java

License:Open Source License

@Override
public void createWidget(MUIElement element, MElementContainer<MUIElement> parent) {
    VerticalLayout pane = new VerticalLayout();
    pane.setSizeFull();//from   www. j  a  va2s. c  o m
    final MPart part = (MPart) element;

    CssLayout toolbarArea = new CssLayout();
    toolbarArea.setStyleName("mparttoolbararea");
    toolbarArea.setSizeUndefined();
    toolbarArea.setWidth("100%");
    pane.addComponent(toolbarArea);

    //create toolbar
    MToolBar toolbar = part.getToolbar();
    if (toolbar != null && toolbar.isToBeRendered()) {
        Component toolbarWidget = (Component) renderingEngine.createGui(toolbar);
        ((AbstractLayout) toolbarWidget).setSizeUndefined();
        toolbarWidget.setStyleName("mparttoolbar");
        toolbarArea.addComponent(toolbarWidget);
    }

    VerticalLayout contributionArea = new VerticalLayout();
    contributionArea.setSizeFull();
    pane.addComponent(contributionArea);
    pane.setExpandRatio(contributionArea, 100);

    pane.setStyleName("part");
    element.setWidget(pane);

    IEclipseContext localContext = part.getContext();
    localContext.set(Component.class, contributionArea);
    localContext.set(ComponentContainer.class, contributionArea);
    localContext.set(VerticalLayout.class, contributionArea);
    localContext.set(MPart.class, part);
    SavePromptSetup savePromptProvider = new SavePromptSetup();
    savePrompts.put(part, savePromptProvider);
    localContext.set(SavePromptSetup.class, savePromptProvider);
    if (part instanceof MInputPart)
        localContext.set(MInputPart.class, (MInputPart) part);

    IContributionFactory contributionFactory = (IContributionFactory) localContext
            .get(IContributionFactory.class.getName());
    Object newPart = contributionFactory.create(part.getContributionURI(), localContext);

    part.setObject(newPart);
}

From source file:org.vaadin.addon.twitter.demo.DemoUI.java

License:Apache License

@Override
protected void init(VaadinRequest request) {
    Responsive.makeResponsive(this);
    CssLayout info = new CssLayout();
    info.setStyleName("tw-docs");
    info.addComponent(markdown.get(0));

    TabSheet tabSheet = new TabSheet();
    tabSheet.setStyleName("tw-demo-tab");
    tabSheet.addStyleName(ValoTheme.TABSHEET_CENTERED_TABS);
    tabSheet.setSizeFull();// w  ww  . j  a v a2s  .c om
    tabSheet.addTab(new TimelineDemo()).setCaption("Timeline");
    tabSheet.addTab(new TweetDemo()).setCaption("Single Tweet");
    tabSheet.addTab(new ButtonDemo(TweetButton.Type.Follow)).setCaption("Follow Button");
    tabSheet.addTab(new ButtonDemo(TweetButton.Type.Share)).setCaption("Share Button");
    tabSheet.addTab(new ButtonDemo(TweetButton.Type.Hashtag)).setCaption("Hashtag Button");
    tabSheet.addTab(new ButtonDemo(TweetButton.Type.Mention)).setCaption("Mention Button");
    tabSheet.addSelectedTabChangeListener(event -> {
        Component old = info.getComponent(0);
        Component newComp = markdown.get(tabSheet.getTabPosition(tabSheet.getTab(tabSheet.getSelectedTab())));
        info.replaceComponent(old, newComp);
    });
    final MHorizontalLayout layout = new MHorizontalLayout(info, tabSheet).withExpand(info, 4)
            .withExpand(tabSheet, 6).withFullWidth().withFullHeight().withMargin(false).withSpacing(true);
    setContent(new MPanel(layout).withFullWidth().withFullHeight().withStyleName(ValoTheme.PANEL_WELL,
            "root-container"));

}

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

License:Apache License

public void refresh() {
    final CssLayout navigationLayout = new CssLayout();
    //navigationLayout.setSpacing(true);
    //navigationLayout.setMargin(true);

    final NavigationVersion navigationVersion = getSite().getCurrentNavigationVersion();

    final String[] elements = navigationVersion.getTree().split(";");
    for (final String element : elements) {
        final int indentLastIndex = element.lastIndexOf('+');
        final String pageName = indentLastIndex == -1 ? element : element.substring(indentLastIndex + 1);

        final ViewVersion pageVersion = getSite().getCurrentViewVersion(pageName);
        if (pageVersion == null) {
            throw new SiteException("Unknown page: " + pageName);
        }/*from  ww  w . ja  v a 2 s .  c  om*/
        if (pageVersion.getViewerRoles().length > 0) {
            boolean roleMatch = false;
            for (final String role : pageVersion.getViewerRoles()) {
                if (getSite().getSecurityProvider().getRoles().contains(role)) {
                    roleMatch = true;
                    break;
                }
            }
            if (!roleMatch) {
                continue;
            }
        }

        final String localizedPageName = getSite().localize("page-link-" + pageName);
        final Resource iconResource = getSite().getIcon("page-icon-" + pageName);

        final HorizontalLayout itemLayout = new HorizontalLayout();
        itemLayout.setSpacing(true);
        itemLayout.setMargin(false);
        itemLayout.setStyleName("horizontal-navigation-" + pageName);
        navigationLayout.addComponent(itemLayout);

        final int indentCount = indentLastIndex + 1;
        final StringBuilder indentBuilder = new StringBuilder();
        for (int i = 0; i < indentCount; i++) {
            indentBuilder.append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
        }

        final Label indent = new Label(indentBuilder.toString(), Label.CONTENT_XHTML);
        itemLayout.addComponent(indent);
        if (iconResource != null) {
            final Embedded embedded = new Embedded(null, iconResource);
            embedded.setWidth(20, UNITS_PIXELS);
            embedded.setHeight(20, UNITS_PIXELS);
            itemLayout.addComponent(embedded);
        }

        final Button link = new Button(localizedPageName);
        link.setStyleName(BaseTheme.BUTTON_LINK);
        link.addClickListener(new ClickListener() {
            @Override
            public void buttonClick(ClickEvent event) {
                UI.getCurrent().getNavigator().navigateTo(pageName);
            }
        });
        /*if (page.getName().equals(pageName)) {
        link.setEnabled(false);
        }*/

        itemLayout.addComponent(link);
        itemLayout.setComponentAlignment(link, Alignment.MIDDLE_LEFT);
    }

    if (getSite().getSecurityProvider().getUser() != null) {
        final HorizontalLayout itemLayout = new HorizontalLayout();
        itemLayout.setStyleName("horizontal-navigation-logout");
        itemLayout.setSpacing(true);
        itemLayout.setMargin(false);
        navigationLayout.addComponent(itemLayout);

        final int indentCount = 0;
        final StringBuilder indentBuilder = new StringBuilder();
        for (int i = 0; i < indentCount; i++) {
            indentBuilder.append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
        }

        final Resource iconResource = getSite().getIcon("page-icon-logout");
        final Label indent = new Label(indentBuilder.toString(), Label.CONTENT_XHTML);
        itemLayout.addComponent(indent);
        if (iconResource != null) {
            final Embedded embedded = new Embedded(null, iconResource);
            embedded.setWidth(20, UNITS_PIXELS);
            embedded.setHeight(20, UNITS_PIXELS);
            itemLayout.addComponent(embedded);
        }

        final Button logoutButton = new Button(getSite().localize("button-logout"));
        logoutButton.setStyleName(BaseTheme.BUTTON_LINK);
        logoutButton.addClickListener(new ClickListener() {
            /** Serial version UID. */
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final ClickEvent event) {
                final Company company = getSite().getSiteContext().getObject(Company.class);
                getUI().getPage().setLocation(company.getUrl());

                // Close the VaadinSession
                getSession().close();

            }
        });

        itemLayout.addComponent(logoutButton);
        itemLayout.setComponentAlignment(logoutButton, Alignment.MIDDLE_LEFT);
    }

    setCompositionRoot(navigationLayout);
}

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

License:Apache License

private ComponentContainer buildLayout() {

    CssLayout topLayout = new CssLayout();
    topLayout.setSizeFull();//w  w w  .  j  a va 2 s .c  o m

    TabSheet tabs = new TabSheet();
    topLayout.addComponent(tabs);
    tabs.setSizeFull();

    tabs.addTab(buildWelcome(), "Welcome");
    tabs.addTab(new ImageDemo(), "FancyImage");
    tabs.addTab(new PanelDemo(), "FancyPanel");
    tabs.addTab(new CssLayoutDemo(), "FancyLayout");

    NotificationsDemo notDemo = new NotificationsDemo();
    tabs.addTab(notDemo, "FancyNotifications");

    // Add notification to top most UI elements you have. Then just give it
    // as reference to child components.
    notifications = new FancyNotifications();
    topLayout.addComponent(notifications);
    notDemo.init(notifications);

    return topLayout;
}

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   w  w  w .ja v a  2  s . com*/
 * @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.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 w w  w  .  ja v  a 2  s . co  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.notifique.Notifique.java

License:Apache License

/**
 * Create a new item into the queue. It is not visible until added with
 *//*ww  w.  j  av  a2s .  com*/
protected Message createMessage(final Component component, String style) {

    final Message m = new Message();

    // Wrap to a CssLayout (this is needed for styling and sizing correctly)
    CssLayout css = new CssLayout();
    css.setWidth("100%");
    css.setStyleName(Notifique.STYLE_ITEM);
    css.addStyleName(style != null ? style : Styles.MESSAGE);
    css.addComponent(component);

    // Wrap component into an animator
    m.component = component;
    m.animatedContent = css;

    return m;
}