use of de.catma.tag.TagInstance 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.tag.TagInstance in project catma by forTEXT.
the class TaggerView method initListeners.
private void initListeners() {
this.tagReferencesChangedListener = new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getNewValue() != null) {
@SuppressWarnings("unchecked") Pair<AnnotationCollection, List<TagReference>> changeValue = (Pair<AnnotationCollection, List<TagReference>>) evt.getNewValue();
List<TagReference> tagReferences = changeValue.getSecond();
List<TagReference> relevantTagReferences = new ArrayList<TagReference>();
for (TagReference tr : tagReferences) {
if (isRelevantTagReference(tr, userMarkupCollectionManager.getUserMarkupCollections())) {
relevantTagReferences.add(tr);
}
}
tagger.setVisible(relevantTagReferences, true);
Set<String> tagInstanceUuids = new HashSet<String>();
for (TagReference tr : relevantTagReferences) {
tagInstanceUuids.add(tr.getTagInstance().getUuid());
}
tagInstanceUuids.forEach(annotationId -> tagger.updateAnnotation(annotationId));
} else if (evt.getOldValue() != null) {
@SuppressWarnings("unchecked") Pair<String, Collection<String>> changeValue = (Pair<String, Collection<String>>) evt.getOldValue();
String collectionId = changeValue.getFirst();
Collection<String> annotationIds = changeValue.getSecond();
if (userMarkupCollectionManager.contains(collectionId)) {
userMarkupCollectionManager.removeTagInstance(annotationIds, false);
}
tagger.removeTagInstances(annotationIds);
annotationPanel.removeAnnotations(annotationIds);
}
}
};
project.addPropertyChangeListener(RepositoryChangeEvent.tagReferencesChanged, tagReferencesChangedListener);
annotationPropertiesChangedListener = new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
TagInstance tagInstance = (TagInstance) evt.getOldValue();
tagger.updateAnnotation(tagInstance.getUuid());
}
};
project.addPropertyChangeListener(RepositoryChangeEvent.propertyValueChanged, annotationPropertiesChangedListener);
tagChangedListener = new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
Object newValue = evt.getNewValue();
Object oldValue = evt.getOldValue();
if (oldValue == null) {
// created
// noop
} else if (newValue == null) {
// removed
@SuppressWarnings("unchecked") Pair<TagsetDefinition, TagDefinition> deleted = (Pair<TagsetDefinition, TagDefinition>) oldValue;
for (AnnotationCollectionReference ref : userMarkupCollectionManager.getCollections(deleted.getSecond())) {
setAnnotationCollectionSelected(ref, false);
setAnnotationCollectionSelected(ref, true);
}
} else {
// update
TagDefinition tag = (TagDefinition) newValue;
for (AnnotationCollection collection : userMarkupCollectionManager.getUserMarkupCollections()) {
List<TagReference> relevantTagReferences = collection.getTagReferences(tag);
tagger.setVisible(relevantTagReferences, false);
tagger.setVisible(relevantTagReferences, true);
}
}
}
};
project.getTagManager().addPropertyChangeListener(TagManagerEvent.tagDefinitionChanged, tagChangedListener);
}
use of de.catma.tag.TagInstance in project catma by forTEXT.
the class AnnotationConflictView method initData.
private void initData() {
documentNameField.setReadOnly(false);
documentNameField.setValue(kwicProvider.getSourceDocumentName());
documentNameField.setReadOnly(true);
collectionNameField.setReadOnly(false);
collectionNameField.setValue(this.collectionConflict.getContentInfoSet().getTitle());
collectionNameField.setReadOnly(true);
TagInstance devTagInstance = this.annotationConflict.getDevTagInstance();
TagInstance masterTagInstance = this.annotationConflict.getMasterTagInstance();
TagDefinition tag = null;
if (devTagInstance != null) {
tag = tagManager.getTagLibrary().getTagDefinition(devTagInstance.getTagDefinitionId());
String tagPath = tagManager.getTagLibrary().getTagPath(tag);
String annotatedKwicText = AnnotatedTextProvider.buildAnnotatedKeywordInContext(this.annotationConflict.getDevTagReferences(), kwicProvider, tag, tagPath);
annotatedKwic.setValue(annotatedKwicText);
} else if (masterTagInstance != null) {
tag = tagManager.getTagLibrary().getTagDefinition(masterTagInstance.getTagDefinitionId());
String tagPath = tagManager.getTagLibrary().getTagPath(tag);
String annotatedKwicText = AnnotatedTextProvider.buildAnnotatedKeywordInContext(this.annotationConflict.getMasterTagReferences(), kwicProvider, tag, tagPath);
annotatedKwic.setValue(annotatedKwicText);
}
if (devTagInstance != null) {
TreeDataProvider<PropertyTreeItem> leftPropertyTreeDataProvider = createPropertyTreeDataProvider(devTagInstance, tag);
leftPropertyGrid.setDataProvider(leftPropertyTreeDataProvider);
leftPropertyGrid.expandRecursively(leftPropertyTreeDataProvider.getTreeData().getRootItems(), 1);
} else {
leftPropertyGrid.setVisible(false);
leftIsDeletedLabel.setVisible(true);
}
if (masterTagInstance != null) {
TreeDataProvider<PropertyTreeItem> rightPropertyTreeDataProvider = createPropertyTreeDataProvider(masterTagInstance, tag);
rightPropertyGrid.setDataProvider(rightPropertyTreeDataProvider);
rightPropertyGrid.expandRecursively(rightPropertyTreeDataProvider.getTreeData().getRootItems(), 1);
} else {
rightPropertyGrid.setVisible(false);
rightIsDeletedLabel.setVisible(true);
}
btBoth.setEnabled(annotationConflict.isBothPossible());
}
Aggregations