Example usage for com.vaadin.ui Alignment TOP_RIGHT

List of usage examples for com.vaadin.ui Alignment TOP_RIGHT

Introduction

In this page you can find the example usage for com.vaadin.ui Alignment TOP_RIGHT.

Prototype

Alignment TOP_RIGHT

To view the source code for com.vaadin.ui Alignment TOP_RIGHT.

Click Source Link

Usage

From source file:de.catma.ui.repository.RepositoryListView.java

License:Open Source License

private void initComponents() {
    repositoryTable = new Table("Available Repositories");
    BeanItemContainer<RepositoryReference> container = new BeanItemContainer<RepositoryReference>(
            RepositoryReference.class);

    for (RepositoryReference ref : repositoryManager.getRepositoryReferences()) {
        container.addBean(ref);/*w w  w.j ava 2 s .c om*/
    }

    repositoryTable.setContainerDataSource(container);

    repositoryTable.setVisibleColumns(new Object[] { "name" });
    repositoryTable.setColumnHeaderMode(Table.COLUMN_HEADER_MODE_HIDDEN);
    repositoryTable.setSelectable(true);
    repositoryTable.setMultiSelect(false);
    repositoryTable.setPageLength(3);
    repositoryTable.setImmediate(true);

    addComponent(repositoryTable);
    setMargin(true);
    setSpacing(true);

    openBt = new Button("Open");
    openBt.setImmediate(true);

    addComponent(openBt);
    setComponentAlignment(openBt, Alignment.TOP_RIGHT);

    if (container.size() > 0) {
        repositoryTable.setValue(container.getIdByIndex(0));
    } else {
        openBt.setEnabled(false);
    }
}

From source file:de.decidr.ui.view.help.HelpDialogComponent.java

License:Apache License

public HelpDialogComponent() {
    super("DecidR Help");
    VerticalLayout layout = (VerticalLayout) getContent();
    layout.setSpacing(true);//ww w.ja v  a2 s.c  o  m

    horLayout = new HorizontalLayout();
    horLayout.setSpacing(false);

    layout.addComponent(horLayout);
    horLayout.setSizeFull();

    closeButton = new Button("Close", new HideHelpDialogAction());
    showMainScreenHelp = new Button("Show in main window", new HideHelpDialogAction());
    showMainScreenHelp.addListener(new ShowHelpAction());

    acc = new Accordion();
    acc.setSizeFull();

    acc.addTab(new AccountManagementHelpComponent(), "Account Management", null);
    acc.addTab(new WorkflowParticipationHelpComponent(), "Workflow Participation", null);
    acc.addTab(new WorkflowInstanceManagementHelpComponent(), "Workflow Instance Management", null);
    acc.addTab(new TenantSettingsHelpComponent(), "Tenant Settings", null);
    acc.addTab(new TenantUserManagementHelpComponent(), "Tenant User Management", null);
    acc.addTab(new WorkflowModelingHelpComponent(), "Workflow Modeling", null);
    acc.addTab(new WorkflowModelEditorHelpComponent(), "Workflow Model Editor", null);
    acc.addTab(new TenantMonitoringHelpComponent(), "Tenant Monitoring", null);
    acc.addTab(new SystemSettingsHelpComponent(), "System Settings", null);
    acc.addTab(new SystemStatusHelpComponent(), "System Status", null);
    acc.addTab(new UserManagementHelpComponent(), "User Management", null);
    acc.addTab(new TenantManagementHelpComponent(), "Tenant Management", null);
    acc.addTab(new GlossaryHelpComponent(), "Glossary", null);

    horLayout.addComponent(showMainScreenHelp);
    horLayout.setComponentAlignment(showMainScreenHelp, Alignment.TOP_LEFT);
    horLayout.addComponent(closeButton);
    horLayout.setComponentAlignment(closeButton, Alignment.TOP_RIGHT);
    layout.addComponent(acc);
}

From source file:de.decidr.ui.view.ProfileSettingsComponent.java

License:Apache License

/**
 * This method initializes the components of the
 * {@link ProfileSettingsComponent}.//ww  w  .  jav  a  2  s .c  om
 */
private void init() {
    settingsForm.setWriteThrough(false);
    settingsItem = new BeanItem(user.getUserProfile(), properties);
    settingsForm.setItemDataSource(settingsItem);
    settingsForm.setFormFieldFactory(new SettingsFieldFactory());

    settingsForm.setVisibleItemProperties(properties);

    addressPanel = new Panel();
    usernamePanel = new Panel();
    profileButtonPanel = new Panel();

    usernameGridLayout = new GridLayout(2, 2);
    verticalLayout = new VerticalLayout();
    addressVerticalLayout = new VerticalLayout();
    profileButtonHorizontalLayout = new HorizontalLayout();

    myProfileLabel = new Label("<h2> My Profile </h2>");
    myProfileLabel.setContentMode(Label.CONTENT_XHTML);
    usernameLabel = new Label("Username: ");
    emailLabel = new Label("Email address: ");
    usernameNameLabel = new Label(user.getUserProfile().getUsername());
    emailNameLabel = new Label(user.getEmail());

    changeEmailLink = new Button("Change email", new ShowChangeEmailAction());
    changeEmailLink.setStyleName(Button.STYLE_LINK);
    changePasswordLink = new Button("Change password", new ShowChangePasswordAction());
    changePasswordLink.setStyleName(Button.STYLE_LINK);
    leaveTenantLink = new Button("Leave tenant", new ShowLeaveTenantDialogAction());
    leaveTenantLink.setStyleName(Button.STYLE_LINK);

    saveButton = new Button("Save", new SaveProfileAction());
    settingsForm.addField("button", saveButton);

    statusCheckBox = new CheckBox();
    statusCheckBox.setValue(user.getUnavailableSince() != null ? true : false);
    statusCheckBox.addListener(new ChangeStatusAction(user.getId()));
    statusCheckBox.setImmediate(true);

    this.setCompositionRoot(verticalLayout);

    verticalLayout.setSpacing(true);
    verticalLayout.addComponent(myProfileLabel);
    verticalLayout.addComponent(usernamePanel);

    usernamePanel.addComponent(usernameGridLayout);
    usernameGridLayout.setSpacing(true);
    usernameGridLayout.addComponent(usernameLabel, 0, 0);
    usernameGridLayout.addComponent(usernameNameLabel, 1, 0);
    usernameGridLayout.addComponent(emailLabel, 0, 1);
    usernameGridLayout.addComponent(emailNameLabel, 1, 1);

    verticalLayout.addComponent(profileButtonPanel);

    profileButtonPanel.addComponent(profileButtonHorizontalLayout);
    profileButtonHorizontalLayout.setSpacing(true);
    profileButtonHorizontalLayout.addComponent(changeEmailLink);
    profileButtonHorizontalLayout.addComponent(changePasswordLink);
    profileButtonHorizontalLayout.addComponent(leaveTenantLink);
    profileButtonHorizontalLayout.addComponent(statusCheckBox);
    statusCheckBox.setCaption("Set my status to unavailable");
    profileButtonHorizontalLayout.setComponentAlignment(statusCheckBox, Alignment.TOP_RIGHT);

    verticalLayout.addComponent(addressPanel);

    addressPanel.addComponent(addressVerticalLayout);

    addressVerticalLayout.setSpacing(true);
    addressVerticalLayout.addComponent(settingsForm);
}

From source file:de.gedoplan.webclients.vaadin.views.CustomerDetailView.java

public void init() {
    Double discount = customerService.calculateCustomerDiscount(customer.getCustomerID()).getDiscount();
    Label name = new Label(new PropertyFormatter(form.getProperty(Customer_.companyName)) {
        @Override/*from ww w  . j a v a  2 s  .  c o m*/
        public String format(Object value) {
            return value + " (" + customer.getCustomerID() + ")";
        }

        @Override
        public Object parse(String formattedValue) throws Exception {
            throw new UnsupportedOperationException("Not supported yet.");
        }
    });
    name.setStyleName(ValoTheme.LABEL_BOLD);
    Label rabattLabel = new Label(Messages.customer_discount.value());
    rabattLabel.setStyleName(ValoTheme.LABEL_BOLD);
    rabattLabel.setSizeUndefined();
    Label rabatt = new Label(new DecimalFormat("#0.00").format(discount) + "%");
    rabatt.setSizeUndefined();
    rabatt.addStyleName(ValoTheme.LABEL_COLORED);
    rabatt.addStyleName(ValoTheme.LABEL_BOLD);
    HorizontalLayout headline = new HorizontalLayout(name, rabattLabel, rabatt);
    headline.setComponentAlignment(rabatt, Alignment.TOP_RIGHT);
    headline.setExpandRatio(name, 1);
    headline.setWidth(100, Unit.PERCENTAGE);
    headline.setSpacing(true);
    headline.setStyleName(ValoTheme.LAYOUT_WELL);
    headline.setMargin(new MMarginInfo(false, true));
    Panel panel = new Panel();
    panel.setContent(form);
    setMargin(true);
    setSpacing(true);
    addComponents(headline, panel);
}

From source file:de.lmu.ifi.dbs.knowing.vaadin.MainApplication.java

License:Apache License

private Window getAboutDialog() {
    if (aboutWindow == null) {
        aboutWindow = new Window("About...");
        aboutWindow.setModal(true);//from  w w  w.java2  s  .c o  m
        aboutWindow.setWidth("400px");

        VerticalLayout layout = (VerticalLayout) aboutWindow.getContent();
        layout.setMargin(true);
        layout.setSpacing(true);
        layout.setStyleName("grey");

        CssLayout titleLayout = new CssLayout();
        H2 title = new H2("Knowing Vaadin Application");
        titleLayout.addComponent(title);
        SmallText description = new SmallText("<br>Copyright (c) Nepomuk Seiler, LMU Database <br>"
                + "Licensed under Apache Software Foundation 2.0 license (ASF).<br><br>"
                + "This software contains modules licenced under<br>"
                + " the Apache Software Foundation 2.0 license (ASF) and EPL<br><br>"
                + "Many thanks to Kai Tdter, Chris Brind, Neil Bartlett and<br>"
                + " Petter Holmstrm for their OSGi and Vaadin<br>"
                + " related work, blogs, and bundles.<br><br>"
                + "The icons are from the Silk icon set by Mark James<br>"
                + "<a href=\"http://www.famfamfam.com/lab/icons/silk/\">http://www.famfamfam.com/lab/icons/silk/</a>");
        description.setSizeUndefined();
        description.setContentMode(Label.CONTENT_XHTML);

        titleLayout.addComponent(description);
        aboutWindow.addComponent(titleLayout);

        @SuppressWarnings("serial")
        Button close = new Button("Close", new Button.ClickListener() {
            @Override
            public void buttonClick(ClickEvent event) {
                (aboutWindow.getParent()).removeWindow(aboutWindow);
            }

        });
        layout.addComponent(close);
        layout.setComponentAlignment(close, Alignment.TOP_RIGHT);
    }
    return aboutWindow;
}

From source file:de.symeda.sormas.ui.caze.CaseContactsView.java

License:Open Source License

public HorizontalLayout createStatusFilterBar() {
    HorizontalLayout statusFilterLayout = new HorizontalLayout();
    statusFilterLayout.setSpacing(true);
    statusFilterLayout.setWidth("100%");
    statusFilterLayout.addStyleName(CssStyles.VSPACE_3);

    statusButtons = new HashMap<>();

    Button statusAll = new Button(I18nProperties.getCaption(Captions.all), e -> {
        criteria.contactStatus(null);//  ww w .  j  av a2s. c  om
        navigateTo(criteria);
    });
    CssStyles.style(statusAll, ValoTheme.BUTTON_BORDERLESS, CssStyles.BUTTON_FILTER);
    statusAll.setCaptionAsHtml(true);
    statusFilterLayout.addComponent(statusAll);
    statusButtons.put(statusAll, I18nProperties.getCaption(Captions.all));
    activeStatusButton = statusAll;

    for (ContactStatus status : ContactStatus.values()) {
        Button statusButton = new Button(status.toString(), e -> {
            criteria.contactStatus(status);
            navigateTo(criteria);
        });
        statusButton.setData(status);
        CssStyles.style(statusButton, ValoTheme.BUTTON_BORDERLESS, CssStyles.BUTTON_FILTER,
                CssStyles.BUTTON_FILTER_LIGHT);
        statusButton.setCaptionAsHtml(true);
        statusFilterLayout.addComponent(statusButton);
        statusButtons.put(statusButton, status.toString());
    }
    statusFilterLayout
            .setExpandRatio(statusFilterLayout.getComponent(statusFilterLayout.getComponentCount() - 1), 1);

    // Bulk operation dropdown
    if (UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS)) {
        statusFilterLayout.setWidth(100, Unit.PERCENTAGE);

        MenuBar bulkOperationsDropdown = new MenuBar();
        MenuItem bulkOperationsItem = bulkOperationsDropdown
                .addItem(I18nProperties.getCaption(Captions.bulkActions), null);

        Command changeCommand = selectedItem -> {
            ControllerProvider.getContactController().showBulkContactDataEditComponent(
                    grid.asMultiSelect().getSelectedItems(), getCaseRef().getUuid());
        };
        bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkEdit), VaadinIcons.ELLIPSIS_H,
                changeCommand);

        Command cancelFollowUpCommand = selectedItem -> {
            ControllerProvider.getContactController()
                    .cancelFollowUpOfAllSelectedItems(grid.asMultiSelect().getSelectedItems(), new Runnable() {
                        public void run() {
                            grid.deselectAll();
                            grid.reload();
                        }
                    });
        };
        bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkCancelFollowUp), VaadinIcons.CLOSE,
                cancelFollowUpCommand);

        Command lostToFollowUpCommand = selectedItem -> {
            ControllerProvider.getContactController().setAllSelectedItemsToLostToFollowUp(
                    grid.asMultiSelect().getSelectedItems(), new Runnable() {
                        public void run() {
                            grid.deselectAll();
                            grid.reload();
                        }
                    });
        };
        bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkLostToFollowUp), VaadinIcons.UNLINK,
                lostToFollowUpCommand);

        Command deleteCommand = selectedItem -> {
            ControllerProvider.getContactController()
                    .deleteAllSelectedItems(grid.asMultiSelect().getSelectedItems(), new Runnable() {
                        public void run() {
                            grid.deselectAll();
                            grid.reload();
                        }
                    });
        };
        bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkDelete), VaadinIcons.TRASH,
                deleteCommand);

        statusFilterLayout.addComponent(bulkOperationsDropdown);
        statusFilterLayout.setComponentAlignment(bulkOperationsDropdown, Alignment.TOP_RIGHT);
        statusFilterLayout.setExpandRatio(bulkOperationsDropdown, 1);
    }

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

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

        statusFilterLayout.addComponent(exportButton);
        statusFilterLayout.setComponentAlignment(exportButton, Alignment.MIDDLE_RIGHT);
        if (!UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS)) {
            statusFilterLayout.setExpandRatio(exportButton, 1);
        }
    }

    if (UserProvider.getCurrent().hasUserRight(UserRight.CONTACT_CREATE)) {
        newButton = new Button(
                I18nProperties.getPrefixCaption(ContactDto.I18N_PREFIX, Captions.contactNewContact));
        newButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
        newButton.setIcon(VaadinIcons.PLUS_CIRCLE);
        newButton.addClickListener(e -> ControllerProvider.getContactController().create(this.getCaseRef()));
        statusFilterLayout.addComponent(newButton);
        statusFilterLayout.setComponentAlignment(newButton, Alignment.MIDDLE_RIGHT);
    }

    statusFilterLayout.addStyleName("top-bar");
    activeStatusButton = statusAll;
    return statusFilterLayout;
}

From source file:de.symeda.sormas.ui.caze.CasesView.java

License:Open Source License

public HorizontalLayout createStatusFilterBar() {
    HorizontalLayout statusFilterLayout = new HorizontalLayout();
    statusFilterLayout.setSpacing(true);
    statusFilterLayout.setMargin(false);
    statusFilterLayout.setWidth(100, Unit.PERCENTAGE);
    statusFilterLayout.addStyleName(CssStyles.VSPACE_3);

    statusButtons = new HashMap<>();

    Button statusAll = new Button(I18nProperties.getCaption(Captions.all), e -> {
        criteria.investigationStatus(null);
        navigateTo(criteria);/*from  www  .ja va2 s . c o  m*/
    });
    CssStyles.style(statusAll, ValoTheme.BUTTON_BORDERLESS, CssStyles.BUTTON_FILTER);
    statusAll.setCaptionAsHtml(true);
    statusFilterLayout.addComponent(statusAll);
    statusButtons.put(statusAll, I18nProperties.getCaption(Captions.all));
    activeStatusButton = statusAll;

    for (InvestigationStatus status : InvestigationStatus.values()) {
        Button statusButton = new Button(status.toString(), e -> {
            criteria.investigationStatus(status);
            navigateTo(criteria);
        });
        statusButton.setData(status);
        CssStyles.style(statusButton, ValoTheme.BUTTON_BORDERLESS, CssStyles.BUTTON_FILTER,
                CssStyles.BUTTON_FILTER_LIGHT);
        statusButton.setCaptionAsHtml(true);
        statusFilterLayout.addComponent(statusButton);
        statusButtons.put(statusButton, status.toString());
    }

    HorizontalLayout actionButtonsLayout = new HorizontalLayout();
    actionButtonsLayout.setSpacing(true);
    {
        // Show archived/active cases button
        if (UserProvider.getCurrent().hasUserRight(UserRight.CASE_VIEW_ARCHIVED)) {
            switchArchivedActiveButton = new Button(I18nProperties.getCaption(Captions.caseShowArchived));
            switchArchivedActiveButton.setStyleName(ValoTheme.BUTTON_LINK);
            switchArchivedActiveButton.addClickListener(e -> {
                criteria.archived(Boolean.TRUE.equals(criteria.getArchived()) ? null : Boolean.TRUE);
                navigateTo(criteria);
            });
            actionButtonsLayout.addComponent(switchArchivedActiveButton);
        }

        // Bulk operation dropdown
        if (UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS)) {
            MenuBar bulkOperationsDropdown = new MenuBar();
            MenuItem bulkOperationsItem = bulkOperationsDropdown
                    .addItem(I18nProperties.getCaption(Captions.bulkActions), null);

            Command changeCommand = selectedItem -> {
                ControllerProvider.getCaseController()
                        .showBulkCaseDataEditComponent(grid.asMultiSelect().getSelectedItems());
            };
            bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkEdit), VaadinIcons.ELLIPSIS_H,
                    changeCommand);

            Command deleteCommand = selectedItem -> {
                ControllerProvider.getCaseController()
                        .deleteAllSelectedItems(grid.asMultiSelect().getSelectedItems(), new Runnable() {
                            public void run() {
                                grid.reload();
                            }
                        });
            };
            bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkDelete), VaadinIcons.TRASH,
                    deleteCommand);

            Command archiveCommand = selectedItem -> {
                ControllerProvider.getCaseController()
                        .archiveAllSelectedItems(grid.asMultiSelect().getSelectedItems(), new Runnable() {
                            public void run() {
                                grid.reload();
                            }
                        });
            };
            archiveItem = bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.actionArchive),
                    VaadinIcons.ARCHIVE, archiveCommand);

            Command dearchiveCommand = selectedItem -> {
                ControllerProvider.getCaseController()
                        .dearchiveAllSelectedItems(grid.asMultiSelect().getSelectedItems(), new Runnable() {
                            public void run() {
                                grid.reload();
                            }
                        });
            };
            dearchiveItem = bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.actionDearchive),
                    VaadinIcons.ARCHIVE, dearchiveCommand);
            dearchiveItem.setVisible(false);

            actionButtonsLayout.addComponent(bulkOperationsDropdown);
        }
    }
    statusFilterLayout.addComponent(actionButtonsLayout);
    statusFilterLayout.setComponentAlignment(actionButtonsLayout, Alignment.TOP_RIGHT);
    statusFilterLayout.setExpandRatio(actionButtonsLayout, 1);

    return statusFilterLayout;
}

From source file:de.symeda.sormas.ui.configuration.outbreak.OutbreakRegionConfigurationForm.java

License:Open Source License

private HorizontalLayout createHeader() {
    HorizontalLayout headerLayout = new HorizontalLayout();
    headerLayout.setWidth(100, Unit.PERCENTAGE);
    headerLayout.setSpacing(true);/*ww w. j  a va  2  s  .co  m*/
    CssStyles.style(headerLayout, CssStyles.VSPACE_2);

    // Headline and info text
    Label infoTextLabel = new Label(I18nProperties.getString(Strings.headingDefineOutbreakDistricts));
    infoTextLabel.setWidthUndefined();
    CssStyles.style(infoTextLabel, CssStyles.VSPACE_TOP_4);
    headerLayout.addComponent(infoTextLabel);

    // Number of affected districts and options to toggle outbreak mode for all districts   
    HorizontalLayout allDistrictsLayout = new HorizontalLayout();
    allDistrictsLayout.setWidthUndefined();
    allDistrictsLayout.setSpacing(true);
    {
        Label allDistrictsLabel = new Label(I18nProperties.getString(Strings.headingSetOutbreakStatus));
        allDistrictsLabel.setWidthUndefined();
        CssStyles.style(allDistrictsLabel, CssStyles.VSPACE_TOP_4);
        allDistrictsLayout.addComponent(allDistrictsLabel);

        OptionGroup outbreakToggle = new OptionGroup();
        CssStyles.style(outbreakToggle, ValoTheme.OPTIONGROUP_HORIZONTAL,
                CssStyles.OPTIONGROUP_HORIZONTAL_SWITCH_CRITICAL);
        outbreakToggle.addItem(OUTBREAK);
        outbreakToggle.addItem(NORMAL);

        if (affectedDistricts.isEmpty()) {
            outbreakToggle.setValue(NORMAL);
        } else if (affectedDistricts.size() == totalDistricts) {
            outbreakToggle.setValue(OUTBREAK);
        }

        outbreakToggle.addValueChangeListener(e -> {
            for (OptionGroup districtOutbreakToggle : outbreakToggles) {
                districtOutbreakToggle.setValue(e.getProperty().getValue());
            }
        });

        outbreakToggle.setWidthUndefined();
        allDistrictsLayout.addComponent(outbreakToggle);

        affectedDistrictsNumberLabel = new Label();
        affectedDistrictsNumberLabel.setWidthUndefined();
        allDistrictsLayout.addComponent(affectedDistrictsNumberLabel);
    }
    headerLayout.addComponent(allDistrictsLayout);
    headerLayout.setComponentAlignment(allDistrictsLayout, Alignment.TOP_RIGHT);

    headerLayout.setExpandRatio(infoTextLabel, 1);

    return headerLayout;
}

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

License:Open Source License

public HorizontalLayout createStatusFilterBar() {
    HorizontalLayout statusFilterLayout = new HorizontalLayout();
    statusFilterLayout.setMargin(false);
    statusFilterLayout.setSpacing(true);
    statusFilterLayout.setWidth(100, Unit.PERCENTAGE);
    statusFilterLayout.addStyleName(CssStyles.VSPACE_3);

    statusButtons = new HashMap<>();

    Button statusAll = new Button(I18nProperties.getCaption(Captions.all), e -> {
        criteria.contactStatus(null);/*  ww  w  . j a  va2 s.c  o  m*/
        navigateTo(criteria);
    });
    CssStyles.style(statusAll, ValoTheme.BUTTON_BORDERLESS, CssStyles.BUTTON_FILTER);
    statusAll.setCaptionAsHtml(true);
    statusFilterLayout.addComponent(statusAll);
    statusButtons.put(statusAll, I18nProperties.getCaption(Captions.all));
    activeStatusButton = statusAll;

    for (ContactStatus status : ContactStatus.values()) {
        Button statusButton = new Button(status.toString(), e -> {
            criteria.contactStatus(status);
            navigateTo(criteria);
        });
        statusButton.setData(status);
        CssStyles.style(statusButton, ValoTheme.BUTTON_BORDERLESS, CssStyles.BUTTON_FILTER,
                CssStyles.BUTTON_FILTER_LIGHT);
        statusButton.setCaptionAsHtml(true);
        statusFilterLayout.addComponent(statusButton);
        statusButtons.put(statusButton, status.toString());
    }

    HorizontalLayout actionButtonsLayout = new HorizontalLayout();
    actionButtonsLayout.setSpacing(true);
    {
        // Show archived/active cases button
        if (UserProvider.getCurrent().hasUserRight(UserRight.CONTACT_VIEW_ARCHIVED)) {
            switchArchivedActiveButton = new Button(I18nProperties.getCaption(Captions.contactShowArchived));
            switchArchivedActiveButton.setStyleName(ValoTheme.BUTTON_LINK);
            switchArchivedActiveButton.addClickListener(e -> {
                criteria.archived(Boolean.TRUE.equals(criteria.getArchived()) ? null : Boolean.TRUE);
                navigateTo(criteria);
            });
            actionButtonsLayout.addComponent(switchArchivedActiveButton);
        }

        // Bulk operation dropdown
        if (UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS)) {
            statusFilterLayout.setWidth(100, Unit.PERCENTAGE);

            MenuBar bulkOperationsDropdown = new MenuBar();
            MenuItem bulkOperationsItem = bulkOperationsDropdown
                    .addItem(I18nProperties.getCaption(Captions.bulkActions), null);

            Command changeCommand = selectedItem -> {
                ControllerProvider.getContactController()
                        .showBulkContactDataEditComponent(grid.asMultiSelect().getSelectedItems(), null);
            };
            bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkEdit), VaadinIcons.ELLIPSIS_H,
                    changeCommand);

            Command cancelFollowUpCommand = selectedItem -> {
                ControllerProvider.getContactController().cancelFollowUpOfAllSelectedItems(
                        grid.asMultiSelect().getSelectedItems(), new Runnable() {
                            public void run() {
                                grid.reload();
                            }
                        });
            };
            bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkCancelFollowUp),
                    VaadinIcons.CLOSE, cancelFollowUpCommand);

            Command lostToFollowUpCommand = selectedItem -> {
                ControllerProvider.getContactController().setAllSelectedItemsToLostToFollowUp(
                        grid.asMultiSelect().getSelectedItems(), new Runnable() {
                            public void run() {
                                grid.reload();
                            }
                        });
            };
            bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkLostToFollowUp),
                    VaadinIcons.UNLINK, lostToFollowUpCommand);

            Command deleteCommand = selectedItem -> {
                ControllerProvider.getContactController()
                        .deleteAllSelectedItems(grid.asMultiSelect().getSelectedItems(), new Runnable() {
                            public void run() {
                                grid.reload();
                            }
                        });
            };
            bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkDelete), VaadinIcons.TRASH,
                    deleteCommand);

            actionButtonsLayout.addComponent(bulkOperationsDropdown);
        }
    }
    statusFilterLayout.addComponent(actionButtonsLayout);
    statusFilterLayout.setComponentAlignment(actionButtonsLayout, Alignment.TOP_RIGHT);
    statusFilterLayout.setExpandRatio(actionButtonsLayout, 1);

    return statusFilterLayout;
}

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

License:Open Source License

public HorizontalLayout createTopBar() {
    HorizontalLayout topLayout = new HorizontalLayout();
    topLayout.setSpacing(true);/*www . j a v  a2 s . c  o m*/
    topLayout.setWidth(100, Unit.PERCENTAGE);

    //      statusButtons = new HashMap<>();
    //
    //      Button contactButton = new Button(I18nProperties.getCaption(Captions.contactRelated), e -> {
    //         grid.reload(getContactRef());
    //         processStatusChangeVisuals(e.getButton());
    //      });
    //      CssStyles.style(contactButton, ValoTheme.BUTTON_BORDERLESS, CssStyles.BUTTON_FILTER);
    //      contactButton.setCaptionAsHtml(true);
    //      topLayout.addComponent(contactButton);
    //      statusButtons.put(contactButton, I18nProperties.getCaption(Captions.contactRelated));
    //
    //      Button personButton = new Button(I18nProperties.getCaption(Captions.contactPersonVisits), e -> {
    //         ContactDto contact = FacadeProvider.getContactFacade().getContactByUuid(getContactRef().getUuid());
    //         grid.reload(contact.getPerson());
    //         processStatusChangeVisuals(e.getButton());
    //      });
    //      CssStyles.style(personButton, ValoTheme.BUTTON_BORDERLESS, CssStyles.BUTTON_FILTER, CssStyles.BUTTON_FILTER_LIGHT);
    //      personButton.setCaptionAsHtml(true);
    //      topLayout.addComponent(personButton);
    //      statusButtons.put(personButton, I18nProperties.getCaption(Captions.contactPersonVisits));

    //      topLayout.setExpandRatio(topLayout.getComponent(topLayout.getComponentCount()-1), 1);

    // Bulk operation dropdown
    if (UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS)) {
        topLayout.setWidth(100, Unit.PERCENTAGE);

        MenuBar bulkOperationsDropdown = new MenuBar();
        MenuItem bulkOperationsItem = bulkOperationsDropdown
                .addItem(I18nProperties.getCaption(Captions.bulkActions), null);

        Command deleteCommand = selectedItem -> {
            ControllerProvider.getVisitController()
                    .deleteAllSelectedItems(grid.asMultiSelect().getSelectedItems(), new Runnable() {
                        public void run() {
                            grid.deselectAll();
                            grid.reload();
                        }
                    });
        };
        bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkDelete), VaadinIcons.TRASH,
                deleteCommand);

        topLayout.addComponent(bulkOperationsDropdown);
        topLayout.setComponentAlignment(bulkOperationsDropdown, Alignment.TOP_RIGHT);
        topLayout.setExpandRatio(bulkOperationsDropdown, 1);
    }

    if (UserProvider.getCurrent().hasUserRight(UserRight.VISIT_CREATE)) {
        newButton = new Button(I18nProperties.getCaption(Captions.visitNewVisit));
        newButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
        newButton.setIcon(VaadinIcons.PLUS_CIRCLE);
        newButton.addClickListener(e -> {
            ControllerProvider.getVisitController().createVisit(this.getContactRef(), r -> grid.reload());
        });
        topLayout.addComponent(newButton);
        topLayout.setComponentAlignment(newButton, Alignment.MIDDLE_RIGHT);
    }

    topLayout.addStyleName(CssStyles.VSPACE_3);
    //      activeStatusButton = contactButton;
    return topLayout;
}