Search in sources :

Example 1 with DateRenderer

use of com.vaadin.ui.renderers.DateRenderer in project SORMAS-Project by hzi-braunschweig.

the class ContactsPreviewGrid method buildGrid.

private void buildGrid() {
    setSizeFull();
    setSelectionMode(Grid.SelectionMode.SINGLE);
    setHeightMode(HeightMode.ROW);
    Language userLanguage = I18nProperties.getUserLanguage();
    removeColumn(SormasToSormasContactPreview.DISEASE);
    addComponentColumn(eventPreview -> {
        String diseaseText = eventPreview.getDisease().toString();
        if (!StringUtils.isEmpty(eventPreview.getDiseaseDetails())) {
            diseaseText += " - " + eventPreview.getDiseaseDetails();
        }
        return new Label(diseaseText);
    }).setId(SormasToSormasContactPreview.DISEASE);
    List<String> columnConfig = new ArrayList<>();
    columnConfig.addAll(Arrays.asList(SormasToSormasContactPreview.UUID, SormasToSormasContactPreview.REPORT_DATE_TIME, SormasToSormasContactPreview.DISEASE, SormasToSormasContactPreview.CONTACT_STATUS, SormasToSormasContactPreview.CONTACT_CLASSIFICATION, SormasToSormasContactPreview.CONTACT_CATEGORY));
    columnConfig.addAll(PreviewGridHelper.createPersonColumns(this, SormasToSormasContactPreview::getPerson));
    columnConfig.addAll(Arrays.asList(SormasToSormasContactPreview.REGION, SormasToSormasContactPreview.DISTRICT, SormasToSormasContactPreview.COMMUNITY, SormasToSormasContactPreview.LAST_CONTACT_DATE));
    setColumns(columnConfig);
    ((Column<SormasToSormasContactPreview, String>) getColumn(SormasToSormasContactPreview.UUID)).setRenderer(new UuidRenderer());
    ((Column<SormasToSormasContactPreview, Date>) getColumn(SormasToSormasContactPreview.REPORT_DATE_TIME)).setRenderer(new DateRenderer(DateHelper.getLocalDateTimeFormat(userLanguage)));
    ((Column<SormasToSormasContactPreview, Date>) getColumn(SormasToSormasContactPreview.LAST_CONTACT_DATE)).setRenderer(new DateRenderer(DateHelper.getLocalDateTimeFormat(userLanguage)));
    for (Column<?, ?> column : getColumns()) {
        column.setCaption(I18nProperties.findPrefixCaption(column.getId(), SormasToSormasContactPreview.I18N_PREFIX, SormasToSormasPersonPreview.I18N_PREFIX));
    }
}
Also used : Arrays(java.util.Arrays) UuidRenderer(de.symeda.sormas.ui.utils.UuidRenderer) SormasToSormasPersonPreview(de.symeda.sormas.api.sormastosormas.sharerequest.SormasToSormasPersonPreview) Date(java.util.Date) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) Collection(java.util.Collection) SormasToSormasContactPreview(de.symeda.sormas.api.sormastosormas.sharerequest.SormasToSormasContactPreview) DateHelper(de.symeda.sormas.api.utils.DateHelper) StringUtils(org.apache.commons.lang3.StringUtils) Language(de.symeda.sormas.api.Language) HeightMode(com.vaadin.shared.ui.grid.HeightMode) ArrayList(java.util.ArrayList) List(java.util.List) Label(com.vaadin.ui.Label) Grid(com.vaadin.ui.Grid) DateRenderer(com.vaadin.ui.renderers.DateRenderer) Language(de.symeda.sormas.api.Language) UuidRenderer(de.symeda.sormas.ui.utils.UuidRenderer) Label(com.vaadin.ui.Label) ArrayList(java.util.ArrayList) DateRenderer(com.vaadin.ui.renderers.DateRenderer)

Example 2 with DateRenderer

use of com.vaadin.ui.renderers.DateRenderer in project SORMAS-Project by hzi-braunschweig.

the class EventPreviewGrid method buildGrid.

private void buildGrid() {
    setSizeFull();
    setSelectionMode(SelectionMode.SINGLE);
    setHeightMode(HeightMode.ROW);
    Language userLanguage = I18nProperties.getUserLanguage();
    removeColumn(SormasToSormasEventPreview.DISEASE);
    addComponentColumn(casePreview -> {
        String diseaseText;
        if (casePreview.getDisease() == null) {
            diseaseText = "";
        } else {
            diseaseText = casePreview.getDisease().toString();
            if (!StringUtils.isEmpty(casePreview.getDiseaseDetails())) {
                diseaseText += " - " + casePreview.getDiseaseDetails();
            }
        }
        return new Label(diseaseText);
    }).setId(SormasToSormasEventPreview.DISEASE);
    removeColumn(SormasToSormasEventPreview.EVENT_LOCATION);
    addComponentColumn(previewData -> new Label(LocationHelper.buildLocationString(previewData.getEventLocation()))).setId(SormasToSormasEventPreview.EVENT_LOCATION);
    setColumns(SormasToSormasEventPreview.UUID, SormasToSormasEventPreview.REPORT_DATE_TIME, SormasToSormasEventPreview.EVENT_TITLE, SormasToSormasEventPreview.EVENT_DESC, SormasToSormasEventPreview.DISEASE, SormasToSormasEventPreview.EVENT_LOCATION);
    ((Column<SormasToSormasEventPreview, String>) getColumn(SormasToSormasEventPreview.UUID)).setRenderer(new UuidRenderer());
    ((Column<SormasToSormasEventPreview, Date>) getColumn(SormasToSormasEventPreview.REPORT_DATE_TIME)).setRenderer(new DateRenderer(DateHelper.getLocalDateTimeFormat(userLanguage)));
    for (Column<?, ?> column : getColumns()) {
        column.setCaption(I18nProperties.findPrefixCaption(column.getId(), SormasToSormasEventPreview.I18N_PREFIX, SormasToSormasPersonPreview.I18N_PREFIX));
    }
}
Also used : UuidRenderer(de.symeda.sormas.ui.utils.UuidRenderer) SormasToSormasPersonPreview(de.symeda.sormas.api.sormastosormas.sharerequest.SormasToSormasPersonPreview) Date(java.util.Date) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) SormasToSormasEventPreview(de.symeda.sormas.api.sormastosormas.sharerequest.SormasToSormasEventPreview) DateHelper(de.symeda.sormas.api.utils.DateHelper) StringUtils(org.apache.commons.lang3.StringUtils) Language(de.symeda.sormas.api.Language) HeightMode(com.vaadin.shared.ui.grid.HeightMode) List(java.util.List) Label(com.vaadin.ui.Label) LocationHelper(de.symeda.sormas.api.utils.LocationHelper) Grid(com.vaadin.ui.Grid) DateRenderer(com.vaadin.ui.renderers.DateRenderer) Language(de.symeda.sormas.api.Language) UuidRenderer(de.symeda.sormas.ui.utils.UuidRenderer) Label(com.vaadin.ui.Label) DateRenderer(com.vaadin.ui.renderers.DateRenderer)

Example 3 with DateRenderer

use of com.vaadin.ui.renderers.DateRenderer in project SORMAS-Project by hzi-braunschweig.

the class ImmunizationGrid method initColumns.

private void initColumns() {
    setColumns(ImmunizationIndexDto.UUID, ImmunizationIndexDto.PERSON_UUID, ImmunizationIndexDto.PERSON_FIRST_NAME, ImmunizationIndexDto.PERSON_LAST_NAME, ImmunizationIndexDto.DISEASE, ImmunizationIndexDto.AGE_AND_BIRTH_DATE, ImmunizationIndexDto.SEX, ImmunizationIndexDto.DISTRICT, ImmunizationIndexDto.MEANS_OF_IMMUNIZATION, ImmunizationIndexDto.MANAGEMENT_STATUS, ImmunizationIndexDto.IMMUNIZATION_STATUS, ImmunizationIndexDto.START_DATE, ImmunizationIndexDto.END_DATE, ImmunizationIndexDto.LAST_VACCINE_TYPE, ImmunizationIndexDto.RECOVERY_DATE);
    ((Column<ImmunizationIndexDto, String>) getColumn(ImmunizationIndexDto.UUID)).setRenderer(new UuidRenderer());
    ((Column<ImmunizationIndexDto, String>) getColumn(ImmunizationIndexDto.PERSON_UUID)).setRenderer(new UuidRenderer());
    ((Column<ImmunizationIndexDto, AgeAndBirthDateDto>) getColumn(ImmunizationIndexDto.AGE_AND_BIRTH_DATE)).setRenderer(value -> value == null ? "" : PersonHelper.getAgeAndBirthdateString(value.getAge(), value.getAgeType(), value.getDateOfBirthDD(), value.getDateOfBirthMM(), value.getDateOfBirthYYYY()), new TextRenderer());
    ((Column<ImmunizationIndexDto, Date>) getColumn(ImmunizationIndexDto.START_DATE)).setRenderer(new DateRenderer(DateFormatHelper.getDateFormat()));
    ((Column<ImmunizationIndexDto, Date>) getColumn(ImmunizationIndexDto.END_DATE)).setRenderer(new DateRenderer(DateFormatHelper.getDateFormat()));
    ((Column<ImmunizationIndexDto, Date>) getColumn(ImmunizationIndexDto.RECOVERY_DATE)).setRenderer(new DateRenderer(DateFormatHelper.getDateFormat()));
    for (Column<ImmunizationIndexDto, ?> column : getColumns()) {
        column.setCaption(I18nProperties.findPrefixCaptionWithDefault(column.getId(), column.getCaption(), ImmunizationIndexDto.I18N_PREFIX, PersonDto.I18N_PREFIX));
        column.setStyleGenerator(FieldAccessColumnStyleGenerator.getDefault(getBeanType(), column.getId()));
    }
}
Also used : ImmunizationIndexDto(de.symeda.sormas.api.immunization.ImmunizationIndexDto) UuidRenderer(de.symeda.sormas.ui.utils.UuidRenderer) DateRenderer(com.vaadin.ui.renderers.DateRenderer) TextRenderer(com.vaadin.ui.renderers.TextRenderer)

Example 4 with DateRenderer

use of com.vaadin.ui.renderers.DateRenderer in project SORMAS-Project by hzi-braunschweig.

the class MergeContactsGrid method buildColumns.

@Override
protected void buildColumns() {
    Column<MergeContactIndexDto, String> diseaseColumn = addColumn(contact -> DiseaseHelper.toString(contact.getDisease(), contact.getDiseaseDetails()));
    diseaseColumn.setId(COLUMN_DISEASE);
    setColumns(COLUMN_UUID, MergeContactIndexDto.CAZE, COLUMN_DISEASE, MergeContactIndexDto.CONTACT_CLASSIFICATION, MergeContactIndexDto.PERSON_FIRST_NAME, MergeContactIndexDto.PERSON_LAST_NAME, MergeContactIndexDto.AGE_AND_BIRTH_DATE, MergeContactIndexDto.SEX, MergeContactIndexDto.DISTRICT_NAME, MergeContactIndexDto.REPORT_DATE_TIME, MergeContactIndexDto.CREATION_DATE, COLUMN_COMPLETENESS, COLUMN_ACTIONS);
    Language userLanguage = I18nProperties.getUserLanguage();
    ((Column<MergeContactIndexDto, Date>) getColumn(MergeContactIndexDto.REPORT_DATE_TIME)).setRenderer(new DateRenderer(DateHelper.getLocalDateTimeFormat(userLanguage)));
    ((Column<MergeContactIndexDto, Date>) getColumn(MergeContactIndexDto.CREATION_DATE)).setRenderer(new DateRenderer(DateHelper.getLocalDateTimeFormat(userLanguage)));
    ((Column<MergeContactIndexDto, AgeAndBirthDateDto>) getColumn(MergeContactIndexDto.AGE_AND_BIRTH_DATE)).setRenderer(value -> value == null ? "" : PersonHelper.getAgeAndBirthdateString(value.getAge(), value.getAgeType(), value.getDateOfBirthDD(), value.getDateOfBirthMM(), value.getDateOfBirthYYYY()), new TextRenderer());
}
Also used : MergeContactIndexDto(de.symeda.sormas.api.contact.MergeContactIndexDto) Language(de.symeda.sormas.api.Language) DateRenderer(com.vaadin.ui.renderers.DateRenderer) TextRenderer(com.vaadin.ui.renderers.TextRenderer)

Example 5 with DateRenderer

use of com.vaadin.ui.renderers.DateRenderer in project SORMAS-Project by hzi-braunschweig.

the class ShareRequestGrid method initGridColumns.

private void initGridColumns() {
    addShowColumn((request) -> {
        ControllerProvider.getSormasToSormasController().showRequestDetails(request);
    });
    addComponentColumn(indexDto -> createActionButtons(indexDto)).setId(COLUMN_ACTIONS);
    setColumns(SHOW_MESSAGE, SormasToSormasShareRequestIndexDto.UUID, SormasToSormasShareRequestIndexDto.CREATION_DATE, SormasToSormasShareRequestIndexDto.DATA_TYPE, SormasToSormasShareRequestIndexDto.ORGANIZATION_NAME, SormasToSormasShareRequestIndexDto.SENDER_NAME, SormasToSormasShareRequestIndexDto.OWNERSHIP_HANDED_OVER, SormasToSormasShareRequestIndexDto.STATUS, SormasToSormasShareRequestIndexDto.COMMENT, COLUMN_ACTIONS);
    ((Column<SormasToSormasShareRequestIndexDto, String>) getColumn(LabMessageIndexDto.UUID)).setRenderer(new UuidRenderer());
    ((Column<SormasToSormasShareRequestIndexDto, Date>) getColumn(SormasToSormasShareRequestIndexDto.CREATION_DATE)).setRenderer(new DateRenderer(DateHelper.getLocalDateTimeFormat(I18nProperties.getUserLanguage())));
    getColumn(SormasToSormasShareRequestIndexDto.ORGANIZATION_NAME).setSortable(false);
    getColumn(SormasToSormasShareRequestIndexDto.OWNERSHIP_HANDED_OVER).setRenderer(new BooleanRenderer());
    for (Column<?, ?> column : getColumns()) {
        column.setCaption(I18nProperties.getPrefixCaption(SormasToSormasShareRequestIndexDto.I18N_PREFIX, column.getId(), column.getCaption()));
    }
    setSortOrder(Collections.singletonList(new GridSortOrder<>(getColumn(SormasToSormasShareRequestIndexDto.CREATION_DATE), SortDirection.DESCENDING)));
}
Also used : UuidRenderer(de.symeda.sormas.ui.utils.UuidRenderer) ShareRequestCriteria(de.symeda.sormas.api.sormastosormas.sharerequest.ShareRequestCriteria) Date(java.util.Date) FacadeProvider(de.symeda.sormas.api.FacadeProvider) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) LabMessageIndexDto(de.symeda.sormas.api.labmessage.LabMessageIndexDto) DateHelper(de.symeda.sormas.api.utils.DateHelper) SortDirection(com.vaadin.shared.data.sort.SortDirection) ControllerProvider(de.symeda.sormas.ui.ControllerProvider) GridSortOrder(com.vaadin.data.provider.GridSortOrder) VaadinIcons(com.vaadin.icons.VaadinIcons) DataProvider(com.vaadin.data.provider.DataProvider) DateRenderer(com.vaadin.ui.renderers.DateRenderer) ButtonHelper(de.symeda.sormas.ui.utils.ButtonHelper) ValoTheme(com.vaadin.ui.themes.ValoTheme) ListDataProvider(com.vaadin.data.provider.ListDataProvider) FilteredGrid(de.symeda.sormas.ui.utils.FilteredGrid) BooleanRenderer(de.symeda.sormas.ui.utils.BooleanRenderer) ShareRequestStatus(de.symeda.sormas.api.sormastosormas.sharerequest.ShareRequestStatus) SortProperty(de.symeda.sormas.api.utils.SortProperty) Collectors(java.util.stream.Collectors) Captions(de.symeda.sormas.api.i18n.Captions) SormasToSormasShareRequestIndexDto(de.symeda.sormas.api.sormastosormas.sharerequest.SormasToSormasShareRequestIndexDto) Consumer(java.util.function.Consumer) ShowDetailsListener(de.symeda.sormas.ui.utils.ShowDetailsListener) HorizontalLayout(com.vaadin.ui.HorizontalLayout) HtmlRenderer(com.vaadin.ui.renderers.HtmlRenderer) Collections(java.util.Collections) Component(com.vaadin.ui.Component) GridSortOrder(com.vaadin.data.provider.GridSortOrder) BooleanRenderer(de.symeda.sormas.ui.utils.BooleanRenderer) UuidRenderer(de.symeda.sormas.ui.utils.UuidRenderer) DateRenderer(com.vaadin.ui.renderers.DateRenderer)

Aggregations

DateRenderer (com.vaadin.ui.renderers.DateRenderer)15 UuidRenderer (de.symeda.sormas.ui.utils.UuidRenderer)9 Language (de.symeda.sormas.api.Language)7 I18nProperties (de.symeda.sormas.api.i18n.I18nProperties)7 Date (java.util.Date)7 List (java.util.List)6 Label (com.vaadin.ui.Label)5 DateHelper (de.symeda.sormas.api.utils.DateHelper)5 TextRenderer (com.vaadin.ui.renderers.TextRenderer)4 FacadeProvider (de.symeda.sormas.api.FacadeProvider)4 CaseIndexDto (de.symeda.sormas.api.caze.CaseIndexDto)4 SortProperty (de.symeda.sormas.api.utils.SortProperty)4 ControllerProvider (de.symeda.sormas.ui.ControllerProvider)4 ShowDetailsListener (de.symeda.sormas.ui.utils.ShowDetailsListener)4 DataProvider (com.vaadin.data.provider.DataProvider)3 ListDataProvider (com.vaadin.data.provider.ListDataProvider)3 SortDirection (com.vaadin.shared.data.sort.SortDirection)3 HeightMode (com.vaadin.shared.ui.grid.HeightMode)3 Grid (com.vaadin.ui.Grid)3 CountryHelper (de.symeda.sormas.api.CountryHelper)3