Search in sources :

Example 1 with IndexedContainer

use of com.vaadin.data.util.IndexedContainer in project VaadinUtils by rlsutton1.

the class PreviewCSV method buildContainerFromCSV.

protected IndexedContainer buildContainerFromCSV(Reader reader, int rowLimit) throws IOException {
    IndexedContainer container = new IndexedContainer();
    try (CSVReader csvReader = new CSVReader(reader)) {
        String[] columnHeaders = null;
        String[] record;
        // Import no more than 100 records as this is only a sample
        int count = 0;
        while (((record = csvReader.readNext()) != null) && count < rowLimit) {
            if (columnHeaders == null) {
                columnHeaders = record;
                addItemProperties(container, record);
                columnHeaders = record;
            } else {
                addRow(container, record, columnHeaders);
                count++;
            }
        }
    }
    return container;
}
Also used : CSVReader(au.com.bytecode.opencsv.CSVReader) IndexedContainer(com.vaadin.data.util.IndexedContainer)

Example 2 with IndexedContainer

use of com.vaadin.data.util.IndexedContainer in project VaadinUtils by rlsutton1.

the class FormHelper method createContainerFromMap.

@SuppressWarnings("unchecked")
public static IndexedContainer createContainerFromMap(String fieldName, Map<?, String> hashMap) {
    IndexedContainer container = new IndexedContainer();
    container.addContainerProperty(fieldName, String.class, "");
    Iterator<?> iter = hashMap.keySet().iterator();
    while (iter.hasNext()) {
        Object itemId = iter.next();
        container.addItem(itemId);
        container.getItem(itemId).getItemProperty(fieldName).setValue(hashMap.get(itemId));
    }
    return container;
}
Also used : IndexedContainer(com.vaadin.data.util.IndexedContainer)

Example 3 with IndexedContainer

use of com.vaadin.data.util.IndexedContainer in project cuba by cuba-platform.

the class CubaComboBox method setContainerDataSource.

@Override
public void setContainerDataSource(Container newDataSource) {
    // CAUTION - copied from super method
    Object oldValue = getValue();
    if (newDataSource == null) {
        newDataSource = new IndexedContainer();
    }
    getCaptionChangeListener().clear();
    if (items != newDataSource) {
        // Removes listeners from the old datasource
        if (items != null) {
            if (items instanceof Container.ItemSetChangeNotifier) {
                ((Container.ItemSetChangeNotifier) items).removeItemSetChangeListener(this);
            }
            if (items instanceof Container.PropertySetChangeNotifier) {
                ((Container.PropertySetChangeNotifier) items).removePropertySetChangeListener(this);
            }
        }
        // Assigns new data source
        items = newDataSource;
        // Clears itemIdMapper also
        itemIdMapper.removeAll();
        // Adds listeners
        if (items != null) {
            if (items instanceof Container.ItemSetChangeNotifier) {
                ((Container.ItemSetChangeNotifier) items).addItemSetChangeListener(this);
            }
            if (items instanceof Container.PropertySetChangeNotifier) {
                ((Container.PropertySetChangeNotifier) items).addPropertySetChangeListener(this);
            }
        }
        // #PL-3098
        if (!newDataSource.containsId(oldValue))
            setValue(null);
        markAsDirty();
    }
}
Also used : IndexedContainer(com.vaadin.data.util.IndexedContainer)

Example 4 with IndexedContainer

use of com.vaadin.data.util.IndexedContainer in project GridFastNavigation by TatuLund.

the class DemoUI method initMessageTable.

private void initMessageTable() {
    messageData = new IndexedContainer();
    messageData.addContainerProperty("Message", String.class, "");
    messageTable = new Table("Server messages");
    messageTable.setSizeFull();
    messageTable.setContainerDataSource(messageData);
    messageTable.setImmediate(true);
}
Also used : Table(com.vaadin.ui.Table) IndexedContainer(com.vaadin.data.util.IndexedContainer)

Example 5 with IndexedContainer

use of com.vaadin.data.util.IndexedContainer in project ANNIS by korpling.

the class DocBrowserTable method setDocNames.

/**
 * Updates the table with docnames and generate the additional columns defined
 * by the user.
 *
 * @param docs the list of documents, wrapped in the {@link Annotation} POJO
 */
void setDocNames(List<Annotation> docs) {
    container = new IndexedContainer();
    container.addContainerProperty(PROP_DOC_NAME, String.class, "n/a");
    MetaColumns metaCols = generateMetaColumns();
    for (MetaDataCol metaDatum : metaCols.visibleColumns) {
        container.addContainerProperty(metaDatum.getColName(), String.class, "n/a");
    }
    for (MetaDataCol metaDatum : metaCols.sortColumns) {
        container.addContainerProperty(metaDatum.getColName(), String.class, "n/a");
    }
    container.addContainerProperty("corpus path", String.class, "n/a");
    container.addContainerProperty("info", Button.class, null);
    container.addContainerProperty("visualizer", Panel.class, null);
    for (Annotation a : docs) {
        String doc = a.getName();
        // reverse path and delete the brackets and set a new separator:
        // corpus > ... > subcorpus > document
        List<String> pathList = a.getAnnotationPath();
        if (pathList == null) {
            pathList = new LinkedList<>();
        }
        Collections.reverse(pathList);
        String path = StringUtils.join(pathList, " > ");
        // use corpus path for row id, since it should be unique by annis db schema
        Item row = container.addItem(path);
        if (row != null) {
            row.getItemProperty(PROP_DOC_NAME).setValue(doc);
            // add the metadata columns.
            for (MetaDataCol metaDataCol : metaCols.visibleColumns) {
                String value = generateCell(a.getAnnotationPath(), metaDataCol);
                row.getItemProperty(metaDataCol.getColName()).setValue(value);
            }
            for (MetaDataCol metaDataCol : metaCols.sortColumns) {
                if (!metaCols.visibleColumns.contains(metaDataCol)) {
                    // corpusName() holds the corpus path
                    String value = generateCell(a.getAnnotationPath(), metaDataCol);
                    row.getItemProperty(metaDataCol.getColName()).setValue(value);
                }
            }
            row.getItemProperty("corpus path").setValue(path);
            row.getItemProperty("visualizer").setValue(generateVisualizerLinks(doc));
            row.getItemProperty("info").setValue(generateInfoButtonCell(doc));
        }
    }
    setContainerDataSource(container);
    Object[] metaDataColNames = new Object[metaCols.visibleColumns.size()];
    for (int i = 0; i < metaDataColNames.length; i++) {
        metaDataColNames[i] = metaCols.visibleColumns.get(i).getColName();
    }
    Object[] columnNames = ArrayUtils.addAll(ArrayUtils.addAll(new Object[] { "document name" }, metaDataColNames), new Object[] { "corpus path", "visualizer", "info" });
    setVisibleColumns(columnNames);
    for (Object colName : columnNames) {
        setColumnHeader((String) colName, (String) colName);
    }
    sortByMetaData(metaCols.sortColumns);
}
Also used : Item(com.vaadin.data.Item) IndexedContainer(com.vaadin.data.util.IndexedContainer) Annotation(annis.model.Annotation)

Aggregations

IndexedContainer (com.vaadin.data.util.IndexedContainer)9 Table (com.vaadin.ui.Table)3 Item (com.vaadin.data.Item)2 VerticalLayout (com.vaadin.ui.VerticalLayout)2 Annotation (annis.model.Annotation)1 CSVReader (au.com.bytecode.opencsv.CSVReader)1 ReportEmailRecipientVisibility (au.com.vaadinutils.jasper.scheduler.entities.ReportEmailRecipientVisibility)1 EmailValidator (au.com.vaadinutils.validator.EmailValidator)1 NewItemHandler (com.vaadin.ui.AbstractSelect.NewItemHandler)1 Button (com.vaadin.ui.Button)1 ClickEvent (com.vaadin.ui.Button.ClickEvent)1 ClickListener (com.vaadin.ui.Button.ClickListener)1 ComboBox (com.vaadin.ui.ComboBox)1 HorizontalLayout (com.vaadin.ui.HorizontalLayout)1 FileNotFoundException (java.io.FileNotFoundException)1 FileReader (java.io.FileReader)1 IOException (java.io.IOException)1 LinkedList (java.util.LinkedList)1