Search in sources :

Example 21 with TagInstance

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);
}
Also used : SelectionEvent(com.vaadin.event.selection.SelectionEvent) Alignment(com.vaadin.ui.Alignment) UI(com.vaadin.ui.UI) ConfirmDialog(org.vaadin.dialogs.ConfirmDialog) KwicProvider(de.catma.indexer.KwicProvider) ErrorHandler(de.catma.ui.module.main.ErrorHandler) TreeDataProvider(com.vaadin.data.provider.TreeDataProvider) VaadinIcons(com.vaadin.icons.VaadinIcons) Objects(com.google.common.base.Objects) IconButton(de.catma.ui.component.IconButton) Collection(java.util.Collection) Set(java.util.Set) TagInstance(de.catma.tag.TagInstance) TreeGrid(com.vaadin.ui.TreeGrid) Collectors(java.util.stream.Collectors) List(java.util.List) Type(com.vaadin.ui.Notification.Type) RendererClickEvent(com.vaadin.ui.renderers.ClickableRenderer.RendererClickEvent) PropertyChangeListener(java.beans.PropertyChangeListener) TagDefinition(de.catma.tag.TagDefinition) Optional(java.util.Optional) RBACPermission(de.catma.rbac.RBACPermission) PropertyDefinition(de.catma.tag.PropertyDefinition) ClickListener(com.vaadin.ui.Button.ClickListener) DescriptionGenerator(com.vaadin.ui.DescriptionGenerator) VerticalLayout(com.vaadin.ui.VerticalLayout) AnnotationCollectionManager(de.catma.document.annotation.AnnotationCollectionManager) ActionGridComponent(de.catma.ui.component.actiongrid.ActionGridComponent) Function(java.util.function.Function) ArrayList(java.util.ArrayList) Registration(com.vaadin.shared.Registration) Notification(com.vaadin.ui.Notification) Label(com.vaadin.ui.Label) TreeGridFactory(de.catma.ui.component.TreeGridFactory) ButtonRenderer(com.vaadin.ui.renderers.ButtonRenderer) SaveCancelListener(de.catma.ui.dialog.SaveCancelListener) PropertyChangeEvent(java.beans.PropertyChangeEvent) ContentMode(com.vaadin.shared.ui.ContentMode) Property(de.catma.tag.Property) TreeData(com.vaadin.data.TreeData) Project(de.catma.project.Project) RepositoryChangeEvent(de.catma.project.Project.RepositoryChangeEvent) IOException(java.io.IOException) SourceDocument(de.catma.document.source.SourceDocument) Annotation(de.catma.document.annotation.Annotation) Consumer(java.util.function.Consumer) TagManagerEvent(de.catma.tag.TagManager.TagManagerEvent) Button(com.vaadin.ui.Button) HorizontalLayout(com.vaadin.ui.HorizontalLayout) ScrollDestination(com.vaadin.shared.ui.grid.ScrollDestination) HtmlRenderer(com.vaadin.ui.renderers.HtmlRenderer) ErrorHandler(de.catma.ui.module.main.ErrorHandler) PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) TagInstance(de.catma.tag.TagInstance) Annotation(de.catma.document.annotation.Annotation) IOException(java.io.IOException)

Example 22 with TagInstance

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);
}
Also used : BackgroundServiceProvider(de.catma.backgroundservice.BackgroundServiceProvider) ZonedDateTime(java.time.ZonedDateTime) VerticalSplitPanel(com.vaadin.ui.VerticalSplitPanel) EditAnnotationPropertiesDialog(de.catma.ui.module.annotate.annotationpanel.EditAnnotationPropertiesDialog) IndexedProject(de.catma.indexer.IndexedProject) ClientCommentReply(de.catma.ui.client.ui.tagger.shared.ClientCommentReply) KwicProvider(de.catma.indexer.KwicProvider) ValueOutOfBoundsException(com.vaadin.ui.Slider.ValueOutOfBoundsException) ExpansionListener(de.catma.ui.module.analyze.visualization.ExpansionListener) ExecutionListener(de.catma.backgroundservice.ExecutionListener) Slider(com.vaadin.ui.Slider) Set(java.util.Set) TagInstance(de.catma.tag.TagInstance) ClosableTab(de.catma.ui.component.tabbedview.ClosableTab) Pager(de.catma.ui.module.annotate.pager.Pager) Type(com.vaadin.ui.Notification.Type) PropertyChangeListener(java.beans.PropertyChangeListener) SliderMode(org.vaadin.sliderpanel.client.SliderMode) DefaultProgressCallable(de.catma.backgroundservice.DefaultProgressCallable) Range(de.catma.document.Range) TagManager(de.catma.tag.TagManager) VerticalLayout(com.vaadin.ui.VerticalLayout) SplitterPositionChangedListener(de.catma.ui.module.annotate.TaggerSplitPanel.SplitterPositionChangedListener) CommentMessage(de.catma.ui.events.CommentMessage) ArrayList(java.util.ArrayList) Pair(de.catma.util.Pair) SaveCancelListener(de.catma.ui.dialog.SaveCancelListener) ResourceSelectionListener(de.catma.ui.module.annotate.resourcepanel.ResourceSelectionListener) Property(de.catma.tag.Property) QueryResultRow(de.catma.queryengine.result.QueryResultRow) IOException(java.io.IOException) SourceDocument(de.catma.document.source.SourceDocument) AnnotationCollection(de.catma.document.annotation.AnnotationCollection) ValueChangeListener(com.vaadin.data.HasValue.ValueChangeListener) Annotation(de.catma.document.annotation.Annotation) TagManagerEvent(de.catma.tag.TagManager.TagManagerEvent) ClientTagInstance(de.catma.ui.client.ui.tagger.shared.ClientTagInstance) Button(com.vaadin.ui.Button) ChangeType(de.catma.project.event.ChangeType) TextRange(de.catma.ui.client.ui.tagger.shared.TextRange) HorizontalLayout(com.vaadin.ui.HorizontalLayout) AnnotateResourcePanel(de.catma.ui.module.annotate.resourcepanel.AnnotateResourcePanel) SplitterPositionChangedEvent(de.catma.ui.module.annotate.TaggerSplitPanel.SplitterPositionChangedEvent) Reply(de.catma.document.comment.Reply) ClientComment(de.catma.ui.client.ui.tagger.shared.ClientComment) URISyntaxException(java.net.URISyntaxException) UI(com.vaadin.ui.UI) ConfirmDialog(org.vaadin.dialogs.ConfirmDialog) RouteToAnalyzeEvent(de.catma.ui.events.routing.RouteToAnalyzeEvent) TaggerContextMenu(de.catma.ui.module.annotate.contextmenu.TaggerContextMenu) ErrorHandler(de.catma.ui.module.main.ErrorHandler) CatmaApplication(de.catma.ui.CatmaApplication) SliderPanel(org.vaadin.sliderpanel.SliderPanel) VaadinIcons(com.vaadin.icons.VaadinIcons) Version(de.catma.tag.Version) IconButton(de.catma.ui.component.IconButton) Collection(java.util.Collection) Logger(java.util.logging.Logger) Collectors(java.util.stream.Collectors) MarginInfo(com.vaadin.shared.ui.MarginInfo) TagReference(de.catma.document.annotation.TagReference) List(java.util.List) TaggerListener(de.catma.ui.module.annotate.Tagger.TaggerListener) Corpus(de.catma.document.corpus.Corpus) TagDefinition(de.catma.tag.TagDefinition) Optional(java.util.Optional) HazelCastService(de.catma.hazelcast.HazelCastService) SliderPanelBuilder(org.vaadin.sliderpanel.SliderPanelBuilder) ValueChangeEvent(com.vaadin.data.HasValue.ValueChangeEvent) KwicPanel(de.catma.ui.module.analyze.visualization.kwic.KwicPanel) ClickListener(com.vaadin.ui.Button.ClickListener) PagerComponent(de.catma.ui.module.annotate.pager.PagerComponent) AnnotationPanel(de.catma.ui.module.annotate.annotationpanel.AnnotationPanel) AnnotationCollectionManager(de.catma.document.annotation.AnnotationCollectionManager) PageChangeListener(de.catma.ui.module.annotate.pager.PagerComponent.PageChangeListener) UIMessageListener(de.catma.ui.UIMessageListener) User(de.catma.user.User) Level(java.util.logging.Level) HashSet(java.util.HashSet) EventBus(com.google.common.eventbus.EventBus) CommentChangeEvent(de.catma.project.event.CommentChangeEvent) Comment(de.catma.document.comment.Comment) Notification(com.vaadin.ui.Notification) Page(de.catma.ui.module.annotate.pager.Page) HazelcastConfiguration(de.catma.hazelcast.HazelcastConfiguration) TagsetDefinition(de.catma.tag.TagsetDefinition) IDGenerator(de.catma.util.IDGenerator) Subscribe(com.google.common.eventbus.Subscribe) TagLibrary(de.catma.tag.TagLibrary) PropertyChangeEvent(java.beans.PropertyChangeEvent) ClickEvent(com.vaadin.ui.Button.ClickEvent) AnnotationCollectionReference(de.catma.document.annotation.AnnotationCollectionReference) Project(de.catma.project.Project) RepositoryChangeEvent(de.catma.project.Project.RepositoryChangeEvent) ReplyChangeEvent(de.catma.project.event.ReplyChangeEvent) TabCaptionChangeListener(de.catma.ui.component.tabbedview.TabCaptionChangeListener) DateTimeFormatter(java.time.format.DateTimeFormatter) ITopic(com.hazelcast.core.ITopic) TagDefinition(de.catma.tag.TagDefinition) PropertyChangeEvent(java.beans.PropertyChangeEvent) AnnotationCollection(de.catma.document.annotation.AnnotationCollection) Set(java.util.Set) HashSet(java.util.HashSet) PropertyChangeListener(java.beans.PropertyChangeListener) AnnotationCollectionReference(de.catma.document.annotation.AnnotationCollectionReference) TagsetDefinition(de.catma.tag.TagsetDefinition) TagInstance(de.catma.tag.TagInstance) ClientTagInstance(de.catma.ui.client.ui.tagger.shared.ClientTagInstance) AnnotationCollection(de.catma.document.annotation.AnnotationCollection) Collection(java.util.Collection) TagReference(de.catma.document.annotation.TagReference) ArrayList(java.util.ArrayList) List(java.util.List) Pair(de.catma.util.Pair)

Example 23 with TagInstance

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());
}
Also used : TagDefinition(de.catma.tag.TagDefinition) TagInstance(de.catma.tag.TagInstance)

Aggregations

TagInstance (de.catma.tag.TagInstance)23 Property (de.catma.tag.Property)17 TagDefinition (de.catma.tag.TagDefinition)15 TagReference (de.catma.document.annotation.TagReference)14 ArrayList (java.util.ArrayList)12 PropertyDefinition (de.catma.tag.PropertyDefinition)10 List (java.util.List)10 Range (de.catma.document.Range)8 AnnotationCollection (de.catma.document.annotation.AnnotationCollection)8 TagsetDefinition (de.catma.tag.TagsetDefinition)8 SourceDocument (de.catma.document.source.SourceDocument)7 AnnotationCollectionReference (de.catma.document.annotation.AnnotationCollectionReference)6 TagLibrary (de.catma.tag.TagLibrary)6 ArrayListMultimap (com.google.common.collect.ArrayListMultimap)5 UI (com.vaadin.ui.UI)5 IDGenerator (de.catma.util.IDGenerator)5 Collection (java.util.Collection)5 Notification (com.vaadin.ui.Notification)4 Type (com.vaadin.ui.Notification.Type)4 Project (de.catma.project.Project)4