Search in sources :

Example 1 with FeatureEditor

use of de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.editor.FeatureEditor 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;
}
Also used : LinkFeatureEditor(de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.editor.LinkFeatureEditor) FeatureState(de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.FeatureState) LinkFeatureEditor(de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.editor.LinkFeatureEditor) FeatureEditor(de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.editor.FeatureEditor)

Example 2 with FeatureEditor

use of de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.editor.FeatureEditor 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;
}
Also used : BooleanFeatureEditor(de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.editor.BooleanFeatureEditor) TextFeatureEditor(de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.editor.TextFeatureEditor) NumberFeatureEditor(de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.editor.NumberFeatureEditor) FeatureState(de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.FeatureState) BooleanFeatureEditor(de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.editor.BooleanFeatureEditor) NumberFeatureEditor(de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.editor.NumberFeatureEditor) TextFeatureEditor(de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.editor.TextFeatureEditor) FeatureEditor(de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.editor.FeatureEditor)

Example 3 with FeatureEditor

use of de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.editor.FeatureEditor in project webanno by webanno.

the class AnnotationFeatureForm method createForwardAnnotationCheckBox.

private CheckBox createForwardAnnotationCheckBox() {
    return new CheckBox("forwardAnnotation") {

        private static final long serialVersionUID = 8908304272310098353L;

        {
            setOutputMarkupId(true);
            add(new AjaxFormComponentUpdatingBehavior("change") {

                private static final long serialVersionUID = 5179816588460867471L;

                @Override
                protected void onUpdate(AjaxRequestTarget aTarget) {
                    if (AnnotationFeatureForm.this.getModelObject().isForwardAnnotation()) {
                        List<AnnotationFeature> features = getEnabledFeatures(AnnotationFeatureForm.this.getModelObject().getSelectedAnnotationLayer());
                        if (features.size() > 1) {
                            // forward annotation process checking)
                            return;
                        }
                        // forward annotations
                        if (!features.isEmpty() && features.get(0).getTagset() == null) {
                            FeatureEditor editor = getFirstFeatureEditor();
                            if (editor != null) {
                                aTarget.focusComponent(editor.getFocusComponent());
                            }
                        } else {
                            aTarget.appendJavaScript(JavascriptUtils.getFocusScript(forwardAnnotationText));
                            selectedTag = "";
                        }
                    }
                }
            });
        }

        @Override
        protected void onConfigure() {
            super.onConfigure();
            setEnabled(isForwardable());
            if (!isForwardable()) {
                AnnotationFeatureForm.this.getModelObject().setForwardAnnotation(false);
            }
        }
    };
}
Also used : AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) CheckBox(org.apache.wicket.markup.html.form.CheckBox) List(java.util.List) ArrayList(java.util.ArrayList) LinkFeatureEditor(de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.editor.LinkFeatureEditor) FeatureEditor(de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.editor.FeatureEditor)

Aggregations

FeatureEditor (de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.editor.FeatureEditor)3 LinkFeatureEditor (de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.editor.LinkFeatureEditor)2 FeatureState (de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.FeatureState)2 BooleanFeatureEditor (de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.editor.BooleanFeatureEditor)1 NumberFeatureEditor (de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.editor.NumberFeatureEditor)1 TextFeatureEditor (de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.editor.TextFeatureEditor)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)1 AjaxFormComponentUpdatingBehavior (org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior)1 CheckBox (org.apache.wicket.markup.html.form.CheckBox)1