use of com.vaadin.contextmenu.ContextMenu in project catma by forTEXT.
the class ProjectView method initActions.
private void initActions() {
documentGridComponent.setSearchFilterProvider(searchInput -> createSearchFilter(searchInput));
documentGrid.addItemClickListener(itemClickEvent -> handleResourceItemClick(itemClickEvent));
ContextMenu addContextMenu = documentGridComponent.getActionGridBar().getBtnAddContextMenu();
MenuItem addDocumentBtn = addContextMenu.addItem("Add Document", clickEvent -> handleAddDocumentRequest());
addDocumentBtn.setEnabled(false);
rbacEnforcer.register(RBACConstraint.ifAuthorized(role -> (project.hasPermission(role, RBACPermission.DOCUMENT_CREATE_OR_UPLOAD)), () -> addDocumentBtn.setEnabled(true)));
MenuItem addCollectionBtn = addContextMenu.addItem("Add Annotation Collection", e -> handleAddCollectionRequest());
addCollectionBtn.setEnabled(false);
rbacEnforcer.register(RBACConstraint.ifAuthorized(role -> (project.hasPermission(role, RBACPermission.COLLECTION_CREATE)), () -> addCollectionBtn.setEnabled(true)));
ContextMenu documentsGridMoreOptionsContextMenu = documentGridComponent.getActionGridBar().getBtnMoreOptionsContextMenu();
MenuItem editDocBtn = documentsGridMoreOptionsContextMenu.addItem("Edit Documents / Collections", (menuItem) -> handleEditResources());
editDocBtn.setEnabled(false);
rbacEnforcer.register(RBACConstraint.ifAuthorized(role -> (project.hasPermission(role, RBACPermission.COLLECTION_DELETE_OR_EDIT) || project.hasPermission(role, RBACPermission.DOCUMENT_DELETE_OR_EDIT)), () -> editDocBtn.setEnabled(true)));
MenuItem deleteDocsBtn = documentsGridMoreOptionsContextMenu.addItem("Delete Documents / Collections", (menuItem) -> handleDeleteResources(menuItem, documentGrid));
deleteDocsBtn.setEnabled(false);
rbacEnforcer.register(RBACConstraint.ifAuthorized(role -> (project.hasPermission(role, RBACPermission.COLLECTION_DELETE_OR_EDIT) || project.hasPermission(role, RBACPermission.DOCUMENT_DELETE_OR_EDIT)), () -> deleteDocsBtn.setEnabled(true)));
documentsGridMoreOptionsContextMenu.addItem("Analyze Documents / Collections", (menuItem) -> handleAnalyzeResources(menuItem, documentGrid));
documentsGridMoreOptionsContextMenu.addItem("Import a Collection", mi -> handleImportCollectionRequest());
MenuItem miExportCollections = documentsGridMoreOptionsContextMenu.addItem("Export Documents & Collections");
StreamResource collectionXmlExportResource = new StreamResource(new CollectionXMLExportStreamSource(() -> getSelectedDocuments(), () -> documentGrid.getSelectedItems().stream().filter(resource -> resource.isCollection()).map(resource -> ((CollectionResource) resource).getCollectionReference()).collect(Collectors.toList()), () -> project), "CATMA-Corpus_Export-" + LocalDateTime.now().format(DateTimeFormatter.ISO_DATE_TIME) + ".tar.gz");
collectionXmlExportResource.setCacheTime(0);
collectionXmlExportResource.setMIMEType("application/gzip");
FileDownloader collectionXmlExportFileDownloader = new FileDownloader(collectionXmlExportResource);
collectionXmlExportFileDownloader.extend(miExportCollections);
documentsGridMoreOptionsContextMenu.addItem("Select filtered entries", mi -> handleSelectFilteredDocuments());
tagsetGridComponent.getActionGridBar().addBtnAddClickListener(click -> handleAddTagsetRequest());
tagsetGridComponent.getActionGridBar().setAddBtnEnabled(false);
rbacEnforcer.register(RBACConstraint.ifAuthorized(role -> project.hasPermission(role, RBACPermission.TAGSET_CREATE_OR_UPLOAD), () -> tagsetGridComponent.getActionGridBar().setAddBtnEnabled(true)));
ContextMenu moreOptionsMenu = tagsetGridComponent.getActionGridBar().getBtnMoreOptionsContextMenu();
MenuItem editTagset = moreOptionsMenu.addItem("Edit Tagset", mi -> handleEditTagsetRequest());
editTagset.setEnabled(false);
rbacEnforcer.register(RBACConstraint.ifAuthorized(role -> (project.hasPermission(role, RBACPermission.TAGSET_DELETE_OR_EDIT)), () -> editTagset.setEnabled(true)));
MenuItem deleteTagSetBtn = moreOptionsMenu.addItem("Delete Tagset", mi -> handleDeleteTagsetRequest());
deleteTagSetBtn.setEnabled(false);
rbacEnforcer.register(RBACConstraint.ifAuthorized(role -> (project.hasPermission(role, RBACPermission.TAGSET_DELETE_OR_EDIT)), () -> deleteTagSetBtn.setEnabled(true)));
MenuItem importTagSetBtn = moreOptionsMenu.addItem("Import Tagsets", mi -> handleImportTagsetsRequest());
importTagSetBtn.setEnabled(false);
rbacEnforcer.register(RBACConstraint.ifAuthorized(role -> (project.hasPermission(role, RBACPermission.TAGSET_CREATE_OR_UPLOAD)), () -> importTagSetBtn.setEnabled(true)));
MenuItem miExportTagsets = moreOptionsMenu.addItem("Export Tagsets");
MenuItem miExportTagsetsAsXML = miExportTagsets.addItem("as XML");
StreamResource tagsetXmlExportResource = new StreamResource(new TagsetXMLExportStreamSource(() -> tagsetGrid.getSelectedItems(), () -> project), "CATMA-Tag-Library_Export-" + LocalDateTime.now().format(DateTimeFormatter.ISO_DATE_TIME) + ".xml");
tagsetXmlExportResource.setCacheTime(0);
tagsetXmlExportResource.setMIMEType("text/xml");
FileDownloader tagsetXmlExportFileDownloader = new FileDownloader(tagsetXmlExportResource);
tagsetXmlExportFileDownloader.extend(miExportTagsetsAsXML);
MenuItem miExportTagsetsAsCSV = miExportTagsets.addItem("as CSV");
StreamResource tagsetCsvExportResource = new StreamResource(new TagsetCSVExportStreamSource(() -> tagsetGrid.getSelectedItems(), () -> project), "CATMA-Tag-Library_Export-" + LocalDateTime.now().format(DateTimeFormatter.ISO_DATE_TIME) + ".csv");
tagsetCsvExportResource.setCacheTime(0);
tagsetCsvExportResource.setMIMEType("text/comma-separated-values");
FileDownloader tagsetCsvExportFileDownloader = new FileDownloader(tagsetCsvExportResource);
tagsetCsvExportFileDownloader.extend(miExportTagsetsAsCSV);
moreOptionsMenu.addItem("Fork Tagsets into another Project", miForkTagset -> handleForkTagsetRequest());
ContextMenu hugeCardMoreOptions = getMoreOptionsContextMenu();
hugeCardMoreOptions.addItem("Commit all changes", mi -> handleCommitRequest());
hugeCardMoreOptions.addItem("Synchronize with the team", mi -> handleSynchronizeRequest());
hugeCardMoreOptions.addSeparator();
hugeCardMoreOptions.addItem("Share project resources (experimental API)", mi -> handleShareProjectResources());
MenuItem miImportCorpus = hugeCardMoreOptions.addItem("Import CATMA 5 Corpus", mi -> handleCorpusImport());
miImportCorpus.setVisible(CATMAPropertyKey.EXPERT.getValue(false) || Boolean.valueOf(((CatmaApplication) UI.getCurrent()).getParameter(Parameter.EXPERT, Boolean.FALSE.toString())));
btSynchBell.addClickListener(event -> handleBtSynchBellClick(event));
// TODO:
// hugeCardMoreOptions.addItem("Print status", e -> project.printStatus());
tagsetGridComponent.setSearchFilterProvider(new SearchFilterProvider<TagsetDefinition>() {
@Override
public SerializablePredicate<TagsetDefinition> createSearchFilter(final String searchInput) {
return new SerializablePredicate<TagsetDefinition>() {
@Override
public boolean test(TagsetDefinition t) {
if (t != null) {
String name = t.getName();
if (name != null) {
return name.toLowerCase().contains(searchInput.toLowerCase());
}
}
return false;
}
};
}
});
tagsetGrid.addItemClickListener(clickEvent -> handleTagsetClick(clickEvent));
}
use of com.vaadin.contextmenu.ContextMenu 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.contextmenu.ContextMenu in project catma by forTEXT.
the class KwicPanel method initActions.
private void initActions(EventBus eventBus) {
ContextMenu moreOptionsMenu = kwicGridComponent.getActionGridBar().getBtnMoreOptionsContextMenu();
moreOptionsMenu.addItem("Annotate selected rows", mi -> handleAnnotateSelectedRequest(eventBus));
ActionGridBar actionBar = kwicGridComponent.getActionGridBar();
actionBar.addButtonAfterSearchField(btnClearSelectedRows);
btnClearSelectedRows.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
handleRemoveRowRequest();
}
});
miRemoveAnnotations = moreOptionsMenu.addItem("Remove selected Annotations", mi -> handleRemoveAnnotationsRequest(eventBus));
miRemoveAnnotations.setEnabled(false);
MenuItem miExport = moreOptionsMenu.addItem("Export");
MenuItem miCSVFlatExport = miExport.addItem("Export as CSV");
StreamResource csvFlatExportResource = new StreamResource(new CSVExportFlatStreamSource(() -> getFilteredQueryResult(), project, kwicItemHandler.getKwicProviderCache(), ((BackgroundServiceProvider) UI.getCurrent())), "CATMA-KWIC_Export-" + LocalDateTime.now().format(DateTimeFormatter.ISO_DATE_TIME) + ".csv");
csvFlatExportResource.setCacheTime(0);
csvFlatExportResource.setMIMEType("text/comma-separated-values");
FileDownloader csvFlatExportFileDownloader = new FileDownloader(csvFlatExportResource);
csvFlatExportFileDownloader.extend(miCSVFlatExport);
kwicGridComponent.setSearchFilterProvider(new SearchFilterProvider<QueryResultRow>() {
@Override
public SerializablePredicate<QueryResultRow> createSearchFilter(String searchInput) {
return (row) -> kwicItemHandler.containsSearchInput(row, searchInput);
}
});
btExpandCompress.addClickListener(clickEvent -> handleMaxMinRequest());
defaultDoubleClickRegistration = kwicGrid.addItemClickListener(clickEvent -> handleKwicItemClick(clickEvent, eventBus));
}
use of com.vaadin.contextmenu.ContextMenu in project catma by forTEXT.
the class QueryResultPanel method createButtonBar.
private void createButtonBar(boolean cardStyle) {
buttonPanel = new HorizontalLayout();
buttonPanel.setWidth("100%");
searchField = new TextField();
searchField.setPlaceholder("\u2315");
buttonPanel.addComponent(searchField);
buttonPanel.setComponentAlignment(searchField, Alignment.MIDDLE_RIGHT);
buttonPanel.setExpandRatio(searchField, 1f);
caretRightBt = new IconButton(VaadinIcons.CARET_RIGHT);
caretRightBt.setVisible(cardStyle);
caretDownBt = new IconButton(VaadinIcons.CARET_DOWN);
caretDownBt.setVisible(cardStyle);
optionsBt = new IconButton(VaadinIcons.ELLIPSIS_DOTS_V);
optionsMenu = new ContextMenu(optionsBt, true);
removeBt = new IconButton(VaadinIcons.ERASER);
buttonPanel.addComponents(removeBt, optionsBt, caretRightBt);
buttonPanel.setComponentAlignment(caretRightBt, Alignment.MIDDLE_RIGHT);
buttonPanel.setComponentAlignment(optionsBt, Alignment.MIDDLE_RIGHT);
buttonPanel.setComponentAlignment(removeBt, Alignment.MIDDLE_RIGHT);
if (cardStyle) {
buttonPanel.addStyleName("analyze-card-buttonbar");
searchField.setEnabled(false);
} else {
buttonPanel.addStyleName("analyze-query-result-panel-buttonbar");
}
addComponent(buttonPanel);
}
use of com.vaadin.contextmenu.ContextMenu in project catma by forTEXT.
the class CollectionSelectionStep method initActions.
private void initActions() {
documentGridComponent.setSearchFilterProvider(searchInput -> createSearchFilter(searchInput));
documentGridComponent.getActionGridBar().addBtnAddClickListener(clickEvent -> handleAddCollectionRequest());
ContextMenu documentsGridMoreOptionsContextMenu = documentGridComponent.getActionGridBar().getBtnMoreOptionsContextMenu();
documentsGridMoreOptionsContextMenu.addItem("Select filtered Documents", mi -> handleSelectFilteredDocuments());
documentsGridMoreOptionsContextMenu.addItem("Select filtered Collections", mi -> handleSelectFilteredCollections());
documentGrid.addSelectionListener(event -> {
if (stepChangeListener != null) {
stepChangeListener.stepChanged(this);
}
});
}
Aggregations