Example usage for com.vaadin.ui Button setIcon

List of usage examples for com.vaadin.ui Button setIcon

Introduction

In this page you can find the example usage for com.vaadin.ui Button setIcon.

Prototype

@Override
public void setIcon(Resource icon) 

Source Link

Document

Sets the component's icon.

Usage

From source file:de.symeda.sormas.ui.configuration.infrastructure.CommunitiesView.java

License:Open Source License

public CommunitiesView() {
    super(VIEW_NAME);

    criteria = ViewModelProviders.of(CommunitiesView.class).get(CommunityCriteria.class);

    grid = new CommunitiesGrid();
    grid.setCriteria(criteria);//from   www  .  j a va2  s .com
    gridLayout = new VerticalLayout();
    gridLayout.addComponent(createFilterBar());
    gridLayout.addComponent(grid);
    gridLayout.setMargin(true);
    gridLayout.setSpacing(false);
    gridLayout.setExpandRatio(grid, 1);
    gridLayout.setSizeFull();
    gridLayout.setStyleName("crud-main-layout");

    if (UserProvider.getCurrent().hasUserRight(UserRight.INFRASTRUCTURE_EXPORT)) {
        Button exportButton = new Button(I18nProperties.getCaption(Captions.export));
        exportButton.setDescription(I18nProperties.getDescription(Descriptions.descExportButton));
        exportButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
        exportButton.setIcon(VaadinIcons.TABLE);
        addHeaderComponent(exportButton);

        StreamResource streamResource = new GridExportStreamResource(grid, "sormas_communities",
                "sormas_communities_" + DateHelper.formatDateForExport(new Date()) + ".csv",
                CommunitiesGrid.EDIT_BTN_ID);
        FileDownloader fileDownloader = new FileDownloader(streamResource);
        fileDownloader.extend(exportButton);
    }

    if (UserProvider.getCurrent().hasUserRight(UserRight.INFRASTRUCTURE_CREATE)) {
        createButton = new Button(I18nProperties.getCaption(Captions.actionNewEntry));
        createButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
        createButton.setIcon(VaadinIcons.PLUS_CIRCLE);
        createButton.addClickListener(e -> ControllerProvider.getInfrastructureController().createCommunity());
        addHeaderComponent(createButton);
    }

    addComponent(gridLayout);
}

From source file:de.symeda.sormas.ui.configuration.infrastructure.DistrictsView.java

License:Open Source License

public DistrictsView() {
    super(VIEW_NAME);

    criteria = ViewModelProviders.of(DistrictsView.class).get(DistrictCriteria.class);

    grid = new DistrictsGrid();
    grid.setCriteria(criteria);//from w w w .java2 s.co  m
    gridLayout = new VerticalLayout();
    gridLayout.addComponent(createFilterBar());
    gridLayout.addComponent(grid);
    gridLayout.setMargin(true);
    gridLayout.setSpacing(false);
    gridLayout.setExpandRatio(grid, 1);
    gridLayout.setSizeFull();
    gridLayout.setStyleName("crud-main-layout");

    if (UserProvider.getCurrent().hasUserRight(UserRight.INFRASTRUCTURE_EXPORT)) {
        Button exportButton = new Button(I18nProperties.getCaption(Captions.export));
        exportButton.setDescription(I18nProperties.getDescription(Descriptions.descExportButton));
        exportButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
        exportButton.setIcon(VaadinIcons.TABLE);
        addHeaderComponent(exportButton);

        StreamResource streamResource = new GridExportStreamResource(grid, "sormas_districts",
                "sormas_districts_" + DateHelper.formatDateForExport(new Date()) + ".csv",
                DistrictsGrid.EDIT_BTN_ID);
        FileDownloader fileDownloader = new FileDownloader(streamResource);
        fileDownloader.extend(exportButton);
    }

    if (UserProvider.getCurrent().hasUserRight(UserRight.INFRASTRUCTURE_CREATE)) {
        createButton = new Button(I18nProperties.getCaption(Captions.actionNewEntry));
        createButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
        createButton.setIcon(VaadinIcons.PLUS_CIRCLE);
        createButton.addClickListener(e -> ControllerProvider.getInfrastructureController().createDistrict());
        addHeaderComponent(createButton);
    }

    addComponent(gridLayout);
}

From source file:de.symeda.sormas.ui.configuration.infrastructure.RegionsView.java

License:Open Source License

public RegionsView() {
    super(VIEW_NAME);

    criteria = ViewModelProviders.of(RegionsView.class).get(RegionCriteria.class);

    grid = new RegionsGrid();
    grid.setCriteria(criteria);// w  ww.j  av a2s.c  om
    gridLayout = new VerticalLayout();
    gridLayout.addComponent(createFilterBar());
    gridLayout.addComponent(grid);
    gridLayout.setMargin(true);
    gridLayout.setSpacing(false);
    gridLayout.setExpandRatio(grid, 1);
    gridLayout.setSizeFull();
    gridLayout.setStyleName("crud-main-layout");

    if (UserProvider.getCurrent().hasUserRight(UserRight.INFRASTRUCTURE_EXPORT)) {
        Button exportButton = new Button(I18nProperties.getCaption(Captions.export));
        exportButton.setDescription(I18nProperties.getDescription(Descriptions.descExportButton));
        exportButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
        exportButton.setIcon(VaadinIcons.TABLE);
        addHeaderComponent(exportButton);

        StreamResource streamResource = new GridExportStreamResource(grid, "sormas_regions",
                "sormas_regions_" + DateHelper.formatDateForExport(new Date()) + ".csv",
                RegionsGrid.EDIT_BTN_ID);
        FileDownloader fileDownloader = new FileDownloader(streamResource);
        fileDownloader.extend(exportButton);
    }

    if (UserProvider.getCurrent().hasUserRight(UserRight.INFRASTRUCTURE_CREATE)) {
        createButton = new Button(I18nProperties.getCaption(Captions.actionNewEntry));
        createButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
        createButton.setIcon(VaadinIcons.PLUS_CIRCLE);
        createButton.addClickListener(e -> ControllerProvider.getInfrastructureController().createRegion());
        addHeaderComponent(createButton);
    }

    addComponent(gridLayout);
}

From source file:de.symeda.sormas.ui.contact.ContactsView.java

License:Open Source License

public ContactsView() {
    super(VIEW_NAME);

    originalViewTitle = getViewTitleLabel().getValue();

    criteria = ViewModelProviders.of(ContactsView.class).get(ContactCriteria.class);
    if (criteria.getArchived() == null) {
        criteria.archived(false);/*from   w  ww .  ja  v a 2s  .c om*/
    }

    grid = new ContactGrid();
    grid.setCriteria(criteria);
    gridLayout = new VerticalLayout();
    gridLayout.addComponent(createFilterBar());
    gridLayout.addComponent(createStatusFilterBar());
    gridLayout.addComponent(grid);
    gridLayout.setMargin(true);
    gridLayout.setSpacing(false);
    gridLayout.setSizeFull();
    gridLayout.setExpandRatio(grid, 1);
    gridLayout.setStyleName("crud-main-layout");
    grid.getDataProvider().addDataProviderListener(e -> updateStatusButtons());

    if (UserProvider.getCurrent().hasUserRight(UserRight.CONTACT_EXPORT)) {

        PopupButton exportButton = new PopupButton(I18nProperties.getCaption(Captions.export));
        exportButton.setIcon(VaadinIcons.DOWNLOAD);
        VerticalLayout exportLayout = new VerticalLayout();
        exportLayout.setSpacing(true);
        exportLayout.setMargin(true);
        exportLayout.addStyleName(CssStyles.LAYOUT_MINIMAL);
        exportLayout.setWidth(200, Unit.PIXELS);
        exportButton.setContent(exportLayout);
        addHeaderComponent(exportButton);

        Button basicExportButton = new Button(I18nProperties.getCaption(Captions.exportBasic));
        basicExportButton.setDescription(I18nProperties.getDescription(Descriptions.descExportButton));
        basicExportButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
        basicExportButton.setIcon(VaadinIcons.TABLE);
        basicExportButton.setWidth(100, Unit.PERCENTAGE);
        exportLayout.addComponent(basicExportButton);

        StreamResource streamResource = new GridExportStreamResource(grid, "sormas_contacts",
                "sormas_contacts_" + DateHelper.formatDateForExport(new Date()) + ".csv");
        FileDownloader fileDownloader = new FileDownloader(streamResource);
        fileDownloader.extend(basicExportButton);

        Button extendedExportButton = new Button(I18nProperties.getCaption(Captions.exportDetailed));
        extendedExportButton
                .setDescription(I18nProperties.getDescription(Descriptions.descDetailedExportButton));
        extendedExportButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
        extendedExportButton.setIcon(VaadinIcons.FILE_TEXT);
        extendedExportButton.setWidth(100, Unit.PERCENTAGE);
        exportLayout.addComponent(extendedExportButton);

        StreamResource extendedExportStreamResource = DownloadUtil.createCsvExportStreamResource(
                ContactExportDto.class,
                (Integer start, Integer max) -> FacadeProvider.getContactFacade()
                        .getExportList(UserProvider.getCurrent().getUuid(), grid.getCriteria(), start, max),
                (propertyId, type) -> {
                    String caption = I18nProperties.getPrefixCaption(ContactExportDto.I18N_PREFIX, propertyId,
                            I18nProperties.getPrefixCaption(ContactDto.I18N_PREFIX, propertyId,
                                    I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, propertyId,
                                            I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, propertyId,
                                                    I18nProperties.getPrefixCaption(SymptomsDto.I18N_PREFIX,
                                                            propertyId,
                                                            I18nProperties.getPrefixCaption(
                                                                    HospitalizationDto.I18N_PREFIX,
                                                                    propertyId))))));
                    if (Date.class.isAssignableFrom(type)) {
                        caption += " (" + DateHelper.getLocalShortDatePattern() + ")";
                    }
                    return caption;
                }, "sormas_contacts_" + DateHelper.formatDateForExport(new Date()) + ".csv");
        new FileDownloader(extendedExportStreamResource).extend(extendedExportButton);

        // Warning if no filters have been selected
        Label warningLabel = new Label(I18nProperties.getString(Strings.infoExportNoFilters));
        warningLabel.setWidth(100, Unit.PERCENTAGE);
        exportLayout.addComponent(warningLabel);
        warningLabel.setVisible(false);

        exportButton.addClickListener(e -> {
            warningLabel.setVisible(!criteria.hasAnyFilterActive());
        });
    }

    addComponent(gridLayout);
}

From source file:de.symeda.sormas.ui.events.EventsView.java

License:Open Source License

public EventsView() {
    super(VIEW_NAME);

    originalViewTitle = getViewTitleLabel().getValue();

    criteria = ViewModelProviders.of(EventsView.class).get(EventCriteria.class);
    if (criteria.getArchived() == null) {
        criteria.archived(false);//from   ww  w  . ja va 2s.  c o m
    }

    grid = new EventGrid();
    grid.setCriteria(criteria);
    gridLayout = new VerticalLayout();
    gridLayout.addComponent(createFilterBar());
    gridLayout.addComponent(createStatusFilterBar());
    gridLayout.addComponent(grid);
    gridLayout.setMargin(true);
    gridLayout.setSpacing(false);
    gridLayout.setSizeFull();
    gridLayout.setExpandRatio(grid, 1);
    gridLayout.setStyleName("crud-main-layout");
    grid.getDataProvider().addDataProviderListener(e -> updateStatusButtons());

    addComponent(gridLayout);

    if (UserProvider.getCurrent().hasUserRight(UserRight.EVENT_EXPORT)) {
        Button exportButton = new Button(I18nProperties.getCaption(Captions.export));
        exportButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
        exportButton.setIcon(VaadinIcons.DOWNLOAD);

        StreamResource streamResource = new GridExportStreamResource(grid, "sormas_events",
                "sormas_events_" + DateHelper.formatDateForExport(new Date()) + ".csv");
        FileDownloader fileDownloader = new FileDownloader(streamResource);
        fileDownloader.extend(exportButton);

        addHeaderComponent(exportButton);
    }

    if (UserProvider.getCurrent().hasUserRight(UserRight.EVENT_CREATE)) {
        createButton = new Button(I18nProperties.getCaption(Captions.eventNewEvent));
        createButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
        createButton.setIcon(VaadinIcons.PLUS_CIRCLE);
        createButton.addClickListener(e -> ControllerProvider.getEventController().create());
        addHeaderComponent(createButton);
    }
}

From source file:de.symeda.sormas.ui.Menu.java

License:Open Source License

public Menu(Navigator navigator) {
    this.navigator = navigator;
    setPrimaryStyleName(ValoTheme.MENU_ROOT);
    menuPart = new CssLayout();
    menuPart.addStyleName(ValoTheme.MENU_PART);

    // header of the menu
    final HorizontalLayout top = new HorizontalLayout();
    top.setDefaultComponentAlignment(Alignment.TOP_CENTER);
    top.addStyleName(ValoTheme.MENU_TITLE);
    top.setSpacing(true);//from  ww  w  . j a v  a  2s.c  om
    Label title = new Label("SORMAS");
    title.setSizeUndefined();
    Image image = new Image(null, new ThemeResource("img/sormas-logo.png"));
    CssStyles.style(image, ValoTheme.MENU_LOGO, ValoTheme.BUTTON_LINK);
    image.addClickListener(new MouseEvents.ClickListener() {
        @Override
        public void click(MouseEvents.ClickEvent event) {
            SormasUI.get().getNavigator().navigateTo(SurveillanceDashboardView.VIEW_NAME);
        }
    });
    top.addComponent(image);
    top.addComponent(title);
    menuPart.addComponent(top);

    // logout menu item
    MenuBar logoutMenu = new MenuBar();
    logoutMenu.addItem(I18nProperties.getCaption(Captions.actionLogout) + " ("
            + UserProvider.getCurrent().getUserName() + ")", VaadinIcons.SIGN_OUT, new Command() {
                @Override
                public void menuSelected(MenuItem selectedItem) {
                    LoginHelper.logout();
                }
            });

    logoutMenu.addStyleName("user-menu");
    menuPart.addComponent(logoutMenu);

    // button for toggling the visibility of the menu when on a small screen
    final Button showMenu = new Button(I18nProperties.getCaption(Captions.menu), new Button.ClickListener() {
        @Override
        public void buttonClick(final Button.ClickEvent event) {
            if (menuPart.getStyleName().contains(VALO_MENU_VISIBLE)) {
                menuPart.removeStyleName(VALO_MENU_VISIBLE);
            } else {
                menuPart.addStyleName(VALO_MENU_VISIBLE);
            }
        }
    });
    showMenu.addStyleName(ValoTheme.BUTTON_PRIMARY);
    showMenu.addStyleName(VALO_MENU_TOGGLE);
    showMenu.setIcon(VaadinIcons.MENU);
    menuPart.addComponent(showMenu);

    // container for the navigation buttons, which are added by addView()
    menuItemsLayout = new CssLayout();
    menuItemsLayout.setPrimaryStyleName(VALO_MENUITEMS);
    menuPart.addComponent(menuItemsLayout);

    addComponent(menuPart);
}

From source file:de.symeda.sormas.ui.Menu.java

License:Open Source License

private void createViewButton(final String name, String caption, Resource icon) {
    Button button = new Button(caption, new Button.ClickListener() {

        @Override/*from   ww  w . j  a  va 2  s.c  om*/
        public void buttonClick(Button.ClickEvent event) {
            navigator.navigateTo(name);

        }
    });
    button.setPrimaryStyleName(ValoTheme.MENU_ITEM);
    button.setIcon(icon);
    menuItemsLayout.addComponent(button);
    viewButtons.put(name, button);
}

From source file:de.symeda.sormas.ui.samples.SamplesView.java

License:Open Source License

public SamplesView() {
    super(VIEW_NAME);

    sampleListComponent = new SampleGridComponent(getViewTitleLabel(), this);
    setSizeFull();/*  www .j a  va2s  .c om*/
    addComponent(sampleListComponent);

    if (UserProvider.getCurrent().hasUserRight(UserRight.SAMPLE_EXPORT)) {
        PopupButton exportButton = new PopupButton(I18nProperties.getCaption(Captions.export));
        exportButton.setIcon(VaadinIcons.DOWNLOAD);
        VerticalLayout exportLayout = new VerticalLayout();
        exportLayout.setSpacing(true);
        exportLayout.setMargin(true);
        exportLayout.addStyleName(CssStyles.LAYOUT_MINIMAL);
        exportLayout.setWidth(200, Unit.PIXELS);
        exportButton.setContent(exportLayout);
        addHeaderComponent(exportButton);

        Button basicExportButton = new Button(I18nProperties.getCaption(Captions.exportBasic));
        basicExportButton.setDescription(I18nProperties.getString(Strings.infoBasicExport));
        basicExportButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
        basicExportButton.setIcon(VaadinIcons.TABLE);
        basicExportButton.setWidth(100, Unit.PERCENTAGE);
        exportLayout.addComponent(basicExportButton);

        StreamResource streamResource = new GridExportStreamResource(sampleListComponent.getGrid(),
                "sormas_samples", "sormas_samples_" + DateHelper.formatDateForExport(new Date()) + ".csv",
                SampleGrid.EDIT_BTN_ID);
        FileDownloader fileDownloader = new FileDownloader(streamResource);
        fileDownloader.extend(basicExportButton);

        Button extendedExportButton = new Button(I18nProperties.getCaption(Captions.exportDetailed));
        extendedExportButton.setDescription(I18nProperties.getString(Strings.infoDetailedExport));
        extendedExportButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
        extendedExportButton.setIcon(VaadinIcons.FILE_TEXT);
        extendedExportButton.setWidth(100, Unit.PERCENTAGE);
        exportLayout.addComponent(extendedExportButton);

        StreamResource extendedExportStreamResource = DownloadUtil.createCsvExportStreamResource(
                SampleExportDto.class,
                (Integer start, Integer max) -> FacadeProvider.getSampleFacade().getExportList(
                        UserProvider.getCurrent().getUuid(), sampleListComponent.getGrid().getCriteria(), start,
                        max),
                (propertyId, type) -> {
                    String caption = I18nProperties.getPrefixCaption(SampleExportDto.I18N_PREFIX, propertyId,
                            I18nProperties.getPrefixCaption(SampleDto.I18N_PREFIX, propertyId,
                                    I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, propertyId,
                                            I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, propertyId,
                                                    I18nProperties.getPrefixCaption(
                                                            AdditionalTestDto.I18N_PREFIX, propertyId)))));
                    if (Date.class.isAssignableFrom(type)) {
                        caption += " (" + DateHelper.getLocalShortDatePattern() + ")";
                    }
                    return caption;
                }, "sormas_samples_" + DateHelper.formatDateForExport(new Date()) + ".csv");
        new FileDownloader(extendedExportStreamResource).extend(extendedExportButton);
    }
}

From source file:de.symeda.sormas.ui.task.TasksView.java

License:Open Source License

public TasksView() {
    super(VIEW_NAME);

    if (!ViewModelProviders.of(TasksView.class).has(TaskCriteria.class)) {
        // init default filter
        TaskCriteria taskCriteria = new TaskCriteria();
        taskCriteria.taskStatus(TaskStatus.PENDING);
        ViewModelProviders.of(TasksView.class).get(TaskCriteria.class, taskCriteria);
    }// w ww  .  ja va  2 s  . c om

    taskListComponent = new TaskGridComponent(getViewTitleLabel(), this);
    addComponent(taskListComponent);

    if (UserProvider.getCurrent().hasUserRight(UserRight.TASK_CREATE)) {
        Button createButton = new Button(I18nProperties.getCaption(Captions.taskNewTask));
        createButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
        createButton.setIcon(VaadinIcons.PLUS_CIRCLE);
        createButton.addClickListener(e -> ControllerProvider.getTaskController().create(TaskContext.GENERAL,
                null, taskListComponent.getGrid()::reload));
        addHeaderComponent(createButton);
    }
}

From source file:de.uni_tuebingen.qbic.qbicmainportlet.QbicmainportletUI.java

License:Open Source License

/**
 * /*  w  w w.j av  a2  s  .  com*/
 * @param datahandler
 * @param request
 * @param user
 */
public void buildMainLayout(DataHandler datahandler, VaadinRequest request, String user) {
    State state = (State) UI.getCurrent().getSession().getAttribute("state");
    MultiscaleController multiscaleController = new MultiscaleController(datahandler.getOpenBisClient(), user);

    final HomeView homeView = new HomeView(datahandler, "Your Projects", user, state, resUrl,
            manager.getTmpFolder());
    DatasetView datasetView = new DatasetView(datahandler, state, resUrl);
    final SampleView sampleView = new SampleView(datahandler, state, resUrl, multiscaleController);
    // BarcodeView barcodeView =
    // new BarcodeView(datahandler.getOpenBisClient(), manager.getBarcodeScriptsFolder(),
    // manager.getBarcodePathVariable());
    final ExperimentView experimentView = new ExperimentView(datahandler, state, resUrl, multiscaleController);
    // ChangePropertiesView changepropertiesView = new ChangePropertiesView(datahandler);

    final AddPatientView addPatientView = new AddPatientView(datahandler, state, resUrl);

    final SearchResultsView searchResultsView = new SearchResultsView(datahandler, "Search results", user,
            state, resUrl);

    Submitter submitter = null;
    try {
        submitter = WorkflowSubmitterFactory.getSubmitter(Type.guseSubmitter, manager);
    } catch (Exception e1) {
        e1.printStackTrace();
    }

    WorkflowViewController controller = new WorkflowViewController(submitter, datahandler, user);

    final ProjectView projectView = new ProjectView(datahandler, state, resUrl, controller, manager);
    final PatientView patientView = new PatientView(datahandler, state, resUrl, controller, manager);

    VerticalLayout navigatorContent = new VerticalLayout();
    // navigatorContent.setResponsive(true);

    final Navigator navigator = new Navigator(UI.getCurrent(), navigatorContent);

    navigator.addView(DatasetView.navigateToLabel, datasetView);
    navigator.addView(SampleView.navigateToLabel, sampleView);
    navigator.addView("", homeView);
    navigator.addView(ProjectView.navigateToLabel, projectView);
    // navigator.addView(BarcodeView.navigateToLabel, barcodeView);
    navigator.addView(ExperimentView.navigateToLabel, experimentView);
    navigator.addView(PatientView.navigateToLabel, patientView);
    navigator.addView(AddPatientView.navigateToLabel, addPatientView);
    navigator.addView(SearchResultsView.navigateToLabel, searchResultsView);

    setNavigator(navigator);

    // Production
    // mainLayout = new VerticalLayout();
    for (Window w : getWindows()) {
        w.setSizeFull();
    }

    mainLayout = new GridLayout(3, 3);
    mainLayout.setResponsive(true);
    mainLayout.setWidth(100, Unit.PERCENTAGE);

    mainLayout.addComponent(navigatorContent, 0, 1, 2, 1);
    mainLayout.setColumnExpandRatio(0, 0.2f);
    mainLayout.setColumnExpandRatio(1, 0.3f);
    mainLayout.setColumnExpandRatio(2, 0.5f);

    // Production
    // HorizontalLayout treeViewAndLevelView = new HorizontalLayout();
    // HorizontalLayout headerView = new HorizontalLayout();
    // headerView.setSpacing(false);
    HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSpacing(true);
    // final HorizontalLayout labelLayout = new HorizontalLayout();
    // headerView.addComponent(buttonLayout);
    // headerView.addComponent(labelLayout);

    Button homeButton = new Button("Home");
    homeButton.setIcon(FontAwesome.HOME);
    homeButton.setResponsive(true);
    homeButton.setStyleName(ValoTheme.BUTTON_LARGE);
    homeButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            navigator.navigateTo("");
        }

    });

    // Production
    buttonLayout.addComponent(homeButton);
    // mainLayout.addComponent(homeButton, 0, 0);

    Boolean includePatientCreation = false;

    List<Project> projects = datahandler.getOpenBisClient().getOpenbisInfoService()
            .listProjectsOnBehalfOfUser(datahandler.getOpenBisClient().getSessionToken(), user);
    int numberOfProjects = 0;
    for (Project project : projects) {
        if (project.getSpaceCode().contains("IVAC")) {
            includePatientCreation = true;
        }
        numberOfProjects += 1;
    }

    // add patient button
    if (includePatientCreation) {
        Button addPatient = new Button("Add Patient");
        addPatient.setIcon(FontAwesome.PLUS);
        addPatient.setStyleName(ValoTheme.BUTTON_LARGE);
        addPatient.setResponsive(true);
        // addPatient.setStyleName("addpatient");

        addPatient.addClickListener(new ClickListener() {
            @Override
            public void buttonClick(ClickEvent event) {
                UI.getCurrent().getNavigator().navigateTo(String.format(AddPatientView.navigateToLabel));
            }
        });

        // Production
        buttonLayout.addComponent(addPatient);
        // mainLayout.addComponent(addPatient, 1, 0);
    }

    mainLayout.addComponent(buttonLayout, 0, 0);

    Button header = new Button(String.format("Total number of projects: %s", numberOfProjects));
    header.setIcon(FontAwesome.HAND_O_RIGHT);
    header.setStyleName(ValoTheme.BUTTON_LARGE);
    header.addStyleName(ValoTheme.BUTTON_BORDERLESS);

    // Production
    // labelLayout.addComponent(header);
    // labelLayout.setWidth(null);

    SearchEngineView searchBarView = new SearchEngineView(datahandler);

    // headerView.setWidth("100%");
    // Production
    // headerView.addComponent(searchBarView);
    // headerView.setComponentAlignment(searchBarView, Alignment.TOP_RIGHT);
    // searchBarView.setSizeUndefined();
    // treeViewAndLevelView.addComponent(navigatorContent);
    // mainLayout.addComponent(headerView);
    // mainLayout.addComponent(treeViewAndLevelView);

    mainLayout.addComponent(header, 1, 0);
    mainLayout.addComponent(searchBarView, 2, 0);

    // Production
    VerticalLayout versionLayout = new VerticalLayout();
    versionLayout.setWidth(100, Unit.PERCENTAGE);
    Label versionLabel = new Label(String.format("version: %s", version));
    Label revisionLabel = new Label(String.format("rev: %s", revision));
    revisionLabel.setWidth(null);
    versionLabel.setWidth(null);

    versionLayout.addComponent(versionLabel);
    if (!isInProductionMode()) {
        versionLayout.addComponent(revisionLabel);
    }
    // versionLayout.setMargin(new MarginInfo(true, false, false, false));
    // mainLayout.addComponent(versionLayout);
    mainLayout.addComponent(versionLayout, 0, 2, 2, 2);
    mainLayout.setRowExpandRatio(2, 1.0f);
    // mainLayout.setSpacing(true);

    versionLayout.setComponentAlignment(versionLabel, Alignment.MIDDLE_RIGHT);
    versionLayout.setComponentAlignment(revisionLabel, Alignment.BOTTOM_RIGHT);

    mainLayout.setComponentAlignment(searchBarView, Alignment.BOTTOM_RIGHT);

    setContent(mainLayout);
    // getContent().setSizeFull();

    // "Responsive design"
    /*
     * getPage().addBrowserWindowResizeListener(new BrowserWindowResizeListener() {
     * 
     * @Override public void browserWindowResized(BrowserWindowResizeEvent event) { int height =
     * event.getHeight(); int width = event.getWidth(); WebBrowser browser =
     * event.getSource().getWebBrowser(); // tv.rebuildLayout(height, width, browser); if
     * (currentView instanceof HomeView) { homeView.updateView(height, width, browser); } else if
     * (currentView instanceof ProjectView) { projectView.updateView(height, width, browser); } else
     * if (currentView instanceof ExperimentView) { experimentView.updateView(height, width,
     * browser); } else if (currentView instanceof PatientView) { patientView.updateView(height,
     * width, browser); } else if (currentView instanceof AddPatientView) {
     * addPatientView.updateView(height, width, browser); } } });
     * 
     * navigator.addViewChangeListener(new ViewChangeListener() {
     * 
     * @Override public boolean beforeViewChange(ViewChangeEvent event) { int height =
     * getPage().getBrowserWindowHeight(); int width = getPage().getBrowserWindowWidth(); WebBrowser
     * browser = getPage().getWebBrowser(); // View oldView = event.getOldView(); //
     * this.setEnabled(oldView, false);
     * 
     * currentView = event.getNewView(); if (currentView instanceof HomeView) {
     * homeView.updateView(height, width, browser); } if (currentView instanceof ProjectView) {
     * projectView.updateView(height, width, browser); } if (currentView instanceof ExperimentView)
     * { experimentView.updateView(height, width, browser); } if (currentView instanceof SampleView)
     * { sampleView.updateView(height, width, browser); } else if (currentView instanceof
     * PatientView) { patientView.updateView(height, width, browser); } else if (currentView
     * instanceof AddPatientView) { addPatientView.updateView(height, width, browser); } return
     * true; }
     * 
     * private void setEnabled(View view, boolean enabled) { // tv.setEnabled(enabled); if (view
     * instanceof HomeView) { homeView.setEnabled(enabled); } if (view instanceof ProjectView) {
     * projectView.setEnabled(enabled); } if (view instanceof ExperimentView) {
     * experimentView.setEnabled(enabled); } if (view instanceof SampleView) {
     * sampleView.setEnabled(enabled); } }
     * 
     * @Override public void afterViewChange(ViewChangeEvent event) { currentView =
     * event.getNewView(); // this.setEnabled(currentView, true); Object currentBean = null; if
     * (currentView instanceof ProjectView) { // TODO refactoring currentBean = new HashMap<String,
     * AbstractMap.SimpleEntry<String, Long>>();
     * 
     * // Production // labelLayout.removeAllComponents(); Button header = new
     * Button(projectView.getHeaderLabel()); header.setStyleName(ValoTheme.BUTTON_LARGE);
     * header.addStyleName(ValoTheme.BUTTON_BORDERLESS); header.setIcon(FontAwesome.HAND_O_RIGHT);
     * 
     * // labelLayout.addComponent(header); } else if (currentView instanceof HomeView) {
     * currentBean = new HashMap<String, AbstractMap.SimpleEntry<String, Long>>();
     * 
     * // labelLayout.removeAllComponents(); Button header = new Button(homeView.getHeader());
     * header.setStyleName(ValoTheme.BUTTON_LARGE);
     * header.addStyleName(ValoTheme.BUTTON_BORDERLESS); header.setIcon(FontAwesome.HAND_O_RIGHT);
     * 
     * // labelLayout.addComponent(header); // currentBean = projectView.getCurrentBean(); } else if
     * (currentView instanceof ExperimentView) { currentBean = experimentView.getCurrentBean();
     * 
     * } else if (currentView instanceof SampleView) { // TODO refactoring currentBean = new
     * HashMap<String, AbstractMap.SimpleEntry<String, Long>>();
     * 
     * // labelLayout.removeAllComponents(); Button header = new Button(sampleView.getHeader());
     * header.setStyleName(ValoTheme.BUTTON_LARGE);
     * header.addStyleName(ValoTheme.BUTTON_BORDERLESS); header.setIcon(FontAwesome.HAND_O_RIGHT);
     * 
     * // labelLayout.addComponent(header);
     * 
     * } else if (currentView instanceof DatasetView) { currentBean = new HashMap<String,
     * AbstractMap.SimpleEntry<String, Long>>(); } else if (currentView instanceof PatientView) {
     * currentBean = new HashMap<String, AbstractMap.SimpleEntry<String, Long>>();
     * 
     * // labelLayout.removeAllComponents(); Button header = new
     * Button(patientView.getHeaderLabel()); header.setStyleName(ValoTheme.BUTTON_LARGE);
     * header.addStyleName(ValoTheme.BUTTON_BORDERLESS); header.setIcon(FontAwesome.HAND_O_RIGHT);
     * // labelLayout.addComponent(header); } else if (currentView instanceof AddPatientView) {
     * currentBean = new HashMap<String, AbstractMap.SimpleEntry<String, Long>>();
     * 
     * // labelLayout.removeAllComponents(); Button header = new Button(addPatientView.getHeader());
     * header.setStyleName(ValoTheme.BUTTON_LARGE);
     * header.addStyleName(ValoTheme.BUTTON_BORDERLESS); header.setIcon(FontAwesome.HAND_O_RIGHT);
     * // labelLayout.addComponent(header); } try { PortletSession portletSession =
     * QbicmainportletUI.getCurrent().getPortletSession(); if (portletSession != null) {
     * portletSession.setAttribute("qbic_download", currentBean, PortletSession.APPLICATION_SCOPE);
     * } } catch (NullPointerException e) { // nothing to do. during initialization that might
     * happen. Nothing to worry about }
     * 
     * 
     * }
     * 
     * });
     */

    /*
     * // go to correct page String requestParams = Page.getCurrent().getUriFragment();
     * 
     * // LOGGER.debug("used urifragement: " + requestParams); if (requestParams != null) {
     * navigator.navigateTo(requestParams.startsWith("!") ? requestParams.substring(1) :
     * requestParams); } else { navigator.navigateTo(""); }
     */
}