From 3c7f797d682f563c72b9496c3a82a245d7d1cb92 Mon Sep 17 00:00:00 2001 From: Mihai Postelnicu Date: Thu, 30 Oct 2025 12:43:08 +0200 Subject: [PATCH] OCE-547 Some Housekeeping updates --- entrypoint.sh | 1 + .../wicket/components/DecimalTextField.java | 31 ++-------- ...ecimalTextFieldBootstrapFormComponent.html | 2 +- .../wicket/converters/DecimalConverter.java | 60 ------------------- pom.xml | 5 ++ 5 files changed, 11 insertions(+), 88 deletions(-) delete mode 100644 forms/src/main/java/org/devgateway/toolkit/forms/wicket/converters/DecimalConverter.java diff --git a/entrypoint.sh b/entrypoint.sh index c4df44d748..ea56ae0dee 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -30,6 +30,7 @@ COMMON_JAVA_ARGS="$(tr '\n' ' ' <<-EOF -Dspring.datasource.password=$POSTGRES_PASSWORD -DJava.awt.headless=true -XX:+UseG1GC + -XX:-UseContainerSupport -Dspring.data.mongodb.uri=mongodb://$MONGO_INITDB_ROOT_USERNAME:$MONGO_INITDB_ROOT_PASSWORD@mongo:27017/ocportal?authSource=admin -Dspring.datasource.url=jdbc:postgresql://db/ocportal -Dgoogle.recaptcha.secret=$RECAPTCHA_SECRET diff --git a/forms/src/main/java/org/devgateway/toolkit/forms/wicket/components/DecimalTextField.java b/forms/src/main/java/org/devgateway/toolkit/forms/wicket/components/DecimalTextField.java index c6785bb026..4933fe3f60 100644 --- a/forms/src/main/java/org/devgateway/toolkit/forms/wicket/components/DecimalTextField.java +++ b/forms/src/main/java/org/devgateway/toolkit/forms/wicket/components/DecimalTextField.java @@ -1,42 +1,19 @@ -/* (c) 2014 - 2016 Open Source Geospatial Foundation - all rights reserved - * (c) 2001 - 2013 OpenPlans - * This code is licensed under the GPL 2.0 license, available at the root - * application directory. - */ package org.devgateway.toolkit.forms.wicket.components; -import org.apache.wicket.markup.html.form.TextField; +import org.apache.wicket.markup.html.form.NumberTextField; import org.apache.wicket.model.IModel; -import org.apache.wicket.util.convert.IConverter; -import org.devgateway.toolkit.forms.wicket.converters.DecimalConverter; /** - * A TextField for {@code java.lang.Double} representations that allows for arbitrary number of - * decimal places, since the default TextField rounds up doubles to three decimals. + * A TextField for decimal numbers extending Wicket's NumberTextField * - * @author groldan + * @author mpostelnicu */ -public class DecimalTextField extends TextField { +public class DecimalTextField extends NumberTextField { private static final long serialVersionUID = 1L; - private DecimalConverter decimalConverter; - public DecimalTextField(String id, IModel model) { super(id, model, Double.class); - decimalConverter = new DecimalConverter(); } - public void setMaximumFractionDigits(int maximumFractionDigits) { - decimalConverter.setMaximumFractionDigits(maximumFractionDigits); - } - - @SuppressWarnings("unchecked") - @Override - public IConverter getConverter(Class type) { - if (Double.class.isAssignableFrom(type)) { - return (IConverter) decimalConverter; - } - return super.getConverter(type); - } } \ No newline at end of file diff --git a/forms/src/main/java/org/devgateway/toolkit/forms/wicket/components/form/DecimalTextFieldBootstrapFormComponent.html b/forms/src/main/java/org/devgateway/toolkit/forms/wicket/components/form/DecimalTextFieldBootstrapFormComponent.html index dcc4a01c36..324e5f520a 100644 --- a/forms/src/main/java/org/devgateway/toolkit/forms/wicket/components/form/DecimalTextFieldBootstrapFormComponent.html +++ b/forms/src/main/java/org/devgateway/toolkit/forms/wicket/components/form/DecimalTextFieldBootstrapFormComponent.html @@ -1,5 +1,5 @@ - + \ No newline at end of file diff --git a/forms/src/main/java/org/devgateway/toolkit/forms/wicket/converters/DecimalConverter.java b/forms/src/main/java/org/devgateway/toolkit/forms/wicket/converters/DecimalConverter.java deleted file mode 100644 index 9a3e68764a..0000000000 --- a/forms/src/main/java/org/devgateway/toolkit/forms/wicket/converters/DecimalConverter.java +++ /dev/null @@ -1,60 +0,0 @@ -/* (c) 2016 Open Source Geospatial Foundation - all rights reserved - * This code is licensed under the GPL 2.0 license, available at the root - * application directory. - */ -package org.devgateway.toolkit.forms.wicket.converters; - -import org.apache.wicket.util.convert.IConverter; -import org.apache.wicket.util.convert.converter.DoubleConverter; - -import java.text.DecimalFormat; -import java.text.DecimalFormatSymbols; -import java.text.NumberFormat; -import java.util.Locale; - -/** - * A {@link IConverter} for {@code java.lang.Double} representations that allows for arbitrary - * number of decimal places, since the default TextField rounds up doubles to three decimals. This - * class will also handle positive and negative infinity symbols - */ -@SuppressWarnings("serial") -public class DecimalConverter extends DoubleConverter { - - private int maximumFractionDigits = 16; - - /** - * Returns the maximum number of fraction digits allowed in the configuration - */ - public int getMaximumFractionDigits() { - return maximumFractionDigits; - } - - public void setMaximumFractionDigits(int maximumFractionDigits) { - this.maximumFractionDigits = maximumFractionDigits; - } - - @Override - public Double convertToObject(String value, Locale locale) { - if (value == null || value.trim().length() == 0) { - return null; - } - final NumberFormat format = getNumberFormat(locale); - final DecimalFormatSymbols symbols = ((DecimalFormat) format).getDecimalFormatSymbols(); - if (value.equals(symbols.getNaN())) { - return Double.valueOf(Double.NaN); - } else if (value.equals(symbols.getInfinity())) { - return Double.valueOf(Double.POSITIVE_INFINITY); - } else if (value.equals("-" + symbols.getInfinity())) { - return Double.valueOf(Double.NEGATIVE_INFINITY); - } else { - return super.convertToObject(value, locale); - } - } - - @Override - protected NumberFormat newNumberFormat(Locale locale) { - NumberFormat format = DecimalFormat.getInstance(); - format.setMaximumFractionDigits(16); - return format; - } -} \ No newline at end of file diff --git a/pom.xml b/pom.xml index a9d8599cde..c98e4e431b 100644 --- a/pom.xml +++ b/pom.xml @@ -85,6 +85,11 @@ Central Repository https://repo.maven.apache.org/maven2 + + clojars + Clojure Libraries + https://repo.clojars.org/ + devgateway-open-source devgateway-open-source