use of de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.model.SourceListView 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.ui.curation.component.model.SourceListView in project webanno by webanno.
the class SuggestionViewPanel method requestUpdate.
/**
* Schedules a update call for this panel via at the end of the given AJAX cycle. This method
* can be called multiple times, even for the same annotation editor, but only resulting in a
* single update and rendering call.
*/
public final void requestUpdate(AjaxRequestTarget aTarget, CurationContainer aCurationContainer, Map<String, Map<Integer, AnnotationSelection>> aAnnotationSelectionByUsernameAndAddress, SourceListView aCurationSegment) {
LOG.trace("request update");
aTarget.registerRespondListener(new AjaxComponentRespondListener(this, _target -> {
updatePanel(_target, aCurationContainer, aAnnotationSelectionByUsernameAndAddress, aCurationSegment);
}));
}
Aggregations