use of de.catma.ui.module.annotate.annotationpanel.EditAnnotationPropertiesDialog 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);
}
}
}
Aggregations