Example usage for com.vaadin.ui CssLayout getComponent

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

Introduction

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

Prototype

public Component getComponent(int index) throws IndexOutOfBoundsException 

Source Link

Document

Returns the component at the given position.

Usage

From source file:com.hybridbpm.ui.MainMenu.java

License:Apache License

public void setSelection(String viewUrl, String parameters) {
    for (Component comp : menuItemsLayout) {
        if (comp instanceof CssLayout) {
            CssLayout dashboardWrapper = (CssLayout) comp;
            if (dashboardWrapper.getComponent(0) instanceof ValoMenuItemButton) {
                ValoMenuItemButton menuItemButton = (ValoMenuItemButton) dashboardWrapper.getComponent(0);
                menuItemButton.removeStyleName("selected");
                if (menuItemButton.getView().getUrl().equals(viewUrl) && menuItemButton.getParameters() == null
                        && (parameters == null || parameters.isEmpty())) {
                    menuItemButton.addStyleName("selected");
                } else if (menuItemButton.getView().getUrl().equals(viewUrl) && parameters != null
                        && Objects.equals(menuItemButton.getParameters(), parameters)) {
                    menuItemButton.addStyleName("selected");
                }/*from   w  w  w.j  ava2s.c om*/
            }
        }
    }
}

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));//from  w  w w .  ja  va2 s  . c  o m

    TabSheet tabSheet = new TabSheet();
    tabSheet.setStyleName("tw-demo-tab");
    tabSheet.addStyleName(ValoTheme.TABSHEET_CENTERED_TABS);
    tabSheet.setSizeFull();
    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"));

}