Search in sources :

Example 1 with FooterRow

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();
}
Also used : BackgroundServiceProvider(de.catma.backgroundservice.BackgroundServiceProvider) GroupedQueryResult(de.catma.queryengine.result.GroupedQueryResult) GridSortOrderBuilder(com.vaadin.data.provider.GridSortOrderBuilder) MenuItem(com.vaadin.ui.MenuBar.MenuItem) LoadingCache(com.google.common.cache.LoadingCache) SelectionListener(com.vaadin.event.selection.SelectionListener) TextField(com.vaadin.ui.TextField) Alignment(com.vaadin.ui.Alignment) UI(com.vaadin.ui.UI) FooterRow(com.vaadin.ui.components.grid.FooterRow) QueryResultRowArray(de.catma.queryengine.result.QueryResultRowArray) KwicProvider(de.catma.indexer.KwicProvider) ErrorHandler(de.catma.ui.module.main.ErrorHandler) Map(java.util.Map) TreeDataProvider(com.vaadin.data.provider.TreeDataProvider) TagQueryResultRow(de.catma.queryengine.result.TagQueryResultRow) VaadinIcons(com.vaadin.icons.VaadinIcons) QueryId(de.catma.queryengine.QueryId) IconButton(de.catma.ui.component.IconButton) Set(java.util.Set) TreeGrid(com.vaadin.ui.TreeGrid) AnnotatedTextProvider(de.catma.ui.module.annotate.annotationpanel.AnnotatedTextProvider) Collectors(java.util.stream.Collectors) BinaryOperator(java.util.function.BinaryOperator) List(java.util.List) Type(com.vaadin.ui.Notification.Type) TagDefinition(de.catma.tag.TagDefinition) ExpandEvent(com.vaadin.event.ExpandEvent) StreamResource(com.vaadin.server.StreamResource) ClickListener(com.vaadin.ui.Button.ClickListener) Column(com.vaadin.ui.Grid.Column) VerticalLayout(com.vaadin.ui.VerticalLayout) LocalDateTime(java.time.LocalDateTime) HashMap(java.util.HashMap) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) Registration(com.vaadin.shared.Registration) Notification(com.vaadin.ui.Notification) TreeGridFactory(de.catma.ui.component.TreeGridFactory) ButtonRenderer(com.vaadin.ui.renderers.ButtonRenderer) WeakReference(java.lang.ref.WeakReference) CSVExportGroupedStreamSource(de.catma.ui.module.analyze.CSVExportGroupedStreamSource) InMemoryDataProvider(com.vaadin.data.provider.InMemoryDataProvider) ContentMode(com.vaadin.shared.ui.ContentMode) QueryResult(de.catma.queryengine.result.QueryResult) Iterator(java.util.Iterator) TreeData(com.vaadin.data.TreeData) ClickEvent(com.vaadin.ui.Button.ClickEvent) Project(de.catma.project.Project) Command(com.vaadin.ui.MenuBar.Command) QueryResultRow(de.catma.queryengine.result.QueryResultRow) ContextMenu(com.vaadin.contextmenu.ContextMenu) FooterCell(com.vaadin.ui.components.grid.FooterCell) Button(com.vaadin.ui.Button) HorizontalLayout(com.vaadin.ui.HorizontalLayout) DateTimeFormatter(java.time.format.DateTimeFormatter) FileDownloader(com.vaadin.server.FileDownloader) SerializablePredicate(com.vaadin.server.SerializablePredicate) HierarchicalQuery(com.vaadin.data.provider.HierarchicalQuery) HtmlRenderer(com.vaadin.ui.renderers.HtmlRenderer) CSVExportFlatStreamSource(de.catma.ui.module.analyze.CSVExportFlatStreamSource) Component(com.vaadin.ui.Component) TreeDataProvider(com.vaadin.data.provider.TreeDataProvider) HtmlRenderer(com.vaadin.ui.renderers.HtmlRenderer) FooterRow(com.vaadin.ui.components.grid.FooterRow) ButtonRenderer(com.vaadin.ui.renderers.ButtonRenderer)

Example 2 with FooterRow

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();
}
Also used : BackgroundServiceProvider(de.catma.backgroundservice.BackgroundServiceProvider) GroupedQueryResult(de.catma.queryengine.result.GroupedQueryResult) GridSortOrderBuilder(com.vaadin.data.provider.GridSortOrderBuilder) MenuItem(com.vaadin.ui.MenuBar.MenuItem) LoadingCache(com.google.common.cache.LoadingCache) SelectionListener(com.vaadin.event.selection.SelectionListener) TextField(com.vaadin.ui.TextField) Alignment(com.vaadin.ui.Alignment) UI(com.vaadin.ui.UI) FooterRow(com.vaadin.ui.components.grid.FooterRow) QueryResultRowArray(de.catma.queryengine.result.QueryResultRowArray) KwicProvider(de.catma.indexer.KwicProvider) ErrorHandler(de.catma.ui.module.main.ErrorHandler) Map(java.util.Map) TreeDataProvider(com.vaadin.data.provider.TreeDataProvider) TagQueryResultRow(de.catma.queryengine.result.TagQueryResultRow) VaadinIcons(com.vaadin.icons.VaadinIcons) QueryId(de.catma.queryengine.QueryId) IconButton(de.catma.ui.component.IconButton) Set(java.util.Set) TreeGrid(com.vaadin.ui.TreeGrid) AnnotatedTextProvider(de.catma.ui.module.annotate.annotationpanel.AnnotatedTextProvider) Collectors(java.util.stream.Collectors) BinaryOperator(java.util.function.BinaryOperator) List(java.util.List) Type(com.vaadin.ui.Notification.Type) TagDefinition(de.catma.tag.TagDefinition) ExpandEvent(com.vaadin.event.ExpandEvent) StreamResource(com.vaadin.server.StreamResource) ClickListener(com.vaadin.ui.Button.ClickListener) Column(com.vaadin.ui.Grid.Column) VerticalLayout(com.vaadin.ui.VerticalLayout) LocalDateTime(java.time.LocalDateTime) HashMap(java.util.HashMap) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) Registration(com.vaadin.shared.Registration) Notification(com.vaadin.ui.Notification) TreeGridFactory(de.catma.ui.component.TreeGridFactory) ButtonRenderer(com.vaadin.ui.renderers.ButtonRenderer) WeakReference(java.lang.ref.WeakReference) CSVExportGroupedStreamSource(de.catma.ui.module.analyze.CSVExportGroupedStreamSource) InMemoryDataProvider(com.vaadin.data.provider.InMemoryDataProvider) ContentMode(com.vaadin.shared.ui.ContentMode) QueryResult(de.catma.queryengine.result.QueryResult) Iterator(java.util.Iterator) TreeData(com.vaadin.data.TreeData) ClickEvent(com.vaadin.ui.Button.ClickEvent) Project(de.catma.project.Project) Command(com.vaadin.ui.MenuBar.Command) QueryResultRow(de.catma.queryengine.result.QueryResultRow) ContextMenu(com.vaadin.contextmenu.ContextMenu) FooterCell(com.vaadin.ui.components.grid.FooterCell) Button(com.vaadin.ui.Button) HorizontalLayout(com.vaadin.ui.HorizontalLayout) DateTimeFormatter(java.time.format.DateTimeFormatter) FileDownloader(com.vaadin.server.FileDownloader) SerializablePredicate(com.vaadin.server.SerializablePredicate) HierarchicalQuery(com.vaadin.data.provider.HierarchicalQuery) HtmlRenderer(com.vaadin.ui.renderers.HtmlRenderer) CSVExportFlatStreamSource(de.catma.ui.module.analyze.CSVExportFlatStreamSource) Component(com.vaadin.ui.Component) TreeDataProvider(com.vaadin.data.provider.TreeDataProvider) HtmlRenderer(com.vaadin.ui.renderers.HtmlRenderer) FooterRow(com.vaadin.ui.components.grid.FooterRow) ButtonRenderer(com.vaadin.ui.renderers.ButtonRenderer)

Example 3 with FooterRow

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();
}
Also used : BackgroundServiceProvider(de.catma.backgroundservice.BackgroundServiceProvider) GroupedQueryResult(de.catma.queryengine.result.GroupedQueryResult) GridSortOrderBuilder(com.vaadin.data.provider.GridSortOrderBuilder) MenuItem(com.vaadin.ui.MenuBar.MenuItem) LoadingCache(com.google.common.cache.LoadingCache) SelectionListener(com.vaadin.event.selection.SelectionListener) TextField(com.vaadin.ui.TextField) Alignment(com.vaadin.ui.Alignment) UI(com.vaadin.ui.UI) FooterRow(com.vaadin.ui.components.grid.FooterRow) QueryResultRowArray(de.catma.queryengine.result.QueryResultRowArray) KwicProvider(de.catma.indexer.KwicProvider) ErrorHandler(de.catma.ui.module.main.ErrorHandler) Map(java.util.Map) TreeDataProvider(com.vaadin.data.provider.TreeDataProvider) TagQueryResultRow(de.catma.queryengine.result.TagQueryResultRow) VaadinIcons(com.vaadin.icons.VaadinIcons) QueryId(de.catma.queryengine.QueryId) IconButton(de.catma.ui.component.IconButton) Set(java.util.Set) TreeGrid(com.vaadin.ui.TreeGrid) AnnotatedTextProvider(de.catma.ui.module.annotate.annotationpanel.AnnotatedTextProvider) Collectors(java.util.stream.Collectors) BinaryOperator(java.util.function.BinaryOperator) List(java.util.List) Type(com.vaadin.ui.Notification.Type) TagDefinition(de.catma.tag.TagDefinition) ExpandEvent(com.vaadin.event.ExpandEvent) StreamResource(com.vaadin.server.StreamResource) ClickListener(com.vaadin.ui.Button.ClickListener) Column(com.vaadin.ui.Grid.Column) VerticalLayout(com.vaadin.ui.VerticalLayout) LocalDateTime(java.time.LocalDateTime) HashMap(java.util.HashMap) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) Registration(com.vaadin.shared.Registration) Notification(com.vaadin.ui.Notification) TreeGridFactory(de.catma.ui.component.TreeGridFactory) ButtonRenderer(com.vaadin.ui.renderers.ButtonRenderer) WeakReference(java.lang.ref.WeakReference) CSVExportGroupedStreamSource(de.catma.ui.module.analyze.CSVExportGroupedStreamSource) InMemoryDataProvider(com.vaadin.data.provider.InMemoryDataProvider) ContentMode(com.vaadin.shared.ui.ContentMode) QueryResult(de.catma.queryengine.result.QueryResult) Iterator(java.util.Iterator) TreeData(com.vaadin.data.TreeData) ClickEvent(com.vaadin.ui.Button.ClickEvent) Project(de.catma.project.Project) Command(com.vaadin.ui.MenuBar.Command) QueryResultRow(de.catma.queryengine.result.QueryResultRow) ContextMenu(com.vaadin.contextmenu.ContextMenu) FooterCell(com.vaadin.ui.components.grid.FooterCell) Button(com.vaadin.ui.Button) HorizontalLayout(com.vaadin.ui.HorizontalLayout) DateTimeFormatter(java.time.format.DateTimeFormatter) FileDownloader(com.vaadin.server.FileDownloader) SerializablePredicate(com.vaadin.server.SerializablePredicate) HierarchicalQuery(com.vaadin.data.provider.HierarchicalQuery) HtmlRenderer(com.vaadin.ui.renderers.HtmlRenderer) CSVExportFlatStreamSource(de.catma.ui.module.analyze.CSVExportFlatStreamSource) Component(com.vaadin.ui.Component) TreeDataProvider(com.vaadin.data.provider.TreeDataProvider) HtmlRenderer(com.vaadin.ui.renderers.HtmlRenderer) FooterRow(com.vaadin.ui.components.grid.FooterRow) ButtonRenderer(com.vaadin.ui.renderers.ButtonRenderer)

Example 4 with FooterRow

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();
}
Also used : BackgroundServiceProvider(de.catma.backgroundservice.BackgroundServiceProvider) GroupedQueryResult(de.catma.queryengine.result.GroupedQueryResult) GridSortOrderBuilder(com.vaadin.data.provider.GridSortOrderBuilder) MenuItem(com.vaadin.ui.MenuBar.MenuItem) LoadingCache(com.google.common.cache.LoadingCache) SelectionListener(com.vaadin.event.selection.SelectionListener) TextField(com.vaadin.ui.TextField) Alignment(com.vaadin.ui.Alignment) UI(com.vaadin.ui.UI) FooterRow(com.vaadin.ui.components.grid.FooterRow) QueryResultRowArray(de.catma.queryengine.result.QueryResultRowArray) KwicProvider(de.catma.indexer.KwicProvider) ErrorHandler(de.catma.ui.module.main.ErrorHandler) Map(java.util.Map) TreeDataProvider(com.vaadin.data.provider.TreeDataProvider) TagQueryResultRow(de.catma.queryengine.result.TagQueryResultRow) VaadinIcons(com.vaadin.icons.VaadinIcons) QueryId(de.catma.queryengine.QueryId) IconButton(de.catma.ui.component.IconButton) Set(java.util.Set) TreeGrid(com.vaadin.ui.TreeGrid) AnnotatedTextProvider(de.catma.ui.module.annotate.annotationpanel.AnnotatedTextProvider) Collectors(java.util.stream.Collectors) BinaryOperator(java.util.function.BinaryOperator) List(java.util.List) Type(com.vaadin.ui.Notification.Type) TagDefinition(de.catma.tag.TagDefinition) ExpandEvent(com.vaadin.event.ExpandEvent) StreamResource(com.vaadin.server.StreamResource) ClickListener(com.vaadin.ui.Button.ClickListener) Column(com.vaadin.ui.Grid.Column) VerticalLayout(com.vaadin.ui.VerticalLayout) LocalDateTime(java.time.LocalDateTime) HashMap(java.util.HashMap) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) Registration(com.vaadin.shared.Registration) Notification(com.vaadin.ui.Notification) TreeGridFactory(de.catma.ui.component.TreeGridFactory) ButtonRenderer(com.vaadin.ui.renderers.ButtonRenderer) WeakReference(java.lang.ref.WeakReference) CSVExportGroupedStreamSource(de.catma.ui.module.analyze.CSVExportGroupedStreamSource) InMemoryDataProvider(com.vaadin.data.provider.InMemoryDataProvider) ContentMode(com.vaadin.shared.ui.ContentMode) QueryResult(de.catma.queryengine.result.QueryResult) Iterator(java.util.Iterator) TreeData(com.vaadin.data.TreeData) ClickEvent(com.vaadin.ui.Button.ClickEvent) Project(de.catma.project.Project) Command(com.vaadin.ui.MenuBar.Command) QueryResultRow(de.catma.queryengine.result.QueryResultRow) ContextMenu(com.vaadin.contextmenu.ContextMenu) FooterCell(com.vaadin.ui.components.grid.FooterCell) Button(com.vaadin.ui.Button) HorizontalLayout(com.vaadin.ui.HorizontalLayout) DateTimeFormatter(java.time.format.DateTimeFormatter) FileDownloader(com.vaadin.server.FileDownloader) SerializablePredicate(com.vaadin.server.SerializablePredicate) HierarchicalQuery(com.vaadin.data.provider.HierarchicalQuery) HtmlRenderer(com.vaadin.ui.renderers.HtmlRenderer) CSVExportFlatStreamSource(de.catma.ui.module.analyze.CSVExportFlatStreamSource) Component(com.vaadin.ui.Component) TreeDataProvider(com.vaadin.data.provider.TreeDataProvider) HtmlRenderer(com.vaadin.ui.renderers.HtmlRenderer) FooterRow(com.vaadin.ui.components.grid.FooterRow) ButtonRenderer(com.vaadin.ui.renderers.ButtonRenderer)

Aggregations

LoadingCache (com.google.common.cache.LoadingCache)4 ContextMenu (com.vaadin.contextmenu.ContextMenu)4 TreeData (com.vaadin.data.TreeData)4 GridSortOrderBuilder (com.vaadin.data.provider.GridSortOrderBuilder)4 HierarchicalQuery (com.vaadin.data.provider.HierarchicalQuery)4 InMemoryDataProvider (com.vaadin.data.provider.InMemoryDataProvider)4 TreeDataProvider (com.vaadin.data.provider.TreeDataProvider)4 ExpandEvent (com.vaadin.event.ExpandEvent)4 SelectionListener (com.vaadin.event.selection.SelectionListener)4 VaadinIcons (com.vaadin.icons.VaadinIcons)4 FileDownloader (com.vaadin.server.FileDownloader)4 SerializablePredicate (com.vaadin.server.SerializablePredicate)4 StreamResource (com.vaadin.server.StreamResource)4 Registration (com.vaadin.shared.Registration)4 ContentMode (com.vaadin.shared.ui.ContentMode)4 Alignment (com.vaadin.ui.Alignment)4 Button (com.vaadin.ui.Button)4 ClickEvent (com.vaadin.ui.Button.ClickEvent)4 ClickListener (com.vaadin.ui.Button.ClickListener)4 Component (com.vaadin.ui.Component)4