Search in sources :

Example 26 with Property

use of com.vaadin.data.Property in project VaadinUtils by rlsutton1.

the class ContainerCSVExport method writeRow.

private void writeRow(CSVWriter writer, Table table, Object id, Set<Object> properties) {
    Item item = table.getItem(id);
    String[] values = new String[properties.size() + extraColumnHeadersAndPropertyIds.size()];
    int i = 0;
    for (Object propertyId : properties) {
        @SuppressWarnings("rawtypes") final Property itemProperty = item.getItemProperty(propertyId);
        if (itemProperty != null && itemProperty.getValue() != null) {
            ColumnGenerator generator = table.getColumnGenerator(propertyId);
            if (generator != null && itemProperty.getType() != Boolean.class) {
                Object value = generator.generateCell(table, id, propertyId);
                if (value instanceof Label) {
                    value = new HtmlToPlainText().getPlainText(Jsoup.parse(((Label) value).getValue()));
                }
                if (value instanceof AbstractLayout) {
                    value = new HtmlToPlainText().getPlainText(Jsoup.parse(itemProperty.getValue().toString()));
                }
                if (value instanceof Link) {
                    value = new HtmlToPlainText().getPlainText(Jsoup.parse(itemProperty.getValue().toString()));
                }
                if (value != null) {
                    values[i++] = value.toString();
                }
            } else {
                values[i++] = itemProperty.getValue().toString();
            }
        } else {
            ColumnGenerator generator = table.getColumnGenerator(propertyId);
            if (generator != null) {
                Object value = generator.generateCell(table, id, propertyId);
                if (value != null) {
                    if (value instanceof ClickableLabel) {
                        value = new HtmlToPlainText().getPlainText(Jsoup.parse(((ClickableLabel) value).getValue()));
                    }
                    if (value instanceof Label) {
                        value = new HtmlToPlainText().getPlainText(Jsoup.parse(((Label) value).getValue()));
                    // value = ((Label) value).getValue();
                    }
                    if (value instanceof AbstractLayout) {
                        // set a string using setData() on the layout.
                        if (((AbstractLayout) value).getData() instanceof ContainerCSVExportData) {
                            value = ((AbstractLayout) value).getData().toString();
                        } else {
                            value = "";
                        }
                    }
                    if (value instanceof Link) {
                        value = new HtmlToPlainText().getPlainText(Jsoup.parse(((Link) value).getCaption()));
                    }
                }
                if (value == null) {
                    value = "";
                }
                values[i++] = value.toString();
            } else {
                values[i++] = "";
            }
        }
    }
    for (Object columnId : extraColumnHeadersAndPropertyIds.values()) {
        String value = getValueForExtraColumn(item, columnId);
        if (value == null) {
            value = "";
        }
        values[i++] = value;
    }
    writer.writeNext(values);
}
Also used : HtmlToPlainText(org.jsoup.examples.HtmlToPlainText) ClickableLabel(au.com.vaadinutils.fields.ClickableLabel) Label(com.vaadin.ui.Label) Item(com.vaadin.data.Item) ColumnGenerator(com.vaadin.ui.Table.ColumnGenerator) ClickableLabel(au.com.vaadinutils.fields.ClickableLabel) AbstractLayout(com.vaadin.ui.AbstractLayout) Property(com.vaadin.data.Property) Link(com.vaadin.ui.Link)

Aggregations

Property (com.vaadin.data.Property)26 Item (com.vaadin.data.Item)18 ValueChangeEvent (com.vaadin.data.Property.ValueChangeEvent)16 Table (com.vaadin.ui.Table)15 UriFragment (org.activiti.explorer.navigation.UriFragment)11 LazyLoadingContainer (org.activiti.explorer.data.LazyLoadingContainer)10 ThemeImageColumnGenerator (org.activiti.explorer.ui.util.ThemeImageColumnGenerator)8 HistoricProcessInstance (org.activiti.engine.history.HistoricProcessInstance)4 WeakItemChangeListener (com.haulmont.cuba.gui.data.impl.WeakItemChangeListener)3 Label (com.vaadin.ui.Label)3 LazyLoadingQuery (org.activiti.explorer.data.LazyLoadingQuery)3 MetaClass (com.haulmont.chile.core.model.MetaClass)2 WeakItemPropertyChangeListener (com.haulmont.cuba.gui.data.impl.WeakItemPropertyChangeListener)2 ErrorMessage (com.vaadin.server.ErrorMessage)2 Collection (java.util.Collection)2 HistoricFormProperty (org.activiti.engine.history.HistoricFormProperty)2 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)2 PrettyTimeLabel (org.activiti.explorer.ui.custom.PrettyTimeLabel)2 ClickableLabel (au.com.vaadinutils.fields.ClickableLabel)1 Enumeration (com.haulmont.chile.core.datatypes.Enumeration)1