use of de.catma.ui.component.actiongrid.SearchFilterProvider 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 de.catma.ui.component.actiongrid.SearchFilterProvider 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 de.catma.ui.component.actiongrid.SearchFilterProvider 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 de.catma.ui.component.actiongrid.SearchFilterProvider in project catma by forTEXT.
the class TagSelectionPanel 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).setExpandRatio(1));
tagsetGridComponent.setSearchFilterProvider(new SearchFilterProvider<TagsetTreeItem>() {
@Override
public SerializablePredicate<TagsetTreeItem> createSearchFilter(String searchInput) {
return new TagsetSearchFilterProvider(searchInput, tagsetData);
}
});
ContextMenu addContextMenu = tagsetGridComponent.getActionGridBar().getBtnAddContextMenu();
addContextMenu.addItem("Add Tagset", clickEvent -> handleAddTagsetRequest());
addContextMenu.addItem("Add Tag", clickEvent -> handleAddTagRequest());
addContextMenu.addItem("Add Subtag", clickEvent -> handleAddSubtagRequest());
tagsetGrid.addExpandListener(expandEvent -> expandEvent.getExpandedItem().setTagsetExpanded(true));
tagsetGrid.addCollapseListener(collapseEvent -> collapseEvent.getCollapsedItem().setTagsetExpanded(false));
}
use of de.catma.ui.component.actiongrid.SearchFilterProvider in project catma by forTEXT.
the class AnnotationPanel method initActions.
private void initActions(Consumer<AnnotationCollection> collectionSelectionListener, Consumer<TagDefinition> tagSelectionListener) {
tagsetGrid.addColumn(tagsetTreeItem -> tagsetTreeItem.getColor(), new HtmlRenderer()).setCaption("Tagsets").setSortable(false).setWidth(100);
tagsetGrid.setHierarchyColumn(tagsetGrid.addColumn(tagsetTreeItem -> tagsetTreeItem.getName()).setCaption("Tags").setSortable(false).setWidth(200));
ButtonRenderer<TagsetTreeItem> propertySummaryRenderer = new ButtonRenderer<>(rendererClickEvent -> handlePropertySummaryClickEvent(rendererClickEvent));
propertySummaryRenderer.setHtmlContentAllowed(true);
tagsetGrid.addColumn(tagsetTreeItem -> tagsetTreeItem.getPropertySummary(), propertySummaryRenderer).setCaption("Properties").setSortable(false).setHidable(true).setWidth(100);
tagsetGrid.addColumn(tagsetTreeItem -> tagsetTreeItem.getPropertyValue()).setCaption("Values").setSortable(false).setHidable(true).setWidth(100);
ButtonRenderer<TagsetTreeItem> visibilityRenderer = new ButtonRenderer<TagsetTreeItem>(rendererClickEvent -> handleVisibilityClickEvent(rendererClickEvent));
visibilityRenderer.setHtmlContentAllowed(true);
tagsetGrid.addColumn(tagsetTreeItem -> tagsetTreeItem.getVisibilityIcon(), visibilityRenderer).setWidth(80).setSortable(false);
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 SerializablePredicate<TagsetTreeItem>() {
@Override
public boolean test(TagsetTreeItem t) {
return testWithChildren(t);
}
private boolean testTagsetTreeItem(TagsetTreeItem t) {
String strValue = t.toString();
if (strValue != null && strValue.toLowerCase().contains(searchInput.toLowerCase())) {
return true;
}
return false;
}
public boolean testWithChildren(TagsetTreeItem t) {
if (t == null) {
return false;
}
if (testTagsetTreeItem(t)) {
return true;
}
for (TagsetTreeItem child : tagsetData.getChildren(t)) {
if (testWithChildren(child)) {
return true;
}
}
return false;
}
};
}
});
tagsetGrid.addItemClickListener(clickEvent -> handleTagSelection(clickEvent, tagSelectionListener));
tagsetGrid.addCollapseListener(event -> event.getCollapsedItem().setTagsetExpanded(false));
tagsetGrid.addExpandListener(event -> event.getExpandedItem().setTagsetExpanded(true));
ContextMenu addContextMenu = tagsetGridComponent.getActionGridBar().getBtnAddContextMenu();
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("Edit/Delete Properties", clickEvent -> handleEditPropertiesRequest());
currentEditableCollectionBox.addValueChangeListener(event -> collectionSelectionListener.accept(event.getValue()));
annotationDetailsPanel.addMinimizeButtonClickListener(clickEvent -> setAnnotationDetailsPanelVisible(false));
btMaximizeAnnotationDetailsRibbon.addClickListener(ClickEvent -> setAnnotationDetailsPanelVisible(true));
btAddCollection.addClickListener(clickEvent -> handelAddCollectionRequest());
}
Aggregations