This is an automated email from the git hooks/post-receive script. New commit to branch feature/8128 in repository tutti. See https://gitlab.nuiton.org/codelutin/tutti.git commit 9b777527beaf2daac2981aec1c837c11a08b31aa Author: Tony CHEMIT <chemit@codelutin.com> Date: Wed Mar 16 17:34:44 2016 +0100 Utilisation des arrondis de poids (see #8128) + utilisation des nouvelles méthodes sur les poids --- .../catches/species/frequency/SpeciesFrequencyRowModel.java | 12 +++++++----- .../catches/species/frequency/SpeciesFrequencyUIModel.java | 10 +++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyRowModel.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyRowModel.java index 38319b6..7c3f22d 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyRowModel.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyRowModel.java @@ -31,6 +31,7 @@ import fr.ifremer.tutti.persistence.entities.referential.Caracteristic; import fr.ifremer.tutti.type.WeightUnit; import fr.ifremer.tutti.ui.swing.util.AbstractTuttiBeanUIModel; import fr.ifremer.tutti.ui.swing.util.computable.ComputableData; +import fr.ifremer.tutti.util.Weights; import org.nuiton.util.beans.Binder; import org.nuiton.util.beans.BinderFactory; @@ -220,13 +221,13 @@ public class SpeciesFrequencyRowModel extends AbstractTuttiBeanUIModel<SpeciesBa @Override public void setWeight(Float weight) { Object oldValue = getWeight(); - computedOrNotWeight.setData(weight); + computedOrNotWeight.setData(weightUnit.round(weight)); firePropertyChange(PROPERTY_WEIGHT, oldValue, weight); } public boolean withWeight() { Float weight = getWeight(); - return weight != null && weight > 0; + return Weights.isNotNullNorZero(weight); } /** @@ -237,8 +238,9 @@ public class SpeciesFrequencyRowModel extends AbstractTuttiBeanUIModel<SpeciesBa if (weight == null) { weight = 0f; } - if (weight + weightToAdd >= 0) { - setWeight(weight + weightToAdd); + float newWeight = weight + weightToAdd; + if (Weights.isNotZero(newWeight)) { + setWeight(newWeight); } } @@ -248,7 +250,7 @@ public class SpeciesFrequencyRowModel extends AbstractTuttiBeanUIModel<SpeciesBa public void setComputedWeight(Float weight) { Object oldValue = getComputedWeight(); - computedOrNotWeight.setComputedData(weight); + computedOrNotWeight.setComputedData(weightUnit.round(weight)); firePropertyChange(PROPERTY_COMPUTED_WEIGHT, oldValue, weight); } diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIModel.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIModel.java index c375999..7fc1f21 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIModel.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIModel.java @@ -571,7 +571,7 @@ public class SpeciesFrequencyUIModel extends AbstractTuttiTableUIModel<SpeciesBa public void setTotalWeight(Float totalWeight) { Object oldValue = getTotalWeight(); - this.totalComputedOrNotWeight.setData(totalWeight); + this.totalComputedOrNotWeight.setData(weightUnit.round(totalWeight)); firePropertyChange(PROPERTY_TOTAL_WEIGHT, oldValue, totalWeight); } @@ -581,16 +581,16 @@ public class SpeciesFrequencyUIModel extends AbstractTuttiTableUIModel<SpeciesBa public void setTotalComputedWeight(Float totalComputedWeight) { Object oldValue = getTotalComputedWeight(); - this.totalComputedOrNotWeight.setComputedData(totalComputedWeight); + this.totalComputedOrNotWeight.setComputedData(weightUnit.round(totalComputedWeight)); firePropertyChange(PROPERTY_TOTAL_COMPUTED_WEIGHT, oldValue, totalComputedWeight); } // Utilisé dans un validateur, ne pas supprimer public boolean isTotalWeightSameAsComputedWeight() { Float totalWeight = getTotalWeight(); - Float computedWeight = getTotalComputedWeight(); - return totalWeight != null && computedWeight != null - && Weights.isEqualWeight(totalWeight, computedWeight); + Float totalComputedWeight = getTotalComputedWeight(); + return totalWeight != null && totalComputedWeight != null + && Weights.isEqualWeight(totalWeight, totalComputedWeight); } public Rtp getRtp() { -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.