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;
}
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;
}
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();
}
}
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);
}
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);
}
Aggregations