Search in sources :

Example 1 with EditAnnotationPropertiesDialog

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);
        }
    }
}
Also used : TagLibrary(de.catma.tag.TagLibrary) TagDefinition(de.catma.tag.TagDefinition) AnnotationCollection(de.catma.document.annotation.AnnotationCollection) ArrayList(java.util.ArrayList) TextRange(de.catma.ui.client.ui.tagger.shared.TextRange) URISyntaxException(java.net.URISyntaxException) Range(de.catma.document.Range) TextRange(de.catma.ui.client.ui.tagger.shared.TextRange) Annotation(de.catma.document.annotation.Annotation) EditAnnotationPropertiesDialog(de.catma.ui.module.annotate.annotationpanel.EditAnnotationPropertiesDialog) TagInstance(de.catma.tag.TagInstance) ClientTagInstance(de.catma.ui.client.ui.tagger.shared.ClientTagInstance) TagReference(de.catma.document.annotation.TagReference) ArrayList(java.util.ArrayList) List(java.util.List) Property(de.catma.tag.Property)

Aggregations

Range (de.catma.document.Range)1 Annotation (de.catma.document.annotation.Annotation)1 AnnotationCollection (de.catma.document.annotation.AnnotationCollection)1 TagReference (de.catma.document.annotation.TagReference)1 Property (de.catma.tag.Property)1 TagDefinition (de.catma.tag.TagDefinition)1 TagInstance (de.catma.tag.TagInstance)1 TagLibrary (de.catma.tag.TagLibrary)1 ClientTagInstance (de.catma.ui.client.ui.tagger.shared.ClientTagInstance)1 TextRange (de.catma.ui.client.ui.tagger.shared.TextRange)1 EditAnnotationPropertiesDialog (de.catma.ui.module.annotate.annotationpanel.EditAnnotationPropertiesDialog)1 URISyntaxException (java.net.URISyntaxException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1