use of de.catma.project.Project in project catma by forTEXT.
the class KwicPanel method handleKwicItemClick.
private void handleKwicItemClick(ItemClick<QueryResultRow> clickEvent, EventBus eventBus) {
if (clickEvent.getMouseEventDetails().isDoubleClick()) {
QueryResultRow selectedRow = clickEvent.getItem();
final String documentId = selectedRow.getSourceDocumentId();
List<QueryResultRow> documentRows = kwicDataProvider.getItems().parallelStream().filter(row -> row.getSourceDocumentId().equals(documentId)).collect(Collectors.toList());
try {
if (project.hasDocument(documentId)) {
eventBus.post(new QueryResultRowInAnnotateEvent(documentId, selectedRow, documentRows, project));
} else {
Notification.show("Info", "The corresponding Document is no longer part of the Project!", Type.WARNING_MESSAGE);
}
} catch (Exception e) {
((ErrorHandler) UI.getCurrent()).showAndLogError("error accessing project data", e);
}
}
}
use of de.catma.project.Project in project catma by forTEXT.
the class KwicPanel method handleAnnotateSelectedRequest.
private void handleAnnotateSelectedRequest(EventBus eventBus) {
final Set<QueryResultRow> selectedRows = kwicGrid.getSelectedItems();
if (selectedRows.isEmpty()) {
Notification.show("Info", "Please select one or more rows to annotate!", Type.HUMANIZED_MESSAGE);
return;
}
Set<String> documentIds = kwicDataProvider.getItems().stream().map(row -> row.getSourceDocumentId()).collect(Collectors.toSet());
WizardContext wizardContext = new WizardContext();
wizardContext.put(AnnotationWizardContextKey.DOCUMENTIDS, documentIds);
AnnotationWizard wizard = new AnnotationWizard(eventBus, project, wizardContext, new SaveCancelListener<WizardContext>() {
@Override
public void savePressed(WizardContext result) {
try {
annotateSelection(selectedRows, result);
} catch (Exception e) {
((ErrorHandler) UI.getCurrent()).showAndLogError("error annotating selected rows", e);
}
}
});
wizard.show();
}
use of de.catma.project.Project 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.project.Project in project catma by forTEXT.
the class QueryResultPanel method initActions.
private void initActions(CloseListener resultPanelCloseListener) {
if (cardStyle) {
caretRightBt.addClickListener(new ClickListener() {
public void buttonClick(ClickEvent event) {
addComponent(treeGridPanel);
((HorizontalLayout) caretRightBt.getParent()).replaceComponent(caretRightBt, caretDownBt);
searchField.setEnabled(true);
}
});
caretDownBt.addClickListener(new ClickListener() {
public void buttonClick(ClickEvent event) {
removeComponent(treeGridPanel);
((HorizontalLayout) caretDownBt.getParent()).replaceComponent(caretDownBt, caretRightBt);
searchField.setEnabled(false);
}
});
}
optionsBt.addClickListener((evt) -> optionsMenu.open(evt.getClientX(), evt.getClientY()));
miGroupByPhrase = optionsMenu.addItem("Group by Phrase", mi -> initPhraseBasedData());
miGroupByPhrase.setEnabled(false);
miGroupByTagPath = optionsMenu.addItem("Group by Tag Path", mi -> initTagBasedData());
miFlatTable = optionsMenu.addItem("Display Annotations as flat table", mi -> initFlatTagBasedData());
miPropertiesAsColumns = optionsMenu.addItem("Display Properties as columns", mi -> initPropertiesAsColumnsTagBasedData());
MenuItem miExport = optionsMenu.addItem("Export");
MenuItem miCSVFlatExport = miExport.addItem("Export flat as CSV");
StreamResource csvFlatExportResource = new StreamResource(new CSVExportFlatStreamSource(() -> getFilteredQueryResult(), project, kwicProviderCache, ((BackgroundServiceProvider) UI.getCurrent())), "CATMA-Query-Result_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);
MenuItem miCSVGroupedByPhraseExport = miExport.addItem("Export grouped as CSV");
StreamResource csvGroupedByPhraseExportResource = new StreamResource(new CSVExportGroupedStreamSource(() -> getFilteredQueryResult(), project, () -> getDisplaySetting().equals(DisplaySetting.GROUPED_BY_TAG), kwicProviderCache, ((BackgroundServiceProvider) UI.getCurrent())), "CATMA-Query-Result_Export-" + LocalDateTime.now().format(DateTimeFormatter.ISO_DATE_TIME) + ".csv");
csvGroupedByPhraseExportResource.setCacheTime(0);
csvGroupedByPhraseExportResource.setMIMEType("text/comma-separated-values");
FileDownloader csvGroupedByPhraseExportFileDownloader = new FileDownloader(csvGroupedByPhraseExportResource);
csvGroupedByPhraseExportFileDownloader.extend(miCSVGroupedByPhraseExport);
MenuItem miFilterPunctuation = optionsMenu.addItem("Filter punctuation", mi -> queryResultGrid.getDataProvider().refreshAll());
miFilterPunctuation.setCheckable(true);
miFilterPunctuation.setChecked(true);
punctuationFilter = new PunctuationFilter(() -> miFilterPunctuation.isChecked());
if (resultPanelCloseListener != null) {
removeBt.addClickListener(clickEvent -> resultPanelCloseListener.closeRequest(QueryResultPanel.this));
} else {
removeBt.setVisible(false);
}
searchField.addValueChangeListener(event -> handleSearchValueInput(event.getValue()));
}
use of de.catma.project.Project in project catma by forTEXT.
the class AnalyzeResourcePanel method initData.
private void initData() {
documentData = new TreeData<>();
try {
Collection<SourceDocument> documents = project.getSourceDocuments();
documentData.addRootItems(documents.stream().map(document -> new DocumentDataItem(document)));
for (DocumentTreeItem documentDataItem : documentData.getRootItems()) {
for (AnnotationCollectionReference umcRef : ((DocumentDataItem) documentDataItem).getDocument().getUserMarkupCollectionRefs()) {
documentData.addItem(documentDataItem, new CollectionDataItem(umcRef, project.hasPermission(project.getRoleForCollection(umcRef.getId()), RBACPermission.COLLECTION_WRITE)));
}
}
documentTree.setDataProvider(new TreeDataProvider<>(documentData));
Collection<SourceDocument> selectedDocuments = corpus.getSourceDocuments();
Collection<AnnotationCollectionReference> selectedCollections = corpus.getUserMarkupCollectionRefs();
documentData.getRootItems().stream().filter(documentItem -> selectedDocuments.contains(((DocumentDataItem) documentItem).getDocument())).forEach(documentTree::select);
for (DocumentTreeItem documentDataItem : documentData.getRootItems()) {
List<DocumentTreeItem> collectionItems = documentData.getChildren(documentDataItem);
for (DocumentTreeItem oneCollection : collectionItems) {
if (selectedCollections.contains(((CollectionDataItem) oneCollection).getCollectionRef())) {
documentTree.getSelectionModel().select(oneCollection);
}
}
}
documentTree.expand(documentData.getRootItems());
} catch (Exception e) {
((ErrorHandler) UI.getCurrent()).showAndLogError("error loading Project data", e);
}
}
Aggregations