use of de.catma.tag.TagsetDefinition in project catma by forTEXT.
the class AnnotateResourcePanel method initData.
private void initData(SourceDocument currentlySelectedSourceDocument, Set<String> currentlysSelectedColletionIds) {
try {
documentData = new TreeData<>();
Collection<SourceDocument> documents = project.getSourceDocuments();
final SourceDocument preselection = currentlySelectedSourceDocument;
documentData.addRootItems(documents.stream().map(document -> new DocumentDataItem(document, preselection != null && document.equals(preselection))));
DocumentTreeItem preselectedItem = null;
for (DocumentTreeItem documentDataItem : documentData.getRootItems()) {
if (documentDataItem.isSelected()) {
preselectedItem = documentDataItem;
}
for (AnnotationCollectionReference umcRef : ((DocumentDataItem) documentDataItem).getDocument().getUserMarkupCollectionRefs()) {
documentData.addItem(documentDataItem, new CollectionDataItem(umcRef, project.hasPermission(project.getRoleForCollection(umcRef.getId()), RBACPermission.COLLECTION_WRITE), (currentlysSelectedColletionIds.isEmpty() || currentlysSelectedColletionIds.contains(umcRef.getId()))));
}
}
documentTree.setDataProvider(new TreeDataProvider<>(documentData));
if (preselectedItem != null) {
documentTree.expand(preselectedItem);
}
tagsetData = new ListDataProvider<TagsetDefinition>(project.getTagsets());
tagsetGrid.setDataProvider(tagsetData);
tagsetData.getItems().forEach(tagsetGrid::select);
documentData.getRootItems().stream().filter(documentItem -> documentItem.isSelected()).findAny().ifPresent(documentItem -> documentTree.expand(documentItem));
} catch (Exception e) {
errorHandler.showAndLogError("Error loading data!", e);
}
}
Aggregations