Search in sources :

Example 1 with ActionBarLink

use of de.tudarmstadt.ukp.clarin.webanno.support.lambda.ActionBarLink in project webanno by webanno.

the class AnnotationPageBase method createOrGetResetDocumentLink.

protected ActionBarLink createOrGetResetDocumentLink() {
    if (resetDocumentLink == null) {
        resetDocumentLink = new ActionBarLink("showResetDocumentDialog", t -> resetDocumentDialog.show(t));
        resetDocumentLink.onConfigure(_this -> {
            AnnotatorState state = AnnotationPageBase.this.getModelObject();
            _this.setEnabled(state.getDocument() != null && !documentService.isAnnotationFinished(state.getDocument(), state.getUser()));
        });
    }
    return resetDocumentLink;
}
Also used : TypeAdapter(de.tudarmstadt.ukp.clarin.webanno.api.annotation.adapter.TypeAdapter) AnnotationFS(org.apache.uima.cas.text.AnnotationFS) SpringBean(org.apache.wicket.spring.injection.annot.SpringBean) AnnotatorState(de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.AnnotatorState) StringResourceModel(org.apache.wicket.model.StringResourceModel) LoggerFactory(org.slf4j.LoggerFactory) CAS(org.apache.uima.cas.CAS) WebAnnoCasUtil(de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil) Sentence(de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence) ActionBarLink(de.tudarmstadt.ukp.clarin.webanno.support.lambda.ActionBarLink) ApplicationPageBase(de.tudarmstadt.ukp.clarin.webanno.ui.core.page.ApplicationPageBase) AnnotationSchemaService(de.tudarmstadt.ukp.clarin.webanno.api.AnnotationSchemaService) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) ChallengeResponseDialog(de.tudarmstadt.ukp.clarin.webanno.support.dialog.ChallengeResponseDialog) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IModel(org.apache.wicket.model.IModel) JCas(org.apache.uima.jcas.JCas) Label(org.apache.wicket.markup.html.basic.Label) DocumentService(de.tudarmstadt.ukp.clarin.webanno.api.DocumentService) CasUtil.select(org.apache.uima.fit.util.CasUtil.select) IOException(java.io.IOException) IFeedback(org.apache.wicket.feedback.IFeedback) Objects(java.util.Objects) List(java.util.List) PropertyModel(org.apache.wicket.model.PropertyModel) AnnotationFeature(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature) AnnotationLayer(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer) SourceDocument(de.tudarmstadt.ukp.clarin.webanno.model.SourceDocument) LambdaModel(de.tudarmstadt.ukp.clarin.webanno.support.lambda.LambdaModel) ActionBarLink(de.tudarmstadt.ukp.clarin.webanno.support.lambda.ActionBarLink) AnnotatorState(de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.AnnotatorState)

Example 2 with ActionBarLink

use of de.tudarmstadt.ukp.clarin.webanno.support.lambda.ActionBarLink 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 3 with ActionBarLink

use of de.tudarmstadt.ukp.clarin.webanno.support.lambda.ActionBarLink in project webanno by webanno.

the class AnnotationPage method commonInit.

private void commonInit() {
    setModel(Model.of(new AnnotatorStateImpl(Mode.ANNOTATION)));
    // Ensure that a user is set
    getModelObject().setUser(userRepository.getCurrentUser());
    add(createUrlFragmentBehavior());
    add(annotationEditor = createAnnotationEditor());
    add(createRightSidebar());
    add(createLeftSidebar());
    add(createDocumentInfoLabel());
    add(getOrCreatePositionInfoLabel());
    add(openDocumentsModal = new OpenDocumentDialog("openDocumentsModal", getModel(), getAllowedProjects()) {

        private static final long serialVersionUID = 5474030848589262638L;

        @Override
        public void onDocumentSelected(AjaxRequestTarget aTarget) {
            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("initialLoadComplete", this::actionInitialLoadComplete));
    add(new LambdaAjaxLink("showOpenDocumentDialog", this::actionShowOpenDocumentDialog));
    add(new ActionBarLink("showPreferencesDialog", this::actionShowPreferencesDialog));
    add(new ActionBarLink("showGuidelinesDialog", guidelinesDialog::show));
    add(new ActionBarLink("showExportDialog", exportDialog::show).onConfigure(_this -> {
        AnnotatorState state = AnnotationPage.this.getModelObject();
        _this.setVisible(state.getProject() != null && (isAdmin(state.getProject(), projectService, state.getUser()) || !state.getProject().isDisableExport()));
    }));
    add(new ActionBarLink("showPreviousDocument", t -> actionShowPreviousDocument(t)).add(new InputBehavior(new KeyType[] { KeyType.Shift, KeyType.Page_up }, EventType.click)));
    add(new ActionBarLink("showNextDocument", t -> actionShowNextDocument(t)).add(new InputBehavior(new KeyType[] { KeyType.Shift, KeyType.Page_down }, EventType.click)));
    add(new ActionBarLink("showNext", t -> actionShowNextPage(t)).add(new InputBehavior(new KeyType[] { KeyType.Page_down }, EventType.click)));
    add(new ActionBarLink("showPrevious", t -> actionShowPreviousPage(t)).add(new InputBehavior(new KeyType[] { KeyType.Page_up }, EventType.click)));
    add(new ActionBarLink("showFirst", t -> actionShowFirstPage(t)).add(new InputBehavior(new KeyType[] { KeyType.Home }, EventType.click)));
    add(new ActionBarLink("showLast", t -> actionShowLastPage(t)).add(new InputBehavior(new KeyType[] { KeyType.End }, EventType.click)));
    add(new ActionBarLink("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 = AnnotationPage.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 : SpringBean(org.apache.wicket.spring.injection.annot.SpringBean) AnnotationEditorBase(de.tudarmstadt.ukp.clarin.webanno.api.annotation.AnnotationEditorBase) LoggerFactory(org.slf4j.LoggerFactory) ConstraintsService(de.tudarmstadt.ukp.clarin.webanno.constraints.ConstraintsService) NoResultException(javax.persistence.NoResultException) AnnotatorStateImpl(de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.AnnotatorStateImpl) AnnotationDetailEditorPanel(de.tudarmstadt.ukp.clarin.webanno.ui.annotation.detail.AnnotationDetailEditorPanel) Sentence(de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence) PAGE_PARAM_DOCUMENT_ID(de.tudarmstadt.ukp.clarin.webanno.api.WebAnnoConst.PAGE_PARAM_DOCUMENT_ID) OpenDocumentDialog(de.tudarmstadt.ukp.clarin.webanno.ui.annotation.dialog.OpenDocumentDialog) UrlFragment(org.wicketstuff.urlfragment.UrlFragment) ActionBarLink(de.tudarmstadt.ukp.clarin.webanno.support.lambda.ActionBarLink) FinishImage(de.tudarmstadt.ukp.clarin.webanno.ui.annotation.component.FinishImage) SessionMetaData(de.tudarmstadt.ukp.clarin.webanno.api.SessionMetaData) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) AnnotationEditorExtensionRegistry(de.tudarmstadt.ukp.clarin.webanno.api.annotation.AnnotationEditorExtensionRegistry) Locale(java.util.Locale) GuidelinesDialog(de.tudarmstadt.ukp.clarin.webanno.ui.annotation.dialog.GuidelinesDialog) Map(java.util.Map) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IModel(org.apache.wicket.model.IModel) StringValue(org.apache.wicket.util.string.StringValue) JCas(org.apache.uima.jcas.JCas) NumberTextField(org.apache.wicket.markup.html.form.NumberTextField) DocumentNamePanel(de.tudarmstadt.ukp.clarin.webanno.ui.annotation.component.DocumentNamePanel) SecurityUtil.isAnnotator(de.tudarmstadt.ukp.clarin.webanno.api.SecurityUtil.isAnnotator) WebAnnoConst(de.tudarmstadt.ukp.clarin.webanno.api.WebAnnoConst) ANNOTATION_IN_PROGRESS_TO_ANNOTATION_FINISHED(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationDocumentStateTransition.ANNOTATION_IN_PROGRESS_TO_ANNOTATION_FINISHED) Model(org.apache.wicket.model.Model) UserDao(de.tudarmstadt.ukp.clarin.webanno.security.UserDao) AnnotationDocument(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationDocument) PAGE_PARAM_FOCUS(de.tudarmstadt.ukp.clarin.webanno.api.WebAnnoConst.PAGE_PARAM_FOCUS) AttributeModifier(org.apache.wicket.AttributeModifier) IHeaderResponse(org.apache.wicket.markup.head.IHeaderResponse) AnnotationDocumentState(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationDocumentState) IFeedback(org.apache.wicket.feedback.IFeedback) SettingsService(de.tudarmstadt.ukp.clarin.webanno.api.SettingsService) List(java.util.List) AnnotationEditorFactory(de.tudarmstadt.ukp.clarin.webanno.api.annotation.AnnotationEditorFactory) ProjectType(de.tudarmstadt.ukp.clarin.webanno.api.ProjectType) SourceDocument(de.tudarmstadt.ukp.clarin.webanno.model.SourceDocument) ApplicationEventPublisherHolder(de.tudarmstadt.ukp.clarin.webanno.support.spring.ApplicationEventPublisherHolder) KeyType(wicket.contrib.input.events.key.KeyType) AnnotationPreferencesDialog(de.tudarmstadt.ukp.clarin.webanno.ui.annotation.dialog.AnnotationPreferencesDialog) Form(org.apache.wicket.markup.html.form.Form) SecurityUtil.isAdmin(de.tudarmstadt.ukp.clarin.webanno.api.SecurityUtil.isAdmin) ExportDocumentDialog(de.tudarmstadt.ukp.clarin.webanno.ui.annotation.dialog.ExportDocumentDialog) ProjectService(de.tudarmstadt.ukp.clarin.webanno.api.ProjectService) SourceDocumentState(de.tudarmstadt.ukp.clarin.webanno.model.SourceDocumentState) AnnotatorState(de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.AnnotatorState) StringResourceModel(org.apache.wicket.model.StringResourceModel) WebAnnoCasUtil.selectByAddr(de.tudarmstadt.ukp.clarin.webanno.api.annotation.util.WebAnnoCasUtil.selectByAddr) Mode(de.tudarmstadt.ukp.clarin.webanno.model.Mode) ArrayList(java.util.ArrayList) AnnotationSchemaService(de.tudarmstadt.ukp.clarin.webanno.api.AnnotationSchemaService) ConfirmationDialog(de.tudarmstadt.ukp.clarin.webanno.support.dialog.ConfirmationDialog) User(de.tudarmstadt.ukp.clarin.webanno.security.model.User) PAGE_PARAM_PROJECT_ID(de.tudarmstadt.ukp.clarin.webanno.api.WebAnnoConst.PAGE_PARAM_PROJECT_ID) MountPath(org.wicketstuff.annotation.mount.MountPath) Project(de.tudarmstadt.ukp.clarin.webanno.model.Project) IRequestParameters(org.apache.wicket.request.IRequestParameters) DecoratedObject(de.tudarmstadt.ukp.clarin.webanno.support.wicket.DecoratedObject) DocumentService(de.tudarmstadt.ukp.clarin.webanno.api.DocumentService) Logger(org.slf4j.Logger) CssContentHeaderItem(org.apache.wicket.markup.head.CssContentHeaderItem) LambdaAjaxSubmitLink(de.tudarmstadt.ukp.clarin.webanno.support.lambda.LambdaAjaxSubmitLink) IOException(java.io.IOException) OnLoadHeaderItem(org.apache.wicket.markup.head.OnLoadHeaderItem) SidebarPanel(de.tudarmstadt.ukp.clarin.webanno.ui.annotation.sidebar.SidebarPanel) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) LambdaAjaxLink(de.tudarmstadt.ukp.clarin.webanno.support.lambda.LambdaAjaxLink) NEW_TO_ANNOTATION_IN_PROGRESS(de.tudarmstadt.ukp.clarin.webanno.model.SourceDocumentStateTransition.NEW_TO_ANNOTATION_IN_PROGRESS) JCasUtil.select(org.apache.uima.fit.util.JCasUtil.select) Session(org.apache.wicket.Session) DocumentOpenedEvent(de.tudarmstadt.ukp.clarin.webanno.api.annotation.event.DocumentOpenedEvent) EventType(wicket.contrib.input.events.EventType) LambdaModel(de.tudarmstadt.ukp.clarin.webanno.support.lambda.LambdaModel) WicketUtil(de.tudarmstadt.ukp.clarin.webanno.support.wicket.WicketUtil) AnnotationEditorRegistry(de.tudarmstadt.ukp.clarin.webanno.api.annotation.AnnotationEditorRegistry) UrlParametersReceivingBehavior(de.tudarmstadt.ukp.clarin.webanno.support.wicketstuff.UrlParametersReceivingBehavior) InputBehavior(wicket.contrib.input.events.InputBehavior) InputBehavior(wicket.contrib.input.events.InputBehavior) 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) LambdaAjaxSubmitLink(de.tudarmstadt.ukp.clarin.webanno.support.lambda.LambdaAjaxSubmitLink) ConfirmationDialog(de.tudarmstadt.ukp.clarin.webanno.support.dialog.ConfirmationDialog) FinishImage(de.tudarmstadt.ukp.clarin.webanno.ui.annotation.component.FinishImage) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) LambdaAjaxLink(de.tudarmstadt.ukp.clarin.webanno.support.lambda.LambdaAjaxLink) ExportDocumentDialog(de.tudarmstadt.ukp.clarin.webanno.ui.annotation.dialog.ExportDocumentDialog) GuidelinesDialog(de.tudarmstadt.ukp.clarin.webanno.ui.annotation.dialog.GuidelinesDialog) OpenDocumentDialog(de.tudarmstadt.ukp.clarin.webanno.ui.annotation.dialog.OpenDocumentDialog) StringResourceModel(org.apache.wicket.model.StringResourceModel)

Example 4 with ActionBarLink

use of de.tudarmstadt.ukp.clarin.webanno.support.lambda.ActionBarLink 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)

Aggregations

AnnotatorState (de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.AnnotatorState)4 ActionBarLink (de.tudarmstadt.ukp.clarin.webanno.support.lambda.ActionBarLink)4 IOException (java.io.IOException)4 JCas (org.apache.uima.jcas.JCas)4 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)4 IFeedback (org.apache.wicket.feedback.IFeedback)4 StringResourceModel (org.apache.wicket.model.StringResourceModel)4 AnnotatorStateImpl (de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.AnnotatorStateImpl)3 ConfirmationDialog (de.tudarmstadt.ukp.clarin.webanno.support.dialog.ConfirmationDialog)3 LambdaAjaxLink (de.tudarmstadt.ukp.clarin.webanno.support.lambda.LambdaAjaxLink)3 LambdaAjaxSubmitLink (de.tudarmstadt.ukp.clarin.webanno.support.lambda.LambdaAjaxSubmitLink)3 FinishImage (de.tudarmstadt.ukp.clarin.webanno.ui.annotation.component.FinishImage)3 AnnotationPreferencesDialog (de.tudarmstadt.ukp.clarin.webanno.ui.annotation.dialog.AnnotationPreferencesDialog)3 ExportDocumentDialog (de.tudarmstadt.ukp.clarin.webanno.ui.annotation.dialog.ExportDocumentDialog)3 GuidelinesDialog (de.tudarmstadt.ukp.clarin.webanno.ui.annotation.dialog.GuidelinesDialog)3 OpenDocumentDialog (de.tudarmstadt.ukp.clarin.webanno.ui.annotation.dialog.OpenDocumentDialog)3 AnnotationSchemaService (de.tudarmstadt.ukp.clarin.webanno.api.AnnotationSchemaService)2 DocumentService (de.tudarmstadt.ukp.clarin.webanno.api.DocumentService)2 AnnotationException (de.tudarmstadt.ukp.clarin.webanno.api.annotation.exception.AnnotationException)2 BratAnnotationEditor (de.tudarmstadt.ukp.clarin.webanno.brat.annotation.BratAnnotationEditor)2