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:com.zklogtool.web.components.OpenSnapshotFileDialog.java

License:Apache License

public OpenSnapshotFileDialog(final TabSheet displayTabSheet, final Window windowHandle) {

    buildMainLayout();//from  ww  w. j  a  v  a2 s. c  om
    setCompositionRoot(mainLayout);

    openButton.addClickListener(new ClickListener() {

        DataState dataState;

        @Override
        public void buttonClick(com.vaadin.ui.Button.ClickEvent event) {

            File snapshot = new File(snapshotFileLabel.getValue());

            SnapshotFileReader snapReader = new SnapshotFileReader(snapshot, 0);

            SnapshotView snapshotView;

            if (!validateInputs()) {
                return;
            }

            try {

                dataState = snapReader.readFuzzySnapshot();

                snapshotView = new SnapshotView(dataState);

            } catch (CRCValidationException e) {

                snapshotFileLabel
                        .setComponentError(new UserError("CRC validation problem. File is probably corrupted"));
                return;

            } catch (IOException e) {

                snapshotFileLabel.setComponentError(new UserError("IO problem with file"));
                return;

            }

            HorizontalLayout horizontalLayout = new HorizontalLayout();
            horizontalLayout.setCaption(tabNameLabel.getValue());
            horizontalLayout.addComponent(snapshotView);
            horizontalLayout.setWidth("100%");
            horizontalLayout.setHeight("100%");
            Tab snapshotTab = displayTabSheet.addTab(horizontalLayout);
            snapshotTab.setClosable(true);
            displayTabSheet.setSelectedTab(snapshotTab);

            windowHandle.close();

        }

    });

}

From source file:com.zklogtool.web.components.OpenTransactionLogFileDialog.java

License:Apache License

public OpenTransactionLogFileDialog(final TabSheet displayTabSheet, final Window windowHandle) {
    buildMainLayout();/* w w  w  .  j  a  v a 2  s.c  om*/
    setCompositionRoot(mainLayout);

    openButton.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(com.vaadin.ui.Button.ClickEvent event) {

            File transactionLogFile = new File(transactionLogFileLabel.getValue());
            File snapshotDir = new File(snapshotDirectoryLabel.getValue());

            if (!transactionLogFile.isFile() && !transactionLogFile.isDirectory()) {

                transactionLogFileLabel.setComponentError(new UserError("IO problem"));
                return;

            }

            if (snapshotDirectoryLabel.getValue() != null && !snapshotDirectoryLabel.getValue().isEmpty()
                    && !snapshotDir.isDirectory()) {

                snapshotDirectoryLabel.setComponentError(new UserError("IO problem"));
                return;

            }

            TransactionLogView transactionLogView = new TransactionLogView(transactionLogFile, snapshotDir,
                    followCheckbox.getValue(), startFromLastCheckbox.getValue(), displayTabSheet,
                    nameLabel.getValue());

            HorizontalLayout horizontalLayout = new HorizontalLayout();
            horizontalLayout.setCaption(nameLabel.getValue());
            horizontalLayout.addComponent(transactionLogView);
            horizontalLayout.setWidth("100%");
            horizontalLayout.setHeight("100%");
            Tab transactionLogTab = displayTabSheet.addTab(horizontalLayout);
            transactionLogTab.setClosable(true);
            displayTabSheet.setSelectedTab(transactionLogTab);

            windowHandle.close();

        }

    });

}

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

License:Open Source License

@SuppressWarnings({ "unchecked", "rawtypes" })
public void showBulkCaseDataEditComponent(Collection<CaseIndexDto> selectedCases) {
    if (selectedCases.size() == 0) {
        new Notification(I18nProperties.getString(Strings.headingNoCasesSelected),
                I18nProperties.getString(Strings.messageNoCasesSelected), Type.WARNING_MESSAGE, false)
                        .show(Page.getCurrent());
        return;/* w w w  . ja  v  a2  s  .  c  o  m*/
    }

    // Check if cases with multiple districts have been selected
    String districtUuid = null;
    for (CaseIndexDto selectedCase : selectedCases) {
        if (districtUuid == null) {
            districtUuid = selectedCase.getDistrictUuid();
        } else if (!districtUuid.equals(selectedCase.getDistrictUuid())) {
            districtUuid = null;
            break;
        }
    }

    DistrictReferenceDto district = FacadeProvider.getDistrictFacade().getDistrictReferenceByUuid(districtUuid);

    // Create a temporary case in order to use the CommitDiscardWrapperComponent
    CaseDataDto tempCase = new CaseDataDto();

    BulkCaseDataForm form = new BulkCaseDataForm(district);
    form.setValue(tempCase);
    final CommitDiscardWrapperComponent<BulkCaseDataForm> editView = new CommitDiscardWrapperComponent<BulkCaseDataForm>(
            form, form.getFieldGroup());

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

    editView.addCommitListener(new CommitListener() {
        @Override
        public void onCommit() {
            CaseDataDto updatedTempCase = form.getValue();
            for (CaseIndexDto indexDto : selectedCases) {
                CaseDataDto caseDto = FacadeProvider.getCaseFacade().getCaseDataByUuid(indexDto.getUuid());
                if (form.getClassificationCheckBox().getValue() == true) {
                    caseDto.setCaseClassification(updatedTempCase.getCaseClassification());
                }
                if (form.getInvestigationStatusCheckBox().getValue() == true) {
                    caseDto.setInvestigationStatus(updatedTempCase.getInvestigationStatus());
                }
                if (form.getOutcomeCheckBox().getValue() == true) {
                    caseDto.setOutcome(updatedTempCase.getOutcome());
                }
                // Setting the surveillance officer is only allowed if all selected cases are in the same district
                if (district != null && form.getSurveillanceOfficerCheckBox().getValue() == true) {
                    caseDto.setSurveillanceOfficer(updatedTempCase.getSurveillanceOfficer());
                }

                FacadeProvider.getCaseFacade().saveCase(caseDto);
            }
            popupWindow.close();
            navigateToIndex();
            Notification.show(I18nProperties.getString(Strings.messageCasesEdited), Type.HUMANIZED_MESSAGE);
        }
    });

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

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

License:Open Source License

public void transferCase(CaseDataDto caze) {
    CaseFacilityChangeForm facilityChangeForm = new CaseFacilityChangeForm(UserRight.CASE_TRANSFER);
    facilityChangeForm.setValue(caze);/*from   ww  w .ja  v a2  s .co m*/
    CommitDiscardWrapperComponent<CaseFacilityChangeForm> facilityChangeView = new CommitDiscardWrapperComponent<CaseFacilityChangeForm>(
            facilityChangeForm, facilityChangeForm.getFieldGroup());
    facilityChangeView.getCommitButton().setCaption(I18nProperties.getCaption(Captions.caseTransferCase));
    facilityChangeView.setMargin(true);

    Window popupWindow = VaadinUiUtil.showPopupWindow(facilityChangeView);
    popupWindow.setCaption(I18nProperties.getString(Strings.headingTransferCase));

    facilityChangeView.addCommitListener(new CommitListener() {
        @Override
        public void onCommit() {
            if (!facilityChangeForm.getFieldGroup().isModified()) {
                CaseDataDto dto = facilityChangeForm.getValue();
                FacadeProvider.getCaseFacade().saveAndTransferCase(dto);
                popupWindow.close();
                Notification.show(I18nProperties.getString(Strings.messageCaseTransfered),
                        Type.WARNING_MESSAGE);
                SormasUI.refreshView();
            }
        }
    });

    Button cancelButton = new Button(I18nProperties.getCaption(Captions.actionCancel));
    cancelButton.setStyleName(ValoTheme.BUTTON_LINK);
    cancelButton.addClickListener(e -> {
        popupWindow.close();
    });
    facilityChangeView.getButtonsPanel().replaceComponent(facilityChangeView.getDiscardButton(), cancelButton);
}

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

License:Open Source License

public void referFromPointOfEntry(CaseDataDto caze) {
    CaseFacilityChangeForm form = new CaseFacilityChangeForm(UserRight.CASE_REFER_FROM_POE);
    form.setValue(caze);//from w ww . ja v a 2  s.  c om
    CommitDiscardWrapperComponent<CaseFacilityChangeForm> view = new CommitDiscardWrapperComponent<CaseFacilityChangeForm>(
            form, form.getFieldGroup());
    view.getCommitButton().setCaption(I18nProperties.getCaption(Captions.caseReferToFacility));

    Window window = VaadinUiUtil.showPopupWindow(view);
    window.setCaption(I18nProperties.getString(Strings.headingReferCaseFromPointOfEntry));

    view.addCommitListener(() -> {
        if (!form.getFieldGroup().isModified()) {
            CaseDataDto dto = form.getValue();
            dto.getHospitalization().setAdmissionDate(new Date());
            FacadeProvider.getCaseFacade().saveCase(dto);
            window.close();
            Notification.show(I18nProperties.getString(Strings.messageCaseReferredFromPoe),
                    Type.ASSISTIVE_NOTIFICATION);
            SormasUI.refreshView();
        }
    });

    Button btnCancel = new Button(I18nProperties.getCaption(Captions.actionCancel));
    btnCancel.addClickListener(e -> {
        window.close();
    });
    view.getButtonsPanel().replaceComponent(view.getDiscardButton(), btnCancel);
}

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

License:Open Source License

public void openClassificationRulesPopup(CaseDataDto caze) {
    VerticalLayout classificationRulesLayout = new VerticalLayout();
    classificationRulesLayout.setMargin(true);

    DiseaseClassificationCriteriaDto diseaseCriteria = FacadeProvider.getCaseClassificationFacade()
            .getByDisease(caze.getDisease());
    if (diseaseCriteria != null) {
        Label suspectContent = new Label();
        suspectContent.setContentMode(ContentMode.HTML);
        suspectContent.setWidth(100, Unit.PERCENTAGE);
        suspectContent.setValue(ClassificationHtmlRenderer.createSuspectHtmlString(diseaseCriteria));
        classificationRulesLayout.addComponent(suspectContent);

        Label probableContent = new Label();
        probableContent.setContentMode(ContentMode.HTML);
        probableContent.setWidth(100, Unit.PERCENTAGE);
        probableContent.setValue(ClassificationHtmlRenderer.createProbableHtmlString(diseaseCriteria));
        classificationRulesLayout.addComponent(probableContent);

        Label confirmedContent = new Label();
        confirmedContent.setContentMode(ContentMode.HTML);
        confirmedContent.setWidth(100, Unit.PERCENTAGE);
        confirmedContent.setValue(ClassificationHtmlRenderer.createConfirmedHtmlString(diseaseCriteria));
        classificationRulesLayout.addComponent(confirmedContent);
    }//from   w  ww  . j  a  v a2 s.c om

    Window popupWindow = VaadinUiUtil.showPopupWindow(classificationRulesLayout);
    popupWindow.addCloseListener(e -> {
        popupWindow.close();
    });
    popupWindow.setWidth(860, Unit.PIXELS);
    popupWindow.setHeight(80, Unit.PERCENTAGE);
    popupWindow.setCaption(
            I18nProperties.getString(Strings.classificationRulesFor) + " " + caze.getDisease().toString());
}

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

License:Open Source License

public void openOutbreakConfigurationWindow(Disease disease,
        OutbreakRegionConfiguration diseaseOutbreakInformation) {
    OutbreakRegionConfigurationForm configurationForm = new OutbreakRegionConfigurationForm(
            diseaseOutbreakInformation);
    final CommitDiscardWrapperComponent<OutbreakRegionConfigurationForm> configurationComponent = new CommitDiscardWrapperComponent<OutbreakRegionConfigurationForm>(
            configurationForm);//from w w w .j  a v  a  2  s  .c  om
    Window popupWindow = VaadinUiUtil.showModalPopupWindow(configurationComponent,
            disease.toShortString() + " " + I18nProperties.getString(Strings.headingOutbreakIn) + " "
                    + diseaseOutbreakInformation.getRegion().toString());

    configurationComponent.addCommitListener(new CommitListener() {
        @Override
        public void onCommit() {
            Set<DistrictReferenceDto> updatedAffectedDistricts = configurationForm.getAffectedDistricts();

            // start an outbreak for every newly affected district
            for (DistrictReferenceDto affectedDistrict : updatedAffectedDistricts) {
                if (!diseaseOutbreakInformation.getAffectedDistricts().contains(affectedDistrict)) {
                    FacadeProvider.getOutbreakFacade().startOutbreak(affectedDistrict, disease);
                }
            }

            // stop outbreaks for districts that are not affected anymore
            for (DistrictReferenceDto prevAffectedDistrict : diseaseOutbreakInformation
                    .getAffectedDistricts()) {
                if (!updatedAffectedDistricts.contains(prevAffectedDistrict)) {
                    FacadeProvider.getOutbreakFacade().endOutbreak(prevAffectedDistrict, disease);
                }
            }

            popupWindow.close();
            Notification.show(I18nProperties.getString(Strings.messageOutbreakSaved), Type.WARNING_MESSAGE);
            SormasUI.get().getNavigator().navigateTo(OutbreaksView.VIEW_NAME);
        }
    });

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

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

License:Open Source License

public void showBulkContactDataEditComponent(Collection<ContactIndexDto> selectedContacts, String caseUuid) {
    if (selectedContacts.size() == 0) {
        new Notification(I18nProperties.getString(Strings.headingNoContactsSelected),
                I18nProperties.getString(Strings.messageNoContactsSelected), Type.WARNING_MESSAGE, false)
                        .show(Page.getCurrent());
        return;//www  .ja va 2s.c om
    }

    // Check if cases with multiple districts have been selected
    String districtUuid = null;
    for (ContactIndexDto selectedContact : selectedContacts) {
        if (districtUuid == null) {
            districtUuid = selectedContact.getCaseDistrictUuid();
        } else if (!districtUuid.equals(selectedContact.getCaseDistrictUuid())) {
            districtUuid = null;
            break;
        }
    }

    DistrictReferenceDto district = FacadeProvider.getDistrictFacade().getDistrictReferenceByUuid(districtUuid);

    // Create a temporary contact in order to use the CommitDiscardWrapperComponent
    ContactDto tempContact = new ContactDto();

    BulkContactDataForm form = new BulkContactDataForm(district);
    form.setValue(tempContact);
    final CommitDiscardWrapperComponent<BulkContactDataForm> editView = new CommitDiscardWrapperComponent<BulkContactDataForm>(
            form, form.getFieldGroup());

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

    editView.addCommitListener(new CommitListener() {
        @Override
        public void onCommit() {
            ContactDto updatedTempContact = form.getValue();
            for (ContactIndexDto indexDto : selectedContacts) {
                ContactDto contactDto = FacadeProvider.getContactFacade().getContactByUuid(indexDto.getUuid());
                if (form.getClassificationCheckBox().getValue() == true) {
                    contactDto.setContactClassification(updatedTempContact.getContactClassification());
                }
                // Setting the contact officer is only allowed if all selected contacts are in the same district
                if (district != null && form.getContactOfficerCheckBox().getValue() == true) {
                    contactDto.setContactOfficer(updatedTempContact.getContactOfficer());
                }

                FacadeProvider.getContactFacade().saveContact(contactDto);
            }
            popupWindow.close();
            if (caseUuid == null) {
                overview();
            } else {
                caseContactsOverview(caseUuid);
            }
            Notification.show(I18nProperties.getString(Strings.messageContactsEdited), Type.HUMANIZED_MESSAGE);
        }
    });

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

From source file:de.symeda.sormas.ui.dashboard.map.CasePopupGrid.java

License:Open Source License

public CasePopupGrid(Window window, FacilityReferenceDto facility,
        DashboardMapComponent dashboardMapComponent) {
    this.facility = facility;
    this.dashboardMapComponent = dashboardMapComponent;
    setWidth(960, Unit.PIXELS);/*from w  w  w  . ja v  a 2  s  . c o  m*/
    setHeightUndefined();

    setSelectionMode(SelectionMode.NONE);

    BeanItemContainer<CaseDataDto> container = new BeanItemContainer<CaseDataDto>(CaseDataDto.class);
    GeneratedPropertyContainer generatedContainer = new GeneratedPropertyContainer(container);
    setContainerDataSource(generatedContainer);

    generatedContainer.addGeneratedProperty(DISEASE_SHORT, new PropertyValueGenerator<String>() {
        @Override
        public String getValue(Item item, Object itemId, Object propertyId) {
            CaseDataDto caseDataDto = (CaseDataDto) itemId;
            String diseaseName = caseDataDto.getDisease().getName();
            return Disease.valueOf(diseaseName).toShortString();
        }

        @Override
        public Class<String> getType() {
            return String.class;
        }
    });

    generatedContainer.addGeneratedProperty(FIRST_NAME, new PropertyValueGenerator<String>() {
        @Override
        public String getValue(Item item, Object itemId, Object propertyId) {
            CaseDataDto caseDataDto = (CaseDataDto) itemId;
            PersonDto personDto = FacadeProvider.getPersonFacade()
                    .getPersonByUuid(caseDataDto.getPerson().getUuid());
            return personDto.getFirstName();
        }

        @Override
        public Class<String> getType() {
            return String.class;
        }
    });

    generatedContainer.addGeneratedProperty(LAST_NAME, new PropertyValueGenerator<String>() {
        @Override
        public String getValue(Item item, Object itemId, Object propertyId) {
            CaseDataDto caseDataDto = (CaseDataDto) itemId;
            PersonDto personDto = FacadeProvider.getPersonFacade()
                    .getPersonByUuid(caseDataDto.getPerson().getUuid());
            return personDto.getLastName();
        }

        @Override
        public Class<String> getType() {
            return String.class;
        }
    });

    setColumns(CaseDataDto.UUID, DISEASE_SHORT, CaseDataDto.CASE_CLASSIFICATION, FIRST_NAME, LAST_NAME,
            CaseDataDto.REPORT_DATE, CaseDataDto.HEALTH_FACILITY_DETAILS);

    getColumn(CaseDataDto.UUID).setRenderer(new V7UuidRenderer());
    getColumn(CaseDataDto.REPORT_DATE).setRenderer(new DateRenderer(DateHelper.getLocalDateTimeFormat()));

    if (facility == null || !FacilityHelper.isOtherOrNoneHealthFacility(facility.getUuid())) {
        getColumn(CaseDataDto.HEALTH_FACILITY_DETAILS).setHidden(true);
    }

    for (Column column : getColumns()) {
        column.setHeaderCaption(I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX,
                column.getPropertyId().toString(), column.getHeaderCaption()));
    }

    addItemClickListener(e -> {
        window.close();
        ControllerProvider.getCaseController().navigateToCase(((CaseDataDto) e.getItemId()).getUuid(), true);
    });

    reload();
}

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

License:Open Source License

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

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

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

    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();
                EpiDataBurialsField.this.removeEntry(entry);
            }
        }, I18nProperties.getCaption(EpiDataBurialDto.I18N_PREFIX));
    }
}