Search in sources :

Example 1 with ButtonRenderer

use of com.vaadin.ui.renderers.ButtonRenderer in project catma by forTEXT.

the class TagsView method initActions.

private void initActions() {
    tagsetGrid.addColumn(tagsetTreeItem -> tagsetTreeItem.getColor(), new HtmlRenderer()).setCaption("Tagsets").setSortable(false).setWidth(200);
    tagsetGrid.setHierarchyColumn(tagsetGrid.addColumn(tagsetTreeItem -> tagsetTreeItem.getName()).setCaption("Tags").setSortable(false).setWidth(300));
    ButtonRenderer<TagsetTreeItem> propertySummaryRenderer = new ButtonRenderer<>(rendererClickEvent -> handlePropertySummaryClickEvent(rendererClickEvent));
    propertySummaryRenderer.setHtmlContentAllowed(true);
    tagsetGrid.addColumn(tagsetTreeItem -> tagsetTreeItem.getPropertySummary(), propertySummaryRenderer).setCaption("Properties").setSortable(false).setHidable(true).setWidth(300);
    tagsetGrid.addColumn(tagsetTreeItem -> tagsetTreeItem.getPropertyValue()).setCaption("Values").setSortable(false).setHidable(true).setWidth(300);
    ButtonRenderer<TagsetTreeItem> btRemovalRenderer = new ButtonRenderer<>(rendererClickEvent -> handleTagsetTreeItemRemovalRequest(rendererClickEvent));
    btRemovalRenderer.setHtmlContentAllowed(true);
    tagsetGrid.addColumn(tagsetTreeItem -> tagsetTreeItem.getRemoveIcon()).setRenderer(btRemovalRenderer).setSortable(false).setHidable(false).setExpandRatio(1);
    tagsetGrid.setStyleGenerator(new StyleGenerator<TagsetTreeItem>() {

        @Override
        public String apply(TagsetTreeItem item) {
            return item.generateStyle();
        }
    });
    tagsetGridComponent.setSearchFilterProvider(new SearchFilterProvider<TagsetTreeItem>() {

        @Override
        public SerializablePredicate<TagsetTreeItem> createSearchFilter(String searchInput) {
            return new TagsetSearchFilterProvider(searchInput, tagsetData);
        }
    });
    tagsetGrid.addExpandListener(expandEvent -> handleExpandCollapseTagset(expandEvent.getExpandedItem(), true));
    tagsetGrid.addCollapseListener(collapseEvent -> handleExpandCollapseTagset(collapseEvent.getCollapsedItem(), false));
    ContextMenu addContextMenu = tagsetGridComponent.getActionGridBar().getBtnAddContextMenu();
    addContextMenu.addItem("Add Tagset", clickEvent -> handleAddTagsetRequest());
    addContextMenu.addItem("Add Tag", clickEvent -> handleAddTagRequest());
    addContextMenu.addItem("Add Subtag", clickEvent -> handleAddSubtagRequest());
    addContextMenu.addItem("Add Property", clickEvent -> handleAddPropertyRequest());
    ContextMenu moreOptionsContextMenu = tagsetGridComponent.getActionGridBar().getBtnMoreOptionsContextMenu();
    moreOptionsContextMenu.addItem("Edit Tag", clickEvent -> handleEditTagRequest());
    moreOptionsContextMenu.addItem("Delete Tag", clickEvent -> handleDeleteTagRequest());
    moreOptionsContextMenu.addItem("Edit/Delete Properties", clickEvent -> handleEditPropertiesRequest());
    moreOptionsContextMenu.addItem("Edit Tagset", clickEvent -> handleEditTagsetRequest());
    moreOptionsContextMenu.addItem("Delete Tagset", clickEvent -> handleDeleteTagsetRequest());
    resourcePanel.setTagsetSelectionListener(selectedTagsets -> {
        tagsets.clear();
        tagsets.addAll(selectedTagsets);
        initData();
    });
}
Also used : ArrayListMultimap(com.google.common.collect.ArrayListMultimap) PropertyDefinition(de.catma.tag.PropertyDefinition) UI(com.vaadin.ui.UI) ConfirmDialog(org.vaadin.dialogs.ConfirmDialog) Multimap(com.google.common.collect.Multimap) ActionGridComponent(de.catma.ui.component.actiongrid.ActionGridComponent) SearchFilterProvider(de.catma.ui.component.actiongrid.SearchFilterProvider) ArrayList(java.util.ArrayList) EventBus(com.google.common.eventbus.EventBus) MaterialTheme(com.github.appreciated.material.MaterialTheme) Notification(com.vaadin.ui.Notification) ErrorHandler(de.catma.ui.module.main.ErrorHandler) Label(com.vaadin.ui.Label) TagsetDefinition(de.catma.tag.TagsetDefinition) SliderPanel(org.vaadin.sliderpanel.SliderPanel) TreeDataProvider(com.vaadin.data.provider.TreeDataProvider) Pair(de.catma.util.Pair) Version(de.catma.tag.Version) TreeGridFactory(de.catma.ui.component.TreeGridFactory) IDGenerator(de.catma.util.IDGenerator) ButtonRenderer(com.vaadin.ui.renderers.ButtonRenderer) SaveCancelListener(de.catma.ui.dialog.SaveCancelListener) PropertyChangeEvent(java.beans.PropertyChangeEvent) TreeData(com.vaadin.data.TreeData) Project(de.catma.project.Project) Collection(java.util.Collection) Set(java.util.Set) IOException(java.io.IOException) TreeGrid(com.vaadin.ui.TreeGrid) Collectors(java.util.stream.Collectors) TagManagerEvent(de.catma.tag.TagManager.TagManagerEvent) ContextMenu(com.vaadin.contextmenu.ContextMenu) List(java.util.List) Type(com.vaadin.ui.Notification.Type) RendererClickEvent(com.vaadin.ui.renderers.ClickableRenderer.RendererClickEvent) PropertyChangeListener(java.beans.PropertyChangeListener) HorizontalLayout(com.vaadin.ui.HorizontalLayout) TagDefinition(de.catma.tag.TagDefinition) SerializablePredicate(com.vaadin.server.SerializablePredicate) Optional(java.util.Optional) HtmlRenderer(com.vaadin.ui.renderers.HtmlRenderer) SingleTextInputDialog(de.catma.ui.dialog.SingleTextInputDialog) SliderPanelBuilder(org.vaadin.sliderpanel.SliderPanelBuilder) SelectionMode(com.vaadin.ui.Grid.SelectionMode) StyleGenerator(com.vaadin.ui.StyleGenerator) RBACPermission(de.catma.rbac.RBACPermission) SliderMode(org.vaadin.sliderpanel.client.SliderMode) HugeCard(de.catma.ui.component.hugecard.HugeCard) HtmlRenderer(com.vaadin.ui.renderers.HtmlRenderer) SerializablePredicate(com.vaadin.server.SerializablePredicate) ContextMenu(com.vaadin.contextmenu.ContextMenu) ButtonRenderer(com.vaadin.ui.renderers.ButtonRenderer)

Example 2 with ButtonRenderer

use of com.vaadin.ui.renderers.ButtonRenderer in project catma by forTEXT.

the class AnnotateResourcePanel method initComponents.

private void initComponents() {
    addStyleName("annotate-resource-panel");
    Label documentTreeLabel = new Label("Documents & Annotations");
    documentTree = TreeGridFactory.createDefaultTreeGrid();
    documentTree.addStyleNames("resource-grid", "flat-undecorated-icon-buttonrenderer");
    ButtonRenderer<DocumentTreeItem> documentSelectionRenderer = new ButtonRenderer<DocumentTreeItem>(documentSelectionClick -> handleVisibilityClickEvent(documentSelectionClick));
    documentSelectionRenderer.setHtmlContentAllowed(true);
    Column<DocumentTreeItem, String> selectionColumn = documentTree.addColumn(documentTreeItem -> documentTreeItem.getSelectionIcon(), documentSelectionRenderer).setWidth(100);
    documentTree.setHierarchyColumn(selectionColumn);
    documentTree.addColumn(documentTreeItem -> documentTreeItem.getName()).setCaption("Name").setWidth(150);
    documentTree.setHeight("250px");
    documentTree.addColumn(documentTreeItem -> documentTreeItem.getPermissionIcon(), new HtmlRenderer()).setWidth(50);
    documentTree.addColumn(documentTreeItem -> documentTreeItem.getIcon(), new HtmlRenderer()).setExpandRatio(1);
    documentActionGridComponent = new ActionGridComponent<TreeGrid<DocumentTreeItem>>(documentTreeLabel, documentTree);
    documentActionGridComponent.getActionGridBar().setMoreOptionsBtnVisible(false);
    addComponent(documentActionGridComponent);
    Label tagsetLabel = new Label("Tagsets");
    tagsetGrid = new Grid<>();
    tagsetGrid.addStyleNames("resource-grid", "flat-undecorated-icon-buttonrenderer", "no-focused-before-border");
    tagsetGrid.setHeight("250px");
    tagsetGrid.addColumn(tagset -> tagset.getName()).setCaption("Name").setWidth(150);
    tagsetGrid.addColumn(tagset -> project.hasPermission(project.getRoleForTagset(tagset.getUuid()), RBACPermission.TAGSET_WRITE) ? VaadinIcons.UNLOCK.getHtml() : VaadinIcons.LOCK.getHtml(), new HtmlRenderer()).setWidth(50);
    tagsetGrid.addColumn(tagset -> VaadinIcons.TAGS.getHtml(), new HtmlRenderer()).setExpandRatio(1);
    tagsetActionGridComponent = new ActionGridComponent<Grid<TagsetDefinition>>(tagsetLabel, tagsetGrid);
    tagsetActionGridComponent.setSelectionModeFixed(SelectionMode.MULTI);
    tagsetActionGridComponent.getActionGridBar().setMoreOptionsBtnVisible(false);
    tagsetActionGridComponent.getActionGridBar().setMargin(new MarginInfo(false, false, false, true));
    addComponent(tagsetActionGridComponent);
}
Also used : SelectionEvent(com.vaadin.event.selection.SelectionEvent) UI(com.vaadin.ui.UI) SearchFilterProvider(de.catma.ui.component.actiongrid.SearchFilterProvider) ErrorHandler(de.catma.ui.module.main.ErrorHandler) TreeDataProvider(com.vaadin.data.provider.TreeDataProvider) VaadinIcons(com.vaadin.icons.VaadinIcons) DocumentChangeEvent(de.catma.project.event.DocumentChangeEvent) Version(de.catma.tag.Version) Collection(java.util.Collection) Set(java.util.Set) TreeGrid(com.vaadin.ui.TreeGrid) Collectors(java.util.stream.Collectors) MarginInfo(com.vaadin.shared.ui.MarginInfo) List(java.util.List) Type(com.vaadin.ui.Notification.Type) RendererClickEvent(com.vaadin.ui.renderers.ClickableRenderer.RendererClickEvent) PropertyChangeListener(java.beans.PropertyChangeListener) Optional(java.util.Optional) SingleTextInputDialog(de.catma.ui.dialog.SingleTextInputDialog) CollectionChangeEvent(de.catma.project.event.CollectionChangeEvent) SelectionMode(com.vaadin.ui.Grid.SelectionMode) RBACPermission(de.catma.rbac.RBACPermission) Column(com.vaadin.ui.Grid.Column) VerticalLayout(com.vaadin.ui.VerticalLayout) ActionGridComponent(de.catma.ui.component.actiongrid.ActionGridComponent) HashSet(java.util.HashSet) EventBus(com.google.common.eventbus.EventBus) Notification(com.vaadin.ui.Notification) Label(com.vaadin.ui.Label) TagsetDefinition(de.catma.tag.TagsetDefinition) TreeGridFactory(de.catma.ui.component.TreeGridFactory) IDGenerator(de.catma.util.IDGenerator) Subscribe(com.google.common.eventbus.Subscribe) ButtonRenderer(com.vaadin.ui.renderers.ButtonRenderer) SaveCancelListener(de.catma.ui.dialog.SaveCancelListener) PropertyChangeEvent(java.beans.PropertyChangeEvent) ListDataProvider(com.vaadin.data.provider.ListDataProvider) TreeData(com.vaadin.data.TreeData) AnnotationCollectionReference(de.catma.document.annotation.AnnotationCollectionReference) Project(de.catma.project.Project) RepositoryChangeEvent(de.catma.project.Project.RepositoryChangeEvent) SourceDocument(de.catma.document.source.SourceDocument) ProjectReadyEvent(de.catma.project.event.ProjectReadyEvent) TagManagerEvent(de.catma.tag.TagManager.TagManagerEvent) ChangeType(de.catma.project.event.ChangeType) SerializablePredicate(com.vaadin.server.SerializablePredicate) HtmlRenderer(com.vaadin.ui.renderers.HtmlRenderer) Collections(java.util.Collections) Grid(com.vaadin.ui.Grid) TreeGrid(com.vaadin.ui.TreeGrid) Grid(com.vaadin.ui.Grid) Label(com.vaadin.ui.Label) MarginInfo(com.vaadin.shared.ui.MarginInfo) TreeGrid(com.vaadin.ui.TreeGrid) HtmlRenderer(com.vaadin.ui.renderers.HtmlRenderer) ButtonRenderer(com.vaadin.ui.renderers.ButtonRenderer)

Example 3 with ButtonRenderer

use of com.vaadin.ui.renderers.ButtonRenderer 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 4 with ButtonRenderer

use of com.vaadin.ui.renderers.ButtonRenderer 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 5 with ButtonRenderer

use of com.vaadin.ui.renderers.ButtonRenderer 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)

Aggregations

TreeData (com.vaadin.data.TreeData)9 TreeDataProvider (com.vaadin.data.provider.TreeDataProvider)9 Notification (com.vaadin.ui.Notification)9 Type (com.vaadin.ui.Notification.Type)9 TreeGrid (com.vaadin.ui.TreeGrid)9 UI (com.vaadin.ui.UI)9 ButtonRenderer (com.vaadin.ui.renderers.ButtonRenderer)9 HtmlRenderer (com.vaadin.ui.renderers.HtmlRenderer)9 Project (de.catma.project.Project)9 TreeGridFactory (de.catma.ui.component.TreeGridFactory)9 ErrorHandler (de.catma.ui.module.main.ErrorHandler)9 List (java.util.List)9 Set (java.util.Set)9 Collectors (java.util.stream.Collectors)9 VaadinIcons (com.vaadin.icons.VaadinIcons)8 SerializablePredicate (com.vaadin.server.SerializablePredicate)8 HorizontalLayout (com.vaadin.ui.HorizontalLayout)8 VerticalLayout (com.vaadin.ui.VerticalLayout)8 TagDefinition (de.catma.tag.TagDefinition)8 ArrayList (java.util.ArrayList)8