Example usage for com.vaadin.ui CssLayout removeAllComponents

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

Introduction

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

Prototype

@Override
public void removeAllComponents() 

Source Link

Document

Removes all components from the container.

Usage

From source file:com.cerebro.gorgone.landingpage.SignInWindow.java

private Component setFirstStep() {
    VerticalLayout firstStep = new VerticalLayout();
    firstStep.setMargin(true);/*  w  w w.  ja v  a 2s.c  o  m*/
    // Body
    HorizontalLayout body = new HorizontalLayout();
    FormLayout datiIniziali = new FormLayout();
    TextField nomePG = new TextField("Nome del Personaggio");
    nomePG.setRequired(true);
    TextField cognomePG = new TextField("Cognome del Personaggio");
    cognomePG.setRequired(true);
    OptionGroup sessoPG = new OptionGroup("Sesso del Personaggio");
    sessoPG.setRequired(true);
    sessoPG.addItems("Maschio", "Femmina");
    ComboBox razzaPG = new ComboBox("Razza");
    razzaPG.setRequired(true);
    Slider age = new Slider("Et");
    age.setImmediate(true);
    age.setWidth("200px");
    age.setVisible(false);
    HorizontalLayout ageDescription = new HorizontalLayout();
    ageDescription.setHeight("250px");
    Label ageText = new Label("Valore dell'et: ");
    Label ageValue = new Label(age.getValue().toString());
    Label periodoVita = new Label("");
    ageDescription.addComponents(ageText, ageValue, periodoVita);
    age.addValueChangeListener((Property.ValueChangeEvent event) -> {
        System.out.println("Valore: " + age.getValue().toString());
        ageValue.setValue(age.getValue().toString());
        Double value = (100 * (age.getValue()) / (age.getMax()));
        if (value < 14) {
            periodoVita.setValue("Bambino");
        } else if (value > 14 && value < 24) {
            periodoVita.setValue("Adolescenza");
        } else if (value > 24 && value < 73) {
            periodoVita.setValue("Et adulta");
        } else if (value > 73) {
            periodoVita.setValue("Et anziana");
        }
    });
    ageDescription.addComponents(ageText, ageValue, periodoVita);
    ageDescription.setVisible(false);
    datiIniziali.addComponents(nomePG, cognomePG, sessoPG, razzaPG, age, ageDescription);
    Panel descrizioneRazza = new Panel();
    CssLayout descrizioneRazzaContent = new CssLayout();
    descrizioneRazza.setWidth("400px");
    descrizioneRazza.setHeight("500px");
    descrizioneRazza.setContent(descrizioneRazzaContent);
    //  Dettagli di popolazione e comportamento ComboBox
    TableQuery tq_races = new TableQuery(DatabaseTables.RACES_TABLE, connPool);
    tq_races.setVersionColumn(DatabaseTables.RACES_VERSION);
    SQLContainer container_races = null;
    try {
        container_races = new SQLContainer(tq_races);
    } catch (Exception ex) {
        logger.error(ex.getMessage());
    }
    razzaPG.setContainerDataSource(container_races);
    razzaPG.setItemCaptionMode(AbstractSelect.ItemCaptionMode.PROPERTY);
    razzaPG.setItemCaptionPropertyId(DatabaseTables.RACES_NAME);
    razzaPG.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            if (razzaPG.getValue() != null) {
                logger.info("Razza selezionata: " + razzaPG.getValue());
                age.setVisible(true);
                ageDescription.setVisible(true);
                descrizioneRazzaContent.removeAllComponents();
                Item item = razzaPG.getContainerDataSource().getItem(razzaPG.getValue());
                race = (String) item.getItemProperty(DatabaseTables.RACES_NAME).getValue();
                Label nameRace = new Label(race);
                FileResource imageSrc = new FileResource(
                        new File(MyUI.basePath + item.getItemProperty(DatabaseTables.RACES_IMAGE).getValue()));
                Image imageRace = new Image(null, imageSrc);
                imageRace.setWidth("200px");
                Label descriptionRace = new Label(
                        (String) item.getItemProperty(DatabaseTables.RACES_DESCRIPTION).getValue(),
                        ContentMode.HTML);
                min_age = (int) item.getItemProperty(DatabaseTables.RACES_MIN_AGE).getValue();
                max_age = (int) item.getItemProperty(DatabaseTables.RACES_MAX_AGE).getValue();
                age.setMin(min_age);
                age.setMax(max_age);
                strenght = (int) item.getItemProperty(DatabaseTables.RACES_STRENGHT).getValue();
                resistance = (int) item.getItemProperty(DatabaseTables.RACES_RESISTANCE).getValue();
                agility = (int) item.getItemProperty(DatabaseTables.RACES_AGILITY).getValue();
                intelligence = (int) item.getItemProperty(DatabaseTables.RACES_INTELLIGENCE).getValue();
                wisdom = (int) item.getItemProperty(DatabaseTables.RACES_WISDOM).getValue();
                charm = (int) item.getItemProperty(DatabaseTables.RACES_CHARM).getValue();
                Label min_ageL = new Label("Et minima: " + min_age);
                Label max_ageL = new Label("Et masima " + max_age);
                //                Panel levels = new Panel();
                //                VerticalLayout levelsContent = new VerticalLayout();
                //                levels.setContent(levelsContent);
                //                Label strenghtL = new Label("Forza: " + strenght);
                //                levelsContent.addComponents(strenghtL);

                String levelTable = "<table><tr><td>Forza</td><td>Resistenza</td><td>Agilit</td><td>Intelligenza</td>"
                        + "<td>Saggezza</td><td>Carisma</td></tr><tr>" + "<td>" + strenght + "</td>" + "<td>"
                        + resistance + "</td>" + "<td>" + agility + "</td>" + "<td>" + intelligence + "</td>"
                        + "<td>" + wisdom + "</td>" + "<td>" + charm + "</td>" + "</tr></table>";
                Label levels = new Label(levelTable, ContentMode.HTML);

                descrizioneRazzaContent.addComponents(nameRace, imageRace, descriptionRace, min_ageL, max_ageL,
                        levels);
            }
        }
    });

    body.addComponents(datiIniziali, descrizioneRazza);
    CssLayout footer = new CssLayout();
    Button next = new Button("Avanti ->");
    next.addClickListener((Button.ClickEvent event) -> {
        user.setNomePG(nomePG.getValue());
        user.setCognomePG(cognomePG.getValue());
        user.setSessoPG(sessoPG.getValue().toString());
        user.setRazzaPG(race);
        user.setEtaPG(age.getValue().toString());
        user.setForzaPG(strenght);
        user.setResistenzaPG(resistance);
        user.setAgilitaPG(agility);
        user.setIntelligenzaPG(intelligence);
        user.setSaggezzaPG(wisdom);
        user.setCarismaPG(charm);
        this.setContent(setSecondStep());
    });
    footer.addComponents(next, createCancelButton());
    firstStep.addComponents(setHeader("2/4"), body, footer);
    return firstStep;
}

From source file:com.cerebro.gorgone.landingpage.SignInWindow.java

private Component setSecondStep() {
    VerticalLayout secondStep = new VerticalLayout();
    HorizontalLayout body = new HorizontalLayout();
    Panel sx = new Panel();
    VerticalLayout sxContent = new VerticalLayout();
    sx.setContent(sxContent);//from  w ww .  j a va2  s.c o  m
    Label welcome = null;
    if (user.getSessoPG().equals("Maschio")) {
        welcome = new Label("Benvenuto: " + user.getNomePG() + "!");
    } else if (user.getSessoPG().equals("Femmina")) {
        welcome = new Label("Benvenuta: " + user.getNomePG() + "!");
    }
    ComboBox carrieraPG = new ComboBox("Scegli la tua carriera:");
    carrieraPG.isRequired();
    Panel careerDescription = new Panel();
    CssLayout careerDescrContent = new CssLayout();
    careerDescription.setContent(careerDescrContent);
    sxContent.addComponents(welcome, carrieraPG, careerDescription);

    //  Dettagli di popolazione e comportamento ComboBox
    TableQuery tq_career = new TableQuery(DatabaseTables.CAREER_TABLE, connPool);
    tq_career.setVersionColumn(DatabaseTables.CAREER_VERSION);
    SQLContainer container_career = null;
    try {
        container_career = new SQLContainer(tq_career);
    } catch (Exception ex) {
        logger.error(ex.getMessage());
    }
    carrieraPG.setContainerDataSource(container_career);
    carrieraPG.setItemCaptionMode(AbstractSelect.ItemCaptionMode.PROPERTY);
    carrieraPG.setItemCaptionPropertyId(DatabaseTables.CAREER_NAME);
    carrieraPG.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            if (carrieraPG.getValue() != null) {
                logger.info("Carriera: " + carrieraPG.getValue().toString());
                careerDescrContent.removeAllComponents();
                Item item = (Item) carrieraPG.getContainerDataSource().getItem(carrieraPG.getValue());
                career = (String) item.getItemProperty(DatabaseTables.CAREER_NAME).getValue();
                Label careerName = new Label(career);
                FileResource imageSrc = new FileResource(
                        new File(MyUI.basePath + item.getItemProperty(DatabaseTables.CAREER_IMAGE).getValue()));
                Image imageCareer = new Image(null, imageSrc);
                imageCareer.setWidth("200px");
                Label careerDescription = new Label(item.getItemProperty(DatabaseTables.CAREER_DESCRIPTION),
                        ContentMode.HTML);
                strenght_car = (int) item.getItemProperty(DatabaseTables.CAREER_STRENGTH).getValue();
                resistance_car = (int) item.getItemProperty(DatabaseTables.CAREER_RESISTANCE).getValue();
                agility_car = (int) item.getItemProperty(DatabaseTables.CAREER_AGILITY).getValue();
                intelligence_car = (int) item.getItemProperty(DatabaseTables.CAREER_INTELLIGENCE).getValue();
                wisdom_car = (int) item.getItemProperty(DatabaseTables.CAREER_WISDOM).getValue();
                charm_car = (int) item.getItemProperty(DatabaseTables.CAREER_CHARM).getValue();
                String modsTable = "<table><tr><td>Forza</td><td>Resistenza</td><td>Agilit</td><td>Intelligenza</td>"
                        + "<td>Saggezza</td><td>Carisma</td></tr><tr>" + "<td>" + strenght_car + "</td>"
                        + "<td>" + resistance_car + "</td>" + "<td>" + agility_car + "</td>" + "<td>"
                        + intelligence_car + "</td>" + "<td>" + wisdom_car + "</td>" + "<td>" + charm_car
                        + "</td>" + "</tr></table>";
                Label mods = new Label(modsTable, ContentMode.HTML);
                careerDescrContent.addComponents(careerName, imageCareer, careerDescription, mods);
            }

        }

    });

    Panel dx = new Panel();
    VerticalLayout dxContent = new VerticalLayout();
    dx.setContent(dxContent);
    ComboBox orientamentoPG = new ComboBox("Scegli il tuo orientamento:");
    orientamentoPG.isRequired();
    Panel orientamentoDescription = new Panel();
    CssLayout orientamentoDescrContent = new CssLayout();
    orientamentoDescription.setContent(orientamentoDescrContent);
    dxContent.addComponents(orientamentoPG, orientamentoDescription);
    //  Dettagli di popolazione e comportamento ComboBox
    TableQuery tq_orientamento = new TableQuery(DatabaseTables.MORALCODE_TABLE, connPool);
    tq_orientamento.setVersionColumn(DatabaseTables.MORALCODE_VERSION);
    SQLContainer container_orientamento = null;
    try {
        container_orientamento = new SQLContainer(tq_orientamento);
    } catch (Exception ex) {
        logger.error(ex.getMessage());
    }
    orientamentoPG.setContainerDataSource(container_orientamento);
    orientamentoPG.setItemCaptionMode(AbstractSelect.ItemCaptionMode.PROPERTY);
    orientamentoPG.setItemCaptionPropertyId(DatabaseTables.MORALCODE_TENDENCY);
    orientamentoPG.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            if (orientamentoPG.getValue() != null) {
                logger.info("Orientamento: " + orientamentoPG.getValue().toString());
                orientamentoDescrContent.removeAllComponents();
                Item item = (Item) orientamentoPG.getContainerDataSource().getItem(orientamentoPG.getValue());
                moralCode = (String) item.getItemProperty(DatabaseTables.MORALCODE_TENDENCY).getValue();
                Label orientamentoName = new Label(moralCode);
                FileResource imageSrc = new FileResource(new File(
                        MyUI.basePath + item.getItemProperty(DatabaseTables.MORALCODE_IMAGE).getValue()));
                Image imageTendency = new Image(null, imageSrc);
                imageTendency.setWidth("200px");
                Label orientamentoDescription = new Label(
                        item.getItemProperty(DatabaseTables.MORALCODE_DESCRIPTION), ContentMode.HTML);

                orientamentoDescrContent.addComponents(orientamentoName, imageTendency,
                        orientamentoDescription);
            }

        }

    });

    body.addComponents(sx, dx);
    CssLayout footer = new CssLayout();
    Button next = new Button("Avanti ->");
    next.addClickListener((Button.ClickEvent event) -> {
        user.setCarrieraPG(career);
        // Gestire modificatori
        user.setForzaPG(user.getForzaPG() + strenght_car);
        user.setResistenzaPG(user.getResistenzaPG() + resistance_car);
        user.setAgilitaPG(user.getAgilitaPG() + agility_car);
        user.setIntelligenzaPG(user.getIntelligenzaPG() + intelligence_car);
        user.setSaggezzaPG(user.getSaggezzaPG() + wisdom_car);
        user.setCarismaPG(user.getCarismaPG() + charm_car);
        user.setOrientamentoPG(moralCode);
        this.setContent(setThirdStep());
    });
    footer.addComponents(next, createCancelButton());
    secondStep.addComponents(setHeader("3/4"), body, footer);
    return secondStep;
}

From source file:com.esofthead.mycollab.module.project.view.bug.BugChartComponent.java

License:Open Source License

private void displayReport() {
    final String reportName = reportDashboard[currentReportIndex];

    final CssLayout bodyContent = (CssLayout) this.bodyContent;
    bodyContent.removeAllComponents();

    if ("BugsByPriority".equals(reportName)) {
        this.setTitle(AppContext.getMessage(BugI18nEnum.WIDGET_CHART_PRIORIY_TITLE));
        IPrioritySummaryChartWidget prioritySummaryChartWidget = ViewManager
                .getCacheComponent(IPrioritySummaryChartWidget.class);
        bodyContent.addComponent(prioritySummaryChartWidget);

        final BugSearchCriteria prioritySearchCriteria = new Cloner().deepClone(baseSearchCriteria);
        prioritySummaryChartWidget.setSearchCriteria(prioritySearchCriteria);
    } else if ("BugsByStatus".equals(reportName)) {
        this.setTitle(AppContext.getMessage(BugI18nEnum.WIDGET_CHART_STATUS_TITLE));
        IStatusSummaryChartWidget statusSummaryChartWidget = ViewManager
                .getCacheComponent(IStatusSummaryChartWidget.class);
        bodyContent.addComponent(statusSummaryChartWidget);

        final BugSearchCriteria statusSearchCriteria = new Cloner().deepClone(baseSearchCriteria);
        statusSummaryChartWidget.setSearchCriteria(statusSearchCriteria);
    } else if ("BugByResolution".equals(reportName)) {
        this.setTitle(AppContext.getMessage(BugI18nEnum.WIDGET_CHART_RESOLUTION_TITLE));
        IBugResolutionSummaryChartWidget resolutionSummaryWdiget = ViewManager
                .getCacheComponent(IBugResolutionSummaryChartWidget.class);
        bodyContent.addComponent(resolutionSummaryWdiget);

        final BugSearchCriteria statusSearchCriteria = new Cloner().deepClone(baseSearchCriteria);
        resolutionSummaryWdiget.setSearchCriteria(statusSearchCriteria);
    }/*from  w  ww.j ava  2 s  . c o  m*/
}

From source file:com.mycollab.module.project.view.UserDashboardViewImpl.java

License:Open Source License

public UserDashboardViewImpl() {
    this.withMargin(false).withFullWidth();

    prjService = AppContextUtil.getSpringBean(ProjectService.class);
    prjKeys = prjService.getProjectKeysUserInvolved(UserUIContext.getUsername(), MyCollabUI.getAccountId());

    tabSheet = new TabSheet();
    tabSheet.addTab(buildDashboardComp(), UserUIContext.getMessage(GenericI18Enum.VIEW_DASHBOARD),
            FontAwesome.DASHBOARD);//  w ww  .  j av a  2 s. co m
    tabSheet.addTab(buildProjectListComp(), UserUIContext.getMessage(ProjectI18nEnum.LIST),
            FontAwesome.BUILDING_O);
    tabSheet.addTab(buildFollowingTicketComp(), UserUIContext.getMessage(ProjectCommonI18nEnum.VIEW_FAVORITES),
            FontAwesome.EYE);
    if (!SiteConfiguration.isCommunityEdition()) {
        tabSheet.addTab(buildCalendarComp(), UserUIContext.getMessage(ProjectCommonI18nEnum.VIEW_CALENDAR),
                FontAwesome.CALENDAR);
    }

    //        tabSheet.addTab(buildSettingComp(), "Settings", FontAwesome.COG);

    tabSheet.addSelectedTabChangeListener(selectedTabChangeEvent -> {
        CssLayout comp = (CssLayout) tabSheet.getSelectedTab();
        comp.removeAllComponents();
        int tabIndex = tabSheet.getTabPosition(tabSheet.getTab(comp));
        if (tabIndex == 0) {
            UserProjectDashboardPresenter userProjectDashboardPresenter = PresenterResolver
                    .getPresenterAndInitView(UserProjectDashboardPresenter.class);
            userProjectDashboardPresenter.onGo(comp, null);
        } else if (tabIndex == 2) {
            FollowingTicketPresenter followingTicketPresenter = PresenterResolver
                    .getPresenterAndInitView(FollowingTicketPresenter.class);
            followingTicketPresenter.onGo(comp, null);
        } else if (tabIndex == 4) {
            SettingPresenter settingPresenter = PresenterResolver.getPresenter(SettingPresenter.class);
            settingPresenter.onGo(comp, null);
        } else if (tabIndex == 3) {
            ICalendarDashboardPresenter calendarPresenter = PresenterResolver
                    .getPresenterAndInitView(ICalendarDashboardPresenter.class);
            calendarPresenter.go(comp, null);
        } else if (tabIndex == 1) {
            ProjectListPresenter projectListPresenter = PresenterResolver
                    .getPresenterAndInitView(ProjectListPresenter.class);
            projectListPresenter.onGo(comp, null);
        }
    });

    this.with(setupHeader(), tabSheet).expand(tabSheet);
}

From source file:com.nfl.dm.clubsites.cms.articles.subapp.articleeditor.navigation.NavigationViewImpl.java

License:Open Source License

@Override
public void setPreview(ViewType viewType, Component preview) {
    CssLayout control = navigationControls.get(viewType);
    if (control != null) {
        control.removeAllComponents();
        control.addComponent(preview);//w  ww  .ja va 2  s. co  m
    }
}

From source file:com.wintindustries.pfserver.interfaces.view.dashboard.DashboardMenu.java

private Component buildFolderTree() {

    CssLayout treeLayout = new CssLayout();
    treeLayout.setWidth("100%");
    if (treeLayout.getComponentCount() > 0) {
        treeLayout.removeAllComponents();
    }/*from  w w  w  .j  a  v a2s .  c om*/

    System.out.println("Init Dataasource");

    for (PFDataSource source : PFCore.core.getDataSources()) {
        System.out.println("NEW TREE");

        Label label = new Label(source.getName(), ContentMode.HTML);
        label.setPrimaryStyleName("valo-menu-subtitle");
        label.addStyleName("h4");

        label.setSizeUndefined();
        treeLayout.addComponent(label);
        //      label.setIcon(FontAwesome.LAPTOP);
        treeLayout.addStyleName("valo-menuitems");

        Tree tree = new Tree();
        //tree.setIcon(FontAwesome.LAPTOP);
        // tree.setWidth("100%");

        // container.setItemSorter(new l);

        source.Session().OpenSession();
        source.Session().getSession().beginTransaction();
        source.Session().getSession().getTransaction().setTimeout(4);

        System.out.println(": " + source.getDatabase().getSessionManager());

        Set<PFFolder> rootFolders = PFLocation.getRootDirectoriesFromDatabase(source.getDatabase());

        System.out.println(": " + source.getDatabase().getSessionManager());

        final PFFolderProxyContainer container = new PFFolderProxyContainer(rootFolders, source);

        container.setSortAlphabetic(true);
        tree.setContainerDataSource(container);
        tree.setItemCaptionMode(AbstractSelect.ItemCaptionMode.PROPERTY);
        tree.setItemCaptionPropertyId("Name");
        tree.setItemIconPropertyId("Icon");

        ItemClickListener treeclick;
        treeclick = new ItemClickListener() {

            @Override
            public void itemClick(final ItemClickEvent event) {

                //  Notification note = new Notification("Notificaton", event.getItemId().toString(), Notification.Type.ERROR_MESSAGE);
                // note.show(Page.getCurrent());
                PFFolderProxy proxyFolder = (PFFolderProxy) event.getItemId();
                MyUI.getPFNavigator().navigateTo(MyUI.PAGE_FOLDERVIEW + "/" + proxyFolder.getIdentifier());
            }
        };

        tree.addItemClickListener(treeclick);

        // Allow all nodes to have children
        //   .dashboard-menu-folder-wrapper
        // all these wrappers are a hacky workaround to a Vaadin CSS glitch
        CssLayout treeWrapper = new CssLayout();
        treeWrapper.setStyleName(".dashboard-menu-folder-wrapper");
        treeWrapper.addComponent(tree);
        treeWrapper.setWidth("40px");
        tree.setWidth("800px");
        tree.setStyleName(".dashboard-menu-folder-tree");

        treeLayout.addComponent(treeWrapper);
        source.Session().getSession().getTransaction().commit();
        source.getDatabase().getSessionManager().CloseSession();
    }

    return treeLayout;

}

From source file:org.ikasan.dashboard.ui.monitor.component.MonitorPanel.java

License:BSD License

protected Component createContentWrapper(final Component small, final Component large) {
    final CssLayout slot = new CssLayout();
    slot.setWidth("100%");
    slot.addStyleName("monitor-panel-slot");

    final CssLayout card1 = new CssLayout();
    card1.setWidth("100%");
    card1.addStyleName(ValoTheme.LAYOUT_CARD);

    final CssLayout card2 = new CssLayout();
    card2.setWidth("100%");
    card2.addStyleName(ValoTheme.LAYOUT_CARD);

    final HorizontalLayout toolbar = new HorizontalLayout();
    toolbar.addStyleName("dashboard-panel-toolbar");
    toolbar.setWidth("100%");

    Label caption = new Label(large.getCaption());
    caption.addStyleName(ValoTheme.LABEL_H4);
    caption.addStyleName(ValoTheme.LABEL_COLORED);
    caption.addStyleName(ValoTheme.LABEL_NO_MARGIN);
    large.setCaption(null);// w w w .  j  a  v a 2s  . c  om

    MenuBar tools = new MenuBar();
    tools.addStyleName(ValoTheme.MENUBAR_BORDERLESS);
    MenuItem max = tools.addItem("", VaadinIcons.EXPAND, new Command() {

        @Override
        public void menuSelected(final MenuItem selectedItem) {
            if (!slot.getStyleName().contains("max")) {
                selectedItem.setIcon(FontAwesome.COMPRESS);
                slot.removeAllComponents();
                card2.removeAllComponents();
                card2.addComponents(toolbar, large);
                slot.addComponents(card2);
                toggleMaximized(slot, true);
            } else {
                slot.removeStyleName("max");
                selectedItem.setIcon(FontAwesome.EXPAND);
                toggleMaximized(slot, false);
                card1.removeAllComponents();
                card1.addComponents(toolbar, small);
                slot.removeAllComponents();
                slot.addComponents(card1);
            }
        }
    });
    max.setStyleName("icon-only");
    MenuItem root = tools.addItem("", VaadinIcons.COG, null);
    root.addItem("Configure", new Command() {
        @Override
        public void menuSelected(final MenuItem selectedItem) {
            Notification.show("Not implemented in this demo");
        }
    });
    root.addSeparator();
    root.addItem("Close", new Command() {
        @Override
        public void menuSelected(final MenuItem selectedItem) {
            Notification.show("Not implemented in this demo");
        }
    });

    toolbar.addComponents(caption, tools);
    toolbar.setExpandRatio(caption, 1);
    toolbar.setComponentAlignment(caption, Alignment.MIDDLE_LEFT);

    card1.addComponents(toolbar, small);
    //        card2.addComponents(toolbar, large);
    slot.addComponent(card1);
    return slot;
}

From source file:ro.zg.netcell.vaadin.action.application.LoadMainWindowHandler.java

License:Apache License

private void addUserHeaderActions(final OpenGroupsApplication app, final ActionContext ac)
        throws ContextAwareException {
    UserActionList actionList = getGlobalActions(ActionLocations.HEADER);
    if (actionList == null) {
        return;/*w w  w .j  a  v a  2s .  c  o m*/
    }
    Collection<UserAction> userActions = actionList.getActions().values();
    OpenGroupsMainWindow window = ac.getWindow();
    User user = app.getCurrentUser();

    CssLayout header = window.getHeader();
    header.removeAllComponents();

    if (user != null) {

        Embedded usericon = new Embedded(null,
                OpenGroupsResources.getIcon(OpenGroupsIconsSet.USER, OpenGroupsIconsSet.MEDIUM));
        usericon.addStyleName("middle-left right-margin-10");
        header.addComponent(usericon);

        Label userInfo = new Label(/*app.getMessage("login.user.info") + ": " +*/ user.getUsername());
        userInfo.setSizeUndefined();
        header.addComponent(userInfo);
        userInfo.addStyleName("username-label");

    }

    /* get the current user types */
    //   List<String> userTypes = UsersManager.getInstance().getCurrentUserTypes(null, app);
    for (final UserAction ua : userActions) {
        /*
         * if the current user is not allowed to read/view the current action then skip it
         */
        //       if (!ua.allowRead(userTypes)) {
        if (!ua.isVisible(ac)) {
            continue;
        }
        Button actButton = new Button(ua.getDisplayName());

        actButton.addListener(new ClickListener() {

            @Override
            public void buttonClick(ClickEvent event) {
                // app.executeAction(ua, null);
                ua.executeHandler(null, app, null, ac);
            }
        });

        header.addComponent(actButton);
        actButton.addStyleName("middle-right left-margin-10");

    }

    Component rootLink = getRootEntityLink(app);
    Component metaLink = getMetaEntityLink(app);
    rootLink.setSizeUndefined();
    metaLink.setSizeUndefined();

    /* add quick links */
    header.addComponent(rootLink);
    header.addComponent(metaLink);
    rootLink.addStyleName("middle-right left-margin-10");
    metaLink.addStyleName("middle-right left-margin-10");
}