Example usage for com.vaadin.v7.ui Table setColumnHeader

List of usage examples for com.vaadin.v7.ui Table setColumnHeader

Introduction

In this page you can find the example usage for com.vaadin.v7.ui Table setColumnHeader.

Prototype

public void setColumnHeader(Object propertyId, String header) 

Source Link

Document

Sets the column header for the specified column.

Usage

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

License:Open Source License

protected void createEditColumn(Table table) {

    ColumnGenerator editColumnGenerator = new ColumnGenerator() {

        @Override//  w w  w .  java2  s  .co m
        public Object generateCell(Table source, Object itemId, Object columnId) {
            return generateEditCell(source, itemId, columnId);
        }
    };
    table.addGeneratedColumn(EDIT_COLUMN_ID, editColumnGenerator);
    table.setColumnWidth(EDIT_COLUMN_ID, 20);
    table.setColumnHeader(EDIT_COLUMN_ID, "");

    table.addItemClickListener(new ItemClickListener() {

        @SuppressWarnings("unchecked")
        @Override
        public void itemClick(ItemClickEvent event) {
            if (event.isDoubleClick() || EDIT_COLUMN_ID.equals(event.getPropertyId())) {
                final E entry = (E) event.getItemId();
                if (entry != null) {
                    editEntry(entry, false, result -> onEntryChanged(result));
                }
            }
        }
    });
}

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

License:Open Source License

@Override
protected void updateColumns() {
    Table table = getTable();

    table.addGeneratedColumn(PERIOD, new Table.ColumnGenerator() {
        @Override/*from  www  . j  a v a 2  s. c  o m*/
        public Object generateCell(Table source, Object itemId, Object columnId) {
            EpiDataBurialDto burial = (EpiDataBurialDto) itemId;
            if (burial.getBurialDateFrom() == null && burial.getBurialDateTo() == null) {
                return I18nProperties.getString(Strings.unknown);
            } else {
                StringBuilder periodBuilder = new StringBuilder();
                periodBuilder.append(burial.getBurialDateFrom() != null
                        ? DateHelper.formatLocalDate(burial.getBurialDateFrom())
                        : "?");
                periodBuilder.append(" - ");
                periodBuilder.append(
                        burial.getBurialDateTo() != null ? DateHelper.formatLocalDate(burial.getBurialDateTo())
                                : "?");
                return periodBuilder.toString();
            }
        }
    });

    table.addGeneratedColumn(CITY, new Table.ColumnGenerator() {
        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            EpiDataBurialDto burial = (EpiDataBurialDto) itemId;
            LocationDto location = burial.getBurialAddress();
            return location.getCity();
        }
    });

    table.addGeneratedColumn(DISTRICT, new Table.ColumnGenerator() {
        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            EpiDataBurialDto burial = (EpiDataBurialDto) itemId;
            LocationDto location = burial.getBurialAddress();
            return location.getDistrict();
        }
    });

    table.setVisibleColumns(EDIT_COLUMN_ID, EpiDataBurialDto.BURIAL_PERSON_NAME,
            EpiDataBurialDto.BURIAL_RELATION, PERIOD, CITY, DISTRICT, EpiDataBurialDto.BURIAL_ILL,
            EpiDataBurialDto.BURIAL_TOUCHING);

    table.setColumnExpandRatio(EDIT_COLUMN_ID, 0);
    table.setColumnExpandRatio(EpiDataBurialDto.BURIAL_PERSON_NAME, 0);
    table.setColumnExpandRatio(EpiDataBurialDto.BURIAL_RELATION, 0);
    table.setColumnExpandRatio(PERIOD, 0);
    table.setColumnExpandRatio(CITY, 0);
    table.setColumnExpandRatio(DISTRICT, 0);
    table.setColumnExpandRatio(EpiDataBurialDto.BURIAL_ILL, 0);
    table.setColumnExpandRatio(EpiDataBurialDto.BURIAL_TOUCHING, 0);

    for (Object columnId : table.getVisibleColumns()) {
        if (!columnId.equals(EDIT_COLUMN_ID)) {
            table.setColumnHeader(columnId,
                    I18nProperties.getPrefixCaption(EPI_DATA_BURIAL_TABLE_PREFIX, (String) columnId));
        }
    }
}

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

License:Open Source License

@Override
protected void updateColumns() {
    Table table = getTable();

    table.addGeneratedColumn(CITY, new Table.ColumnGenerator() {
        @Override// w ww.ja v  a2 s .  c o  m
        public Object generateCell(Table source, Object itemId, Object columnId) {
            EpiDataGatheringDto gathering = (EpiDataGatheringDto) itemId;
            LocationDto location = gathering.getGatheringAddress();
            return location.getCity();
        }
    });

    table.addGeneratedColumn(DISTRICT, new Table.ColumnGenerator() {
        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            EpiDataGatheringDto gathering = (EpiDataGatheringDto) itemId;
            LocationDto location = gathering.getGatheringAddress();
            return location.getDistrict();
        }
    });

    table.addGeneratedColumn(GATHERING_DAY, new Table.ColumnGenerator() {
        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            EpiDataGatheringDto gathering = (EpiDataGatheringDto) itemId;
            if (gathering.getGatheringDate() != null) {
                return DateHelper.formatLocalDate(gathering.getGatheringDate());
            } else {
                return I18nProperties.getString(Strings.unknown);
            }
        }
    });

    table.setVisibleColumns(EDIT_COLUMN_ID, EpiDataGatheringDto.DESCRIPTION, GATHERING_DAY, CITY, DISTRICT);

    table.setColumnExpandRatio(EDIT_COLUMN_ID, 0);
    table.setColumnExpandRatio(EpiDataGatheringDto.DESCRIPTION, 0);
    table.setColumnExpandRatio(GATHERING_DAY, 0);
    table.setColumnExpandRatio(CITY, 0);
    table.setColumnExpandRatio(DISTRICT, 0);

    for (Object columnId : table.getVisibleColumns()) {
        if (!columnId.equals(EDIT_COLUMN_ID)) {
            table.setColumnHeader(columnId,
                    I18nProperties.getPrefixCaption(EpiDataGatheringDto.I18N_PREFIX, (String) columnId));
        }
    }
}

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

License:Open Source License

@Override
protected void updateColumns() {
    Table table = getTable();

    table.addGeneratedColumn(PERIOD, new Table.ColumnGenerator() {
        @Override//from   ww  w  .j a v  a 2  s.  co  m
        public Object generateCell(Table source, Object itemId, Object columnId) {
            EpiDataTravelDto travel = (EpiDataTravelDto) itemId;
            if (travel.getTravelDateFrom() == null && travel.getTravelDateTo() == null) {
                return I18nProperties.getString(Strings.unknown);
            } else {
                StringBuilder periodBuilder = new StringBuilder();
                periodBuilder.append(travel.getTravelDateFrom() != null
                        ? DateHelper.formatLocalDate(travel.getTravelDateFrom())
                        : "?");
                periodBuilder.append(" - ");
                periodBuilder.append(
                        travel.getTravelDateTo() != null ? DateHelper.formatLocalDate(travel.getTravelDateTo())
                                : "?");
                return periodBuilder.toString();
            }
        }
    });

    table.setVisibleColumns(EDIT_COLUMN_ID, EpiDataTravelDto.TRAVEL_TYPE, EpiDataTravelDto.TRAVEL_DESTINATION,
            PERIOD);

    table.setColumnExpandRatio(EDIT_COLUMN_ID, 0);
    table.setColumnExpandRatio(EpiDataTravelDto.TRAVEL_TYPE, 0);
    table.setColumnExpandRatio(EpiDataTravelDto.TRAVEL_DESTINATION, 0);
    table.setColumnExpandRatio(PERIOD, 0);

    for (Object columnId : table.getVisibleColumns()) {
        if (!columnId.equals(EDIT_COLUMN_ID)) {
            table.setColumnHeader(columnId,
                    I18nProperties.getPrefixCaption(EpiDataTravelDto.I18N_PREFIX, (String) columnId));
        }
    }
}

From source file:de.symeda.sormas.ui.hospitalization.PreviousHospitalizationsField.java

License:Open Source License

@Override
protected void updateColumns() {

    Table table = getTable();

    table.addGeneratedColumn(PERIOD, new Table.ColumnGenerator() {
        @Override/*from  w  w w  . j  a  va  2  s.  c  om*/
        public Object generateCell(Table source, Object itemId, Object columnId) {
            PreviousHospitalizationDto prevHospitalization = (PreviousHospitalizationDto) itemId;
            if (prevHospitalization.getAdmissionDate() == null
                    && prevHospitalization.getDischargeDate() == null) {
                return I18nProperties.getString(Strings.unknown);
            } else {
                StringBuilder periodBuilder = new StringBuilder();
                periodBuilder.append(prevHospitalization.getAdmissionDate() != null
                        ? DateHelper.formatLocalDate(prevHospitalization.getAdmissionDate())
                        : "?");
                periodBuilder.append(" - ");
                periodBuilder.append(prevHospitalization.getDischargeDate() != null
                        ? DateHelper.formatLocalDate(prevHospitalization.getDischargeDate())
                        : "?");
                return periodBuilder.toString();
            }
        }
    });

    table.addGeneratedColumn(COMMUNITY, new Table.ColumnGenerator() {
        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            PreviousHospitalizationDto prevHospitalization = (PreviousHospitalizationDto) itemId;
            return prevHospitalization.getCommunity();
        }
    });

    table.addGeneratedColumn(DISTRICT, new Table.ColumnGenerator() {
        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            PreviousHospitalizationDto prevHospitalization = (PreviousHospitalizationDto) itemId;
            return prevHospitalization.getDistrict();
        }
    });

    table.setVisibleColumns(EDIT_COLUMN_ID, PERIOD, PreviousHospitalizationDto.HEALTH_FACILITY, COMMUNITY,
            DISTRICT, PreviousHospitalizationDto.DESCRIPTION, PreviousHospitalizationDto.ISOLATED);

    table.setColumnExpandRatio(EDIT_COLUMN_ID, 0);
    table.setColumnExpandRatio(PERIOD, 0);
    table.setColumnExpandRatio(PreviousHospitalizationDto.HEALTH_FACILITY, 0);
    table.setColumnExpandRatio(COMMUNITY, 0);
    table.setColumnExpandRatio(DISTRICT, 0);
    table.setColumnExpandRatio(PreviousHospitalizationDto.DESCRIPTION, 0);
    table.setColumnExpandRatio(PreviousHospitalizationDto.ISOLATED, 0);

    for (Object columnId : table.getVisibleColumns()) {
        if (!columnId.equals(EDIT_COLUMN_ID)) {
            table.setColumnHeader(columnId,
                    I18nProperties.getPrefixCaption(PreviousHospitalizationDto.I18N_PREFIX, (String) columnId));
        }
    }
}