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