From ef2ab768e0fbe8f75a64d5e13de397b212d1b56d Mon Sep 17 00:00:00 2001 From: Richard Eckart de Castilho Date: Tue, 29 Oct 2024 10:17:02 +0100 Subject: [PATCH 1/5] #5101 - Limited option on integer features cannot be turned off - Fix ability to turn off limiting - Slightly improve form layout --- .../feature/number/NumberFeatureTraits.java | 20 +++--- .../number/NumberFeatureTraitsEditor.html | 22 +++---- .../number/NumberFeatureTraitsEditor.java | 64 +++++++++---------- .../ui/project/layers/ProjectLayersPanel.html | 2 + .../layers/ProjectLayersPanel.properties | 2 +- 5 files changed, 56 insertions(+), 54 deletions(-) diff --git a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/feature/number/NumberFeatureTraits.java b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/feature/number/NumberFeatureTraits.java index 18ed45f6a60..c65d6c9aa48 100644 --- a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/feature/number/NumberFeatureTraits.java +++ b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/feature/number/NumberFeatureTraits.java @@ -17,6 +17,8 @@ */ package de.tudarmstadt.ukp.inception.annotation.feature.number; +import static de.tudarmstadt.ukp.inception.annotation.feature.number.NumberFeatureTraits.EditorType.SPINNER; + import java.io.Serializable; import com.fasterxml.jackson.annotation.JsonEnumDefaultValue; @@ -54,7 +56,7 @@ public String toString() private boolean limited = false; private Number minimum = 0; private Number maximum = 0; - private EditorType editorType = EditorType.SPINNER; + private EditorType editorType = SPINNER; public NumberFeatureTraits() { @@ -66,9 +68,9 @@ public boolean isLimited() return limited; } - public void setLimited(boolean limited) + public void setLimited(boolean aLimited) { - this.limited = limited; + limited = aLimited; } public Number getMinimum() @@ -76,9 +78,9 @@ public Number getMinimum() return minimum; } - public void setMinimum(Number minimum) + public void setMinimum(Number aMinimum) { - this.minimum = minimum; + minimum = aMinimum; } public Number getMaximum() @@ -86,9 +88,9 @@ public Number getMaximum() return maximum; } - public void setMaximum(Number maximum) + public void setMaximum(Number aMaximum) { - this.maximum = maximum; + maximum = aMaximum; } public EditorType getEditorType() @@ -96,8 +98,8 @@ public EditorType getEditorType() return editorType; } - public void setEditorType(EditorType editorType) + public void setEditorType(EditorType aEditorType) { - this.editorType = editorType; + editorType = aEditorType; } } diff --git a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/feature/number/NumberFeatureTraitsEditor.html b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/feature/number/NumberFeatureTraitsEditor.html index aaf148c1118..283ae5e7ced 100644 --- a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/feature/number/NumberFeatureTraitsEditor.html +++ b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/feature/number/NumberFeatureTraitsEditor.html @@ -18,18 +18,18 @@ --> -
-
-
- - +
+
+
+
+ + +
-
- -
+
@@ -37,7 +37,7 @@
-
+
diff --git a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/feature/number/NumberFeatureTraitsEditor.java b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/feature/number/NumberFeatureTraitsEditor.java index d4945d09e28..77176ca8216 100644 --- a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/feature/number/NumberFeatureTraitsEditor.java +++ b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/feature/number/NumberFeatureTraitsEditor.java @@ -17,6 +17,8 @@ */ package de.tudarmstadt.ukp.inception.annotation.feature.number; +import static de.tudarmstadt.ukp.inception.annotation.feature.number.NumberFeatureTraits.EditorType.SPINNER; +import static de.tudarmstadt.ukp.inception.support.lambda.HtmlElementEvents.CHANGE_EVENT; import static de.tudarmstadt.ukp.inception.support.lambda.LambdaBehavior.visibleWhen; import java.io.Serializable; @@ -31,7 +33,6 @@ import org.apache.wicket.model.CompoundPropertyModel; import org.apache.wicket.model.IModel; import org.apache.wicket.model.Model; -import org.apache.wicket.model.PropertyModel; import org.apache.wicket.spring.injection.annot.SpringBean; import org.wicketstuff.jquery.core.Options; import org.wicketstuff.kendo.ui.form.NumberTextField; @@ -70,7 +71,7 @@ public NumberFeatureTraitsEditor(String aId, feature = aFeature; traits = Model.of(readTraits()); - Form form = new Form(MID_FORM, CompoundPropertyModel.of(traits)) + var form = new Form(MID_FORM, CompoundPropertyModel.of(traits)) { private static final long serialVersionUID = 4456748721289266655L; @@ -82,8 +83,6 @@ protected void onSubmit() } }; form.setOutputMarkupPlaceholderTag(true); - form.add(visibleWhen( - () -> traits.getObject().isLimited() && feature.getObject().getTagset() == null)); add(form); Class clazz = Integer.class; @@ -101,25 +100,30 @@ protected void onSubmit() } } - DropDownChoice editorType = new DropDownChoice<>( - CID_EDITOR_TYPE); - editorType.setModel(PropertyModel.of(traits, "editorType")); + var limited = new CheckBox("limited"); + limited.add(new LambdaAjaxFormComponentUpdatingBehavior(CHANGE_EVENT, + target -> target.add(form))); + form.add(limited); + + var editorType = new DropDownChoice(CID_EDITOR_TYPE); + // editorType.setModel(PropertyModel.of(traits, "editorType")); editorType.setChoices(Arrays.asList(NumberFeatureTraits.EditorType.values())); editorType.add(new LambdaAjaxFormComponentUpdatingBehavior("change")); - editorType.add(visibleWhen(() -> isEditorTypeSelectionPossible())); + editorType.add(visibleWhen( + () -> traits.getObject().isLimited() && isEditorTypeSelectionPossible())); form.add(editorType); var minimum = new NumberTextField<>("minimum", clazz, options); - minimum.setModel(PropertyModel.of(traits, "minimum")); + minimum.add(visibleWhen(() -> traits.getObject().isLimited())); form.add(minimum); var maximum = new NumberTextField<>("maximum", clazz, options); - maximum.setModel(PropertyModel.of(traits, "maximum")); + maximum.add(visibleWhen(() -> traits.getObject().isLimited())); form.add(maximum); minimum.add(new LambdaAjaxFormComponentUpdatingBehavior("change", target -> { - BigDecimal min = new BigDecimal(traits.getObject().getMinimum().toString()); - BigDecimal max = new BigDecimal(traits.getObject().getMaximum().toString()); + var min = new BigDecimal(traits.getObject().getMinimum().toString()); + var max = new BigDecimal(traits.getObject().getMaximum().toString()); if (min.compareTo(max) > 0) { traits.getObject().setMaximum(traits.getObject().getMinimum()); } @@ -127,19 +131,13 @@ protected void onSubmit() })); maximum.add(new LambdaAjaxFormComponentUpdatingBehavior("change", target -> { - BigDecimal min = new BigDecimal(traits.getObject().getMinimum().toString()); - BigDecimal max = new BigDecimal(traits.getObject().getMaximum().toString()); + var min = new BigDecimal(traits.getObject().getMinimum().toString()); + var max = new BigDecimal(traits.getObject().getMaximum().toString()); if (min.compareTo(max) > 0) { traits.getObject().setMinimum(traits.getObject().getMaximum()); } target.add(form); })); - - CheckBox multipleRows = new CheckBox("limited"); - multipleRows.setModel(PropertyModel.of(traits, "limited")); - multipleRows.add( - new LambdaAjaxFormComponentUpdatingBehavior("change", target -> target.add(form))); - add(multipleRows); } /** @@ -168,9 +166,9 @@ private UimaPrimitiveFeatureSupport_ImplBase getFeatureSupp */ private Traits readTraits() { - Traits result = new Traits(); + var result = new Traits(); - NumberFeatureTraits t = getFeatureSupport().readTraits(feature.getObject()); + var t = getFeatureSupport().readTraits(feature.getObject()); result.setLimited(t.isLimited()); result.setMinimum(t.getMinimum()); @@ -186,13 +184,13 @@ private Traits readTraits() */ private void writeTraits() { - NumberFeatureTraits t = new NumberFeatureTraits(); + var t = new NumberFeatureTraits(); t.setLimited(traits.getObject().isLimited()); t.setMinimum(traits.getObject().getMinimum()); t.setMaximum(traits.getObject().getMaximum()); - t.setEditorType(isEditorTypeSelectionPossible() ? traits.getObject().getEditorType() - : NumberFeatureTraits.EditorType.SPINNER); + t.setEditorType( + isEditorTypeSelectionPossible() ? traits.getObject().getEditorType() : SPINNER); getFeatureSupport().writeTraits(feature.getObject(), t); } @@ -216,9 +214,9 @@ public boolean isLimited() return limited; } - public void setLimited(boolean limited) + public void setLimited(boolean aLimited) { - this.limited = limited; + limited = aLimited; } public Number getMinimum() @@ -226,9 +224,9 @@ public Number getMinimum() return minimum; } - public void setMinimum(Number minimum) + public void setMinimum(Number aMinimum) { - this.minimum = minimum; + minimum = aMinimum; } public Number getMaximum() @@ -236,9 +234,9 @@ public Number getMaximum() return maximum; } - public void setMaximum(Number maximum) + public void setMaximum(Number aMaximum) { - this.maximum = maximum; + maximum = aMaximum; } public NumberFeatureTraits.EditorType getEditorType() @@ -246,9 +244,9 @@ public NumberFeatureTraits.EditorType getEditorType() return editorType; } - public void setEditorType(NumberFeatureTraits.EditorType editorType) + public void setEditorType(NumberFeatureTraits.EditorType aEditorType) { - this.editorType = editorType; + editorType = aEditorType; } } } diff --git a/inception/inception-ui-project/src/main/java/de/tudarmstadt/ukp/clarin/webanno/ui/project/layers/ProjectLayersPanel.html b/inception/inception-ui-project/src/main/java/de/tudarmstadt/ukp/clarin/webanno/ui/project/layers/ProjectLayersPanel.html index cd2a24eeb0f..bd17ea65701 100644 --- a/inception/inception-ui-project/src/main/java/de/tudarmstadt/ukp/clarin/webanno/ui/project/layers/ProjectLayersPanel.html +++ b/inception/inception-ui-project/src/main/java/de/tudarmstadt/ukp/clarin/webanno/ui/project/layers/ProjectLayersPanel.html @@ -156,6 +156,7 @@
+
Type cannot be changed after creation
@@ -284,6 +285,7 @@