Search in sources :

Example 1 with ActionBar

use of de.tudarmstadt.ukp.clarin.webanno.api.annotation.actionbar.ActionBar in project webanno by webanno.

the class AnnotationPage method createChildComponents.

private void createChildComponents() {
    add(createUrlFragmentBehavior());
    centerArea = new WebMarkupContainer("centerArea");
    centerArea.add(visibleWhen(() -> getModelObject().getDocument() != null));
    centerArea.setOutputMarkupPlaceholderTag(true);
    centerArea.add(createDocumentInfoLabel());
    add(centerArea);
    actionBar = new ActionBar("actionBar");
    centerArea.add(actionBar);
    add(createRightSidebar());
    createAnnotationEditor(null);
    leftSidebar = createLeftSidebar();
    add(leftSidebar);
}
Also used : WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) ActionBar(de.tudarmstadt.ukp.clarin.webanno.api.annotation.actionbar.ActionBar)

Example 2 with ActionBar

use of de.tudarmstadt.ukp.clarin.webanno.api.annotation.actionbar.ActionBar 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 preferencesa
    rightSidebar.add(new AttributeModifier("style", LambdaModel.of(() -> String.format("flex-basis: %d%%;", getModelObject().getPreferences().getSidebarSize()))));
    rightSidebar.setOutputMarkupId(true);
    add(rightSidebar);
    centerArea = new WebMarkupContainer("centerArea");
    centerArea.add(visibleWhen(() -> getModelObject().getDocument() != null));
    centerArea.setOutputMarkupPlaceholderTag(true);
    centerArea.add(new DocumentNamePanel("documentNamePanel", getModel()));
    actionBar = new ActionBar("actionBar");
    centerArea.add(actionBar);
    rightSidebar.add(detailEditor = createDetailEditor());
    annotationEditor = new BratAnnotationEditor("mergeView", getModel(), detailEditor, this::getEditorCas);
    centerArea.add(annotationEditor);
    add(centerArea);
    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))));
    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.setState(state);
                CAS editorCas = getEditorCas();
                setCurationSegmentBeginEnd(editorCas);
                suggestionView.requestUpdate(aTarget, curationContainer, annotationSelectionByUsernameAndAddress, curationSegment);
                annotationEditor.requestRender(aTarget);
                update(aTarget);
            } catch (Exception e) {
                handleException(aTarget, e);
            }
        }
    };
    centerArea.add(suggestionView);
    curationContainer = new CurationContainer();
    curationContainer.setState(getModelObject());
}
Also used : AnnotatorStateImpl(de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.AnnotatorStateImpl) AnnotatorState(de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.AnnotatorState) CurationContainer(de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.model.CurationContainer) AttributeModifier(org.apache.wicket.AttributeModifier) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) LinkedList(java.util.LinkedList) 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) DocumentNamePanel(de.tudarmstadt.ukp.clarin.webanno.ui.annotation.component.DocumentNamePanel) IFeedback(org.apache.wicket.feedback.IFeedback) ActionBar(de.tudarmstadt.ukp.clarin.webanno.api.annotation.actionbar.ActionBar) SentenceOrientedPagingStrategy(de.tudarmstadt.ukp.clarin.webanno.api.annotation.paging.SentenceOrientedPagingStrategy) UserAnnotationSegment(de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.model.UserAnnotationSegment)

Example 3 with ActionBar

use of de.tudarmstadt.ukp.clarin.webanno.api.annotation.actionbar.ActionBar 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 4 with ActionBar

use of de.tudarmstadt.ukp.clarin.webanno.api.annotation.actionbar.ActionBar 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);
    rightSidebar.add(detailEditor = createDetailEditor());
    centerArea = new WebMarkupContainer("centerArea");
    centerArea.add(visibleWhen(() -> getModelObject().getDocument() != null));
    centerArea.setOutputMarkupPlaceholderTag(true);
    centerArea.add(createDocumentInfoLabel());
    actionBar = new ActionBar("actionBar");
    centerArea.add(actionBar);
    annotationEditor = new BratAnnotationEditor("mergeView", getModel(), detailEditor, this::getEditorCas);
    centerArea.add(annotationEditor);
    add(centerArea);
    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))));
    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.setState(state);
                CAS editorCas = getEditorCas();
                setCurationSegmentBeginEnd(editorCas);
                suggestionView.requestUpdate(aTarget, curationContainer, annotationSelectionByUsernameAndAddress, curationSegment);
                annotationEditor.requestRender(aTarget);
                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());
            }
        }
    };
    centerArea.add(suggestionView);
    curationContainer = new CurationContainer();
    curationContainer.setState(getModelObject());
}
Also used : AnnotatorStateImpl(de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.AnnotatorStateImpl) AnnotatorState(de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.AnnotatorState) CurationContainer(de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.model.CurationContainer) AttributeModifier(org.apache.wicket.AttributeModifier) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) LinkedList(java.util.LinkedList) 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) 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) UserAnnotationSegment(de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.model.UserAnnotationSegment)

Aggregations

ActionBar (de.tudarmstadt.ukp.clarin.webanno.api.annotation.actionbar.ActionBar)4 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)4 AnnotationException (de.tudarmstadt.ukp.clarin.webanno.api.annotation.exception.AnnotationException)3 AnnotatorStateImpl (de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.AnnotatorStateImpl)3 SentenceOrientedPagingStrategy (de.tudarmstadt.ukp.clarin.webanno.api.annotation.paging.SentenceOrientedPagingStrategy)3 BratAnnotationEditor (de.tudarmstadt.ukp.clarin.webanno.brat.annotation.BratAnnotationEditor)3 SuggestionViewPanel (de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.SuggestionViewPanel)3 CurationContainer (de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.model.CurationContainer)3 UserAnnotationSegment (de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.model.UserAnnotationSegment)3 IOException (java.io.IOException)3 LinkedList (java.util.LinkedList)3 UIMAException (org.apache.uima.UIMAException)3 CAS (org.apache.uima.cas.CAS)3 AttributeModifier (org.apache.wicket.AttributeModifier)3 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)3 IFeedback (org.apache.wicket.feedback.IFeedback)3 ListModel (org.apache.wicket.model.util.ListModel)3 AnnotatorState (de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.AnnotatorState)2 DocumentNamePanel (de.tudarmstadt.ukp.clarin.webanno.ui.annotation.component.DocumentNamePanel)2 User (de.tudarmstadt.ukp.clarin.webanno.security.model.User)1