use of de.catma.document.annotation.Annotation in project catma by forTEXT.
the class AnnotationDetailsPanel method handleDeleteAnnotationRequest.
private void handleDeleteAnnotationRequest(RendererClickEvent<AnnotationTreeItem> clickEvent) {
AnnotationDataItem item = (AnnotationDataItem) clickEvent.getItem();
final Annotation annotation = item.getAnnotation();
if (project.hasPermission(project.getRoleForCollection(annotation.getUserMarkupCollection().getUuid()), RBACPermission.COLLECTION_WRITE)) {
if (!isCurrentEditedCollection.apply(annotation.getUserMarkupCollection().getUuid())) {
changeCollectionListener.accept(annotation.getUserMarkupCollection().getUuid());
annotationDetailsProvider.refreshAll();
} else {
ConfirmDialog.show(UI.getCurrent(), "Info", "Are you sure you want to delete this Annotation?", "Delete", "Cancel", dlg -> {
if (dlg.isConfirmed()) {
collectionManager.removeTagInstance(annotation.getTagInstance().getUuid());
}
});
}
} else {
Notification.show("Info", "You do not have the permission to make changes to the Collection of this Annotation, " + "please contact the Project maintainer!", Type.HUMANIZED_MESSAGE);
}
}
use of de.catma.document.annotation.Annotation in project catma by forTEXT.
the class TaggerView method tagInstanceAdded.
public void tagInstanceAdded(ClientTagInstance clientTagInstance) {
AnnotationCollection collection = annotationPanel.getSelectedEditableCollection();
if (collection == null) {
// shouldn't happen, but just in case
Notification.show("Info", "Please make sure you have an editable Collection available " + "and select this Collection as 'currently being edited'! " + "Your Annotation hasn't been saved!", Type.ERROR_MESSAGE);
} else {
TagLibrary tagLibrary = collection.getTagLibrary();
TagDefinition tagDef = tagLibrary.getTagDefinition(clientTagInstance.getTagDefinitionID());
TagInstance ti = new TagInstance(clientTagInstance.getInstanceID(), tagDef.getUuid(), project.getUser().getIdentifier(), ZonedDateTime.now().format(DateTimeFormatter.ofPattern(Version.DATETIMEPATTERN)), tagDef.getUserDefinedPropertyDefinitions(), tagDef.getTagsetDefinitionUuid());
List<TagReference> tagReferences = new ArrayList<TagReference>();
try {
String userMarkupCollectionUuid = collection.getId();
for (TextRange tr : clientTagInstance.getRanges()) {
Range r = new Range(tr.getStartPos(), tr.getEndPos());
TagReference ref = new TagReference(ti, sourceDocument.getUuid(), r, userMarkupCollectionUuid);
tagReferences.add(ref);
}
final Annotation annotation = new Annotation(ti, tagReferences, collection, tagLibrary.getTagPath(tagDef));
if (!tagDef.getUserDefinedPropertyDefinitions().isEmpty()) {
EditAnnotationPropertiesDialog editAnnotationPropertiesDialog = new EditAnnotationPropertiesDialog(project, annotation, new SaveCancelListener<List<Property>>() {
@Override
public void savePressed(List<Property> notOfInterest) {
userMarkupCollectionManager.addTagReferences(tagReferences, collection);
}
});
editAnnotationPropertiesDialog.show();
} else {
userMarkupCollectionManager.addTagReferences(tagReferences, collection);
}
} catch (URISyntaxException e) {
errorHandler.showAndLogError("Error adding Annotations!", e);
}
}
}
use of de.catma.document.annotation.Annotation in project catma by forTEXT.
the class AnnotationDetailsPanel method initListeners.
private void initListeners() {
annotationPropertiesChangedListener = new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
TagInstance tagInstance = (TagInstance) evt.getOldValue();
findAnnotationDataItem(tagInstance.getUuid()).ifPresent(annotationDataItem -> {
Annotation annotation = annotationDataItem.getAnnotation();
annotationDetailData.removeItem(annotationDataItem);
try {
addAnnotation(annotation);
} catch (Exception e) {
((ErrorHandler) UI.getCurrent()).showAndLogError("error adding Annotation", e);
}
});
}
};
project.addPropertyChangeListener(RepositoryChangeEvent.propertyValueChanged, annotationPropertiesChangedListener);
propertyDefinitionChangedListener = new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
refreshAnnotations();
}
};
project.getTagManager().addPropertyChangeListener(TagManagerEvent.userPropertyDefinitionChanged, propertyDefinitionChangedListener);
tagChangedListener = new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
if ((evt.getOldValue() != null) && (evt.getNewValue() == null)) {
}
refreshAnnotations();
}
};
project.getTagManager().addPropertyChangeListener(TagManagerEvent.tagDefinitionChanged, tagChangedListener);
}
use of de.catma.document.annotation.Annotation in project catma by forTEXT.
the class AnnotationDetailsPanel method initComponents.
private void initComponents() {
setSpacing(true);
setMargin(false);
setSizeFull();
addStyleName("annotation-details-panel");
HorizontalLayout headerPanel = new HorizontalLayout();
headerPanel.setWidth("100%");
addComponent(headerPanel);
btClearSelected = new IconButton(VaadinIcons.ERASER);
btClearSelected.setDescription("Clear the list of selected Annotations");
headerPanel.addComponent(btClearSelected);
headerPanel.setComponentAlignment(btClearSelected, Alignment.TOP_RIGHT);
headerPanel.setExpandRatio(btClearSelected, 1.0f);
btMinimize = new IconButton(VaadinIcons.ANGLE_DOUBLE_DOWN);
headerPanel.addComponent(btMinimize);
headerPanel.setComponentAlignment(btMinimize, Alignment.TOP_RIGHT);
annotationDetailData = new TreeData<>();
annotationDetailsProvider = new TreeDataProvider<>(annotationDetailData);
annotationDetailsTree = TreeGridFactory.createDefaultGrid(annotationDetailsProvider);
annotationDetailsTree.setSizeFull();
annotationDetailsTree.addStyleNames("annotation-details-panel-annotation-details-grid", "flat-undecorated-icon-buttonrenderer");
annotationDetailsTree.addColumn(annotationTreeItem -> annotationTreeItem.getDetail(), new HtmlRenderer()).setCaption("Annotation").setWidth(200).setSortable(false);
annotationDetailsTree.addColumn(annotationTreeItem -> annotationTreeItem.getTag()).setCaption("Tag").setSortable(false).setWidth(80);
annotationDetailsTree.addColumn(annotationTreeItem -> annotationTreeItem.getAuthor()).setCaption("Author").setSortable(false).setWidth(60);
annotationDetailsTree.addColumn(annotationTreeItem -> annotationTreeItem.getCollection()).setCaption("Collection").setSortable(false).setWidth(60);
annotationDetailsTree.addColumn(annotationTreeItem -> annotationTreeItem.getTagset()).setCaption("Tagset").setSortable(false).setWidth(70);
annotationDetailsTree.addColumn(annotationTreeItem -> annotationTreeItem.getAnnotationId()).setCaption("Annotation ID").setHidable(true).setHidden(true).setSortable(false).setWidth(100);
ButtonRenderer<AnnotationTreeItem> editAnnotationRenderer = new ButtonRenderer<AnnotationTreeItem>(clickEvent -> handleEditAnnotationRequest(clickEvent));
editAnnotationRenderer.setHtmlContentAllowed(true);
annotationDetailsTree.addColumn(annotationTreeItem -> annotationTreeItem.getEditIcon(), editAnnotationRenderer).setWidth(50);
ButtonRenderer<AnnotationTreeItem> deleteAnnotationRenderer = new ButtonRenderer<AnnotationTreeItem>(clickEvent -> handleDeleteAnnotationRequest(clickEvent));
deleteAnnotationRenderer.setHtmlContentAllowed(true);
annotationDetailsTree.addColumn(annotationTreeItem -> annotationTreeItem.getDeleteIcon(), deleteAnnotationRenderer).setExpandRatio(1);
annotationDetailsTree.setDescriptionGenerator(new DescriptionGenerator<AnnotationTreeItem>() {
@Override
public String apply(AnnotationTreeItem annotationTreeItem) {
return annotationTreeItem.getDescription();
}
}, ContentMode.HTML);
ActionGridComponent<TreeGrid<AnnotationTreeItem>> annotationDetailsGridComponent = new ActionGridComponent<>(new Label("Selected Annotations"), annotationDetailsTree);
annotationDetailsGridComponent.setMargin(false);
addComponent(annotationDetailsGridComponent);
setExpandRatio(annotationDetailsGridComponent, 1.0f);
}
use of de.catma.document.annotation.Annotation in project catma by forTEXT.
the class AnnotationDetailsPanel method handleEditAnnotationRequest.
private void handleEditAnnotationRequest(RendererClickEvent<AnnotationTreeItem> clickEvent) {
AnnotationDataItem item = (AnnotationDataItem) clickEvent.getItem();
final Annotation annotation = item.getAnnotation();
if (project.hasPermission(project.getRoleForCollection(annotation.getUserMarkupCollection().getUuid()), RBACPermission.COLLECTION_WRITE)) {
String tagId = annotation.getTagInstance().getTagDefinitionId();
TagDefinition tag = project.getTagManager().getTagLibrary().getTagDefinition(tagId);
if (tag.getUserDefinedPropertyDefinitions().isEmpty()) {
Notification.show("Info", "There are no Properties defined for the Tag of this Annotation!", Type.HUMANIZED_MESSAGE);
} else {
EditAnnotationPropertiesDialog editAnnotationPropertiesDialog = new EditAnnotationPropertiesDialog(project, annotation, new SaveCancelListener<List<Property>>() {
@Override
public void savePressed(List<Property> result) {
try {
collectionManager.updateProperty(annotation.getUserMarkupCollection(), annotation.getTagInstance(), result);
} catch (IOException e) {
((ErrorHandler) UI.getCurrent()).showAndLogError("error updating Annotation Properties", e);
}
}
});
editAnnotationPropertiesDialog.show();
}
} else {
Notification.show("Info", "You do not have the permission to make changes to the Collection of this Annotation, " + "please contact the Project maintainer!", Type.HUMANIZED_MESSAGE);
}
}
Aggregations