Example usage for com.vaadin.ui Window close

List of usage examples for com.vaadin.ui Window close

Introduction

In this page you can find the example usage for com.vaadin.ui Window close.

Prototype

public void close() 

Source Link

Document

Method that handles window closing (from UI).

Usage

From source file:de.symeda.sormas.ui.epidata.EpiDataGatheringsField.java

License:Open Source License

@Override
protected void editEntry(EpiDataGatheringDto entry, boolean create,
        Consumer<EpiDataGatheringDto> commitCallback) {
    EpiDataGatheringEditForm editForm = new EpiDataGatheringEditForm(UserRight.CASE_EDIT);
    editForm.setValue(entry);//from  w w w  . j  a  v a 2  s  . c  om

    final CommitDiscardWrapperComponent<EpiDataGatheringEditForm> editView = new CommitDiscardWrapperComponent<EpiDataGatheringEditForm>(
            editForm, editForm.getFieldGroup());
    editView.getCommitButton().setCaption(I18nProperties.getString(Strings.done));

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

    editView.addCommitListener(new CommitListener() {
        @Override
        public void onCommit() {
            if (!editForm.getFieldGroup().isModified()) {
                commitCallback.accept(editForm.getValue());
            }
        }
    });

    if (!isEmpty(entry)) {
        editView.addDeleteListener(new DeleteListener() {
            @Override
            public void onDelete() {
                popupWindow.close();
                EpiDataGatheringsField.this.removeEntry(entry);
            }
        }, I18nProperties.getCaption(EpiDataGatheringDto.I18N_PREFIX));
    }
}

From source file:de.symeda.sormas.ui.epidata.EpiDataTravelsField.java

License:Open Source License

@Override
protected void editEntry(EpiDataTravelDto entry, boolean create, Consumer<EpiDataTravelDto> commitCallback) {
    EpiDataTravelEditForm editForm = new EpiDataTravelEditForm(UserRight.CASE_EDIT);
    editForm.setValue(entry);/*from   w  ww . ja  v a2s.  c  o m*/

    final CommitDiscardWrapperComponent<EpiDataTravelEditForm> editView = new CommitDiscardWrapperComponent<EpiDataTravelEditForm>(
            editForm, editForm.getFieldGroup());
    editView.getCommitButton().setCaption(I18nProperties.getString(Strings.done));

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

    editView.addCommitListener(new CommitListener() {
        @Override
        public void onCommit() {
            if (!editForm.getFieldGroup().isModified()) {
                commitCallback.accept(editForm.getValue());
            }
        }
    });

    if (!isEmpty(entry)) {
        editView.addDeleteListener(new DeleteListener() {
            @Override
            public void onDelete() {
                popupWindow.close();
                EpiDataTravelsField.this.removeEntry(entry);
            }
        }, I18nProperties.getCaption(EpiDataTravelDto.I18N_PREFIX));
    }
}

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   w  w w.j  a  v  a2  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.hospitalization.PreviousHospitalizationsField.java

License:Open Source License

@Override
protected void editEntry(PreviousHospitalizationDto entry, boolean create,
        Consumer<PreviousHospitalizationDto> commitCallback) {

    PreviousHospitalizationEditForm editForm = new PreviousHospitalizationEditForm(create, UserRight.CASE_EDIT);
    editForm.setValue(entry);//www  . j  a v  a2  s .  c o m

    final CommitDiscardWrapperComponent<PreviousHospitalizationEditForm> editView = new CommitDiscardWrapperComponent<PreviousHospitalizationEditForm>(
            editForm, editForm.getFieldGroup());
    editView.getCommitButton().setCaption(I18nProperties.getString(Strings.done));

    Window popupWindow = VaadinUiUtil.showModalPopupWindow(editView,
            I18nProperties.getCaption(PreviousHospitalizationDto.I18N_PREFIX));

    editView.addCommitListener(new CommitListener() {
        @Override
        public void onCommit() {
            if (!editForm.getFieldGroup().isModified()) {
                commitCallback.accept(editForm.getValue());
            }
        }
    });

    if (!isEmpty(entry)) {
        editView.addDeleteListener(new DeleteListener() {
            @Override
            public void onDelete() {
                popupWindow.close();
                PreviousHospitalizationsField.this.removeEntry(entry);
            }
        }, I18nProperties.getCaption(PreviousHospitalizationDto.I18N_PREFIX));
    }

}

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

License:Open Source License

private void requestSampleCollectionTaskCreation(SampleDto dto, SampleEditForm form) {
    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);/* w  ww.  ja v  a 2 s.c o m*/

    ConfirmationComponent requestTaskComponent = VaadinUiUtil.buildYesNoConfirmationComponent();

    Label description = new Label(I18nProperties.getString(Strings.messageCreateCollectionTask),
            ContentMode.HTML);
    description.setWidth(100, Unit.PERCENTAGE);
    layout.addComponent(description);
    layout.addComponent(requestTaskComponent);
    layout.setComponentAlignment(requestTaskComponent, Alignment.BOTTOM_RIGHT);
    layout.setSizeUndefined();
    layout.setSpacing(true);

    Window popupWindow = VaadinUiUtil.showPopupWindow(layout);
    popupWindow.setSizeUndefined();
    popupWindow.setCaption(I18nProperties.getString(Strings.headingCreateNewTaskQuestion));
    requestTaskComponent.getConfirmButton().addClickListener(new ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            popupWindow.close();
            ControllerProvider.getTaskController().createSampleCollectionTask(TaskContext.CASE,
                    dto.getAssociatedCase(), dto);
        }
    });
    requestTaskComponent.getCancelButton().addClickListener(new ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            popupWindow.close();
        }
    });
}

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

License:Open Source License

public void showChangePathogenTestResultWindow(CommitDiscardWrapperComponent<SampleEditForm> editComponent,
        String sampleUuid, PathogenTestResultType newResult) {
    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);/*w  ww .  j a va 2 s  .c  o m*/

    ConfirmationComponent confirmationComponent = VaadinUiUtil.buildYesNoConfirmationComponent();

    Label description = new Label(String
            .format(I18nProperties.getString(Strings.messageChangePathogenTestResult), newResult.toString()));
    description.setWidth(100, Unit.PERCENTAGE);
    layout.addComponent(description);
    layout.addComponent(confirmationComponent);
    layout.setComponentAlignment(confirmationComponent, Alignment.BOTTOM_RIGHT);
    layout.setSizeUndefined();
    layout.setSpacing(true);

    Window popupWindow = VaadinUiUtil.showPopupWindow(layout);
    popupWindow.setSizeUndefined();
    popupWindow.setCaption(I18nProperties.getString(Strings.headingChangePathogenTestResult));
    confirmationComponent.getConfirmButton().addClickListener(new ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            editComponent.commit();
            SampleDto sample = FacadeProvider.getSampleFacade().getSampleByUuid(sampleUuid);
            sample.setPathogenTestResult(newResult);
            FacadeProvider.getSampleFacade().saveSample(sample);
            popupWindow.close();
            SormasUI.refreshView();
        }
    });
    confirmationComponent.getCancelButton().addClickListener(new ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            popupWindow.close();
        }
    });
}

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

License:Open Source License

public void edit(TaskIndexDto dto, Runnable callback) {
    // get fresh data
    TaskDto newDto = FacadeProvider.getTaskFacade().getByUuid(dto.getUuid());

    TaskEditForm form = new TaskEditForm(false, UserRight.TASK_EDIT);
    form.setValue(newDto);//www .  java  2s  .  c om
    final CommitDiscardWrapperComponent<TaskEditForm> editView = new CommitDiscardWrapperComponent<TaskEditForm>(
            form, form.getFieldGroup());

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

    editView.addCommitListener(new CommitListener() {
        @Override
        public void onCommit() {
            if (!form.getFieldGroup().isModified()) {
                TaskDto dto = form.getValue();
                FacadeProvider.getTaskFacade().saveTask(dto);
                popupWindow.close();
                callback.run();
            }
        }
    });

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

    if (UserProvider.getCurrent().hasUserRole(UserRole.ADMIN)) {
        editView.addDeleteListener(new DeleteListener() {
            @Override
            public void onDelete() {
                FacadeProvider.getTaskFacade().deleteTask(newDto,
                        UserProvider.getCurrent().getUserReference().getUuid());
                UI.getCurrent().removeWindow(popupWindow);
                callback.run();
            }
        }, I18nProperties.getString(Strings.entityTask));
    }
}

From source file:de.symeda.sormas.ui.user.UserController.java

License:Open Source License

public Button createResetPasswordButton(String userUuid, CommitDiscardWrapperComponent<UserEditForm> editView) {
    Button resetPasswordButton = new Button(null, VaadinIcons.UNLOCK);
    resetPasswordButton.setCaption(I18nProperties.getCaption(Captions.userResetPassword));
    resetPasswordButton.addStyleName(ValoTheme.BUTTON_LINK);
    resetPasswordButton.addClickListener(new ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override//from  ww w.j a  v a  2s .com
        public void buttonClick(ClickEvent event) {
            ConfirmationComponent resetPasswordComponent = getResetPasswordConfirmationComponent(userUuid,
                    editView);
            Window popupWindow = VaadinUiUtil.showPopupWindow(resetPasswordComponent);
            resetPasswordComponent.addDoneListener(new DoneListener() {
                public void onDone() {
                    popupWindow.close();
                }
            });
            resetPasswordComponent.getCancelButton().addClickListener(new ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(ClickEvent event) {
                    popupWindow.close();
                }
            });
            popupWindow.setCaption(I18nProperties.getString(Strings.headingUpdatePassword));
        }
    });

    return resetPasswordButton;
}

From source file:de.symeda.sormas.ui.utils.VaadinUiUtil.java

License:Open Source License

public static Window showSimplePopupWindow(String caption, String contentText) {
    Window window = new Window(null);
    window.setModal(true);/* ww w . j a  va  2 s.  c om*/
    window.setSizeUndefined();
    window.setResizable(false);
    window.center();

    VerticalLayout popupLayout = new VerticalLayout();
    popupLayout.setMargin(true);
    popupLayout.setSpacing(true);
    popupLayout.setSizeUndefined();
    Label contentLabel = new Label(contentText);
    contentLabel.setWidth(100, Unit.PERCENTAGE);
    popupLayout.addComponent(contentLabel);
    Button okayButton = new Button(I18nProperties.getCaption(Captions.actionOkay));
    okayButton.addClickListener(e -> {
        window.close();
    });
    CssStyles.style(okayButton, ValoTheme.BUTTON_PRIMARY);
    popupLayout.addComponent(okayButton);
    popupLayout.setComponentAlignment(okayButton, Alignment.BOTTOM_RIGHT);

    window.setCaption(caption);
    window.setContent(popupLayout);

    UI.getCurrent().addWindow(window);

    return window;
}

From source file:de.symeda.sormas.ui.utils.VaadinUiUtil.java

License:Open Source License

public static Window showModalPopupWindow(CommitDiscardWrapperComponent<?> content, String caption) {

    final Window popupWindow = VaadinUiUtil.showPopupWindow(content);
    popupWindow.setCaption(caption);/*  w w w.j a  v a 2  s  . c  o m*/
    content.setMargin(true);

    content.addDoneListener(new DoneListener() {
        public void onDone() {
            popupWindow.close();
        }
    });

    return popupWindow;
}