use of com.vaadin.data.util.BeanItemContainer in project ANNIS by korpling.
the class DocBrowserTable method generateInfoButtonCell.
public Button generateInfoButtonCell(final String docName) {
Button btn = new Button();
btn.setStyleName(ChameleonTheme.BUTTON_BORDERLESS);
btn.setIcon(INFO_ICON);
btn.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(Button.ClickEvent event) {
try {
List<Annotation> annos = getDocMetaData(docName);
/**
* Transforms to a list of key value pairs. The values concates the
* namespace and ordinary value. Namespaces "NULL" are ignored.
*/
// create datasource and bind it to a table
BeanItemContainer<Annotation> metaContainer = new BeanItemContainer<>(Annotation.class);
metaContainer.addAll(annos);
metaContainer.sort(new Object[] { "namespace", "name" }, new boolean[] { true, true });
Table metaTable = new Table();
metaTable.setContainerDataSource(metaContainer);
metaTable.addGeneratedColumn("genname", new MetaDataPanel.MetaTableNameGenerator(metaContainer));
metaTable.addGeneratedColumn("genvalue", new MetaDataPanel.MetaTableValueGenerator(metaContainer));
metaTable.setVisibleColumns("genname", "genvalue");
metaTable.setColumnHeaders(new String[] { "Name", "Value" });
metaTable.setSizeFull();
metaTable.setColumnWidth("genname", -1);
metaTable.setColumnExpandRatio("genvalue", 1.0f);
metaTable.addStyleName(ChameleonTheme.TABLE_STRIPED);
// create and style the extra window for the metadata table
Window metaWin = new Window();
metaWin.setContent(metaTable);
metaWin.setCaption("metadata doc " + docName);
metaWin.center();
metaWin.setWidth(400, Unit.PIXELS);
metaWin.setHeight(400, Unit.PIXELS);
// paint the window
docBrowserPanel.getUI().addWindow(metaWin);
} catch (UniformInterfaceException ex) {
log.error("can not retrieve metadata for document " + docName, ex);
}
}
});
return btn;
}
Aggregations