use of de.tudarmstadt.ukp.clarin.webanno.model.Mode.CURATION in project webanno by webanno.
the class AnnotationPreferencesDialogContent method loadModel.
private Preferences loadModel(AnnotatorState state) {
AnnotationPreference prefs = state.getPreferences();
// Import current settings from the annotator
Preferences model = new Preferences();
model.windowSize = Math.max(prefs.getWindowSize(), 1);
model.sidebarSize = prefs.getSidebarSize();
model.fontZoom = prefs.getFontZoom();
model.scrollPage = prefs.isScrollPage();
model.colorPerLayer = prefs.getColorPerLayer();
model.readonlyLayerColoringBehaviour = prefs.getReadonlyLayerColoringBehaviour();
model.rememberLayer = prefs.isRememberLayer();
model.collapseArcs = prefs.isCollapseArcs();
AnnotationEditorFactory editorFactory = annotationEditorRegistry.getEditorFactory(state.getPreferences().getEditor());
if (editorFactory == null) {
editorFactory = annotationEditorRegistry.getDefaultEditorFactory();
}
model.editor = Pair.of(editorFactory.getBeanName(), editorFactory.getDisplayName());
model.annotationLayers = annotationService.listAnnotationLayer(state.getProject()).stream().filter(layer -> layer.isEnabled()).filter(layer -> !Token.class.getName().equals(layer.getName())).filter(layer -> !(layer.getType().equals(CHAIN_TYPE) && (state.getMode().equals(CORRECTION) || // disable coreference annotation for correction/curation pages
state.getMode().equals(CURATION)))).collect(Collectors.toList());
return model;
}
use of de.tudarmstadt.ukp.clarin.webanno.model.Mode.CURATION in project webanno by webanno.
the class SuggestionViewPanel method onClientEvent.
/**
* Method is called, if user has clicked on a span or an arc in the sentence panel. The span or
* arc respectively is identified and copied to the merge CAS.
*/
protected void onClientEvent(AjaxRequestTarget aTarget, UserAnnotationSegment aSegment) throws UIMAException, IOException, AnnotationException {
if (isDocumentFinished(documentService, aSegment.getAnnotatorState())) {
error("This document is already closed. Please ask the project manager to re-open it.");
aTarget.addChildren(getPage(), IFeedback.class);
return;
}
IRequestParameters request = getRequest().getPostParameters();
StringValue action = request.getParameterValue(PARAM_ACTION);
if (!action.isEmpty()) {
String type = removePrefix(request.getParameterValue(PARAM_TYPE).toString());
AnnotationLayer layer = schemaService.getLayer(TypeUtil.getLayerId(type));
VID sourceVid = VID.parse(request.getParameterValue(PARAM_ID).toString());
CAS targetCas = readEditorCas(aSegment.getAnnotatorState());
CAS sourceCas = readAnnotatorCas(aSegment);
AnnotatorState sourceState = aSegment.getAnnotatorState();
if (CHAIN_TYPE.equals(layer.getType())) {
error("Coreference annotations are not supported in curation");
aTarget.addChildren(getPage(), IFeedback.class);
return;
}
if (ACTION_CONTEXT_MENU.equals(action.toString())) {
// No bulk actions supports for slots at the moment.
if (sourceVid.isSlotSet()) {
return;
}
List<IMenuItem> items = contextMenu.getItemList();
items.clear();
items.add(new LambdaMenuItem(String.format("Merge all %s", layer.getUiName()), _target -> actionAcceptAll(_target, aSegment, layer)));
contextMenu.onOpen(aTarget);
return;
}
// check if clicked on a span
CasMerge casMerge = new CasMerge(schemaService);
if (ACTION_SELECT_SPAN_FOR_MERGE.equals(action.toString())) {
mergeSpan(casMerge, targetCas, sourceCas, sourceVid, sourceState.getDocument(), sourceState.getUser().getUsername(), layer);
} else // check if clicked on an arc (relation or slot)
if (ACTION_SELECT_ARC_FOR_MERGE.equals(action.toString())) {
// this is a slot arc
if (sourceVid.isSlotSet()) {
mergeSlot(casMerge, targetCas, sourceCas, sourceVid, sourceState.getDocument(), sourceState.getUser().getUsername(), layer);
} else // normal relation annotation arc is clicked
{
mergeRelation(casMerge, targetCas, sourceCas, sourceVid, sourceState.getDocument(), sourceState.getUser().getUsername(), layer);
}
}
writeEditorCas(sourceState, targetCas);
// Update timestamp
AnnotationFS sourceAnnotation = selectAnnotationByAddr(sourceCas, sourceVid.getId());
int sentenceNumber = getSentenceNumber(sourceAnnotation.getCAS(), sourceAnnotation.getBegin());
sourceState.getDocument().setSentenceAccessed(sentenceNumber);
if (sourceState.getPreferences().isScrollPage()) {
sourceState.getPagingStrategy().moveToOffset(sourceState, targetCas, sourceAnnotation.getBegin(), CENTERED);
}
onChange(aTarget);
}
}
Aggregations