Search in sources :

Example 1 with UserAnnotationSegment

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

the class AutomationPage method commonInit.

private void commonInit() {
    setVersioned(false);
    setModel(Model.of(new AnnotatorStateImpl(Mode.AUTOMATION)));
    WebMarkupContainer rightSidebar = new WebMarkupContainer("rightSidebar");
    // Override sidebar width from preferences
    rightSidebar.add(new AttributeModifier("style", LambdaModel.of(() -> String.format("flex-basis: %d%%;", getModelObject().getPreferences().getSidebarSize()))));
    rightSidebar.setOutputMarkupId(true);
    add(rightSidebar);
    List<UserAnnotationSegment> segments = new LinkedList<>();
    UserAnnotationSegment userAnnotationSegment = new UserAnnotationSegment();
    if (getModelObject().getDocument() != null) {
        userAnnotationSegment.setSelectionByUsernameAndAddress(annotationSelectionByUsernameAndAddress);
        userAnnotationSegment.setAnnotatorState(getModelObject());
        segments.add(userAnnotationSegment);
    }
    suggestionView = new SuggestionViewPanel("automateView", new ListModel<>(segments)) {

        private static final long serialVersionUID = 2583509126979792202L;

        @Override
        public void onChange(AjaxRequestTarget aTarget) {
            try {
                // update begin/end of the curation segment based on bratAnnotatorModel changes
                // (like sentence change in auto-scroll mode,....
                aTarget.addChildren(getPage(), IFeedback.class);
                AnnotatorState state = AutomationPage.this.getModelObject();
                curationContainer.setBratAnnotatorModel(state);
                JCas editorCas = getEditorCas();
                setCurationSegmentBeginEnd(editorCas);
                suggestionView.updatePanel(aTarget, curationContainer, annotationSelectionByUsernameAndAddress, curationSegment);
                annotationEditor.requestRender(aTarget);
                aTarget.add(getOrCreatePositionInfoLabel());
                update(aTarget);
            } catch (Exception e) {
                handleException(aTarget, e);
            }
        }
    };
    add(suggestionView);
    rightSidebar.add(detailEditor = createDetailEditor());
    annotationEditor = new BratAnnotationEditor("mergeView", getModel(), detailEditor, this::getEditorCas);
    add(annotationEditor);
    curationContainer = new CurationContainer();
    curationContainer.setBratAnnotatorModel(getModelObject());
    add(documentNamePanel = new DocumentNamePanel("documentNamePanel", getModel()));
    add(getOrCreatePositionInfoLabel());
    add(openDocumentsModal = new OpenDocumentDialog("openDocumentsModal", getModel(), getAllowedProjects()) {

        private static final long serialVersionUID = 5474030848589262638L;

        @Override
        public void onDocumentSelected(AjaxRequestTarget aTarget) {
            // Reload the page using AJAX. This does not add the project/document ID to the URL,
            // but being AJAX it flickers less.
            actionLoadDocument(aTarget);
        // if (state.getDocument() == null) {
        // setResponsePage(getApplication().getHomePage());
        // return;
        // }
        // 
        // try {
        // aCallbackTarget.addChildren(getPage(), IFeedback.class);
        // 
        // String username = SecurityContextHolder.getContext().getAuthentication()
        // .getName();
        // 
        // actionLoadDocument(aCallbackTarget);
        // User user = userRepository.get(username);
        // detailEditor.setEnabled(!FinishImage.isFinished(
        // new Model<AnnotatorState>(state), user, documentService));
        // detailEditor.loadFeatureEditorModels(aCallbackTarget);
        // }
        // catch (Exception e) {
        // handleException(aCallbackTarget, e);
        // }
        // finishDocumentIcon.setModelObject(state);
        // aCallbackTarget.add(finishDocumentIcon.setOutputMarkupId(true));
        // aCallbackTarget.appendJavaScript(
        // "Wicket.Window.unloadConfirmation=false;window.location.reload()");
        // aCallbackTarget.add(documentNamePanel.setOutputMarkupId(true));
        // aCallbackTarget.add(getOrCreatePositionInfoLabel());
        }
    });
    add(preferencesModal = new AnnotationPreferencesDialog("preferencesDialog", getModel()));
    preferencesModal.setOnChangeAction(this::actionCompletePreferencesChange);
    add(exportDialog = new ExportDocumentDialog("exportDialog", getModel()));
    add(guidelinesDialog = new GuidelinesDialog("guidelinesDialog", getModel()));
    Form<Void> gotoPageTextFieldForm = new Form<>("gotoPageTextFieldForm");
    gotoPageTextField = new NumberTextField<>("gotoPageText", Model.of(1), Integer.class);
    // FIXME minimum and maximum should be obtained from the annotator state
    gotoPageTextField.setMinimum(1);
    gotoPageTextField.setOutputMarkupId(true);
    gotoPageTextFieldForm.add(gotoPageTextField);
    LambdaAjaxSubmitLink gotoPageLink = new LambdaAjaxSubmitLink("gotoPageLink", gotoPageTextFieldForm, this::actionGotoPage);
    gotoPageTextFieldForm.setDefaultButton(gotoPageLink);
    gotoPageTextFieldForm.add(gotoPageLink);
    add(gotoPageTextFieldForm);
    add(new LambdaAjaxLink("showOpenDocumentModal", this::actionShowOpenDocumentDialog));
    add(new LambdaAjaxLink("showPreferencesDialog", this::actionShowPreferencesDialog));
    add(new ActionBarLink("showGuidelinesDialog", guidelinesDialog::show));
    add(new LambdaAjaxLink("showExportDialog", exportDialog::show) {

        private static final long serialVersionUID = -3082002656840117267L;

        {
            setOutputMarkupId(true);
            setOutputMarkupPlaceholderTag(true);
        }

        @Override
        protected void onConfigure() {
            super.onConfigure();
            AnnotatorState state = AutomationPage.this.getModelObject();
            setVisible(state.getProject() != null && (SecurityUtil.isAdmin(state.getProject(), projectService, state.getUser()) || !state.getProject().isDisableExport()));
        }
    });
    add(new LambdaAjaxLink("showPreviousDocument", t -> actionShowPreviousDocument(t)).add(new InputBehavior(new KeyType[] { KeyType.Shift, KeyType.Page_up }, EventType.click)));
    add(new LambdaAjaxLink("showNextDocument", t -> actionShowNextDocument(t)).add(new InputBehavior(new KeyType[] { KeyType.Shift, KeyType.Page_down }, EventType.click)));
    add(new LambdaAjaxLink("showNext", t -> actionShowNextPage(t)).add(new InputBehavior(new KeyType[] { KeyType.Page_down }, EventType.click)));
    add(new LambdaAjaxLink("showPrevious", t -> actionShowPreviousPage(t)).add(new InputBehavior(new KeyType[] { KeyType.Page_up }, EventType.click)));
    add(new LambdaAjaxLink("showFirst", t -> actionShowFirstPage(t)).add(new InputBehavior(new KeyType[] { KeyType.Home }, EventType.click)));
    add(new LambdaAjaxLink("showLast", t -> actionShowLastPage(t)).add(new InputBehavior(new KeyType[] { KeyType.End }, EventType.click)));
    add(new LambdaAjaxLink("toggleScriptDirection", this::actionToggleScriptDirection));
    add(createOrGetResetDocumentDialog());
    add(createOrGetResetDocumentLink());
    add(finishDocumentDialog = new ConfirmationDialog("finishDocumentDialog", new StringResourceModel("FinishDocumentDialog.title", this, null), new StringResourceModel("FinishDocumentDialog.text", this, null)));
    add(finishDocumentLink = new LambdaAjaxLink("showFinishDocumentDialog", this::actionFinishDocument) {

        private static final long serialVersionUID = 874573384012299998L;

        @Override
        protected void onConfigure() {
            super.onConfigure();
            AnnotatorState state = AutomationPage.this.getModelObject();
            setEnabled(state.getDocument() != null && !documentService.isAnnotationFinished(state.getDocument(), state.getUser()));
        }
    });
    finishDocumentIcon = new FinishImage("finishImage", getModel());
    finishDocumentIcon.setOutputMarkupId(true);
    finishDocumentLink.add(finishDocumentIcon);
}
Also used : AnnotationPreferencesDialog(de.tudarmstadt.ukp.clarin.webanno.ui.annotation.dialog.AnnotationPreferencesDialog) Form(org.apache.wicket.markup.html.form.Form) ActionBarLink(de.tudarmstadt.ukp.clarin.webanno.support.lambda.ActionBarLink) AnnotatorStateImpl(de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.AnnotatorStateImpl) AnnotatorState(de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.AnnotatorState) JCas(org.apache.uima.jcas.JCas) LambdaAjaxSubmitLink(de.tudarmstadt.ukp.clarin.webanno.support.lambda.LambdaAjaxSubmitLink) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) ConfirmationDialog(de.tudarmstadt.ukp.clarin.webanno.support.dialog.ConfirmationDialog) LambdaAjaxLink(de.tudarmstadt.ukp.clarin.webanno.support.lambda.LambdaAjaxLink) ExportDocumentDialog(de.tudarmstadt.ukp.clarin.webanno.ui.annotation.dialog.ExportDocumentDialog) IFeedback(org.apache.wicket.feedback.IFeedback) DocumentNamePanel(de.tudarmstadt.ukp.clarin.webanno.ui.annotation.component.DocumentNamePanel) StringResourceModel(org.apache.wicket.model.StringResourceModel) InputBehavior(wicket.contrib.input.events.InputBehavior) CurationContainer(de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.model.CurationContainer) AttributeModifier(org.apache.wicket.AttributeModifier) LinkedList(java.util.LinkedList) AnnotationException(de.tudarmstadt.ukp.clarin.webanno.api.annotation.exception.AnnotationException) UIMAException(org.apache.uima.UIMAException) IOException(java.io.IOException) FinishImage(de.tudarmstadt.ukp.clarin.webanno.ui.annotation.component.FinishImage) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) GuidelinesDialog(de.tudarmstadt.ukp.clarin.webanno.ui.annotation.dialog.GuidelinesDialog) SuggestionViewPanel(de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.SuggestionViewPanel) ListModel(org.apache.wicket.model.util.ListModel) OpenDocumentDialog(de.tudarmstadt.ukp.clarin.webanno.ui.annotation.dialog.OpenDocumentDialog) BratAnnotationEditor(de.tudarmstadt.ukp.clarin.webanno.brat.annotation.BratAnnotationEditor) UserAnnotationSegment(de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.model.UserAnnotationSegment)

Example 2 with UserAnnotationSegment

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

the class CorrectionPage method commonInit.

private void commonInit() {
    setVersioned(false);
    setModel(Model.of(new AnnotatorStateImpl(Mode.CORRECTION)));
    WebMarkupContainer rightSidebar = new WebMarkupContainer("rightSidebar");
    // Override sidebar width from preferences
    rightSidebar.add(new AttributeModifier("style", LambdaModel.of(() -> String.format("flex-basis: %d%%;", getModelObject().getPreferences().getSidebarSize()))));
    rightSidebar.setOutputMarkupId(true);
    add(rightSidebar);
    List<UserAnnotationSegment> segments = new LinkedList<>();
    UserAnnotationSegment userAnnotationSegment = new UserAnnotationSegment();
    if (getModelObject().getDocument() != null) {
        userAnnotationSegment.setSelectionByUsernameAndAddress(annotationSelectionByUsernameAndAddress);
        userAnnotationSegment.setAnnotatorState(getModelObject());
        segments.add(userAnnotationSegment);
    }
    suggestionView = new SuggestionViewPanel("correctionView", new ListModel<>(segments)) {

        private static final long serialVersionUID = 2583509126979792202L;

        @Override
        public void onChange(AjaxRequestTarget aTarget) {
            AnnotatorState state = CorrectionPage.this.getModelObject();
            aTarget.addChildren(getPage(), IFeedback.class);
            try {
                // update begin/end of the curation segment based on bratAnnotatorModel changes
                // (like sentence change in auto-scroll mode,....
                curationContainer.setBratAnnotatorModel(state);
                JCas editorCas = getEditorCas();
                setCurationSegmentBeginEnd(editorCas);
                suggestionView.updatePanel(aTarget, curationContainer, annotationSelectionByUsernameAndAddress, curationSegment);
                annotationEditor.requestRender(aTarget);
                aTarget.add(getOrCreatePositionInfoLabel());
                update(aTarget);
            } 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());
            }
        }
    };
    suggestionView.setOutputMarkupId(true);
    add(suggestionView);
    rightSidebar.add(detailEditor = createDetailEditor());
    annotationEditor = new BratAnnotationEditor("mergeView", getModel(), detailEditor, this::getEditorCas);
    add(annotationEditor);
    curationContainer = new CurationContainer();
    curationContainer.setBratAnnotatorModel(getModelObject());
    add(documentNamePanel = createDocumentInfoLabel());
    add(getOrCreatePositionInfoLabel());
    add(openDocumentsModal = new OpenDocumentDialog("openDocumentsModal", getModel(), getAllowedProjects()) {

        private static final long serialVersionUID = 5474030848589262638L;

        @Override
        public void onDocumentSelected(AjaxRequestTarget aTarget) {
            // Reload the page using AJAX. This does not add the project/document ID to the URL,
            // but being AJAX it flickers less.
            actionLoadDocument(aTarget);
        }
    });
    add(preferencesModal = new AnnotationPreferencesDialog("preferencesDialog", getModel()));
    preferencesModal.setOnChangeAction(this::actionCompletePreferencesChange);
    add(exportDialog = new ExportDocumentDialog("exportDialog", getModel()));
    add(guidelinesDialog = new GuidelinesDialog("guidelinesDialog", getModel()));
    Form<Void> gotoPageTextFieldForm = new Form<>("gotoPageTextFieldForm");
    gotoPageTextField = new NumberTextField<>("gotoPageText", Model.of(1), Integer.class);
    // FIXME minimum and maximum should be obtained from the annotator state
    gotoPageTextField.setMinimum(1);
    gotoPageTextField.setOutputMarkupId(true);
    gotoPageTextFieldForm.add(gotoPageTextField);
    LambdaAjaxSubmitLink gotoPageLink = new LambdaAjaxSubmitLink("gotoPageLink", gotoPageTextFieldForm, this::actionGotoPage);
    gotoPageTextFieldForm.setDefaultButton(gotoPageLink);
    gotoPageTextFieldForm.add(gotoPageLink);
    add(gotoPageTextFieldForm);
    add(new LambdaAjaxLink("showOpenDocumentModal", this::actionShowOpenDocumentDialog));
    add(new LambdaAjaxLink("showPreferencesDialog", this::actionShowPreferencesDialog));
    add(new ActionBarLink("showGuidelinesDialog", guidelinesDialog::show));
    add(new LambdaAjaxLink("showExportDialog", exportDialog::show) {

        private static final long serialVersionUID = -708400631769656072L;

        {
            setOutputMarkupId(true);
            setOutputMarkupPlaceholderTag(true);
        }

        @Override
        protected void onConfigure() {
            super.onConfigure();
            AnnotatorState state = CorrectionPage.this.getModelObject();
            setVisible(state.getProject() != null && (SecurityUtil.isAdmin(state.getProject(), projectService, state.getUser()) || !state.getProject().isDisableExport()));
        }
    });
    add(new LambdaAjaxLink("showPreviousDocument", t -> actionShowPreviousDocument(t)).add(new InputBehavior(new KeyType[] { KeyType.Shift, KeyType.Page_up }, EventType.click)));
    add(new LambdaAjaxLink("showNextDocument", t -> actionShowNextDocument(t)).add(new InputBehavior(new KeyType[] { KeyType.Shift, KeyType.Page_down }, EventType.click)));
    add(new LambdaAjaxLink("showNext", t -> actionShowNextPage(t)).add(new InputBehavior(new KeyType[] { KeyType.Page_down }, EventType.click)));
    add(new LambdaAjaxLink("showPrevious", t -> actionShowPreviousPage(t)).add(new InputBehavior(new KeyType[] { KeyType.Page_up }, EventType.click)));
    add(new LambdaAjaxLink("showFirst", t -> actionShowFirstPage(t)).add(new InputBehavior(new KeyType[] { KeyType.Home }, EventType.click)));
    add(new LambdaAjaxLink("showLast", t -> actionShowLastPage(t)).add(new InputBehavior(new KeyType[] { KeyType.End }, EventType.click)));
    add(new LambdaAjaxLink("toggleScriptDirection", this::actionToggleScriptDirection));
    add(createOrGetResetDocumentDialog());
    add(createOrGetResetDocumentLink());
    add(finishDocumentDialog = new ConfirmationDialog("finishDocumentDialog", new StringResourceModel("FinishDocumentDialog.title", this, null), new StringResourceModel("FinishDocumentDialog.text", this, null)));
    add(finishDocumentLink = new LambdaAjaxLink("showFinishDocumentDialog", this::actionFinishDocument) {

        private static final long serialVersionUID = 874573384012299998L;

        @Override
        protected void onConfigure() {
            super.onConfigure();
            AnnotatorState state = CorrectionPage.this.getModelObject();
            setEnabled(state.getDocument() != null && !documentService.isAnnotationFinished(state.getDocument(), state.getUser()));
        }
    });
    finishDocumentIcon = new FinishImage("finishImage", getModel());
    finishDocumentIcon.setOutputMarkupId(true);
    finishDocumentLink.add(finishDocumentIcon);
}
Also used : AnnotationPreferencesDialog(de.tudarmstadt.ukp.clarin.webanno.ui.annotation.dialog.AnnotationPreferencesDialog) Form(org.apache.wicket.markup.html.form.Form) ActionBarLink(de.tudarmstadt.ukp.clarin.webanno.support.lambda.ActionBarLink) AnnotatorStateImpl(de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.AnnotatorStateImpl) AnnotatorState(de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.AnnotatorState) JCas(org.apache.uima.jcas.JCas) LambdaAjaxSubmitLink(de.tudarmstadt.ukp.clarin.webanno.support.lambda.LambdaAjaxSubmitLink) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) ConfirmationDialog(de.tudarmstadt.ukp.clarin.webanno.support.dialog.ConfirmationDialog) LambdaAjaxLink(de.tudarmstadt.ukp.clarin.webanno.support.lambda.LambdaAjaxLink) ExportDocumentDialog(de.tudarmstadt.ukp.clarin.webanno.ui.annotation.dialog.ExportDocumentDialog) IFeedback(org.apache.wicket.feedback.IFeedback) UIMAException(org.apache.uima.UIMAException) StringResourceModel(org.apache.wicket.model.StringResourceModel) InputBehavior(wicket.contrib.input.events.InputBehavior) CurationContainer(de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.model.CurationContainer) AttributeModifier(org.apache.wicket.AttributeModifier) LinkedList(java.util.LinkedList) AnnotationException(de.tudarmstadt.ukp.clarin.webanno.api.annotation.exception.AnnotationException) UIMAException(org.apache.uima.UIMAException) IOException(java.io.IOException) FinishImage(de.tudarmstadt.ukp.clarin.webanno.ui.annotation.component.FinishImage) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) GuidelinesDialog(de.tudarmstadt.ukp.clarin.webanno.ui.annotation.dialog.GuidelinesDialog) SuggestionViewPanel(de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.SuggestionViewPanel) ListModel(org.apache.wicket.model.util.ListModel) OpenDocumentDialog(de.tudarmstadt.ukp.clarin.webanno.ui.annotation.dialog.OpenDocumentDialog) BratAnnotationEditor(de.tudarmstadt.ukp.clarin.webanno.brat.annotation.BratAnnotationEditor) UserAnnotationSegment(de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.model.UserAnnotationSegment)

Example 3 with UserAnnotationSegment

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

the class SuggestionViewPanel method init.

/**
 * Initializes the user annotation segments later to be filled with content.
 */
public void init(AjaxRequestTarget aTarget, CurationContainer aCurationContainer, Map<String, Map<Integer, AnnotationSelection>> aAnnotationSelectionByUsernameAndAddress, SourceListView aCurationSegment) throws UIMAException, ClassNotFoundException, IOException {
    AnnotatorState state = aCurationContainer.getAnnotatorState();
    SourceDocument sourceDocument = state.getDocument();
    Map<String, JCas> jCases = new HashMap<>();
    // This is the CAS that the user can actively edit
    JCas annotatorCas = getAnnotatorCas(state, aAnnotationSelectionByUsernameAndAddress, sourceDocument, jCases);
    // We store the CAS that the user will edit as the "CURATION USER"
    jCases.put(CURATION_USER, annotatorCas);
    // get differing feature structures
    Map<String, Map<VID, AnnotationState>> annoStates = calcColors(state, aCurationSegment, annotatorCas, jCases);
    List<String> usernamesSorted = new ArrayList<>(jCases.keySet());
    Collections.sort(usernamesSorted);
    final Mode mode = state.getMode();
    boolean isAutomationMode = mode.equals(Mode.AUTOMATION);
    boolean isCorrectionMode = mode.equals(Mode.CORRECTION);
    boolean isCurationMode = mode.equals(Mode.CURATION);
    List<UserAnnotationSegment> segments = new ArrayList<>();
    for (String username : usernamesSorted) {
        if ((!username.equals(CURATION_USER) && isCurationMode) || (username.equals(CURATION_USER) && (isAutomationMode || isCorrectionMode))) {
            JCas jCas = jCases.get(username);
            // Set up coloring strategy
            ColoringStrategy curationColoringStrategy = makeColoringStrategy(annoStates.get(username));
            // Create curation view for the current user
            UserAnnotationSegment seg = new UserAnnotationSegment();
            seg.setUsername(username);
            seg.setAnnotatorState(state);
            seg.setCollectionData(getCollectionInformation(annotationService, aCurationContainer));
            seg.setDocumentResponse(render(jCas, state, curationColoringStrategy));
            seg.setSelectionByUsernameAndAddress(aAnnotationSelectionByUsernameAndAddress);
            segments.add(seg);
        }
    }
    sentenceListView.setModelObject(segments);
    if (aTarget != null) {
        aTarget.add(this);
    }
}
Also used : HashMap(java.util.HashMap) Mode(de.tudarmstadt.ukp.clarin.webanno.model.Mode) AnnotatorState(de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.AnnotatorState) SourceDocument(de.tudarmstadt.ukp.clarin.webanno.model.SourceDocument) ArrayList(java.util.ArrayList) JCas(org.apache.uima.jcas.JCas) ColoringStrategy(de.tudarmstadt.ukp.clarin.webanno.api.annotation.coloring.ColoringStrategy) Map(java.util.Map) HashMap(java.util.HashMap) UserAnnotationSegment(de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.model.UserAnnotationSegment)

Example 4 with UserAnnotationSegment

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

the class SuggestionViewPanel method updatePanel.

/**
 * @param aTarget
 *            the AJAX target.
 * @param aCurationContainer
 *            the container.
 * @param aAnnotationSelectionByUsernameAndAddress
 *            selections by user.
 * @param aCurationSegment
 *            the segment.
 * @throws UIMAException
 *             hum?
 * @throws ClassNotFoundException
 *             hum?
 * @throws IOException
 *             hum?
 * @throws AnnotationException
 *             hum?
 */
public void updatePanel(AjaxRequestTarget aTarget, CurationContainer aCurationContainer, Map<String, Map<Integer, AnnotationSelection>> aAnnotationSelectionByUsernameAndAddress, SourceListView aCurationSegment) throws UIMAException, ClassNotFoundException, IOException, AnnotationException {
    AnnotatorState state = aCurationContainer.getAnnotatorState();
    SourceDocument sourceDocument = state.getDocument();
    Map<String, JCas> jCases = new HashMap<>();
    // This is the CAS that the user can actively edit
    JCas annotatorCas = getAnnotatorCas(state, aAnnotationSelectionByUsernameAndAddress, sourceDocument, jCases);
    // We store the CAS that the user will edit as the "CURATION USER"
    jCases.put(CURATION_USER, annotatorCas);
    // get differing feature structures
    Map<String, Map<VID, AnnotationState>> annoStates = calcColors(state, aCurationSegment, annotatorCas, jCases);
    sentenceListView.visitChildren(BratSuggestionVisualizer.class, (v, visit) -> {
        BratSuggestionVisualizer vis = (BratSuggestionVisualizer) v;
        UserAnnotationSegment seg = vis.getModelObject();
        JCas jCas = jCases.get(seg.getUsername());
        // Set up coloring strategy
        ColoringStrategy curationColoringStrategy = makeColoringStrategy(annoStates.get(seg.getUsername()));
        // Create curation view for the current user
        try {
            seg.setCollectionData(getCollectionInformation(annotationService, aCurationContainer));
            seg.setDocumentResponse(render(jCas, state, curationColoringStrategy));
            seg.setAnnotatorState(state);
            seg.setSelectionByUsernameAndAddress(aAnnotationSelectionByUsernameAndAddress);
        } catch (IOException e) {
            error("Unable to render: " + e.getMessage());
            LOG.error("Unable to render", e);
        }
        vis.requestRender(aTarget);
    });
}
Also used : BratSuggestionVisualizer(de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.model.BratSuggestionVisualizer) HashMap(java.util.HashMap) AnnotatorState(de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.AnnotatorState) SourceDocument(de.tudarmstadt.ukp.clarin.webanno.model.SourceDocument) JCas(org.apache.uima.jcas.JCas) ColoringStrategy(de.tudarmstadt.ukp.clarin.webanno.api.annotation.coloring.ColoringStrategy) IOException(java.io.IOException) Map(java.util.Map) HashMap(java.util.HashMap) UserAnnotationSegment(de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.model.UserAnnotationSegment)

Aggregations

AnnotatorState (de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.AnnotatorState)4 UserAnnotationSegment (de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.model.UserAnnotationSegment)4 JCas (org.apache.uima.jcas.JCas)4 IOException (java.io.IOException)3 ColoringStrategy (de.tudarmstadt.ukp.clarin.webanno.api.annotation.coloring.ColoringStrategy)2 AnnotationException (de.tudarmstadt.ukp.clarin.webanno.api.annotation.exception.AnnotationException)2 AnnotatorStateImpl (de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.AnnotatorStateImpl)2 BratAnnotationEditor (de.tudarmstadt.ukp.clarin.webanno.brat.annotation.BratAnnotationEditor)2 SourceDocument (de.tudarmstadt.ukp.clarin.webanno.model.SourceDocument)2 ConfirmationDialog (de.tudarmstadt.ukp.clarin.webanno.support.dialog.ConfirmationDialog)2 ActionBarLink (de.tudarmstadt.ukp.clarin.webanno.support.lambda.ActionBarLink)2 LambdaAjaxLink (de.tudarmstadt.ukp.clarin.webanno.support.lambda.LambdaAjaxLink)2 LambdaAjaxSubmitLink (de.tudarmstadt.ukp.clarin.webanno.support.lambda.LambdaAjaxSubmitLink)2 FinishImage (de.tudarmstadt.ukp.clarin.webanno.ui.annotation.component.FinishImage)2 AnnotationPreferencesDialog (de.tudarmstadt.ukp.clarin.webanno.ui.annotation.dialog.AnnotationPreferencesDialog)2 ExportDocumentDialog (de.tudarmstadt.ukp.clarin.webanno.ui.annotation.dialog.ExportDocumentDialog)2 GuidelinesDialog (de.tudarmstadt.ukp.clarin.webanno.ui.annotation.dialog.GuidelinesDialog)2 OpenDocumentDialog (de.tudarmstadt.ukp.clarin.webanno.ui.annotation.dialog.OpenDocumentDialog)2 SuggestionViewPanel (de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.SuggestionViewPanel)2 CurationContainer (de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.model.CurationContainer)2