Search in sources :

Example 11 with DateRenderer

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

the class CasePreviewGrid method buildGrid.

private void buildGrid() {
    setSizeFull();
    setSelectionMode(SelectionMode.SINGLE);
    setHeightMode(HeightMode.ROW);
    Language userLanguage = I18nProperties.getUserLanguage();
    removeColumn(SormasToSormasCasePreview.DISEASE);
    addComponentColumn(casePreview -> {
        String diseaseText = casePreview.getDisease().toString();
        if (!StringUtils.isEmpty(casePreview.getDiseaseDetails())) {
            diseaseText += " - " + casePreview.getDiseaseDetails();
        }
        if (casePreview.getDiseaseVariant() != null) {
            diseaseText += diseaseText + " - " + casePreview.getDiseaseVariant().getCaption();
        }
        return new Label(diseaseText);
    }).setId(SormasToSormasCasePreview.DISEASE);
    removeColumn(SormasToSormasCasePreview.HEALTH_FACILITY);
    addComponentColumn(casePreview -> {
        FacilityReferenceDto healthFacility = casePreview.getHealthFacility();
        if (healthFacility == null) {
            return null;
        }
        return new Label(FacilityHelper.buildFacilityString(healthFacility.getUuid(), healthFacility.getCaption(), casePreview.getHealthFacilityDetails()));
    }).setId(SormasToSormasCasePreview.HEALTH_FACILITY);
    removeColumn(SormasToSormasCasePreview.POINT_OF_ENTRY);
    addComponentColumn(casePreview -> {
        PointOfEntryReferenceDto pointOfEntry = casePreview.getPointOfEntry();
        if (pointOfEntry == null) {
            return null;
        }
        return new Label(InfrastructureHelper.buildPointOfEntryString(pointOfEntry.getUuid(), pointOfEntry.getCaption(), casePreview.getPointOfEntryDetails()));
    }).setId(SormasToSormasCasePreview.POINT_OF_ENTRY);
    List<String> columnConfig = new ArrayList<>();
    columnConfig.addAll(Arrays.asList(SormasToSormasCasePreview.UUID, SormasToSormasCasePreview.REPORT_DATE, SormasToSormasCasePreview.DISEASE, SormasToSormasCasePreview.CASE_CLASSIFICATION, SormasToSormasCasePreview.INVESTIGATION_STATUS, SormasToSormasCasePreview.OUTCOME));
    columnConfig.addAll(PreviewGridHelper.createPersonColumns(this, SormasToSormasCasePreview::getPerson));
    columnConfig.addAll(Arrays.asList(SormasToSormasCasePreview.REGION, SormasToSormasCasePreview.DISTRICT, SormasToSormasCasePreview.COMMUNITY, SormasToSormasCasePreview.HEALTH_FACILITY, SormasToSormasCasePreview.POINT_OF_ENTRY, SormasToSormasCasePreview.ONSET_DATE));
    setColumns(columnConfig);
    ((Column<SormasToSormasCasePreview, String>) getColumn(SormasToSormasContactPreview.UUID)).setRenderer(new UuidRenderer());
    ((Column<SormasToSormasCasePreview, Date>) getColumn(SormasToSormasCasePreview.REPORT_DATE)).setRenderer(new DateRenderer(DateHelper.getLocalDateTimeFormat(userLanguage)));
    ((Column<SormasToSormasCasePreview, Date>) getColumn(SormasToSormasCasePreview.ONSET_DATE)).setRenderer(new DateRenderer(DateHelper.getLocalDateTimeFormat(userLanguage)));
    for (Column<?, ?> column : getColumns()) {
        column.setCaption(I18nProperties.findPrefixCaption(column.getId(), SormasToSormasCasePreview.I18N_PREFIX, SormasToSormasPersonPreview.I18N_PREFIX));
    }
}
Also used : Arrays(java.util.Arrays) InfrastructureHelper(de.symeda.sormas.api.infrastructure.InfrastructureHelper) 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) FacilityHelper(de.symeda.sormas.api.infrastructure.facility.FacilityHelper) 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) FacilityReferenceDto(de.symeda.sormas.api.infrastructure.facility.FacilityReferenceDto) HeightMode(com.vaadin.shared.ui.grid.HeightMode) ArrayList(java.util.ArrayList) List(java.util.List) SormasToSormasCasePreview(de.symeda.sormas.api.sormastosormas.sharerequest.SormasToSormasCasePreview) PointOfEntryReferenceDto(de.symeda.sormas.api.infrastructure.pointofentry.PointOfEntryReferenceDto) Label(com.vaadin.ui.Label) Grid(com.vaadin.ui.Grid) DateRenderer(com.vaadin.ui.renderers.DateRenderer) Language(de.symeda.sormas.api.Language) FacilityReferenceDto(de.symeda.sormas.api.infrastructure.facility.FacilityReferenceDto) UuidRenderer(de.symeda.sormas.ui.utils.UuidRenderer) Label(com.vaadin.ui.Label) ArrayList(java.util.ArrayList) PointOfEntryReferenceDto(de.symeda.sormas.api.infrastructure.pointofentry.PointOfEntryReferenceDto) DateRenderer(com.vaadin.ui.renderers.DateRenderer)

Example 12 with DateRenderer

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

the class CampaignDataGrid method addDefaultColumns.

protected void addDefaultColumns() {
    addEditColumn(e -> {
        ControllerProvider.getCampaignController().navigateToFormDataView(e.getUuid());
    });
    setColumns(EDIT_BTN_ID, CampaignFormDataIndexDto.CAMPAIGN, CampaignFormDataIndexDto.FORM, CampaignFormDataIndexDto.REGION, CampaignFormDataIndexDto.DISTRICT, CampaignFormDataIndexDto.COMMUNITY, CampaignFormDataIndexDto.FORM_DATE);
    getColumn(EDIT_BTN_ID).setWidth(40).setStyleGenerator(item -> CssStyles.GRID_CELL_LINK);
    ((Column<CampaignFormDataIndexDto, Date>) getColumn(CampaignFormDataIndexDto.FORM_DATE)).setRenderer(new DateRenderer(DateHelper.getLocalDateFormat(I18nProperties.getUserLanguage())));
    for (Column<?, ?> column : getColumns()) {
        column.setCaption(I18nProperties.getPrefixCaption(CampaignFormDataIndexDto.I18N_PREFIX, column.getId(), column.getCaption()));
    }
}
Also used : DateRenderer(com.vaadin.ui.renderers.DateRenderer)

Example 13 with DateRenderer

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

the class EventSelectionGrid method buildGrid.

private void buildGrid() {
    setSizeFull();
    setSelectionMode(SelectionMode.SINGLE);
    setHeightMode(HeightMode.ROW);
    Language userLanguage = I18nProperties.getUserLanguage();
    setColumns(EventIndexDto.EVENT_LOCATION, EventIndexDto.EVENT_TITLE, EventGrid.createEventDateColumn(this), EventIndexDto.EVENT_STATUS, EventIndexDto.REPORT_DATE_TIME);
    for (Column<EventIndexDto, ?> column : getColumns()) {
        column.setCaption(I18nProperties.getPrefixCaption(EventIndexDto.I18N_PREFIX, column.getId(), column.getCaption()));
        column.setStyleGenerator(FieldAccessColumnStyleGenerator.forSensitiveData(EventIndexDto.class, column.getId()));
    }
    getColumn(EventIndexDto.EVENT_TITLE).setMaximumWidth(300);
    ((Column<EventIndexDto, Date>) getColumn(EventIndexDto.REPORT_DATE_TIME)).setRenderer(new DateRenderer(DateHelper.getLocalDateTimeFormat(userLanguage)));
}
Also used : Language(de.symeda.sormas.api.Language) EventIndexDto(de.symeda.sormas.api.event.EventIndexDto) DateRenderer(com.vaadin.ui.renderers.DateRenderer)

Example 14 with DateRenderer

use of com.vaadin.ui.renderers.DateRenderer in project cuba by cuba-platform.

the class WebDateRenderer method createImplementation.

@Override
protected DateRenderer createImplementation() {
    if (dateFormat == null) {
        checkNotNullArgument(formatString, "Format string may not be null");
        checkNotNullArgument(locale, "Locale may not be null");
        dateFormat = new SimpleDateFormat(formatString, locale);
    }
    return new DateRenderer(dateFormat, getNullRepresentation());
}
Also used : DateRenderer(com.vaadin.ui.renderers.DateRenderer) SimpleDateFormat(java.text.SimpleDateFormat)

Example 15 with DateRenderer

use of com.vaadin.ui.renderers.DateRenderer in project jmix by jmix-framework.

the class DateRendererImpl method createImplementation.

@Override
protected DateRenderer createImplementation() {
    if (dateFormat == null) {
        checkNotNullArgument(formatString, "Format string may not be null");
        checkNotNullArgument(locale, "Locale may not be null");
        dateFormat = new SimpleDateFormat(formatString, locale);
    }
    return new DateRenderer(dateFormat, getNullRepresentation());
}
Also used : DateRenderer(com.vaadin.ui.renderers.DateRenderer) SimpleDateFormat(java.text.SimpleDateFormat)

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