Example usage for com.vaadin.ui.themes ValoTheme BUTTON_LINK

List of usage examples for com.vaadin.ui.themes ValoTheme BUTTON_LINK

Introduction

In this page you can find the example usage for com.vaadin.ui.themes ValoTheme BUTTON_LINK.

Prototype

String BUTTON_LINK

To view the source code for com.vaadin.ui.themes ValoTheme BUTTON_LINK.

Click Source Link

Document

Makes the button look like the Link component.

Usage

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);//  w  ww  .j a  v  a2s  .c om
    });
    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.caze.CasesView.java

License:Open Source License

private void updateArchivedButton() {
    if (switchArchivedActiveButton == null) {
        return;//from   www . ja  v a 2  s. c  o m
    }

    if (Boolean.TRUE.equals(criteria.getArchived())) {
        getViewTitleLabel()
                .setValue(I18nProperties.getPrefixCaption("View", viewName.replaceAll("/", ".") + ".archive"));
        switchArchivedActiveButton.setCaption(I18nProperties.getCaption(Captions.caseShowActive));
        switchArchivedActiveButton.setStyleName(ValoTheme.BUTTON_PRIMARY);
        if (archiveItem != null && dearchiveItem != null) {
            archiveItem.setVisible(false);
            dearchiveItem.setVisible(true);
        }
    } else {
        getViewTitleLabel().setValue(originalViewTitle);
        switchArchivedActiveButton.setCaption(I18nProperties.getCaption(Captions.caseShowArchived));
        switchArchivedActiveButton.setStyleName(ValoTheme.BUTTON_LINK);
        if (archiveItem != null && dearchiveItem != null) {
            dearchiveItem.setVisible(false);
            archiveItem.setVisible(true);
        }
    }
}

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

License:Open Source License

@Override
protected void addFields() {
    addField(ContactDto.CONTACT_CLASSIFICATION, OptionGroup.class);
    addField(ContactDto.CONTACT_STATUS, OptionGroup.class);
    addField(ContactDto.UUID, TextField.class);
    addField(ContactDto.REPORTING_USER, ComboBox.class);
    DateField lastContactDate = addField(ContactDto.LAST_CONTACT_DATE, DateField.class);
    addField(ContactDto.REPORT_DATE_TIME, DateField.class);
    OptionGroup contactProximity = addField(ContactDto.CONTACT_PROXIMITY, OptionGroup.class);
    contactProximity.removeStyleName(ValoTheme.OPTIONGROUP_HORIZONTAL);
    ComboBox relationToCase = addField(ContactDto.RELATION_TO_CASE, ComboBox.class);
    addField(ContactDto.DESCRIPTION, TextArea.class).setRows(3);

    addField(ContactDto.FOLLOW_UP_STATUS, ComboBox.class);
    addField(ContactDto.FOLLOW_UP_COMMENT, TextArea.class).setRows(1);
    addDateField(ContactDto.FOLLOW_UP_UNTIL, DateField.class, -1);

    ComboBox contactOfficerField = addField(ContactDto.CONTACT_OFFICER, ComboBox.class);
    contactOfficerField.setNullSelectionAllowed(true);

    setReadOnly(true, ContactDto.UUID, ContactDto.REPORTING_USER, ContactDto.REPORT_DATE_TIME,
            ContactDto.CONTACT_STATUS, ContactDto.FOLLOW_UP_STATUS, ContactDto.FOLLOW_UP_UNTIL);

    FieldHelper.setRequiredWhen(getFieldGroup(), ContactDto.FOLLOW_UP_STATUS,
            Arrays.asList(ContactDto.FOLLOW_UP_COMMENT),
            Arrays.asList(FollowUpStatus.CANCELED, FollowUpStatus.LOST));

    addValueChangeListener(e -> {//from www.  ja  v a  2s  .c  om
        if (getValue() != null) {
            CaseDataDto caseDto = FacadeProvider.getCaseFacade()
                    .getCaseDataByUuid(getValue().getCaze().getUuid());
            updateLastContactDateValidator();
            updateDiseaseConfiguration(caseDto.getDisease());

            updateFollowUpStatusComponents();

            contactOfficerField.addItems(FacadeProvider.getUserFacade()
                    .getUserRefsByDistrict(caseDto.getDistrict(), false, UserRole.CONTACT_OFFICER));

            getContent().removeComponent(TO_CASE_BTN_LOC);
            if (getValue().getResultingCase() != null) {
                // link to case
                Link linkToData = ControllerProvider.getCaseController().createLinkToData(
                        getValue().getResultingCase().getUuid(),
                        I18nProperties.getCaption(Captions.contactOpenContactCase));
                getContent().addComponent(linkToData, TO_CASE_BTN_LOC);
            } else if (getValue().getContactClassification() == ContactClassification.CONFIRMED) {
                // only when confirmed
                if (UserProvider.getCurrent().hasUserRight(UserRight.CONTACT_CONVERT)) {
                    Button toCaseButton = new Button(
                            I18nProperties.getCaption(Captions.contactCreateContactCase));
                    toCaseButton.addStyleName(ValoTheme.BUTTON_LINK);

                    toCaseButton.addClickListener(new ClickListener() {
                        @Override
                        public void buttonClick(ClickEvent event) {
                            PersonReferenceDto personRef = getValue().getPerson();
                            CaseReferenceDto caseRef = getValue().getCaze();
                            CaseDataDto caze = FacadeProvider.getCaseFacade()
                                    .getCaseDataByUuid(caseRef.getUuid());
                            ControllerProvider.getCaseController().create(personRef, caze.getDisease(),
                                    getValue());
                        }
                    });

                    getContent().addComponent(toCaseButton, TO_CASE_BTN_LOC);
                }
            }
        }
    });

    setRequired(true, ContactDto.CONTACT_CLASSIFICATION, ContactDto.CONTACT_STATUS);
    FieldHelper.addSoftRequiredStyle(lastContactDate, contactProximity, relationToCase);
}

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);//from   w  w w.j ava  2 s .  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());
    }

    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.ContactsView.java

License:Open Source License

private void updateArchivedButton() {
    if (switchArchivedActiveButton == null) {
        return;//from w  ww .j a va 2s  . c  om
    }

    if (Boolean.TRUE.equals(criteria.getArchived())) {
        getViewTitleLabel()
                .setValue(I18nProperties.getPrefixCaption("View", viewName.replaceAll("/", ".") + ".archive"));
        switchArchivedActiveButton
                .setCaption(I18nProperties.getCaption(I18nProperties.getCaption(Captions.contactShowActive)));
        switchArchivedActiveButton.setStyleName(ValoTheme.BUTTON_PRIMARY);
    } else {
        getViewTitleLabel().setValue(originalViewTitle);
        switchArchivedActiveButton
                .setCaption(I18nProperties.getCaption(I18nProperties.getCaption(Captions.contactShowArchived)));
        switchArchivedActiveButton.setStyleName(ValoTheme.BUTTON_LINK);
    }
}

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

License:Open Source License

public CommitDiscardWrapperComponent<EventDataForm> getEventDataEditComponent(final String eventUuid) {
    EventDto event = findEvent(eventUuid);
    EventDataForm eventEditForm = new EventDataForm(false, UserRight.EVENT_EDIT);
    eventEditForm.setValue(event);//from   w ww.  j  a va 2s.  com
    final CommitDiscardWrapperComponent<EventDataForm> editView = new CommitDiscardWrapperComponent<EventDataForm>(
            eventEditForm, eventEditForm.getFieldGroup());

    editView.addCommitListener(new CommitListener() {
        @Override
        public void onCommit() {
            if (!eventEditForm.getFieldGroup().isModified()) {
                EventDto eventDto = eventEditForm.getValue();
                eventDto = FacadeProvider.getEventFacade().saveEvent(eventDto);
                Notification.show(I18nProperties.getString(Strings.messageEventSaved), Type.WARNING_MESSAGE);
                SormasUI.refreshView();
            }
        }
    });

    if (UserProvider.getCurrent().hasUserRole(UserRole.ADMIN)) {
        editView.addDeleteListener(new DeleteListener() {
            @Override
            public void onDelete() {
                FacadeProvider.getEventFacade().deleteEvent(event.toReference(),
                        UserProvider.getCurrent().getUserReference().getUuid());
                UI.getCurrent().getNavigator().navigateTo(EventsView.VIEW_NAME);
            }
        }, I18nProperties.getString(Strings.entityEvent));
    }

    // Initialize 'Archive' button
    if (UserProvider.getCurrent().hasUserRight(UserRight.EVENT_ARCHIVE)) {
        boolean archived = FacadeProvider.getEventFacade().isArchived(eventUuid);
        Button archiveEventButton = new Button();
        archiveEventButton.addStyleName(ValoTheme.BUTTON_LINK);
        if (archived) {
            archiveEventButton.setCaption(I18nProperties.getCaption(Captions.actionDearchive));
        } else {
            archiveEventButton.setCaption(I18nProperties.getCaption(Captions.actionArchive));
        }
        archiveEventButton.addClickListener(e -> {
            editView.commit();
            archiveOrDearchiveEvent(eventUuid, !archived);
        });

        editView.getButtonsPanel().addComponentAsFirst(archiveEventButton);
        editView.getButtonsPanel().setComponentAlignment(archiveEventButton, Alignment.BOTTOM_LEFT);
    }

    return editView;
}

From source file:de.symeda.sormas.ui.events.EventsView.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.eventStatus(null);//from w  ww . ja v  a2 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 (EventStatus status : EventStatus.values()) {
        Button statusButton = new Button(status.toString(), e -> {
            criteria.eventStatus(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.EVENT_VIEW_ARCHIVED)) {
            switchArchivedActiveButton = new Button(I18nProperties.getCaption(Captions.eventShowArchived));
            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.getEventController()
                        .showBulkEventDataEditComponent(grid.asMultiSelect().getSelectedItems());
            };
            bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkEdit), VaadinIcons.ELLIPSIS_H,
                    changeCommand);

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

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

            Command dearchiveCommand = selectedItem -> {
                ControllerProvider.getEventController()
                        .dearchiveAllSelectedItems(grid.asMultiSelect().getSelectedItems(), new Runnable() {
                            public void run() {
                                grid.reload();
                            }
                        });
            };
            dearchiveItem = bulkOperationsItem.addItem(
                    I18nProperties.getCaption(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.events.EventsView.java

License:Open Source License

private void updateArchivedButton() {
    if (switchArchivedActiveButton == null) {
        return;//from w  w  w  .jav  a2  s  .  c o  m
    }

    if (Boolean.TRUE.equals(criteria.getArchived())) {
        getViewTitleLabel()
                .setValue(I18nProperties.getPrefixCaption("View", viewName.replaceAll("/", ".") + ".archive"));
        switchArchivedActiveButton
                .setCaption(I18nProperties.getCaption(I18nProperties.getCaption(Captions.eventShowActive)));
        switchArchivedActiveButton.setStyleName(ValoTheme.BUTTON_PRIMARY);
        if (archiveItem != null && dearchiveItem != null) {
            archiveItem.setVisible(false);
            dearchiveItem.setVisible(true);
        }
    } else {
        getViewTitleLabel().setValue(originalViewTitle);
        switchArchivedActiveButton
                .setCaption(I18nProperties.getCaption(I18nProperties.getCaption(Captions.eventShowArchived)));
        switchArchivedActiveButton.setStyleName(ValoTheme.BUTTON_LINK);
        if (archiveItem != null && dearchiveItem != null) {
            dearchiveItem.setVisible(false);
            archiveItem.setVisible(true);
        }
    }
}

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);//  ww w .  j  av 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.samples.PathogenTestListEntry.java

License:Open Source License

public void addEditListener(ClickListener editClickListener) {
    if (editButton == null) {
        editButton = new Button(VaadinIcons.PENCIL);
        CssStyles.style(editButton, ValoTheme.BUTTON_LINK, CssStyles.BUTTON_COMPACT);
        addComponent(editButton);//from   w w  w  .j av a2s .co m
        setComponentAlignment(editButton, Alignment.MIDDLE_RIGHT);
        setExpandRatio(editButton, 0);
    }
    editButton.addClickListener(editClickListener);
}