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);
}
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());
}
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);
}
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());
}
Aggregations