use of de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.FeatureState in project webanno by webanno.
the class AnnotationDetailEditorPanel method actionCreateForward.
private void actionCreateForward(AjaxRequestTarget aTarget, JCas aJCas, boolean aIsForwarded) throws IOException, AnnotationException {
LOG.trace("actionForward(isForwarded: {})", aIsForwarded);
if (isAnnotationFinished()) {
throw new AnnotationException("This document is already closed. Please ask your " + "project manager to re-open it via the Monitoring page");
}
AnnotatorState state = getModelObject();
// Re-set the selected layer from the drop-down since it might have changed if we
// have previously created a relation annotation
state.setSelectedAnnotationLayer(annotationFeatureForm.getLayerSelector().getModelObject());
internalCommitAnnotation(aTarget, aJCas);
if (!aIsForwarded) {
if (state.getSelection().getEnd() >= state.getWindowEndOffset()) {
autoScroll(aJCas, true);
}
List<FeatureState> featureStates = getModelObject().getFeatureStates();
if (featureStates.get(0).value != null) {
LOG.info("BEGIN auto-forward annotation for tagset-based annotation");
AnnotationFS nextToken = WebAnnoCasUtil.getNextToken(aJCas, state.getSelection().getBegin(), state.getSelection().getEnd());
if (nextToken != null) {
if (getModelObject().getWindowEndOffset() > nextToken.getBegin()) {
state.getSelection().selectSpan(aJCas, nextToken.getBegin(), nextToken.getEnd());
actionCreateForward(aTarget, aJCas, true);
}
}
LOG.info("END auto-forward annotation for tagset-based annotation");
} else {
LOG.info("BEGIN auto-forward annotation for free-text annotation");
// remove the entire annotation.
if (featureStates.get(0).value == null) {
TypeAdapter adapter = annotationService.getAdapter(state.getSelectedAnnotationLayer());
AnnotationFS fs = selectByAddr(aJCas, state.getSelection().getAnnotation().getId());
deleteAnnotation(aJCas, state, fs, featureStates.get(0).feature.getLayer(), adapter);
}
AnnotationFS nextToken = WebAnnoCasUtil.getNextToken(aJCas, state.getSelection().getBegin(), state.getSelection().getEnd());
if (nextToken != null) {
if (getModelObject().getWindowEndOffset() > nextToken.getBegin()) {
state.getSelection().selectSpan(aJCas, nextToken.getBegin(), nextToken.getEnd());
actionCreateForward(aTarget, aJCas, true);
}
}
LOG.info("END auto-forward annotation for free-text annotation");
}
LOG.trace("onAutoForward()");
onAutoForward(aTarget);
}
aTarget.add(annotationFeatureForm);
internalCompleteAnnotation(aTarget, aJCas);
}
use of de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.FeatureState in project webanno by webanno.
the class FeatureStateModel method setObject.
@Override
public void setObject(FeatureState object) {
FeatureState fm = state.getObject().getFeatureState(feature);
fm.value = object.value;
// Probably don't need to copy the other fields
}
use of de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.FeatureState in project webanno by webanno.
the class SlotFeatureSupport method createEditor.
@Override
public FeatureEditor createEditor(String aId, MarkupContainer aOwner, AnnotationActionHandler aHandler, final IModel<AnnotatorState> aStateModel, final IModel<FeatureState> aFeatureStateModel) {
FeatureState featureState = aFeatureStateModel.getObject();
final FeatureEditor editor;
switch(featureState.feature.getMultiValueMode()) {
case ARRAY:
switch(featureState.feature.getLinkMode()) {
case WITH_ROLE:
editor = new LinkFeatureEditor(aId, aOwner, aHandler, aStateModel, aFeatureStateModel);
break;
default:
throw unsupportedFeatureTypeException(featureState);
}
break;
case NONE:
throw unsupportedLinkModeException(featureState);
default:
throw unsupportedMultiValueModeException(featureState);
}
return editor;
}
use of de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.FeatureState in project webanno by webanno.
the class PrimitiveUimaFeatureSupport method createEditor.
@Override
public FeatureEditor createEditor(String aId, MarkupContainer aOwner, AnnotationActionHandler aHandler, final IModel<AnnotatorState> aStateModel, final IModel<FeatureState> aFeatureStateModel) {
FeatureState featureState = aFeatureStateModel.getObject();
final FeatureEditor editor;
switch(featureState.feature.getMultiValueMode()) {
case NONE:
switch(featureState.feature.getType()) {
case CAS.TYPE_NAME_INTEGER:
{
editor = new NumberFeatureEditor(aId, aOwner, aFeatureStateModel);
break;
}
case CAS.TYPE_NAME_FLOAT:
{
editor = new NumberFeatureEditor(aId, aOwner, aFeatureStateModel);
break;
}
case CAS.TYPE_NAME_BOOLEAN:
{
editor = new BooleanFeatureEditor(aId, aOwner, aFeatureStateModel);
break;
}
case CAS.TYPE_NAME_STRING:
{
editor = new TextFeatureEditor(aId, aOwner, aFeatureStateModel);
break;
}
default:
throw unsupportedFeatureTypeException(featureState);
}
break;
case // fallthrough
ARRAY:
throw unsupportedLinkModeException(featureState);
default:
throw unsupportedMultiValueModeException(featureState);
}
return editor;
}
use of de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.FeatureState in project webanno by webanno.
the class LinkFeatureEditor method onConfigure.
/**
* Hides feature if "Hide un-constraint feature" is enabled and constraint rules are applied and
* feature doesn't match any constraint rule
*/
@Override
public void onConfigure() {
// Update entries for important tags.
removeAutomaticallyAddedUnusedEntries();
FeatureState featureState = getModelObject();
autoAddImportantTags(featureState.tagset, featureState.possibleValues);
// if enabled and constraints rule execution returns anything other than green
setVisible(!hideUnconstraintFeature || (getModelObject().indicator.isAffected() && getModelObject().indicator.getStatusColor().equals("green")));
}
Aggregations