diff --git a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/feature/multistring/MultiSelectTextFeatureEditor.java b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/feature/multistring/MultiSelectTextFeatureEditor.java index f7d9d6c64f4..983d9c3e747 100644 --- a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/feature/multistring/MultiSelectTextFeatureEditor.java +++ b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/feature/multistring/MultiSelectTextFeatureEditor.java @@ -78,10 +78,6 @@ public MultiSelectTextFeatureEditor(String aId, MarkupContainer aOwner, add(new ConstraintsInUseIndicator(CID_TEXT_INDICATOR, getModel())); } - /** - * Hides feature if "Hide un-constraint feature" is enabled and constraint rules are applied and - * feature doesn't match any constraint rule - */ @SuppressWarnings("unchecked") @Override public void onConfigure() @@ -94,6 +90,8 @@ public void onConfigure() field = (FormComponent) field.replaceWith(createInput()); } + // Hides feature if "Hide un-constraint feature" is enabled and constraint rules are applied + // and feature doesn't match any constraint rule // if enabled and constraints rule execution returns anything other than green var featState = getModelObject(); setVisible(!featState.feature.isHideUnconstraintFeature() || // diff --git a/inception/inception-ui-kb/src/main/java/de/tudarmstadt/ukp/inception/ui/kb/feature/ConceptFeatureEditor.java b/inception/inception-ui-kb/src/main/java/de/tudarmstadt/ukp/inception/ui/kb/feature/ConceptFeatureEditor.java index 1abded24240..b676084136f 100644 --- a/inception/inception-ui-kb/src/main/java/de/tudarmstadt/ukp/inception/ui/kb/feature/ConceptFeatureEditor.java +++ b/inception/inception-ui-kb/src/main/java/de/tudarmstadt/ukp/inception/ui/kb/feature/ConceptFeatureEditor.java @@ -80,7 +80,7 @@ public class ConceptFeatureEditor public ConceptFeatureEditor(String aId, MarkupContainer aItem, IModel aModel, IModel aStateModel, AnnotationActionHandler aHandler) { - super(aId, aItem, aModel, aStateModel, aHandler); + super(aId, aItem, aModel); AnnotationFeature feat = getModelObject().feature; ConceptFeatureTraits traits = readFeatureTraits(feat); diff --git a/inception/inception-ui-kb/src/main/java/de/tudarmstadt/ukp/inception/ui/kb/feature/ConceptFeatureEditor_ImplBase.java b/inception/inception-ui-kb/src/main/java/de/tudarmstadt/ukp/inception/ui/kb/feature/ConceptFeatureEditor_ImplBase.java index d999109ddfd..68e0dbec4af 100644 --- a/inception/inception-ui-kb/src/main/java/de/tudarmstadt/ukp/inception/ui/kb/feature/ConceptFeatureEditor_ImplBase.java +++ b/inception/inception-ui-kb/src/main/java/de/tudarmstadt/ukp/inception/ui/kb/feature/ConceptFeatureEditor_ImplBase.java @@ -75,8 +75,7 @@ public abstract class ConceptFeatureEditor_ImplBase private @SpringBean EntityLinkingProperties entityLinkingProperties; public ConceptFeatureEditor_ImplBase(String aId, MarkupContainer aItem, - IModel aModel, IModel aStateModel, - AnnotationActionHandler aHandler) + IModel aModel) { super(aId, aItem, new CompoundPropertyModel<>(aModel)); diff --git a/inception/inception-ui-kb/src/main/java/de/tudarmstadt/ukp/inception/ui/kb/feature/MultiValueConceptFeatureEditor.java b/inception/inception-ui-kb/src/main/java/de/tudarmstadt/ukp/inception/ui/kb/feature/MultiValueConceptFeatureEditor.java index 7dd5d52801a..b91b6667b22 100644 --- a/inception/inception-ui-kb/src/main/java/de/tudarmstadt/ukp/inception/ui/kb/feature/MultiValueConceptFeatureEditor.java +++ b/inception/inception-ui-kb/src/main/java/de/tudarmstadt/ukp/inception/ui/kb/feature/MultiValueConceptFeatureEditor.java @@ -46,20 +46,86 @@ public class MultiValueConceptFeatureEditor { private static final long serialVersionUID = -8326017157405023711L; + private static final String CID_VALUE = "value"; + private @SpringBean FeatureSupportRegistry featureSupportRegistry; - private MultiSelect focusComponent; + private final AnnotationActionHandler handler; + private final IModel stateModel; + + private FormComponent> focusComponent; public MultiValueConceptFeatureEditor(String aId, MarkupContainer aItem, IModel aModel, IModel aStateModel, AnnotationActionHandler aHandler) { - super(aId, aItem, aModel, aStateModel, aHandler); + super(aId, aItem, aModel); - focusComponent = new KBHandleMultiSelect("value", aHandler, aStateModel); + handler = aHandler; + stateModel = aStateModel; + + focusComponent = createInput(); add(focusComponent); } + @SuppressWarnings("unchecked") + @Override + public void onConfigure() + { + super.onConfigure(); + + // Workaround for https://github.com/sebfz1/wicket-jquery-ui/issues/352 + if ((isEnabledInHierarchy() && !(focusComponent instanceof MultiSelect)) + || !isEnabledInHierarchy() && (focusComponent instanceof MultiSelect)) { + focusComponent = (FormComponent>) focusComponent + .replaceWith(createInput()); + } + } + + private FormComponent> createInput() + { + if (isEnabledInHierarchy()) { + return createEditableInput(); + } + else { + return createReadOnlyInput(); + } + } + + private FormComponent> createEditableInput() + { + return new KBHandleMultiSelect(CID_VALUE, handler, stateModel); + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + private FormComponent> createReadOnlyInput() + { + var input = new com.googlecode.wicket.kendo.ui.form.multiselect. // + MultiSelect(CID_VALUE) + { + private static final long serialVersionUID = 1L; + + @Override + public void onConfigure(JQueryBehavior aBehavior) + { + super.onConfigure(aBehavior); + styleMultiSelect(aBehavior); + } + }; + input.setChoiceRenderer( + new org.apache.wicket.markup.html.form.ChoiceRenderer<>("uiLabel", "identifier")); + input.setChoices(() -> input.getModel().map(ArrayList::new).getObject()); + return (FormComponent) input; + } + + private void styleMultiSelect(JQueryBehavior aBehavior) + { + aBehavior.setOption("autoWidth", true); + aBehavior.setOption("animation", false); + aBehavior.setOption("delay", 250); + aBehavior.setOption("height", 300); + } + @Override public FormComponent> getFocusComponent() { @@ -113,10 +179,8 @@ public void onConfigure(JQueryBehavior aBehavior) { super.onConfigure(aBehavior); - aBehavior.setOption("autoWidth", true); - aBehavior.setOption("animation", false); - aBehavior.setOption("delay", 250); - aBehavior.setOption("height", 300); + styleMultiSelect(aBehavior); + // These three settings should avoid a query when simply clicking into the multiselect // field, but they seem to have no effect // aBehavior.setOption("autoBind", false);