use of de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.AnnotatorState in project webanno by webanno.
the class AnnotationFeatureForm method actionDelete.
private void actionDelete(AjaxRequestTarget aTarget) throws IOException, AnnotationException {
AnnotatorState state = AnnotationFeatureForm.this.getModelObject();
AnnotationLayer layer = state.getSelectedAnnotationLayer();
TypeAdapter adapter = annotationService.getAdapter(layer);
JCas jCas = editorPanel.getEditorCas();
AnnotationFS fs = selectByAddr(jCas, state.getSelection().getAnnotation().getId());
if (layer.isReadonly()) {
error("Cannot replace an annotation on a read-only layer.");
aTarget.addChildren(getPage(), IFeedback.class);
return;
}
AttachStatus attachStatus = editorPanel.checkAttachStatus(aTarget, state.getProject(), fs);
if (attachStatus.readOnlyAttached) {
error("Cannot delete an annotation to which annotations on read-only layers attach.");
aTarget.addChildren(getPage(), IFeedback.class);
return;
}
if (adapter instanceof SpanAdapter && attachStatus.attachCount > 0) {
deleteAnnotationDialog.setContentModel(new StringResourceModel("DeleteDialog.text", this, Model.of(layer)).setParameters(attachStatus.attachCount));
deleteAnnotationDialog.setConfirmAction((aCallbackTarget) -> {
editorPanel.actionDelete(aCallbackTarget);
});
deleteAnnotationDialog.show(aTarget);
} else {
editorPanel.actionDelete(aTarget);
}
}
use of de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.AnnotatorState 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);
}
use of de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.AnnotatorState in project webanno by webanno.
the class AnnotationPage method actionFinishDocument.
private void actionFinishDocument(AjaxRequestTarget aTarget) {
finishDocumentDialog.setConfirmAction((aCallbackTarget) -> {
ensureRequiredFeatureValuesSet(aCallbackTarget, getEditorCas());
AnnotatorState state = getModelObject();
AnnotationDocument annotationDocument = documentService.getAnnotationDocument(state.getDocument(), state.getUser());
documentService.transitionAnnotationDocumentState(annotationDocument, ANNOTATION_IN_PROGRESS_TO_ANNOTATION_FINISHED);
// manually update state change!! No idea why it is not updated in the DB
// without calling createAnnotationDocument(...)
documentService.createAnnotationDocument(annotationDocument);
aCallbackTarget.add(finishDocumentIcon);
aCallbackTarget.add(finishDocumentLink);
aCallbackTarget.add(detailEditor);
aCallbackTarget.add(createOrGetResetDocumentLink());
});
finishDocumentDialog.show(aTarget);
}
use of de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.AnnotatorState in project webanno by webanno.
the class AnnotationPage method actionGotoPage.
private void actionGotoPage(AjaxRequestTarget aTarget, Form<?> aForm) throws Exception {
AnnotatorState state = getModelObject();
JCas jcas = getEditorCas();
List<Sentence> sentences = new ArrayList<>(select(jcas, Sentence.class));
int selectedSentence = gotoPageTextField.getModelObject();
selectedSentence = Math.min(selectedSentence, sentences.size());
gotoPageTextField.setModelObject(selectedSentence);
state.setFirstVisibleUnit(sentences.get(selectedSentence - 1));
state.setFocusUnitIndex(selectedSentence);
actionRefreshDocument(aTarget);
}
use of de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.AnnotatorState in project webanno by webanno.
the class AutomationPage method actionFinishDocument.
private void actionFinishDocument(AjaxRequestTarget aTarget) {
finishDocumentDialog.setConfirmAction((aCallbackTarget) -> {
ensureRequiredFeatureValuesSet(aCallbackTarget, getEditorCas());
AnnotatorState state = getModelObject();
AnnotationDocument annotationDocument = documentService.getAnnotationDocument(state.getDocument(), state.getUser());
documentService.transitionAnnotationDocumentState(annotationDocument, ANNOTATION_IN_PROGRESS_TO_ANNOTATION_FINISHED);
aCallbackTarget.add(finishDocumentIcon);
aCallbackTarget.add(finishDocumentLink);
aCallbackTarget.add(detailEditor);
aCallbackTarget.add(createOrGetResetDocumentLink());
});
finishDocumentDialog.show(aTarget);
}
Aggregations