use of de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.AnnotatorStateImpl 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);
}
use of de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.AnnotatorStateImpl in project webanno by webanno.
the class CopyAnnotationTest method simpleCopyToEmptyTest.
@Test
public void simpleCopyToEmptyTest() throws Exception {
AnnotatorState state = new AnnotatorStateImpl(Mode.CURATION);
state.setUser(new User());
JCas jcas = JCasFactory.createJCas();
Type type = jcas.getTypeSystem().getType(POS.class.getTypeName());
AnnotationFS clickedFs = createPOSAnno(jcas, type, "NN", 0, 0);
JCas mergeCAs = JCasFactory.createJCas();
createTokenAnno(mergeCAs, 0, 0);
MergeCas.addSpanAnnotation(state, annotationSchemaService, posLayer, mergeCAs, clickedFs, false);
assertEquals(1, CasUtil.selectCovered(mergeCAs.getCas(), type, 0, 0).size());
}
use of de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.AnnotatorStateImpl in project webanno by webanno.
the class CopyAnnotationTest method copySpanWithSlotNoStackingTest.
@Test
public void copySpanWithSlotNoStackingTest() throws Exception {
slotLayer.setAllowStacking(false);
JCas jcasA = JCasFactory.createJCas(DiffUtils.createMultiLinkWithRoleTestTypeSytem("f1"));
Type type = jcasA.getTypeSystem().getType(DiffUtils.HOST_TYPE);
Feature feature = type.getFeatureByBaseName("f1");
AnnotationFS clickedFs = DiffUtils.makeLinkHostMultiSPanFeatureFS(jcasA, 0, 0, feature, "A", DiffUtils.makeLinkFS(jcasA, "slot1", 0, 0));
JCas mergeCAs = JCasFactory.createJCas(DiffUtils.createMultiLinkWithRoleTestTypeSytem("f1"));
DiffUtils.makeLinkHostMultiSPanFeatureFS(mergeCAs, 0, 0, feature, "C", DiffUtils.makeLinkFS(mergeCAs, "slot1", 0, 0));
MergeCas.addSpanAnnotation(new AnnotatorStateImpl(Mode.CURATION), annotationSchemaService, slotLayer, mergeCAs, clickedFs, false);
assertEquals(1, CasUtil.selectCovered(mergeCAs.getCas(), type, 0, 0).size());
}
use of de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.AnnotatorStateImpl in project webanno by webanno.
the class CopyAnnotationTest method simpleCopyToDiffExistingAnnoWithStackingTest.
@Test
public void simpleCopyToDiffExistingAnnoWithStackingTest() throws Exception {
AnnotatorState state = new AnnotatorStateImpl(Mode.CURATION);
state.setUser(new User());
posLayer.setAllowStacking(true);
JCas jcas = JCasFactory.createJCas();
Type type = jcas.getTypeSystem().getType(POS.class.getTypeName());
AnnotationFS clickedFs = createPOSAnno(jcas, type, "NN", 0, 0);
JCas mergeCAs = JCasFactory.createJCas();
createTokenAnno(mergeCAs, 0, 0);
AnnotationFS existingFs = mergeCAs.getCas().createAnnotation(type, 0, 0);
Feature posValue = type.getFeatureByBaseName("PosValue");
existingFs.setStringValue(posValue, "NE");
mergeCAs.addFsToIndexes(existingFs);
MergeCas.addSpanAnnotation(state, annotationSchemaService, posLayer, mergeCAs, clickedFs, true);
assertEquals(2, CasUtil.selectCovered(mergeCAs.getCas(), type, 0, 0).size());
}
use of de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.AnnotatorStateImpl in project webanno by webanno.
the class CopyAnnotationTest method copySpanWithSlotWithStackingTest.
@Test
public void copySpanWithSlotWithStackingTest() throws Exception {
AnnotatorState state = new AnnotatorStateImpl(Mode.CURATION);
state.setUser(new User());
slotLayer.setAllowStacking(true);
JCas jcasA = JCasFactory.createJCas(DiffUtils.createMultiLinkWithRoleTestTypeSytem("f1"));
Type type = jcasA.getTypeSystem().getType(DiffUtils.HOST_TYPE);
Feature feature = type.getFeatureByBaseName("f1");
AnnotationFS clickedFs = DiffUtils.makeLinkHostMultiSPanFeatureFS(jcasA, 0, 0, feature, "A", DiffUtils.makeLinkFS(jcasA, "slot1", 0, 0));
JCas mergeCAs = JCasFactory.createJCas(DiffUtils.createMultiLinkWithRoleTestTypeSytem("f1"));
DiffUtils.makeLinkHostMultiSPanFeatureFS(mergeCAs, 0, 0, feature, "C", DiffUtils.makeLinkFS(mergeCAs, "slot1", 0, 0));
MergeCas.addSpanAnnotation(state, annotationSchemaService, slotLayer, mergeCAs, clickedFs, true);
assertEquals(2, CasUtil.selectCovered(mergeCAs.getCas(), type, 0, 0).size());
}
Aggregations