use of com.vaadin.ui.components.grid.FooterRow in project catma by forTEXT.
the class QueryResultPanel method initTagBasedData.
void initTagBasedData() {
displaySetting = DisplaySetting.GROUPED_BY_TAG;
miGroupByTagPath.setEnabled(false);
miGroupByPhrase.setEnabled(true);
miFlatTable.setEnabled(true);
miPropertiesAsColumns.setEnabled(true);
treeGridPanel.removeAllComponents();
initQueryResultGrid();
TreeDataProvider<QueryResultRowItem> queryResultDataProvider = new TreeDataProvider<QueryResultRowItem>(getTagBasedTreeData());
queryResultDataProvider.addFilter(punctuationFilter);
Column<QueryResultRowItem, ?> tagPathColumn = queryResultGrid.addColumn(QueryResultRowItem::getKey).setCaption("Tag Path").setRenderer(new HtmlRenderer()).setDescriptionGenerator(item -> item.getDetailedKeyInContext(), ContentMode.HTML).setId("tagPath").setWidth(300);
if (resultContainsProperties) {
queryResultGrid.addColumn(QueryResultRowItem::getPropertyName).setCaption("Property").setWidth(100);
queryResultGrid.addColumn(QueryResultRowItem::getPropertyValue).setCaption("Property Value").setWidth(300);
tagPathColumn.setWidth(130);
}
Column<QueryResultRowItem, ?> freqColumn = queryResultGrid.addColumn(QueryResultRowItem::getFrequency).setId("frequency").setCaption("Frequency");
if ((itemSelectionListener == null) && (itemRemovedListener == null)) {
freqColumn.setExpandRatio(1);
} else {
freqColumn.setWidth(130);
}
if (itemSelectionListener != null) {
ButtonRenderer<QueryResultRowItem> selectItemsRenderer = new ButtonRenderer<QueryResultRowItem>(rendererClickEvent -> itemSelectionListener.itemSelected(rendererClickEvent.getItem()));
selectItemsRenderer.setHtmlContentAllowed(true);
queryResultGrid.addColumn((item) -> VaadinIcons.ARROW_CIRCLE_DOWN_O.getHtml()).setCaption("Select").setRenderer(selectItemsRenderer).setWidth(70);
}
if (itemRemovedListener != null) {
ButtonRenderer<QueryResultRowItem> removeItemsRenderer = new ButtonRenderer<QueryResultRowItem>(rendererClickEvent -> itemRemovedListener.itemRemoved(rendererClickEvent.getItem()));
removeItemsRenderer.setHtmlContentAllowed(true);
queryResultGrid.addColumn((item) -> VaadinIcons.ERASER.getHtml()).setCaption("Remove").setRenderer(removeItemsRenderer).setExpandRatio(1);
}
queryResultGrid.setDataProvider(queryResultDataProvider);
FooterRow footer = queryResultGrid.prependFooterRow();
queryResultGrid.setFooterVisible(true);
queryResultDataProvider.addDataProviderListener(event -> handleTotalTypesChange("Tags", footer.getCell("tagPath"), resultContainsProperties ? "Property Values" : "Annotations", footer.getCell("frequency"), queryResultDataProvider));
handleTotalTypesChange("Tags", footer.getCell("tagPath"), resultContainsProperties ? "Property Values" : "Annotations", footer.getCell("frequency"), queryResultDataProvider);
treeGridPanel.addComponent(queryResultGrid);
if (queryResultDataProvider.getTreeData().getRootItems().size() == 0) {
Notification.show("Info", "Your query result does not contain annotated occurrences!", Type.HUMANIZED_MESSAGE);
}
initInfoLabel();
queryResultGrid.setSortOrder(new GridSortOrderBuilder<QueryResultRowItem>().thenDesc(freqColumn).build());
fireDisplaySettingChanged();
}
use of com.vaadin.ui.components.grid.FooterRow in project catma by forTEXT.
the class QueryResultPanel method initPhraseBasedData.
void initPhraseBasedData() {
displaySetting = DisplaySetting.GROUPED_BY_PHRASE;
miGroupByTagPath.setEnabled(true);
miGroupByPhrase.setEnabled(false);
miFlatTable.setEnabled(true);
miPropertiesAsColumns.setEnabled(true);
treeGridPanel.removeAllComponents();
initQueryResultGrid();
queryResultGrid.addColumn(QueryResultRowItem::getKey).setCaption("Phrase").setDescriptionGenerator(item -> item.getDetailedKeyInContext(), ContentMode.HTML).setRenderer(new HtmlRenderer()).setId("phrase").setWidth(310);
Column<QueryResultRowItem, Integer> freqColumn = queryResultGrid.addColumn(QueryResultRowItem::getFrequency).setCaption("Frequency").setId("frequency");
if ((itemSelectionListener == null) && (itemRemovedListener == null)) {
freqColumn.setExpandRatio(1);
} else {
freqColumn.setWidth(120);
}
if (itemSelectionListener != null) {
ButtonRenderer<QueryResultRowItem> selectItemsRenderer = new ButtonRenderer<QueryResultRowItem>(rendererClickEvent -> itemSelectionListener.itemSelected(rendererClickEvent.getItem()));
selectItemsRenderer.setHtmlContentAllowed(true);
queryResultGrid.addColumn((item) -> VaadinIcons.ARROW_CIRCLE_DOWN_O.getHtml()).setCaption("Select").setRenderer(selectItemsRenderer).setExpandRatio(1);
}
if (itemRemovedListener != null) {
ButtonRenderer<QueryResultRowItem> removeItemsRenderer = new ButtonRenderer<QueryResultRowItem>(rendererClickEvent -> itemRemovedListener.itemRemoved(rendererClickEvent.getItem()));
removeItemsRenderer.setHtmlContentAllowed(true);
queryResultGrid.addColumn((item) -> VaadinIcons.ERASER.getHtml()).setCaption("Remove").setRenderer(removeItemsRenderer).setExpandRatio(1);
}
FooterRow footer = queryResultGrid.prependFooterRow();
queryResultGrid.setFooterVisible(true);
TreeDataProvider<QueryResultRowItem> queryResultDataProvider = new TreeDataProvider<QueryResultRowItem>(getPhraseBasedTreeData());
queryResultDataProvider.addFilter(punctuationFilter);
queryResultGrid.setDataProvider(queryResultDataProvider);
queryResultDataProvider.addDataProviderListener(event -> handleTotalTypesChange("Types", footer.getCell("phrase"), "Tokens", footer.getCell("frequency"), queryResultDataProvider));
handleTotalTypesChange("Types", footer.getCell("phrase"), "Tokens", footer.getCell("frequency"), queryResultDataProvider);
treeGridPanel.addComponent(queryResultGrid);
queryResultGrid.setSortOrder(new GridSortOrderBuilder<QueryResultRowItem>().thenDesc(freqColumn).build());
initInfoLabel();
fireDisplaySettingChanged();
}
use of com.vaadin.ui.components.grid.FooterRow in project catma by forTEXT.
the class QueryResultPanel method initPropertiesAsColumnsTagBasedData.
void initPropertiesAsColumnsTagBasedData() {
displaySetting = DisplaySetting.PROPERTIES_AS_COLUMNS;
miGroupByTagPath.setEnabled(true);
miGroupByPhrase.setEnabled(true);
miFlatTable.setEnabled(true);
miPropertiesAsColumns.setEnabled(false);
treeGridPanel.removeAllComponents();
initQueryResultGrid();
TreeDataProvider<QueryResultRowItem> queryResultDataProvider = new TreeDataProvider<QueryResultRowItem>(getPropertiesAsColumnsTagBasedTreeData());
queryResultDataProvider.addFilter(punctuationFilter);
Column<QueryResultRowItem, ?> tagPathColumn = queryResultGrid.addColumn(QueryResultRowItem::getTagPath).setCaption("Tag Path").setWidth(200);
if (includeQueryId) {
// TODO: add a queryId column
}
queryResultGrid.addColumn(QueryResultRowItem::getKey).setCaption("Annotation").setDescriptionGenerator(item -> item.getDetailedKeyInContext(), ContentMode.HTML).setRenderer(new HtmlRenderer()).setId("annotation").setWidth(200);
for (String propertyName : propertyNames) {
queryResultGrid.addColumn(item -> item.getPropertyValue(propertyName)).setCaption(propertyName).setWidth(200);
}
queryResultGrid.addColumn(QueryResultRowItem::getDocumentName).setCaption("Document").setWidth(200);
queryResultGrid.addColumn(QueryResultRowItem::getCollectionName).setCaption("Collection").setWidth(200);
if (itemSelectionListener != null) {
ButtonRenderer<QueryResultRowItem> selectItemsRenderer = new ButtonRenderer<QueryResultRowItem>(rendererClickEvent -> itemSelectionListener.itemSelected(rendererClickEvent.getItem()));
selectItemsRenderer.setHtmlContentAllowed(true);
queryResultGrid.addColumn((item) -> VaadinIcons.ARROW_CIRCLE_DOWN_O.getHtml()).setCaption("Select").setRenderer(selectItemsRenderer).setExpandRatio(1);
}
if (itemRemovedListener != null) {
ButtonRenderer<QueryResultRowItem> removeItemsRenderer = new ButtonRenderer<QueryResultRowItem>(rendererClickEvent -> itemRemovedListener.itemRemoved(rendererClickEvent.getItem()));
removeItemsRenderer.setHtmlContentAllowed(true);
queryResultGrid.addColumn((item) -> VaadinIcons.ERASER.getHtml()).setCaption("Remove").setRenderer(removeItemsRenderer).setExpandRatio(1);
}
FooterRow footer = queryResultGrid.prependFooterRow();
queryResultGrid.setFooterVisible(true);
queryResultDataProvider.addDataProviderListener(event -> handleTotalTypesChange(null, null, "Annotations", footer.getCell("annotation"), queryResultDataProvider));
queryResultGrid.setDataProvider(queryResultDataProvider);
handleTotalTypesChange(null, null, "Annotations", footer.getCell("annotation"), queryResultDataProvider);
treeGridPanel.addComponent(queryResultGrid);
if (queryResultDataProvider.getTreeData().getRootItems().size() == 0) {
Notification.show("Info", "Your query result does not contain annotated occurrences!", Type.HUMANIZED_MESSAGE);
}
queryResultGrid.setSortOrder(new GridSortOrderBuilder<QueryResultRowItem>().thenAsc(tagPathColumn).build());
initInfoLabel();
fireDisplaySettingChanged();
}
use of com.vaadin.ui.components.grid.FooterRow in project catma by forTEXT.
the class QueryResultPanel method initFlatTagBasedData.
void initFlatTagBasedData() {
displaySetting = DisplaySetting.ANNOTATIONS_AS_FLAT_TABLE;
miGroupByTagPath.setEnabled(true);
miGroupByPhrase.setEnabled(true);
miFlatTable.setEnabled(false);
miPropertiesAsColumns.setEnabled(true);
treeGridPanel.removeAllComponents();
initQueryResultGrid();
TreeDataProvider<QueryResultRowItem> queryResultDataProvider = new TreeDataProvider<QueryResultRowItem>(getFlatTagBasedTreeData());
queryResultDataProvider.addFilter(punctuationFilter);
Column<QueryResultRowItem, ?> tagPathColumn = queryResultGrid.addColumn(QueryResultRowItem::getTagPath).setCaption("Tag Path").setDescriptionGenerator(item -> item.getDetailedKeyInContext(), ContentMode.HTML).setWidth(200);
if (includeQueryId) {
// TODO: add a queryId column
}
queryResultGrid.addColumn(QueryResultRowItem::getDocumentName).setCaption("Document").setWidth(200);
queryResultGrid.addColumn(QueryResultRowItem::getCollectionName).setCaption("Collection").setWidth(200);
queryResultGrid.addColumn(QueryResultRowItem::getKey).setCaption("Annotation").setId("annotation").setRenderer(new HtmlRenderer()).setWidth(200);
if (resultContainsProperties) {
queryResultGrid.addColumn(QueryResultRowItem::getPropertyName).setCaption("Property").setWidth(100);
queryResultGrid.addColumn(QueryResultRowItem::getPropertyValue).setId("propertyvalue").setCaption("Property Value").setWidth(300);
}
if (itemSelectionListener != null) {
ButtonRenderer<QueryResultRowItem> selectItemsRenderer = new ButtonRenderer<QueryResultRowItem>(rendererClickEvent -> itemSelectionListener.itemSelected(rendererClickEvent.getItem()));
selectItemsRenderer.setHtmlContentAllowed(true);
queryResultGrid.addColumn((item) -> VaadinIcons.ARROW_CIRCLE_DOWN_O.getHtml()).setCaption("Select").setRenderer(selectItemsRenderer).setExpandRatio(1);
}
if (itemRemovedListener != null) {
ButtonRenderer<QueryResultRowItem> removeItemsRenderer = new ButtonRenderer<QueryResultRowItem>(rendererClickEvent -> itemRemovedListener.itemRemoved(rendererClickEvent.getItem()));
removeItemsRenderer.setHtmlContentAllowed(true);
queryResultGrid.addColumn((item) -> VaadinIcons.ERASER.getHtml()).setCaption("Remove").setRenderer(removeItemsRenderer).setExpandRatio(1);
}
queryResultGrid.setDataProvider(queryResultDataProvider);
FooterRow footer = queryResultGrid.prependFooterRow();
queryResultGrid.setFooterVisible(true);
if (resultContainsProperties) {
queryResultDataProvider.addDataProviderListener(event -> handleTotalTypesChange(null, null, "Property Values", footer.getCell("propertyvalue"), queryResultDataProvider));
handleTotalTypesChange(null, null, "Property Values", footer.getCell("propertyvalue"), queryResultDataProvider);
} else {
queryResultDataProvider.addDataProviderListener(event -> handleTotalTypesChange(null, null, "Annotations", footer.getCell("annotation"), queryResultDataProvider));
handleTotalTypesChange(null, null, "Annotations", footer.getCell("annotation"), queryResultDataProvider);
}
treeGridPanel.addComponent(queryResultGrid);
if (queryResultDataProvider.getTreeData().getRootItems().size() == 0) {
Notification.show("Info", "Your query result does not contain annotated occurrences!", Type.HUMANIZED_MESSAGE);
}
queryResultGrid.setSortOrder(new GridSortOrderBuilder<QueryResultRowItem>().thenAsc(tagPathColumn).build());
initInfoLabel();
fireDisplaySettingChanged();
}
Aggregations