Example usage for com.vaadin.server Page getCurrent

List of usage examples for com.vaadin.server Page getCurrent

Introduction

In this page you can find the example usage for com.vaadin.server Page getCurrent.

Prototype

public static Page getCurrent() 

Source Link

Document

Gets the Page to which the current uI belongs.

Usage

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

License:Open Source License

public void deleteAllSelectedItems(Collection<ContactIndexDto> selectedRows, Runnable callback) {
    if (selectedRows.size() == 0) {
        new Notification(I18nProperties.getString(Strings.headingNoContactsSelected),
                I18nProperties.getString(Strings.messageNoContactsSelected), Type.WARNING_MESSAGE, false)
                        .show(Page.getCurrent());
    } else {/*from  www  . j  a v a 2s.  com*/
        VaadinUiUtil.showDeleteConfirmationWindow(String
                .format(I18nProperties.getString(Strings.confirmationDeleteContacts), selectedRows.size()),
                new Runnable() {
                    public void run() {
                        for (ContactIndexDto selectedRow : selectedRows) {
                            FacadeProvider.getContactFacade().deleteContact(
                                    new ContactReferenceDto((selectedRow).getUuid()),
                                    UserProvider.getCurrent().getUuid());
                        }
                        callback.run();
                        new Notification(I18nProperties.getString(Strings.headingContactsDeleted),
                                I18nProperties.getString(Strings.messageContactsDeleted),
                                Type.HUMANIZED_MESSAGE, false).show(Page.getCurrent());
                    }
                });
    }
}

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

License:Open Source License

public void cancelFollowUpOfAllSelectedItems(Collection<ContactIndexDto> selectedRows, Runnable callback) {
    if (selectedRows.size() == 0) {
        new Notification(I18nProperties.getString(Strings.headingNoContactsSelected),
                I18nProperties.getString(Strings.messageNoContactsSelected), Type.WARNING_MESSAGE, false)
                        .show(Page.getCurrent());
    } else {//from  ww w  . j  a v a 2s  . c  o  m
        VaadinUiUtil.showDeleteConfirmationWindow(String
                .format(I18nProperties.getString(Strings.confirmationCancelFollowUp), selectedRows.size()),
                new Runnable() {
                    public void run() {
                        for (ContactIndexDto contact : selectedRows) {
                            if (contact.getFollowUpStatus() != FollowUpStatus.NO_FOLLOW_UP) {
                                ContactDto contactDto = FacadeProvider.getContactFacade()
                                        .getContactByUuid(contact.getUuid());
                                contactDto.setFollowUpStatus(FollowUpStatus.CANCELED);
                                contactDto.setFollowUpComment(
                                        String.format(I18nProperties.getString(Strings.infoCanceledBy),
                                                UserProvider.getCurrent().getUserName()));
                                FacadeProvider.getContactFacade().saveContact(contactDto);
                            }
                        }
                        callback.run();
                        new Notification(I18nProperties.getString(Strings.headingFollowUpCanceled),
                                I18nProperties.getString(Strings.messageFollowUpCanceled),
                                Type.HUMANIZED_MESSAGE, false).show(Page.getCurrent());
                    }
                });
    }
}

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

License:Open Source License

public void setAllSelectedItemsToLostToFollowUp(Collection<ContactIndexDto> selectedRows, Runnable callback) {
    if (selectedRows.size() == 0) {
        new Notification(I18nProperties.getString(Strings.headingNoContactsSelected),
                I18nProperties.getString(Strings.messageNoContactsSelected), Type.WARNING_MESSAGE, false)
                        .show(Page.getCurrent());
    } else {/*from   ww  w .  j av a2  s.c  om*/
        VaadinUiUtil.showDeleteConfirmationWindow(String
                .format(I18nProperties.getString(Strings.confirmationLostToFollowUp), selectedRows.size()),
                new Runnable() {
                    public void run() {
                        for (ContactIndexDto contact : selectedRows) {
                            if (contact.getFollowUpStatus() != FollowUpStatus.NO_FOLLOW_UP) {
                                ContactDto contactDto = FacadeProvider.getContactFacade()
                                        .getContactByUuid(contact.getUuid());
                                contactDto.setFollowUpStatus(FollowUpStatus.LOST);
                                contactDto.setFollowUpComment(
                                        String.format(I18nProperties.getString(Strings.infoLostToFollowUpBy),
                                                UserProvider.getCurrent().getUserName()));
                                FacadeProvider.getContactFacade().saveContact(contactDto);
                            }
                        }
                        callback.run();
                        new Notification(I18nProperties.getString(Strings.headingFollowUpStatusChanged),
                                I18nProperties.getString(Strings.messageFollowUpStatusChanged),
                                Type.HUMANIZED_MESSAGE, false).show(Page.getCurrent());
                    }
                });
    }
}

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

License:Open Source License

public VerticalLayout createFilterBar() {
    VerticalLayout filterLayout = new VerticalLayout();
    filterLayout.setSpacing(false);/*w w w .ja v a 2 s  .  c o m*/
    filterLayout.setMargin(false);
    filterLayout.setWidth(100, Unit.PERCENTAGE);

    firstFilterRowLayout = new HorizontalLayout();
    firstFilterRowLayout.setMargin(false);
    firstFilterRowLayout.setSpacing(true);
    firstFilterRowLayout.setSizeUndefined();
    {
        classificationFilter = new ComboBox();
        classificationFilter.setWidth(140, Unit.PIXELS);
        classificationFilter.setInputPrompt(I18nProperties.getPrefixCaption(ContactIndexDto.I18N_PREFIX,
                ContactIndexDto.CONTACT_CLASSIFICATION));
        classificationFilter.addItems((Object[]) ContactClassification.values());
        classificationFilter.addValueChangeListener(e -> {
            criteria.contactClassification((ContactClassification) e.getProperty().getValue());
            navigateTo(criteria);
        });
        firstFilterRowLayout.addComponent(classificationFilter);

        diseaseFilter = new ComboBox();
        diseaseFilter.setWidth(140, Unit.PIXELS);
        diseaseFilter.setInputPrompt(
                I18nProperties.getPrefixCaption(ContactIndexDto.I18N_PREFIX, ContactIndexDto.CASE_DISEASE));
        diseaseFilter.addItems(
                FacadeProvider.getDiseaseConfigurationFacade().getAllActivePrimaryDiseases().toArray());
        diseaseFilter.addValueChangeListener(e -> {
            criteria.caseDisease(((Disease) e.getProperty().getValue()));
            navigateTo(criteria);
        });
        firstFilterRowLayout.addComponent(diseaseFilter);

        followUpStatusFilter = new ComboBox();
        followUpStatusFilter.setWidth(140, Unit.PIXELS);
        followUpStatusFilter.setInputPrompt(
                I18nProperties.getPrefixCaption(ContactIndexDto.I18N_PREFIX, ContactIndexDto.FOLLOW_UP_STATUS));
        followUpStatusFilter.addItems((Object[]) FollowUpStatus.values());
        followUpStatusFilter.addValueChangeListener(e -> {
            criteria.followUpStatus(((FollowUpStatus) e.getProperty().getValue()));
            navigateTo(criteria);
        });
        firstFilterRowLayout.addComponent(followUpStatusFilter);

        searchField = new TextField();
        searchField.setWidth(200, Unit.PIXELS);
        searchField.setNullRepresentation("");
        searchField.setInputPrompt(I18nProperties.getString(Strings.promptContactsSearchField));
        searchField.addTextChangeListener(e -> {
            criteria.nameUuidCaseLike(e.getText());
            grid.reload();
        });
        firstFilterRowLayout.addComponent(searchField);

        addShowMoreOrLessFiltersButtons(firstFilterRowLayout);

        resetButton = new Button(I18nProperties.getCaption(Captions.actionResetFilters));
        resetButton.setVisible(false);
        resetButton.addClickListener(event -> {
            ViewModelProviders.of(ContactsView.class).remove(ContactCriteria.class);
            navigateTo(null);
        });
        firstFilterRowLayout.addComponent(resetButton);
    }
    filterLayout.addComponent(firstFilterRowLayout);

    secondFilterRowLayout = new HorizontalLayout();
    secondFilterRowLayout.setMargin(false);
    secondFilterRowLayout.setSpacing(true);
    secondFilterRowLayout.setSizeUndefined();
    {
        UserDto user = UserProvider.getCurrent().getUser();
        regionFilter = new ComboBox();
        if (user.getRegion() == null) {
            regionFilter.setWidth(140, Unit.PIXELS);
            regionFilter.setInputPrompt(I18nProperties.getPrefixCaption(ContactIndexDto.I18N_PREFIX,
                    ContactIndexDto.CASE_REGION_UUID));
            regionFilter.addItems(FacadeProvider.getRegionFacade().getAllAsReference());
            regionFilter.addValueChangeListener(e -> {
                RegionReferenceDto region = (RegionReferenceDto) e.getProperty().getValue();
                criteria.caseRegion(region);
                navigateTo(criteria);
            });
            secondFilterRowLayout.addComponent(regionFilter);
        }

        districtFilter = new ComboBox();
        districtFilter.setWidth(140, Unit.PIXELS);
        districtFilter.setInputPrompt(I18nProperties.getPrefixCaption(ContactIndexDto.I18N_PREFIX,
                ContactIndexDto.CASE_DISTRICT_UUID));
        districtFilter.setDescription(I18nProperties.getDescription(Descriptions.descDistrictFilter));
        districtFilter.addValueChangeListener(e -> {
            DistrictReferenceDto district = (DistrictReferenceDto) e.getProperty().getValue();
            criteria.caseDistrict(district);
            navigateTo(criteria);
        });

        if (user.getRegion() != null && user.getDistrict() == null) {
            districtFilter
                    .addItems(FacadeProvider.getDistrictFacade().getAllByRegion(user.getRegion().getUuid()));
            districtFilter.setEnabled(true);
        } else {
            regionFilter.addValueChangeListener(e -> {
                RegionReferenceDto region = (RegionReferenceDto) e.getProperty().getValue();
                districtFilter.removeAllItems();
                if (region != null) {
                    districtFilter
                            .addItems(FacadeProvider.getDistrictFacade().getAllByRegion(region.getUuid()));
                    districtFilter.setEnabled(true);
                } else {
                    districtFilter.setEnabled(false);
                }
            });
            districtFilter.setEnabled(false);
        }
        secondFilterRowLayout.addComponent(districtFilter);

        facilityFilter = new ComboBox();
        facilityFilter.setWidth(140, Unit.PIXELS);
        facilityFilter.setInputPrompt(I18nProperties.getPrefixCaption(ContactIndexDto.I18N_PREFIX,
                ContactIndexDto.CASE_HEALTH_FACILITY_UUID));
        facilityFilter.setDescription(I18nProperties.getDescription(Descriptions.descFacilityFilter));
        facilityFilter.addValueChangeListener(e -> {
            FacilityReferenceDto facility = (FacilityReferenceDto) e.getProperty().getValue();
            criteria.caseFacility(facility);
            navigateTo(criteria);
        });
        facilityFilter.setEnabled(false);
        secondFilterRowLayout.addComponent(facilityFilter);

        districtFilter.addValueChangeListener(e -> {
            facilityFilter.removeAllItems();
            DistrictReferenceDto district = (DistrictReferenceDto) e.getProperty().getValue();
            if (district != null) {
                facilityFilter.addItems(
                        FacadeProvider.getFacilityFacade().getHealthFacilitiesByDistrict(district, true));
                facilityFilter.setEnabled(true);
            } else {
                facilityFilter.setEnabled(false);
            }
        });

        officerFilter = new ComboBox();
        officerFilter.setWidth(140, Unit.PIXELS);
        officerFilter.setInputPrompt(I18nProperties.getPrefixCaption(ContactIndexDto.I18N_PREFIX,
                ContactIndexDto.CONTACT_OFFICER_UUID));
        if (user.getRegion() != null) {
            officerFilter.addItems(FacadeProvider.getUserFacade().getUsersByRegionAndRoles(user.getRegion(),
                    UserRole.CONTACT_OFFICER));
        }
        officerFilter.addValueChangeListener(e -> {
            UserReferenceDto officer = (UserReferenceDto) e.getProperty().getValue();
            criteria.contactOfficer(officer);
            navigateTo(criteria);
        });
        secondFilterRowLayout.addComponent(officerFilter);

        reportedByFilter = new ComboBox();
        reportedByFilter.setWidth(140, Unit.PIXELS);
        reportedByFilter.setInputPrompt(I18nProperties.getString(Strings.reportedBy));
        reportedByFilter.addItems((Object[]) UserRole.values());
        reportedByFilter.addValueChangeListener(e -> {
            criteria.reportingUserRole((UserRole) e.getProperty().getValue());
            navigateTo(criteria);
        });
        secondFilterRowLayout.addComponent(reportedByFilter);
    }
    filterLayout.addComponent(secondFilterRowLayout);
    secondFilterRowLayout.setVisible(false);

    dateFilterRowLayout = new HorizontalLayout();
    dateFilterRowLayout.setSpacing(true);
    dateFilterRowLayout.setSizeUndefined();
    {
        Button applyButton = new Button(I18nProperties.getCaption(Captions.actionApplyDateFilter));

        weekAndDateFilter = new EpiWeekAndDateFilterComponent<>(applyButton, false, false, null,
                ContactDateType.class, I18nProperties.getString(Strings.promptContactDateType),
                ContactDateType.REPORT_DATE);
        weekAndDateFilter.getWeekFromFilter()
                .setInputPrompt(I18nProperties.getString(Strings.promptContactEpiWeekFrom));
        weekAndDateFilter.getWeekToFilter()
                .setInputPrompt(I18nProperties.getString(Strings.promptContactEpiWeekTo));
        weekAndDateFilter.getDateFromFilter()
                .setInputPrompt(I18nProperties.getString(Strings.promptContactDateFrom));
        weekAndDateFilter.getDateToFilter()
                .setInputPrompt(I18nProperties.getString(Strings.promptContactDateTo));
        dateFilterRowLayout.addComponent(weekAndDateFilter);
        dateFilterRowLayout.addComponent(applyButton);

        applyButton.addClickListener(e -> {
            DateFilterOption dateFilterOption = (DateFilterOption) weekAndDateFilter.getDateFilterOptionFilter()
                    .getValue();
            Date fromDate, toDate;
            if (dateFilterOption == DateFilterOption.DATE) {
                fromDate = DateHelper.getStartOfDay(weekAndDateFilter.getDateFromFilter().getValue());
                toDate = DateHelper.getEndOfDay(weekAndDateFilter.getDateToFilter().getValue());
            } else {
                fromDate = DateHelper
                        .getEpiWeekStart((EpiWeek) weekAndDateFilter.getWeekFromFilter().getValue());
                toDate = DateHelper.getEpiWeekEnd((EpiWeek) weekAndDateFilter.getWeekToFilter().getValue());
            }
            if ((fromDate != null && toDate != null) || (fromDate == null && toDate == null)) {
                applyButton.removeStyleName(ValoTheme.BUTTON_PRIMARY);
                ContactDateType contactDateType = (ContactDateType) weekAndDateFilter.getDateTypeSelector()
                        .getValue();
                if (contactDateType == ContactDateType.LAST_CONTACT_DATE) {
                    criteria.lastContactDateBetween(fromDate, toDate);
                    criteria.reportDateBetween(null, null);
                } else {
                    criteria.reportDateBetween(fromDate, toDate);
                    criteria.lastContactDateBetween(null, null);
                }
                navigateTo(criteria);
            } else {
                if (dateFilterOption == DateFilterOption.DATE) {
                    Notification notification = new Notification(
                            I18nProperties.getString(Strings.headingMissingDateFilter),
                            I18nProperties.getString(Strings.messageMissingDateFilter), Type.WARNING_MESSAGE,
                            false);
                    notification.setDelayMsec(-1);
                    notification.show(Page.getCurrent());
                } else {
                    Notification notification = new Notification(
                            I18nProperties.getString(Strings.headingMissingEpiWeekFilter),
                            I18nProperties.getString(Strings.messageMissingEpiWeekFilter), Type.WARNING_MESSAGE,
                            false);
                    notification.setDelayMsec(-1);
                    notification.show(Page.getCurrent());
                }
            }
        });
    }
    filterLayout.addComponent(dateFilterRowLayout);
    dateFilterRowLayout.setVisible(false);

    return filterLayout;
}

From source file:de.symeda.sormas.ui.dashboard.DashboardFilterLayout.java

License:Open Source License

private void createDateFilters() {
    HorizontalLayout dateFilterLayout = new HorizontalLayout();
    dateFilterLayout.addStyleName(CssStyles.LAYOUT_MINIMAL);
    dateFilterLayout.setSpacing(true);//from w  w  w .j  a  v a  2 s.c  om
    addComponent(dateFilterLayout);
    Date now = new Date();

    // Date filters
    Button todayButton = new Button(I18nProperties.getCaption(Captions.dashboardToday));
    initializeDateFilterButton(todayButton);
    todayButton.addClickListener(e -> {
        setDateFilter(DateHelper.getStartOfDay(now), DateHelper.getEndOfDay(now));
        dashboardView.refreshDashboard();
    });

    Button yesterdayButton = new Button(I18nProperties.getCaption(Captions.dashboardYesterday));
    initializeDateFilterButton(yesterdayButton);
    yesterdayButton.addClickListener(e -> {
        setDateFilter(DateHelper.getStartOfDay(DateHelper.subtractDays(now, 1)),
                DateHelper.getEndOfDay(DateHelper.subtractDays(now, 1)));
        dashboardView.refreshDashboard();
    });

    Button thisWeekButton = new Button(I18nProperties.getCaption(Captions.dashboardThisWeek));
    initializeDateFilterButton(thisWeekButton);
    thisWeekButton.addClickListener(e -> {
        setDateFilter(DateHelper.getStartOfWeek(now), DateHelper.getEndOfWeek(now));
        dashboardView.refreshDashboard();
    });
    CssStyles.style(thisWeekButton, CssStyles.BUTTON_FILTER_DARK);
    CssStyles.removeStyles(thisWeekButton, CssStyles.BUTTON_FILTER_LIGHT);

    Button lastWeekButton = new Button(I18nProperties.getCaption(Captions.dashboardLastWeek));
    initializeDateFilterButton(lastWeekButton);
    lastWeekButton.addClickListener(e -> {
        setDateFilter(DateHelper.getStartOfWeek(DateHelper.subtractWeeks(now, 1)),
                DateHelper.getEndOfWeek(DateHelper.subtractWeeks(now, 1)));
        dashboardView.refreshDashboard();
    });

    Button thisYearButton = new Button(I18nProperties.getCaption(Captions.dashboardThisYear));
    initializeDateFilterButton(thisYearButton);
    thisYearButton.addClickListener(e -> {
        setDateFilter(DateHelper.getStartOfYear(now), DateHelper.getEndOfYear(now));
        dashboardView.refreshDashboard();
    });

    Button lastYearButton = new Button(I18nProperties.getCaption(Captions.dashboardLastYear));
    initializeDateFilterButton(lastYearButton);
    lastYearButton.addClickListener(e -> {
        setDateFilter(DateHelper.getStartOfYear(DateHelper.subtractYears(now, 1)),
                DateHelper.getEndOfYear(DateHelper.subtractYears(now, 1)));
        dashboardView.refreshDashboard();
    });

    customButton = new PopupButton(I18nProperties.getCaption(Captions.dashboardCustom));
    initializeDateFilterButton(customButton);

    // Custom filter
    HorizontalLayout customDateFilterLayout = new HorizontalLayout();
    customDateFilterLayout.setSpacing(true);
    customDateFilterLayout.setMargin(true);

    // 'Apply custom filter' button
    Button applyButton = new Button(I18nProperties.getCaption(Captions.dashboardApplyCustomFilter));
    CssStyles.style(applyButton, CssStyles.FORCE_CAPTION, ValoTheme.BUTTON_PRIMARY);

    // Date & Epi Week filter
    EpiWeekAndDateFilterComponent<NewCaseDateType> weekAndDateFilter = new EpiWeekAndDateFilterComponent<>(
            applyButton, true, true, I18nProperties.getString(Strings.infoCaseDate));
    customDateFilterLayout.addComponent(weekAndDateFilter);
    dashboardDataProvider
            .setDateFilterOption((DateFilterOption) weekAndDateFilter.getDateFilterOptionFilter().getValue());
    dashboardDataProvider.setFromDate(
            DateHelper.getEpiWeekStart((EpiWeek) weekAndDateFilter.getWeekFromFilter().getValue()));
    dashboardDataProvider
            .setToDate(DateHelper.getEpiWeekEnd((EpiWeek) weekAndDateFilter.getWeekToFilter().getValue()));

    customDateFilterLayout.addComponent(applyButton);

    // Apply button listener
    applyButton.addClickListener(e -> {
        DateFilterOption dateFilterOption = (DateFilterOption) weekAndDateFilter.getDateFilterOptionFilter()
                .getValue();
        Date fromDate = null;
        Date toDate = null;
        EpiWeek fromWeek = null;
        EpiWeek toWeek = null;
        dashboardDataProvider.setDateFilterOption(dateFilterOption);
        if (dateFilterOption == DateFilterOption.DATE) {
            fromDate = weekAndDateFilter.getDateFromFilter().getValue();
            dashboardDataProvider.setFromDate(fromDate);
            toDate = weekAndDateFilter.getDateToFilter().getValue();
            dashboardDataProvider.setToDate(toDate);
        } else {
            fromWeek = (EpiWeek) weekAndDateFilter.getWeekFromFilter().getValue();
            dashboardDataProvider.setFromDate(DateHelper.getEpiWeekStart(fromWeek));
            toWeek = (EpiWeek) weekAndDateFilter.getWeekToFilter().getValue();
            dashboardDataProvider.setToDate(DateHelper.getEpiWeekEnd(toWeek));
        }

        if ((fromDate != null && toDate != null) || (fromWeek != null && toWeek != null)) {
            changeDateFilterButtonsStyles(customButton);
            dashboardView.refreshDashboard();
            if (dateFilterOption == DateFilterOption.DATE) {
                customButton.setCaption(DateHelper.formatLocalShortDate(fromDate) + " - "
                        + DateHelper.formatLocalShortDate(toDate));
            } else {
                customButton.setCaption(fromWeek.toShortString() + " - " + toWeek.toShortString());
            }
        } else {
            if (dateFilterOption == DateFilterOption.DATE) {
                new Notification(I18nProperties.getString(Strings.headingMissingDateFilter),
                        I18nProperties.getString(Strings.messageMissingDateFilter), Type.ERROR_MESSAGE, false)
                                .show(Page.getCurrent());
            } else {
                new Notification(I18nProperties.getString(Strings.headingMissingEpiWeekFilter),
                        I18nProperties.getString(Strings.messageMissingEpiWeekFilter), Type.ERROR_MESSAGE,
                        false).show(Page.getCurrent());
            }
        }
    });

    customButton.setContent(customDateFilterLayout);

    dateFilterLayout.addComponents(todayButton, yesterdayButton, thisWeekButton, lastWeekButton, thisYearButton,
            lastYearButton, customButton);

    infoLabel = new Label(VaadinIcons.INFO_CIRCLE.getHtml(), ContentMode.HTML);
    infoLabel.setSizeUndefined();
    CssStyles.style(infoLabel, CssStyles.LABEL_XLARGE, CssStyles.LABEL_SECONDARY);
    addComponent(infoLabel);
    setComponentAlignment(infoLabel, Alignment.TOP_RIGHT);
}

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

License:Open Source License

public void showBulkEventDataEditComponent(Collection<EventIndexDto> selectedEvents) {
    if (selectedEvents.size() == 0) {
        new Notification(I18nProperties.getString(Strings.headingNoEventsSelected),
                I18nProperties.getString(Strings.messageNoEventsSelected), Type.WARNING_MESSAGE, false)
                        .show(Page.getCurrent());
        return;//from   ww w  .  j a v  a 2 s . co  m
    }

    // Create a temporary event in order to use the CommitDiscardWrapperComponent
    EventDto tempEvent = new EventDto();

    BulkEventDataForm form = new BulkEventDataForm();
    form.setValue(tempEvent);
    final CommitDiscardWrapperComponent<BulkEventDataForm> editView = new CommitDiscardWrapperComponent<BulkEventDataForm>(
            form, form.getFieldGroup());

    Window popupWindow = VaadinUiUtil.showModalPopupWindow(editView,
            I18nProperties.getString(Strings.headingEditEvents));

    editView.addCommitListener(new CommitListener() {
        @Override
        public void onCommit() {
            EventDto updatedTempEvent = form.getValue();
            for (EventIndexDto indexDto : selectedEvents) {
                EventDto eventDto = FacadeProvider.getEventFacade().getEventByUuid(indexDto.getUuid());
                if (form.getEventStatusCheckBox().getValue() == true) {
                    eventDto.setEventStatus(updatedTempEvent.getEventStatus());
                }

                FacadeProvider.getEventFacade().saveEvent(eventDto);
            }
            popupWindow.close();
            navigateToIndex();
            Notification.show(I18nProperties.getString(Strings.messageEventsEdited), Type.HUMANIZED_MESSAGE);
        }
    });

    editView.addDiscardListener(new DiscardListener() {
        @Override
        public void onDiscard() {
            popupWindow.close();
        }
    });
}

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

License:Open Source License

public void deleteAllSelectedItems(Collection<EventIndexDto> selectedRows, Runnable callback) {
    if (selectedRows.size() == 0) {
        new Notification(I18nProperties.getString(Strings.headingNoEventsSelected),
                I18nProperties.getString(Strings.messageNoEventsSelected), Type.WARNING_MESSAGE, false)
                        .show(Page.getCurrent());
    } else {//  ww w .j  a  v a  2s.c  o m
        VaadinUiUtil.showDeleteConfirmationWindow(
                String.format(I18nProperties.getString(Strings.confirmationDeleteEvents), selectedRows.size()),
                new Runnable() {
                    public void run() {
                        for (EventIndexDto selectedRow : selectedRows) {
                            FacadeProvider.getEventFacade().deleteEvent(
                                    new EventReferenceDto(selectedRow.getUuid()),
                                    UserProvider.getCurrent().getUuid());
                        }
                        callback.run();
                        new Notification(I18nProperties.getString(Strings.headingEventsDeleted),
                                I18nProperties.getString(Strings.messageEventsDeleted), Type.HUMANIZED_MESSAGE,
                                false).show(Page.getCurrent());
                    }
                });
    }
}

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

License:Open Source License

public void archiveAllSelectedItems(Collection<EventIndexDto> selectedRows, Runnable callback) {
    if (selectedRows.size() == 0) {
        new Notification(I18nProperties.getString(Strings.headingNoEventsSelected),
                I18nProperties.getString(Strings.messageNoEventsSelected), Type.WARNING_MESSAGE, false)
                        .show(Page.getCurrent());
    } else {//from  w w  w.j  av  a  2 s . co m
        VaadinUiUtil.showConfirmationPopup(I18nProperties.getString(Strings.headingConfirmArchiving),
                new Label(String.format(I18nProperties.getString(Strings.confirmationArchiveEvents),
                        selectedRows.size())),
                I18nProperties.getString(Strings.yes), I18nProperties.getString(Strings.no), null, e -> {
                    if (e.booleanValue() == true) {
                        for (EventIndexDto selectedRow : selectedRows) {
                            FacadeProvider.getEventFacade().archiveOrDearchiveEvent(selectedRow.getUuid(),
                                    true);
                        }
                        callback.run();
                        new Notification(I18nProperties.getString(Strings.headingEventsArchived),
                                I18nProperties.getString(Strings.messageEventsArchived), Type.HUMANIZED_MESSAGE,
                                false).show(Page.getCurrent());
                    }
                });
    }
}

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

License:Open Source License

public void dearchiveAllSelectedItems(Collection<EventIndexDto> selectedRows, Runnable callback) {
    if (selectedRows.size() == 0) {
        new Notification(I18nProperties.getString(Strings.headingNoEventsSelected),
                I18nProperties.getString(Strings.messageNoEventsSelected), Type.WARNING_MESSAGE, false)
                        .show(Page.getCurrent());
    } else {/*from w ww .  j  a  v  a2s.c  o m*/
        VaadinUiUtil.showConfirmationPopup(I18nProperties.getString(Strings.headingConfirmDearchiving),
                new Label(String.format(I18nProperties.getString(Strings.confirmationDearchiveEvents),
                        selectedRows.size())),
                I18nProperties.getString(Strings.yes), I18nProperties.getString(Strings.no), null, e -> {
                    if (e.booleanValue() == true) {
                        for (EventIndexDto selectedRow : selectedRows) {
                            FacadeProvider.getEventFacade().archiveOrDearchiveEvent(selectedRow.getUuid(),
                                    false);
                        }
                        callback.run();
                        new Notification(I18nProperties.getString(Strings.headingEventsDearchived),
                                I18nProperties.getString(Strings.messageEventsDearchived),
                                Type.HUMANIZED_MESSAGE, false).show(Page.getCurrent());
                    }
                });
    }
}

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

License:Open Source License

public void deleteAllSelectedItems(Collection<EventParticipantIndexDto> selectedRows, Runnable callback) {
    if (selectedRows.size() == 0) {
        new Notification(I18nProperties.getString(Strings.headingNoEventParticipantsSelected),
                I18nProperties.getString(Strings.messageNoEventParticipantsSelected), Type.WARNING_MESSAGE,
                false).show(Page.getCurrent());
    } else {//from   www. j  a  v a 2  s .  c  om
        VaadinUiUtil.showDeleteConfirmationWindow(
                String.format(I18nProperties.getString(Strings.confirmationDeleteEventParticipants),
                        selectedRows.size()),
                new Runnable() {
                    public void run() {
                        for (Object selectedRow : selectedRows) {
                            FacadeProvider.getEventParticipantFacade().deleteEventParticipant(
                                    new EventParticipantReferenceDto(
                                            ((EventParticipantDto) selectedRow).getUuid()),
                                    UserProvider.getCurrent().getUuid());
                        }
                        callback.run();
                        new Notification(I18nProperties.getString(Strings.headingEventParticipantsDeleted),
                                I18nProperties.getString(Strings.messageEventParticipantsDeleted),
                                Type.HUMANIZED_MESSAGE, false).show(Page.getCurrent());
                    }
                });
    }
}