Example usage for com.vaadin.ui Button addClickListener

List of usage examples for com.vaadin.ui Button addClickListener

Introduction

In this page you can find the example usage for com.vaadin.ui Button addClickListener.

Prototype

public Registration addClickListener(ClickListener listener) 

Source Link

Document

Adds the button click listener.

Usage

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

License:Open Source License

private HorizontalLayout createHeader() {
    HorizontalLayout mapHeaderLayout = new HorizontalLayout();
    mapHeaderLayout.setWidth(100, Unit.PERCENTAGE);
    mapHeaderLayout.setSpacing(true);/*from  ww w  .  j  av a2 s  .  com*/
    CssStyles.style(mapHeaderLayout, CssStyles.VSPACE_4);

    Label mapLabel = new Label();
    if (dashboardDataProvider.getDashboardType() == DashboardType.SURVEILLANCE) {
        mapLabel.setValue(I18nProperties.getString(Strings.headingCaseStatusMap));
    } else {
        mapLabel.setValue(I18nProperties.getString(Strings.headingContactMap));
    }
    mapLabel.setSizeUndefined();
    CssStyles.style(mapLabel, CssStyles.H2, CssStyles.VSPACE_4, CssStyles.VSPACE_TOP_NONE);

    mapHeaderLayout.addComponent(mapLabel);
    mapHeaderLayout.setComponentAlignment(mapLabel, Alignment.BOTTOM_LEFT);
    mapHeaderLayout.setExpandRatio(mapLabel, 1);

    // "Expand" and "Collapse" buttons
    Button expandMapButton = new Button("", VaadinIcons.EXPAND);
    CssStyles.style(expandMapButton, CssStyles.BUTTON_SUBTLE);
    expandMapButton.addStyleName(CssStyles.VSPACE_NONE);
    Button collapseMapButton = new Button("", VaadinIcons.COMPRESS);
    CssStyles.style(collapseMapButton, CssStyles.BUTTON_SUBTLE);
    collapseMapButton.addStyleName(CssStyles.VSPACE_NONE);

    expandMapButton.addClickListener(e -> {
        externalExpandListener.accept(true);
        mapHeaderLayout.removeComponent(expandMapButton);
        mapHeaderLayout.addComponent(collapseMapButton);
        mapHeaderLayout.setComponentAlignment(collapseMapButton, Alignment.MIDDLE_RIGHT);
    });
    collapseMapButton.addClickListener(e -> {
        externalExpandListener.accept(false);
        mapHeaderLayout.removeComponent(collapseMapButton);
        mapHeaderLayout.addComponent(expandMapButton);
        mapHeaderLayout.setComponentAlignment(expandMapButton, Alignment.MIDDLE_RIGHT);
    });
    mapHeaderLayout.addComponent(expandMapButton);
    mapHeaderLayout.setComponentAlignment(expandMapButton, Alignment.MIDDLE_RIGHT);

    return mapHeaderLayout;
}

From source file:de.symeda.sormas.ui.dashboard.surveillance.SurveillanceOverviewLayout.java

License:Open Source License

private void addDiseaseBurdenView() {
    HorizontalLayout layout = new HorizontalLayout();
    layout.setWidth(100, Unit.PERCENTAGE);
    layout.setMargin(false);/*  w w w.  j a v  a  2s .co  m*/

    layout.addComponent(diseaseTileViewLayout);
    layout.setExpandRatio(diseaseTileViewLayout, 1);

    // "Expand" and "Collapse" buttons
    Button showTableViewButton = new Button("", VaadinIcons.TABLE);
    CssStyles.style(showTableViewButton, CssStyles.BUTTON_SUBTLE);
    showTableViewButton.addStyleName(CssStyles.VSPACE_NONE);

    Button showTileViewButton = new Button("", VaadinIcons.SQUARE_SHADOW);
    CssStyles.style(showTileViewButton, CssStyles.BUTTON_SUBTLE);
    showTileViewButton.addStyleName(CssStyles.VSPACE_NONE);

    showTableViewButton.addClickListener(e -> {
        layout.removeComponent(diseaseTileViewLayout);
        layout.addComponent(diseaseBurdenComponent);
        layout.setExpandRatio(diseaseBurdenComponent, 1);

        layout.removeComponent(showTableViewButton);
        layout.addComponent(showTileViewButton);
        layout.setComponentAlignment(showTileViewButton, Alignment.TOP_RIGHT);
    });
    showTileViewButton.addClickListener(e -> {
        layout.removeComponent(diseaseBurdenComponent);
        layout.addComponent(diseaseTileViewLayout);
        layout.setExpandRatio(diseaseTileViewLayout, 1);

        layout.removeComponent(showTileViewButton);
        layout.addComponent(showTableViewButton);
        layout.setComponentAlignment(showTableViewButton, Alignment.TOP_RIGHT);
    });

    layout.addComponent(showTableViewButton);
    layout.setComponentAlignment(showTableViewButton, Alignment.TOP_RIGHT);

    diseaseBurdenView = layout;
    addComponent(diseaseBurdenView, BURDEN_LOC);

    if (UserRole.isSupervisor(UserProvider.getCurrent().getUser().getUserRoles()))
        showTableViewButton.click();
}

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 www .j  a v  a 2s.  c om*/
    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.importer.CaseImporter.java

License:Open Source License

private void handleSimilarity(ImportSimilarityInput input, Consumer<ImportSimilarityResult> resultConsumer) {
    currentUI.accessSynchronously(new Runnable() {
        @Override/*from   w  w w.  j a  v a  2s .  c o  m*/
        public void run() {
            CasePickOrImportField pickOrImportField = new CasePickOrImportField(input.getCaze(),
                    input.getPerson(), input.getSimilarCases());
            pickOrImportField.setWidth(1024, Unit.PIXELS);

            final CommitDiscardWrapperComponent<CasePickOrImportField> component = new CommitDiscardWrapperComponent<>(
                    pickOrImportField);

            component.addCommitListener(new CommitListener() {
                @Override
                public void onCommit() {
                    CaseIndexDto pickedCase = pickOrImportField.getValue();
                    if (pickedCase != null) {
                        if (pickOrImportField.isOverrideCase()) {
                            resultConsumer.accept(new ImportSimilarityResult(pickedCase,
                                    ImportSimilarityResultOption.OVERRIDE));
                        } else {
                            resultConsumer.accept(
                                    new ImportSimilarityResult(pickedCase, ImportSimilarityResultOption.PICK));
                        }
                    } else {
                        // TODO May be wrong here!
                        resultConsumer
                                .accept(new ImportSimilarityResult(null, ImportSimilarityResultOption.CREATE));
                    }
                }
            });

            DiscardListener discardListener = new DiscardListener() {
                @Override
                public void onDiscard() {
                    resultConsumer
                            .accept(new ImportSimilarityResult(null, ImportSimilarityResultOption.CANCEL));
                }
            };
            component.addDiscardListener(discardListener);
            component.getDiscardButton().setCaption(I18nProperties.getCaption(Captions.actionCancel));
            component.getCommitButton().setCaption(I18nProperties.getCaption(Captions.actionConfirm));

            Button skipButton = new Button(I18nProperties.getCaption(Captions.actionSkip));
            skipButton.addClickListener(e -> {
                currentUI.accessSynchronously(new Runnable() {
                    @Override
                    public void run() {
                        component.removeDiscardListener(discardListener);
                        component.discard();
                        resultConsumer
                                .accept(new ImportSimilarityResult(null, ImportSimilarityResultOption.SKIP));
                    }
                });
            });
            component.getButtonsPanel().addComponentAsFirst(skipButton);

            pickOrImportField.setSelectionChangeCallback((commitAllowed) -> {
                component.getCommitButton().setEnabled(commitAllowed);
            });

            VaadinUiUtil.showModalPopupWindow(component,
                    I18nProperties.getString(Strings.headingPickOrCreateCase));
        }
    });
}

From source file:de.symeda.sormas.ui.reports.ReportsView.java

License:Open Source License

public HorizontalLayout createFilterBar() {
    HorizontalLayout filterLayout = new HorizontalLayout();
    filterLayout.setMargin(false);// ww  w  .j av a 2  s  .c o  m
    filterLayout.setSpacing(true);
    filterLayout.addStyleName(CssStyles.VSPACE_3);
    filterLayout.setWidth(100, Unit.PERCENTAGE);

    EpiWeek prevEpiWeek = DateHelper.getPreviousEpiWeek(new Date());
    int year = prevEpiWeek.getYear();
    int week = prevEpiWeek.getWeek();

    yearFilter = new ComboBox();
    yearFilter.setWidth(200, Unit.PIXELS);
    yearFilter.addItems(DateHelper.getYearsToNow());
    yearFilter.select(year);
    yearFilter.setCaption(I18nProperties.getString(Strings.year));
    yearFilter.setItemCaptionMode(ItemCaptionMode.ID_TOSTRING);
    yearFilter.addValueChangeListener(e -> {
        updateEpiWeeks((int) e.getProperty().getValue(), (int) epiWeekFilter.getValue());
        reloadGrid();
    });
    filterLayout.addComponent(yearFilter);

    epiWeekFilter = new ComboBox();
    epiWeekFilter.setWidth(200, Unit.PIXELS);
    updateEpiWeeks(year, week);
    epiWeekFilter.setCaption(I18nProperties.getString(Strings.epiWeek));
    epiWeekFilter.addValueChangeListener(e -> {
        reloadGrid();
    });
    filterLayout.addComponent(epiWeekFilter);

    Button lastWeekButton = new Button(I18nProperties.getCaption(Captions.dashboardLastWeek));
    lastWeekButton.addStyleName(CssStyles.FORCE_CAPTION);
    lastWeekButton.addClickListener(e -> {
        EpiWeek epiWeek = DateHelper.getPreviousEpiWeek(new Date());
        yearFilter.select(epiWeek.getYear());
        epiWeekFilter.select(epiWeek.getWeek());
    });
    filterLayout.addComponent(lastWeekButton);

    Label infoLabel = new Label(VaadinIcons.INFO_CIRCLE.getHtml(), ContentMode.HTML);
    infoLabel.setDescription(I18nProperties.getString(Strings.infoWeeklyReportsView));
    infoLabel.setSizeUndefined();
    CssStyles.style(infoLabel, CssStyles.LABEL_XLARGE, CssStyles.LABEL_SECONDARY);
    filterLayout.addComponent(infoLabel);
    filterLayout.setComponentAlignment(infoLabel, Alignment.MIDDLE_RIGHT);
    filterLayout.setExpandRatio(infoLabel, 1);

    return filterLayout;
}

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

License:Open Source License

public CommitDiscardWrapperComponent<SampleEditForm> getSampleEditComponent(final String sampleUuid) {
    SampleEditForm form = new SampleEditForm(UserRight.SAMPLE_EDIT);
    form.setWidth(form.getWidth() * 10 / 12, Unit.PIXELS);
    SampleDto dto = FacadeProvider.getSampleFacade().getSampleByUuid(sampleUuid);
    form.setValue(dto);//from   w ww .jav a  2  s.com
    final CommitDiscardWrapperComponent<SampleEditForm> editView = new CommitDiscardWrapperComponent<SampleEditForm>(
            form, form.getFieldGroup());

    editView.addCommitListener(new CommitListener() {
        @Override
        public void onCommit() {
            if (!form.getFieldGroup().isModified()) {
                SampleDto dto = form.getValue();
                SampleDto originalDto = FacadeProvider.getSampleFacade().getSampleByUuid(dto.getUuid());
                FacadeProvider.getSampleFacade().saveSample(dto);
                SormasUI.refreshView();

                if (dto.getSpecimenCondition() != originalDto.getSpecimenCondition()
                        && dto.getSpecimenCondition() == SpecimenCondition.NOT_ADEQUATE
                        && UserProvider.getCurrent().hasUserRight(UserRight.TASK_CREATE)) {
                    requestSampleCollectionTaskCreation(dto, form);
                } else {
                    Notification.show(I18nProperties.getString(Strings.messageSampleSaved),
                            Type.TRAY_NOTIFICATION);
                }
            }
        }
    });

    if (UserProvider.getCurrent().hasUserRole(UserRole.ADMIN)) {
        editView.addDeleteListener(new DeleteListener() {
            @Override
            public void onDelete() {
                FacadeProvider.getSampleFacade().deleteSample(dto.toReference(),
                        UserProvider.getCurrent().getUserReference().getUuid());
                UI.getCurrent().getNavigator().navigateTo(SamplesView.VIEW_NAME);
            }
        }, I18nProperties.getString(Strings.entitySample));
    }

    // Initialize 'Refer to another laboratory' button or link to referred sample
    Button referOrLinkToOtherLabButton = new Button();
    referOrLinkToOtherLabButton.addStyleName(ValoTheme.BUTTON_LINK);
    if (dto.getReferredTo() == null) {
        if (UserProvider.getCurrent().hasUserRight(UserRight.SAMPLE_TRANSFER)) {
            referOrLinkToOtherLabButton.setCaption(I18nProperties.getCaption(Captions.sampleRefer));
            referOrLinkToOtherLabButton.addClickListener(new ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(ClickEvent event) {
                    try {
                        form.commit();
                        SampleDto sampleDto = form.getValue();
                        sampleDto = FacadeProvider.getSampleFacade().saveSample(sampleDto);
                        createReferral(sampleDto);
                    } catch (SourceException | InvalidValueException e) {
                        Notification.show(I18nProperties.getString(Strings.messageSampleErrors),
                                Type.ERROR_MESSAGE);
                    }
                }
            });

            editView.getButtonsPanel().addComponentAsFirst(referOrLinkToOtherLabButton);
            editView.getButtonsPanel().setComponentAlignment(referOrLinkToOtherLabButton,
                    Alignment.BOTTOM_LEFT);
        }
    } else {
        SampleDto referredDto = FacadeProvider.getSampleFacade().getSampleByUuid(dto.getReferredTo().getUuid());
        referOrLinkToOtherLabButton.setCaption(
                I18nProperties.getCaption(Captions.sampleReferredTo) + " " + referredDto.getLab().toString());
        referOrLinkToOtherLabButton.addClickListener(new ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(ClickEvent event) {
                navigateToData(dto.getReferredTo().getUuid());
            }
        });

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

    return editView;
}

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

License:Open Source License

@Override
protected void addFields() {
    addField(SampleDto.LAB_SAMPLE_ID, TextField.class);
    DateTimeField sampleDateField = addField(SampleDto.SAMPLE_DATE_TIME, DateTimeField.class);
    sampleDateField.setInvalidCommitted(false);
    addField(SampleDto.SAMPLE_MATERIAL, ComboBox.class);
    addField(SampleDto.SAMPLE_MATERIAL_TEXT, TextField.class);
    ComboBox sampleSource = addField(SampleDto.SAMPLE_SOURCE, ComboBox.class);
    DateField shipmentDate = addDateField(SampleDto.SHIPMENT_DATE, DateField.class, 7);
    addField(SampleDto.SHIPMENT_DETAILS, TextField.class);
    DateField receivedDate = addField(SampleDto.RECEIVED_DATE, DateField.class);
    ComboBox lab = addField(SampleDto.LAB, ComboBox.class);
    lab.addItems(FacadeProvider.getFacilityFacade().getAllLaboratories(true));
    TextField labDetails = addField(SampleDto.LAB_DETAILS, TextField.class);
    labDetails.setVisible(false);//from w w w. ja v  a  2  s  .c o  m
    addField(SampleDto.SPECIMEN_CONDITION, ComboBox.class);
    addField(SampleDto.NO_TEST_POSSIBLE_REASON, TextField.class);
    addField(SampleDto.COMMENT, TextArea.class).setRows(2);
    CheckBox shipped = addField(SampleDto.SHIPPED, CheckBox.class);
    CheckBox received = addField(SampleDto.RECEIVED, CheckBox.class);
    ComboBox pathogenTestResultField = addField(SampleDto.PATHOGEN_TEST_RESULT, ComboBox.class);

    initializeRequestedTests();

    // Validators
    sampleDateField.addValidator(new DateComparisonValidator(sampleDateField, shipmentDate, true, false,
            I18nProperties.getValidationError(Validations.beforeDate, sampleDateField.getCaption(),
                    shipmentDate.getCaption())));
    sampleDateField.addValidator(new DateComparisonValidator(sampleDateField, receivedDate, true, false,
            I18nProperties.getValidationError(Validations.beforeDate, sampleDateField.getCaption(),
                    receivedDate.getCaption())));
    shipmentDate.addValidator(new DateComparisonValidator(shipmentDate, sampleDateField, false, false,
            I18nProperties.getValidationError(Validations.afterDate, shipmentDate.getCaption(),
                    sampleDateField.getCaption())));
    shipmentDate.addValidator(new DateComparisonValidator(shipmentDate, receivedDate, true, false,
            I18nProperties.getValidationError(Validations.beforeDate, shipmentDate.getCaption(),
                    receivedDate.getCaption())));
    receivedDate.addValidator(new DateComparisonValidator(receivedDate, sampleDateField, false, false,
            I18nProperties.getValidationError(Validations.afterDate, receivedDate.getCaption(),
                    sampleDateField.getCaption())));
    receivedDate.addValidator(new DateComparisonValidator(receivedDate, shipmentDate, false, false,
            I18nProperties.getValidationError(Validations.afterDate, receivedDate.getCaption(),
                    shipmentDate.getCaption())));

    FieldHelper.setVisibleWhen(getFieldGroup(), SampleDto.SAMPLE_MATERIAL_TEXT, SampleDto.SAMPLE_MATERIAL,
            Arrays.asList(SampleMaterial.OTHER), true);
    FieldHelper.setVisibleWhen(getFieldGroup(), SampleDto.NO_TEST_POSSIBLE_REASON, SampleDto.SPECIMEN_CONDITION,
            Arrays.asList(SpecimenCondition.NOT_ADEQUATE), true);
    FieldHelper.setRequiredWhen(getFieldGroup(), SampleDto.SAMPLE_MATERIAL,
            Arrays.asList(SampleDto.SAMPLE_MATERIAL_TEXT), Arrays.asList(SampleMaterial.OTHER));
    FieldHelper.setRequiredWhen(getFieldGroup(), SampleDto.SPECIMEN_CONDITION,
            Arrays.asList(SampleDto.NO_TEST_POSSIBLE_REASON), Arrays.asList(SpecimenCondition.NOT_ADEQUATE));

    addValueChangeListener(e -> {
        CaseDataDto caze = FacadeProvider.getCaseFacade()
                .getCaseDataByUuid(getValue().getAssociatedCase().getUuid());

        FieldHelper.setRequiredWhen(getFieldGroup(), received,
                Arrays.asList(SampleDto.RECEIVED_DATE, SampleDto.SPECIMEN_CONDITION), Arrays.asList(true));
        FieldHelper.setEnabledWhen(getFieldGroup(), received, Arrays.asList(true),
                Arrays.asList(SampleDto.RECEIVED_DATE, SampleDto.LAB_SAMPLE_ID, SampleDto.SPECIMEN_CONDITION,
                        SampleDto.NO_TEST_POSSIBLE_REASON),
                true);

        if (caze.getDisease() != Disease.NEW_INFLUENCA) {
            sampleSource.setVisible(false);
        }

        if (UserProvider.getCurrent().hasUserRight(UserRight.SAMPLE_EDIT_NOT_OWNED)
                || UserProvider.getCurrent().getUuid().equals(getValue().getReportingUser().getUuid())) {
            FieldHelper.setEnabledWhen(getFieldGroup(), shipped, Arrays.asList(true),
                    Arrays.asList(SampleDto.SHIPMENT_DATE, SampleDto.SHIPMENT_DETAILS), true);
            FieldHelper.setRequiredWhen(getFieldGroup(), shipped, Arrays.asList(SampleDto.SHIPMENT_DATE),
                    Arrays.asList(true));
            setRequired(true, SampleDto.SAMPLE_DATE_TIME, SampleDto.SAMPLE_MATERIAL, SampleDto.LAB);
        } else {
            getField(SampleDto.SAMPLE_DATE_TIME).setEnabled(false);
            getField(SampleDto.SAMPLE_MATERIAL).setEnabled(false);
            getField(SampleDto.SAMPLE_MATERIAL_TEXT).setEnabled(false);
            getField(SampleDto.LAB).setEnabled(false);
            getField(SampleDto.SHIPPED).setEnabled(false);
            getField(SampleDto.SHIPMENT_DATE).setEnabled(false);
            getField(SampleDto.SHIPMENT_DETAILS).setEnabled(false);
            getField(SampleDto.SAMPLE_SOURCE).setEnabled(false);
        }

        shipped.addValueChangeListener(event -> {
            if ((boolean) event.getProperty().getValue() == true) {
                if (shipmentDate.getValue() == null) {
                    shipmentDate.setValue(new Date());
                }
            }
        });

        received.addValueChangeListener(event -> {
            if ((boolean) event.getProperty().getValue() == true) {
                if (receivedDate.getValue() == null) {
                    receivedDate.setValue(new Date());
                }
            }
        });

        // Initialize referral and report information
        VerticalLayout reportInfoLayout = new VerticalLayout();

        String reportInfoText = I18nProperties.getString(Strings.reportedOn) + " "
                + DateHelper.formatLocalDateTime(getValue().getReportDateTime()) + " "
                + I18nProperties.getString(Strings.by) + " " + getValue().getReportingUser().toString();
        Label reportInfoLabel = new Label(reportInfoText);
        reportInfoLabel.setEnabled(false);
        reportInfoLayout.addComponent(reportInfoLabel);

        SampleReferenceDto referredFromRef = FacadeProvider.getSampleFacade()
                .getReferredFrom(getValue().getUuid());
        if (referredFromRef != null) {
            SampleDto referredFrom = FacadeProvider.getSampleFacade()
                    .getSampleByUuid(referredFromRef.getUuid());
            Button referredButton = new Button(I18nProperties.getCaption(Captions.sampleReferredFrom) + " "
                    + referredFrom.getLab().toString());
            referredButton.addStyleName(ValoTheme.BUTTON_LINK);
            referredButton.addStyleName(CssStyles.VSPACE_NONE);
            referredButton.addClickListener(
                    s -> ControllerProvider.getSampleController().navigateToData(referredFrom.getUuid()));
            reportInfoLayout.addComponent(referredButton);
        }

        getContent().addComponent(reportInfoLayout, REPORT_INFORMATION_LOC);

        if (FacadeProvider.getPathogenTestFacade().hasPathogenTest(getValue().toReference())) {
            pathogenTestResultField.setRequired(true);
        } else {
            pathogenTestResultField.setEnabled(false);
        }
    });

    lab.addValueChangeListener(event -> {
        if (event.getProperty().getValue() != null && ((FacilityReferenceDto) event.getProperty().getValue())
                .getUuid().equals(FacilityDto.OTHER_LABORATORY_UUID)) {
            labDetails.setVisible(true);
            labDetails.setRequired(true);
        } else {
            labDetails.setVisible(false);
            labDetails.setRequired(false);
            labDetails.clear();
        }
    });
}

From source file:de.symeda.sormas.ui.statistics.DatabaseExportView.java

License:Open Source License

private HorizontalLayout createSelectionButtonsLayout() {
    HorizontalLayout selectionButtonsLayout = new HorizontalLayout();
    selectionButtonsLayout.setMargin(false);
    selectionButtonsLayout.setSpacing(true);

    Button selectAll = new Button(I18nProperties.getCaption(Captions.actionSelectAll));
    CssStyles.style(selectAll, ValoTheme.BUTTON_LINK);
    selectAll.addClickListener(e -> {
        for (CheckBox checkBox : databaseTableToggles.keySet()) {
            checkBox.setValue(true);//from w  w  w .j a  va 2s  .  c o m
        }
    });
    selectionButtonsLayout.addComponent(selectAll);

    Button selectAllSormasData = new Button(I18nProperties.getCaption(Captions.exportSelectSormasData));
    CssStyles.style(selectAllSormasData, ValoTheme.BUTTON_LINK);
    selectAllSormasData.addClickListener(e -> {
        for (CheckBox checkBox : databaseTableToggles.keySet()) {
            if (databaseTableToggles.get(checkBox).getDatabaseTableType() == DatabaseTableType.SORMAS) {
                checkBox.setValue(true);
            } else {
                checkBox.setValue(false);
            }
        }
    });
    selectionButtonsLayout.addComponent(selectAllSormasData);

    Button deselectAll = new Button(I18nProperties.getCaption(Captions.actionDeselectAll));
    CssStyles.style(deselectAll, ValoTheme.BUTTON_LINK);
    deselectAll.addClickListener(e -> {
        for (CheckBox checkBox : databaseTableToggles.keySet()) {
            checkBox.setValue(false);
        }
    });
    selectionButtonsLayout.addComponent(deselectAll);

    return selectionButtonsLayout;
}

From source file:de.symeda.sormas.ui.statistics.StatisticsFilterValuesElement.java

License:Open Source License

private VerticalLayout createUtilityButtonsLayout() {
    VerticalLayout utilityButtonsLayout = new VerticalLayout();
    utilityButtonsLayout.setMargin(false);
    utilityButtonsLayout.setSpacing(false);
    utilityButtonsLayout.setSizeUndefined();

    Button addAllButton = new Button(I18nProperties.getCaption(Captions.all), VaadinIcons.PLUS_CIRCLE);
    CssStyles.style(addAllButton, ValoTheme.BUTTON_LINK);
    addAllButton.addClickListener(e -> {
        for (TokenizableValue tokenizable : getFilterValues()) {
            tokenField.addTokenizable(tokenizable);
        }/*from   w w  w . j  a  v a  2  s. c o m*/
    });

    Button removeAllButton = new Button(I18nProperties.getCaption(Captions.actionClear),
            VaadinIcons.CLOSE_CIRCLE);
    CssStyles.style(removeAllButton, ValoTheme.BUTTON_LINK);
    removeAllButton.addClickListener(e -> {
        for (Tokenizable tokenizable : tokenField.getValue()) {
            tokenField.removeTokenizable(tokenizable);
        }
    });

    utilityButtonsLayout.addComponent(addAllButton);
    utilityButtonsLayout.addComponent(removeAllButton);

    return utilityButtonsLayout;
}

From source file:de.symeda.sormas.ui.statistics.StatisticsView.java

License:Open Source License

private void addFiltersLayout(VerticalLayout statisticsLayout) {
    Label filtersLayoutTitle = new Label(I18nProperties.getString(Strings.headingFilters));
    filtersLayoutTitle.setWidthUndefined();
    CssStyles.style(filtersLayoutTitle, CssStyles.STATISTICS_TITLE);
    statisticsLayout.addComponent(filtersLayoutTitle);

    VerticalLayout filtersSectionLayout = new VerticalLayout();
    CssStyles.style(filtersSectionLayout, CssStyles.STATISTICS_TITLE_BOX);
    filtersSectionLayout.setSpacing(true);
    filtersSectionLayout.setWidth(100, Unit.PERCENTAGE);
    Label filtersInfoText = new Label(I18nProperties.getString(Strings.infoStatisticsFilter), ContentMode.HTML);
    filtersSectionLayout.addComponent(filtersInfoText);

    filtersLayout = new VerticalLayout();
    filtersLayout.setSpacing(true);/*ww  w. j av a  2  s .c  o m*/
    filtersLayout.setMargin(false);
    filtersSectionLayout.addComponent(filtersLayout);

    // Filters footer
    HorizontalLayout filtersSectionFooter = new HorizontalLayout();
    {
        filtersSectionFooter.setSpacing(true);

        Button addFilterButton = new Button(I18nProperties.getCaption(Captions.statisticsAddFilter),
                VaadinIcons.PLUS);
        CssStyles.style(addFilterButton, ValoTheme.BUTTON_PRIMARY);
        addFilterButton.addClickListener(e -> {
            filtersLayout.addComponent(createFilterComponentLayout());
        });
        filtersSectionFooter.addComponent(addFilterButton);

        Button resetFiltersButton = new Button(I18nProperties.getCaption(Captions.statisticsResetFilters));
        resetFiltersButton.addClickListener(e -> {
            filtersLayout.removeAllComponents();
            filterComponents.clear();
        });
        filtersSectionFooter.addComponent(resetFiltersButton);
    }
    filtersSectionLayout.addComponent(filtersSectionFooter);

    statisticsLayout.addComponent(filtersSectionLayout);
}