Search in sources :

Example 1 with SourceListView

use of de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.model.SourceListView in project webanno by webanno.

the class CurationPage method commonInit.

private void commonInit() {
    setModel(Model.of(new AnnotatorStateImpl(Mode.CURATION)));
    centerArea = new WebMarkupContainer("centerArea");
    centerArea.add(visibleWhen(() -> getModelObject().getDocument() != null));
    centerArea.setOutputMarkupPlaceholderTag(true);
    centerArea.add(new DocumentNamePanel("documentNamePanel", getModel()));
    add(centerArea);
    actionBar = new ActionBar("actionBar");
    centerArea.add(actionBar);
    getModelObject().setPagingStrategy(new SentenceOrientedPagingStrategy());
    centerArea.add(getModelObject().getPagingStrategy().createPositionLabel(MID_NUMBER_OF_PAGES, getModel()).add(visibleWhen(() -> getModelObject().getDocument() != null)).add(LambdaBehavior.onEvent(RenderAnnotationsEvent.class, (c, e) -> e.getRequestHandler().add(c))));
    // Ensure that a user is set
    getModelObject().setUser(new User(CURATION_USER, Role.ROLE_USER));
    curationContainer = new CurationContainer();
    curationContainer.setState(getModelObject());
    WebMarkupContainer sidebarCell = new WebMarkupContainer("rightSidebar");
    sidebarCell.setOutputMarkupPlaceholderTag(true);
    // Override sidebar width from preferences
    sidebarCell.add(new AttributeModifier("style", () -> String.format("flex-basis: %d%%;", getModelObject() != null ? getModelObject().getPreferences().getSidebarSize() : 10)));
    add(sidebarCell);
    curationView = new SourceListView();
    List<UserAnnotationSegment> segments = new LinkedList<>();
    UserAnnotationSegment userAnnotationSegments = new UserAnnotationSegment();
    if (getModelObject() != null) {
        userAnnotationSegments.setSelectionByUsernameAndAddress(annotationSelectionByUsernameAndAddress);
        userAnnotationSegments.setAnnotatorState(getModelObject());
        segments.add(userAnnotationSegments);
    }
    // update source list model only first time.
    sourceListModel = sourceListModel == null ? curationContainer.getCurationViews() : sourceListModel;
    suggestionViewPanel = new SuggestionViewPanel("suggestionViewPanel", new ListModel<>(segments)) {

        private static final long serialVersionUID = 2583509126979792202L;

        @Override
        public void onChange(AjaxRequestTarget aTarget) {
            try {
                // update begin/end of the curationsegment based on annotator state
                // changes
                // (like sentence change in auto-scroll mode,....
                aTarget.addChildren(getPage(), IFeedback.class);
                CurationPage.this.updatePanel(aTarget, curationContainer);
            } catch (UIMAException e) {
                error(ExceptionUtils.getRootCause(e));
            } catch (ClassNotFoundException | AnnotationException | IOException e) {
                error("Error: " + e.getMessage());
            }
        }
    };
    suggestionViewPanel.setOutputMarkupPlaceholderTag(true);
    suggestionViewPanel.add(visibleWhen(() -> getModelObject() != null && getModelObject().getDocument() != null));
    centerArea.add(suggestionViewPanel);
    editor = new AnnotationDetailEditorPanel("annotationDetailEditorPanel", this, getModel()) {

        private static final long serialVersionUID = 2857345299480098279L;

        @Override
        protected void onChange(AjaxRequestTarget aTarget) {
            aTarget.addChildren(getPage(), IFeedback.class);
            try {
                updatePanel(aTarget, curationContainer);
            } catch (UIMAException e) {
                LOG.error("Error: " + e.getMessage(), e);
                error("Error: " + ExceptionUtils.getRootCauseMessage(e));
            } catch (Exception e) {
                LOG.error("Error: " + e.getMessage(), e);
                error("Error: " + e.getMessage());
            }
        }

        @Override
        protected void onAutoForward(AjaxRequestTarget aTarget) {
            annotationEditor.requestRender(aTarget);
        }

        @Override
        protected void onConfigure() {
            super.onConfigure();
            setEnabled(getModelObject() != null && getModelObject().getDocument() != null && !documentService.getSourceDocument(getModelObject().getDocument().getProject(), getModelObject().getDocument().getName()).getState().equals(SourceDocumentState.CURATION_FINISHED));
        }

        @Override
        public CAS getEditorCas() throws IOException {
            return CurationPage.this.getEditorCas();
        }
    };
    sidebarCell.add(editor);
    annotationEditor = new BratAnnotationEditor("mergeView", getModel(), editor, this::getEditorCas);
    annotationEditor.setHighlightEnabled(false);
    annotationEditor.add(visibleWhen(() -> getModelObject() != null && getModelObject().getDocument() != null));
    annotationEditor.setOutputMarkupPlaceholderTag(true);
    // reset sentenceAddress and lastSentenceAddress to the orginal once
    centerArea.add(annotationEditor);
    // add container for sentences panel
    sentenceListContainer = new WebMarkupContainer("sentenceListContainer");
    sentenceListContainer.setOutputMarkupPlaceholderTag(true);
    sentenceListContainer.add(visibleWhen(() -> getModelObject() != null && getModelObject().getDocument() != null));
    add(sentenceListContainer);
    // add container for list of sentences panel
    sentenceLinksListView = new WebMarkupContainer("sentenceLinkListView");
    sentenceLinksListView.setOutputMarkupPlaceholderTag(true);
    sentenceLinksListView.add(new ListView<SourceListView>("sentenceLinkList", LoadableDetachableModel.of(() -> curationContainer.getCurationViews())) {

        private static final long serialVersionUID = 8539162089561432091L;

        @Override
        protected void populateItem(ListItem<SourceListView> item) {
            item.add(new SentenceLink("sentenceNumber", item.getModel()));
        }
    });
    sentenceListContainer.add(sentenceLinksListView);
}
Also used : User(de.tudarmstadt.ukp.clarin.webanno.security.model.User) AnnotatorStateImpl(de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.AnnotatorStateImpl) SourceListView(de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.model.SourceListView) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AnnotationDetailEditorPanel(de.tudarmstadt.ukp.clarin.webanno.ui.annotation.detail.AnnotationDetailEditorPanel) DocumentNamePanel(de.tudarmstadt.ukp.clarin.webanno.ui.annotation.component.DocumentNamePanel) IFeedback(org.apache.wicket.feedback.IFeedback) UIMAException(org.apache.uima.UIMAException) ActionBar(de.tudarmstadt.ukp.clarin.webanno.api.annotation.actionbar.ActionBar) SentenceOrientedPagingStrategy(de.tudarmstadt.ukp.clarin.webanno.api.annotation.paging.SentenceOrientedPagingStrategy) CurationContainer(de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.model.CurationContainer) IOException(java.io.IOException) AttributeModifier(org.apache.wicket.AttributeModifier) LinkedList(java.util.LinkedList) NoResultException(javax.persistence.NoResultException) AnnotationException(de.tudarmstadt.ukp.clarin.webanno.api.annotation.exception.AnnotationException) UIMAException(org.apache.uima.UIMAException) IOException(java.io.IOException) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) CAS(org.apache.uima.cas.CAS) SuggestionViewPanel(de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.SuggestionViewPanel) ListModel(org.apache.wicket.model.util.ListModel) BratAnnotationEditor(de.tudarmstadt.ukp.clarin.webanno.brat.annotation.BratAnnotationEditor) UserAnnotationSegment(de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.model.UserAnnotationSegment)

Example 2 with SourceListView

use of de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.model.SourceListView in project webanno by webanno.

the class SuggestionViewPanel method requestUpdate.

/**
 * Schedules a update call for this panel via at the end of the given AJAX cycle. This method
 * can be called multiple times, even for the same annotation editor, but only resulting in a
 * single update and rendering call.
 */
public final void requestUpdate(AjaxRequestTarget aTarget, CurationContainer aCurationContainer, Map<String, Map<Integer, AnnotationSelection>> aAnnotationSelectionByUsernameAndAddress, SourceListView aCurationSegment) {
    LOG.trace("request update");
    aTarget.registerRespondListener(new AjaxComponentRespondListener(this, _target -> {
        updatePanel(_target, aCurationContainer, aAnnotationSelectionByUsernameAndAddress, aCurationSegment);
    }));
}
Also used : TypeAdapter(de.tudarmstadt.ukp.clarin.webanno.api.annotation.adapter.TypeAdapter) SpringBean(org.apache.wicket.spring.injection.annot.SpringBean) Configuration(de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff.Configuration) ConfigurationSet(de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff.ConfigurationSet) LoggerFactory(org.slf4j.LoggerFactory) IMenuItem(com.googlecode.wicket.jquery.ui.widget.menu.IMenuItem) WebAnnoCasUtil(de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil) Sentence(de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence) AnnotationException(de.tudarmstadt.ukp.clarin.webanno.api.annotation.exception.AnnotationException) CasMergeOperationResult(de.tudarmstadt.ukp.clarin.webanno.curation.casmerge.CasMergeOperationResult) CorrectionDocumentService(de.tudarmstadt.ukp.clarin.webanno.api.CorrectionDocumentService) VObject(de.tudarmstadt.ukp.clarin.webanno.api.annotation.rendering.model.VObject) Map(java.util.Map) AlreadyMergedException(de.tudarmstadt.ukp.clarin.webanno.curation.casmerge.AlreadyMergedException) ColoringRules(de.tudarmstadt.ukp.clarin.webanno.api.annotation.coloring.ColoringRules) AnnotatorStateUtils.updateDocumentTimestampAfterWrite(de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.AnnotatorStateUtils.updateDocumentTimestampAfterWrite) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ColoringService(de.tudarmstadt.ukp.clarin.webanno.api.annotation.coloring.ColoringService) CurationContainer(de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.model.CurationContainer) LambdaMenuItem(de.tudarmstadt.ukp.clarin.webanno.support.lambda.LambdaMenuItem) WebAnnoCasUtil.selectAnnotationByAddr(de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.selectAnnotationByAddr) FeatureStructure(org.apache.uima.cas.FeatureStructure) CasMerge(de.tudarmstadt.ukp.clarin.webanno.curation.casmerge.CasMerge) IModel(org.apache.wicket.model.IModel) StringValue(org.apache.wicket.util.string.StringValue) ListView(org.apache.wicket.markup.html.list.ListView) WebAnnoCasUtil.getSentenceNumber(de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.getSentenceNumber) UIMAException(org.apache.uima.UIMAException) GetCollectionInformationResponse(de.tudarmstadt.ukp.clarin.webanno.brat.message.GetCollectionInformationResponse) DiffResult(de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff.DiffResult) AnnotationSelection(de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.model.AnnotationSelection) ListItem(org.apache.wicket.markup.html.list.ListItem) Collection(java.util.Collection) CENTERED(de.tudarmstadt.ukp.clarin.webanno.api.annotation.paging.FocusPosition.CENTERED) Model(org.apache.wicket.model.Model) UserDao(de.tudarmstadt.ukp.clarin.webanno.security.UserDao) Set(java.util.Set) MarkupContainer(org.apache.wicket.MarkupContainer) UserAnnotationSegment(de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.model.UserAnnotationSegment) AnnotationDocument(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationDocument) AnnotationDocumentState(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationDocumentState) IFeedback(org.apache.wicket.feedback.IFeedback) ContextMenu(de.tudarmstadt.ukp.clarin.webanno.support.wicket.ContextMenu) LINK_ROLE_AS_LABEL(de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.LinkCompareBehavior.LINK_ROLE_AS_LABEL) List(java.util.List) TypeUtil(de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.TypeUtil) AnnotationLayer(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer) SourceDocument(de.tudarmstadt.ukp.clarin.webanno.model.SourceDocument) CasDiff.getDiffAdapters(de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff.getDiffAdapters) ApplicationEventPublisherHolder(de.tudarmstadt.ukp.clarin.webanno.support.spring.ApplicationEventPublisherHolder) BratRenderer(de.tudarmstadt.ukp.clarin.webanno.brat.render.BratRenderer) VDocument(de.tudarmstadt.ukp.clarin.webanno.api.annotation.rendering.model.VDocument) USE(de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.model.AnnotationState.USE) AnnotationFS(org.apache.uima.cas.text.AnnotationFS) AnnotatorState(de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.AnnotatorState) AGREE(de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.model.AnnotationState.AGREE) CAS(org.apache.uima.cas.CAS) HashMap(java.util.HashMap) ColoringStrategy(de.tudarmstadt.ukp.clarin.webanno.api.annotation.coloring.ColoringStrategy) Mode(de.tudarmstadt.ukp.clarin.webanno.model.Mode) MergeConflictException(de.tudarmstadt.ukp.clarin.webanno.curation.casmerge.MergeConflictException) ArrayList(java.util.ArrayList) AnnotationSchemaService(de.tudarmstadt.ukp.clarin.webanno.api.AnnotationSchemaService) SourceListView(de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.model.SourceListView) Token(de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token) AnnotationState(de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.model.AnnotationState) User(de.tudarmstadt.ukp.clarin.webanno.security.model.User) GetDocumentResponse(de.tudarmstadt.ukp.clarin.webanno.brat.message.GetDocumentResponse) DISAGREE(de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.model.AnnotationState.DISAGREE) Project(de.tudarmstadt.ukp.clarin.webanno.model.Project) IRequestParameters(org.apache.wicket.request.IRequestParameters) BratSuggestionVisualizer(de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.model.BratSuggestionVisualizer) LinkedHashSet(java.util.LinkedHashSet) PreRenderer(de.tudarmstadt.ukp.clarin.webanno.api.annotation.rendering.PreRenderer) DO_NOT_USE(de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.model.AnnotationState.DO_NOT_USE) DocumentService(de.tudarmstadt.ukp.clarin.webanno.api.DocumentService) CURATION(de.tudarmstadt.ukp.clarin.webanno.model.Mode.CURATION) Logger(org.slf4j.Logger) CasUtil.select(org.apache.uima.fit.util.CasUtil.select) CurationDocumentService(de.tudarmstadt.ukp.clarin.webanno.curation.storage.CurationDocumentService) IOException(java.io.IOException) RELATION_TYPE(de.tudarmstadt.ukp.clarin.webanno.api.WebAnnoConst.RELATION_TYPE) SPAN_TYPE(de.tudarmstadt.ukp.clarin.webanno.api.WebAnnoConst.SPAN_TYPE) AjaxComponentRespondListener(de.tudarmstadt.ukp.clarin.webanno.support.wicket.AjaxComponentRespondListener) BratAnnotatorUtility.isDocumentFinished(de.tudarmstadt.ukp.clarin.webanno.brat.util.BratAnnotatorUtility.isDocumentFinished) JSONUtil(de.tudarmstadt.ukp.clarin.webanno.support.JSONUtil) CasDiff.doDiffSingle(de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff.doDiffSingle) StringUtils.isBlank(org.apache.commons.lang3.StringUtils.isBlank) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) BulkAnnotationEvent(de.tudarmstadt.ukp.clarin.webanno.api.annotation.event.BulkAnnotationEvent) AnnotationFeature(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature) DiffAdapter(de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.api.DiffAdapter) CHAIN_TYPE(de.tudarmstadt.ukp.clarin.webanno.api.WebAnnoConst.CHAIN_TYPE) VID(de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.VID) Collections(java.util.Collections) AjaxComponentRespondListener(de.tudarmstadt.ukp.clarin.webanno.support.wicket.AjaxComponentRespondListener)

Aggregations

AnnotationException (de.tudarmstadt.ukp.clarin.webanno.api.annotation.exception.AnnotationException)2 User (de.tudarmstadt.ukp.clarin.webanno.security.model.User)2 CurationContainer (de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.model.CurationContainer)2 SourceListView (de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.model.SourceListView)2 UserAnnotationSegment (de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.model.UserAnnotationSegment)2 IOException (java.io.IOException)2 UIMAException (org.apache.uima.UIMAException)2 CAS (org.apache.uima.cas.CAS)2 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)2 IFeedback (org.apache.wicket.feedback.IFeedback)2 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)2 IMenuItem (com.googlecode.wicket.jquery.ui.widget.menu.IMenuItem)1 AnnotationSchemaService (de.tudarmstadt.ukp.clarin.webanno.api.AnnotationSchemaService)1 CorrectionDocumentService (de.tudarmstadt.ukp.clarin.webanno.api.CorrectionDocumentService)1 DocumentService (de.tudarmstadt.ukp.clarin.webanno.api.DocumentService)1 CHAIN_TYPE (de.tudarmstadt.ukp.clarin.webanno.api.WebAnnoConst.CHAIN_TYPE)1 RELATION_TYPE (de.tudarmstadt.ukp.clarin.webanno.api.WebAnnoConst.RELATION_TYPE)1 SPAN_TYPE (de.tudarmstadt.ukp.clarin.webanno.api.WebAnnoConst.SPAN_TYPE)1 ActionBar (de.tudarmstadt.ukp.clarin.webanno.api.annotation.actionbar.ActionBar)1 TypeAdapter (de.tudarmstadt.ukp.clarin.webanno.api.annotation.adapter.TypeAdapter)1