Search in sources :

Example 1 with LambdaAjaxFormComponentUpdatingBehavior

use of de.tudarmstadt.ukp.clarin.webanno.support.lambda.LambdaAjaxFormComponentUpdatingBehavior in project webanno by webanno.

the class LayerSelectionPanel method createForwardAnnotationCheckBox.

/**
 * Part of <i>forward annotation</i> mode: creates the checkbox to toggle forward annotation
 * mode.
 */
private CheckBox createForwardAnnotationCheckBox() {
    CheckBox checkbox = new CheckBox("forwardAnnotation");
    checkbox.setOutputMarkupId(true);
    checkbox.add(LambdaBehavior.onConfigure(_this -> {
        // Force-disable forward annotation mode if current layer is not forwardable
        if (!isForwardable()) {
            getModelObject().setForwardAnnotation(false);
        }
    }));
    checkbox.add(new LambdaAjaxFormComponentUpdatingBehavior("change", _target -> owner.getFeatureEditorListPanel().focusForwardAnnotationComponent(_target, true)));
    return checkbox;
}
Also used : SpringBean(org.apache.wicket.spring.injection.annot.SpringBean) AnnotatorState(de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.AnnotatorState) AnnotationPageBase(de.tudarmstadt.ukp.clarin.webanno.api.annotation.page.AnnotationPageBase) AnnotationDetailEditorPanel.handleException(de.tudarmstadt.ukp.clarin.webanno.ui.annotation.detail.AnnotationDetailEditorPanel.handleException) Strings.escapeMarkup(org.apache.wicket.util.string.Strings.escapeMarkup) CAS(org.apache.uima.cas.CAS) LambdaBehavior(de.tudarmstadt.ukp.clarin.webanno.support.lambda.LambdaBehavior) CheckBox(org.apache.wicket.markup.html.form.CheckBox) CompoundPropertyModel(org.apache.wicket.model.CompoundPropertyModel) ArrayList(java.util.ArrayList) AnnotationSchemaService(de.tudarmstadt.ukp.clarin.webanno.api.AnnotationSchemaService) Token(de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token) BootstrapSelect(de.agilecoders.wicket.extensions.markup.html.bootstrap.form.select.BootstrapSelect) LambdaBehavior.visibleWhen(de.tudarmstadt.ukp.clarin.webanno.support.lambda.LambdaBehavior.visibleWhen) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) Objects.isNull(java.util.Objects.isNull) ChoiceRenderer(org.apache.wicket.markup.html.form.ChoiceRenderer) DefaultLayerChangedEvent(de.tudarmstadt.ukp.clarin.webanno.ui.annotation.event.DefaultLayerChangedEvent) SINGLE_TOKEN(de.tudarmstadt.ukp.clarin.webanno.model.AnchoringMode.SINGLE_TOKEN) IModel(org.apache.wicket.model.IModel) UserPreferencesService(de.tudarmstadt.ukp.clarin.webanno.api.annotation.preferences.UserPreferencesService) Label(org.apache.wicket.markup.html.basic.Label) LambdaAjaxFormComponentUpdatingBehavior(de.tudarmstadt.ukp.clarin.webanno.support.lambda.LambdaAjaxFormComponentUpdatingBehavior) Model(org.apache.wicket.model.Model) UserDao(de.tudarmstadt.ukp.clarin.webanno.security.UserDao) IOException(java.io.IOException) LoadableDetachableModel(org.apache.wicket.model.LoadableDetachableModel) SPAN_TYPE(de.tudarmstadt.ukp.clarin.webanno.api.WebAnnoConst.SPAN_TYPE) Collectors(java.util.stream.Collectors) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) Panel(org.apache.wicket.markup.html.panel.Panel) List(java.util.List) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AnnotationFeature(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature) AnnotationLayer(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer) CHAIN_TYPE(de.tudarmstadt.ukp.clarin.webanno.api.WebAnnoConst.CHAIN_TYPE) Broadcast(org.apache.wicket.event.Broadcast) FeatureSupportRegistry(de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.FeatureSupportRegistry) CheckBox(org.apache.wicket.markup.html.form.CheckBox) LambdaAjaxFormComponentUpdatingBehavior(de.tudarmstadt.ukp.clarin.webanno.support.lambda.LambdaAjaxFormComponentUpdatingBehavior)

Example 2 with LambdaAjaxFormComponentUpdatingBehavior

use of de.tudarmstadt.ukp.clarin.webanno.support.lambda.LambdaAjaxFormComponentUpdatingBehavior in project webanno by webanno.

the class AnnotationPreferencesDialogContent method createLayerContainer.

private ListView<AnnotationLayer> createLayerContainer() {
    return new ListView<AnnotationLayer>("annotationLayers") {

        private static final long serialVersionUID = -4040731191748923013L;

        @Override
        protected void populateItem(ListItem<AnnotationLayer> aItem) {
            Preferences prefs = form.getModelObject();
            AnnotationLayer layer = aItem.getModelObject();
            Set<Long> hiddenLayerIds = stateModel.getObject().getPreferences().getHiddenAnnotationLayerIds();
            // add visibility checkbox
            CheckBox layerVisible = new CheckBox("annotationLayerActive", Model.of(!hiddenLayerIds.contains(layer.getId())));
            layerVisible.add(new LambdaAjaxFormComponentUpdatingBehavior("change", _target -> {
                if (!layerVisible.getModelObject()) {
                    hiddenLayerIds.add(layer.getId());
                } else {
                    hiddenLayerIds.remove(layer.getId());
                }
            }));
            aItem.add(layerVisible);
            // add coloring strategy choice
            DropDownChoice<ColoringStrategyType> layerColor = new BootstrapSelect<>("layercoloring");
            layerColor.setModel(Model.of(prefs.colorPerLayer.get(layer.getId())));
            layerColor.setChoiceRenderer(new ChoiceRenderer<>("descriptiveName"));
            layerColor.setChoices(asList(ColoringStrategyType.values()));
            layerColor.add(new LambdaAjaxFormComponentUpdatingBehavior("change", _target -> prefs.colorPerLayer.put(layer.getId(), layerColor.getModelObject())));
            aItem.add(layerColor);
            // add label
            aItem.add(new Label("annotationLayerDesc", layer.getUiName()));
        }
    };
}
Also used : Form(org.apache.wicket.markup.html.form.Form) SpringBean(org.apache.wicket.spring.injection.annot.SpringBean) ProjectService(de.tudarmstadt.ukp.clarin.webanno.api.ProjectService) AnnotatorState(de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.AnnotatorState) ColoringStrategyType(de.tudarmstadt.ukp.clarin.webanno.api.annotation.coloring.ColoringStrategyType) LoggerFactory(org.slf4j.LoggerFactory) CheckBox(org.apache.wicket.markup.html.form.CheckBox) CompoundPropertyModel(org.apache.wicket.model.CompoundPropertyModel) ANNOTATION(de.tudarmstadt.ukp.clarin.webanno.model.Mode.ANNOTATION) AnnotationSchemaService(de.tudarmstadt.ukp.clarin.webanno.api.AnnotationSchemaService) Token(de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token) BootstrapSelect(de.agilecoders.wicket.extensions.markup.html.bootstrap.form.select.BootstrapSelect) LambdaBehavior.visibleWhen(de.tudarmstadt.ukp.clarin.webanno.support.lambda.LambdaBehavior.visibleWhen) Pair(org.apache.commons.lang3.tuple.Pair) AnnotationPreference(de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.AnnotationPreference) Arrays.asList(java.util.Arrays.asList) Map(java.util.Map) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ChoiceRenderer(org.apache.wicket.markup.html.form.ChoiceRenderer) IModel(org.apache.wicket.model.IModel) ListView(org.apache.wicket.markup.html.list.ListView) Label(org.apache.wicket.markup.html.basic.Label) NumberTextField(org.apache.wicket.markup.html.form.NumberTextField) CURATION(de.tudarmstadt.ukp.clarin.webanno.model.Mode.CURATION) Logger(org.slf4j.Logger) ListItem(org.apache.wicket.markup.html.list.ListItem) LambdaAjaxFormComponentUpdatingBehavior(de.tudarmstadt.ukp.clarin.webanno.support.lambda.LambdaAjaxFormComponentUpdatingBehavior) Model(org.apache.wicket.model.Model) UserDao(de.tudarmstadt.ukp.clarin.webanno.security.UserDao) Set(java.util.Set) ModalWindow(org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow) ReadonlyColoringBehaviour(de.tudarmstadt.ukp.clarin.webanno.api.annotation.coloring.ReadonlyColoringBehaviour) IOException(java.io.IOException) LambdaAjaxButton(de.tudarmstadt.ukp.clarin.webanno.support.lambda.LambdaAjaxButton) Collectors(java.util.stream.Collectors) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) Serializable(java.io.Serializable) CORRECTION(de.tudarmstadt.ukp.clarin.webanno.model.Mode.CORRECTION) Panel(org.apache.wicket.markup.html.panel.Panel) List(java.util.List) AnnotationEditorFactory(de.tudarmstadt.ukp.clarin.webanno.api.annotation.AnnotationEditorFactory) PreferencesUtil(de.tudarmstadt.ukp.clarin.webanno.api.annotation.page.PreferencesUtil) LambdaAjaxLink(de.tudarmstadt.ukp.clarin.webanno.support.lambda.LambdaAjaxLink) AnnotationLayer(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer) CHAIN_TYPE(de.tudarmstadt.ukp.clarin.webanno.api.WebAnnoConst.CHAIN_TYPE) AnnotationEditorRegistry(de.tudarmstadt.ukp.clarin.webanno.api.annotation.AnnotationEditorRegistry) Label(org.apache.wicket.markup.html.basic.Label) AnnotationLayer(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer) LambdaAjaxFormComponentUpdatingBehavior(de.tudarmstadt.ukp.clarin.webanno.support.lambda.LambdaAjaxFormComponentUpdatingBehavior) ListView(org.apache.wicket.markup.html.list.ListView) CheckBox(org.apache.wicket.markup.html.form.CheckBox) ListItem(org.apache.wicket.markup.html.list.ListItem) BootstrapSelect(de.agilecoders.wicket.extensions.markup.html.bootstrap.form.select.BootstrapSelect) ColoringStrategyType(de.tudarmstadt.ukp.clarin.webanno.api.annotation.coloring.ColoringStrategyType)

Aggregations

BootstrapSelect (de.agilecoders.wicket.extensions.markup.html.bootstrap.form.select.BootstrapSelect)2 AnnotationSchemaService (de.tudarmstadt.ukp.clarin.webanno.api.AnnotationSchemaService)2 CHAIN_TYPE (de.tudarmstadt.ukp.clarin.webanno.api.WebAnnoConst.CHAIN_TYPE)2 AnnotatorState (de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.AnnotatorState)2 AnnotationLayer (de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer)2 UserDao (de.tudarmstadt.ukp.clarin.webanno.security.UserDao)2 LambdaAjaxFormComponentUpdatingBehavior (de.tudarmstadt.ukp.clarin.webanno.support.lambda.LambdaAjaxFormComponentUpdatingBehavior)2 LambdaBehavior.visibleWhen (de.tudarmstadt.ukp.clarin.webanno.support.lambda.LambdaBehavior.visibleWhen)2 Token (de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token)2 IOException (java.io.IOException)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)2 Label (org.apache.wicket.markup.html.basic.Label)2 CheckBox (org.apache.wicket.markup.html.form.CheckBox)2 ChoiceRenderer (org.apache.wicket.markup.html.form.ChoiceRenderer)2 DropDownChoice (org.apache.wicket.markup.html.form.DropDownChoice)2 Panel (org.apache.wicket.markup.html.panel.Panel)2 ProjectService (de.tudarmstadt.ukp.clarin.webanno.api.ProjectService)1 SPAN_TYPE (de.tudarmstadt.ukp.clarin.webanno.api.WebAnnoConst.SPAN_TYPE)1