This is an automated email from the git hooks/post-receive script. New commit to branch feature/8116 in repository tutti. See https://gitlab.nuiton.org/codelutin/tutti.git commit 9479b97233bf40172168d169399a5f7ad31462a7 Author: Kevin Morin <morin@codelutin.com> Date: Wed Mar 16 16:33:23 2016 +0100 - ajout d'une colonne "poids calculé par rtp" - remplacement de la checkbox "utiliser les rtp" par "Recopie des poids via RTP" qui désactive la colonne de saisie des poids et qui recopie automatiquement les poids rtp dans la colonne poids fixes #8116 --- .../filtered-resources/tutti-help-fr.properties | 26 +------- .../frequency/SpeciesFrequencyRowModel.java | 46 +++++++------- .../frequency/SpeciesFrequencyTableModel.java | 23 ++++--- .../species/frequency/SpeciesFrequencyUI.jaxx | 2 +- .../species/frequency/SpeciesFrequencyUI.jcss | 11 ++-- .../frequency/SpeciesFrequencyUIHandler.java | 72 +++++++++++++++------- .../species/frequency/SpeciesFrequencyUIModel.java | 40 ++++++------ .../resources/i18n/tutti-ui-swing_en_GB.properties | 3 + .../resources/i18n/tutti-ui-swing_fr_FR.properties | 3 + 9 files changed, 124 insertions(+), 102 deletions(-) diff --git a/tutti-ui-swing/src/main/filtered-resources/tutti-help-fr.properties b/tutti-ui-swing/src/main/filtered-resources/tutti-help-fr.properties index 644d302..5d74622 100644 --- a/tutti-ui-swing/src/main/filtered-resources/tutti-help-fr.properties +++ b/tutti-ui-swing/src/main/filtered-resources/tutti-help-fr.properties @@ -1,28 +1,5 @@ -### -# #%L -# Tutti :: UI -# $Id:$ -# $HeadURL:$ -# %% -# Copyright (C) 2012 - 2016 Ifremer -# %% -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public -# License along with this program. If not, see -# <http://www.gnu.org/licenses/gpl-3.0.html>. -# #L% -### #Generated by org.nuiton.jaxx.plugin.GenerateHelpIdsMojo -#Mon Mar 14 08:39:04 CET 2016 +#Wed Mar 16 14:34:44 CET 2016 tutti.config.help=config.html tutti.createAccidentalBatch.action.cancel.help=editFishingOperation.html\#captureCapturesAccidentellesActions tutti.createAccidentalBatch.action.saveAndClose.help=editFishingOperation.html\#captureCapturesAccidentellesActions @@ -341,6 +318,7 @@ tutti.editSpeciesFrequencies.action.reset.help=editFishingOperation.html\#captur tutti.editSpeciesFrequencies.action.saveAndClose.help=editFishingOperation.html\#captureEspecesMensurationActions tutti.editSpeciesFrequencies.action.saveAndContinue.help=editFishingOperation.html\#captureEspecesMensurationActions tutti.editSpeciesFrequencies.field.addIndividualObservationOnRafale.help= +tutti.editSpeciesFrequencies.field.copyRtpWeights.help= tutti.editSpeciesFrequencies.field.copyToSizeTableMode.all.help= tutti.editSpeciesFrequencies.field.copyToSizeTableMode.nothing.help= tutti.editSpeciesFrequencies.field.copyToSizeTableMode.size.help= 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..51976ae 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 @@ -30,7 +30,6 @@ import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequencys; 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 org.nuiton.util.beans.Binder; import org.nuiton.util.beans.BinderFactory; @@ -52,7 +51,7 @@ public class SpeciesFrequencyRowModel extends AbstractTuttiBeanUIModel<SpeciesBa public static final String PROPERTY_WEIGHT = "weight"; - public static final String PROPERTY_COMPUTED_WEIGHT = "computedOrNotWeight"; + public static final String PROPERTY_RTP_COMPUTED_WEIGHT = "rtpComputedWeight"; public static final String PROPERTY_LENGHT_STEP_CARACTERISTIC = "lengthStepCaracteristic"; @@ -75,7 +74,14 @@ public class SpeciesFrequencyRowModel extends AbstractTuttiBeanUIModel<SpeciesBa * * @since 4.5 */ - protected ComputableData<Float> computedOrNotWeight = new ComputableData<>(); + protected Float weight; + + /** + * Weight of fishes computed with RTPs. + * + * @since 4.5 + */ + protected Float rtpComputedWeight; /** * Length step caracteristic. @@ -133,8 +139,6 @@ public class SpeciesFrequencyRowModel extends AbstractTuttiBeanUIModel<SpeciesBa public SpeciesFrequencyRowModel(WeightUnit weightUnit) { super(fromBeanBinder, toBeanBinder); this.weightUnit = weightUnit; - computedOrNotWeight.addPropagateListener(PROPERTY_WEIGHT, this); - computedOrNotWeight.addPropagateListener(PROPERTY_COMPUTED_WEIGHT, this); } //------------------------------------------------------------------------// @@ -214,13 +218,13 @@ public class SpeciesFrequencyRowModel extends AbstractTuttiBeanUIModel<SpeciesBa @Override public Float getWeight() { - return computedOrNotWeight.getData(); + return weight; } @Override public void setWeight(Float weight) { Object oldValue = getWeight(); - computedOrNotWeight.setData(weight); + this.weight = weight; firePropertyChange(PROPERTY_WEIGHT, oldValue, weight); } @@ -233,7 +237,6 @@ public class SpeciesFrequencyRowModel extends AbstractTuttiBeanUIModel<SpeciesBa * @param weightToAdd weight (can be negative) to add */ public void addToWeight(float weightToAdd) { - Float weight = computedOrNotWeight.getData(); if (weight == null) { weight = 0f; } @@ -242,22 +245,18 @@ public class SpeciesFrequencyRowModel extends AbstractTuttiBeanUIModel<SpeciesBa } } - public Float getComputedWeight() { - return computedOrNotWeight.getComputedData(); - } - - public void setComputedWeight(Float weight) { - Object oldValue = getComputedWeight(); - computedOrNotWeight.setComputedData(weight); - firePropertyChange(PROPERTY_COMPUTED_WEIGHT, oldValue, weight); + public Float getRtpComputedWeight() { + return rtpComputedWeight; } - public ComputableData<Float> getComputedOrNotWeight() { - return computedOrNotWeight; + public void setRtpComputedWeight(Float rtpComputedWeight) { + Object oldValue = getRtpComputedWeight(); + this.rtpComputedWeight = rtpComputedWeight; + firePropertyChange(PROPERTY_RTP_COMPUTED_WEIGHT, oldValue, rtpComputedWeight); } - public void setComputedOrNotWeight(ComputableData<Float> computedOrNotWeight) { - this.computedOrNotWeight = computedOrNotWeight; + public boolean withRtpComputedWeight() { + return rtpComputedWeight != null; } @Override @@ -296,14 +295,13 @@ public class SpeciesFrequencyRowModel extends AbstractTuttiBeanUIModel<SpeciesBa } public boolean isEmpty() { - return lengthStep == null && (computedOrNotWeight.getData() == null || number == null); + return lengthStep == null && (weight == null || number == null); } public Float computeAverageWeight() { Float averageWeight = null; - Float weight = computedOrNotWeight.getDataOrComputedData(); - if (weight != null && number != null) { - averageWeight = number == 0 ? 0 : weight / number; + if (withWeight() && withNumber()) { + averageWeight = weight / number; } return averageWeight; } diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyTableModel.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyTableModel.java index 956b852..6716bfb 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyTableModel.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyTableModel.java @@ -56,10 +56,15 @@ public class SpeciesFrequencyTableModel extends AbstractApplicationTableModel<Sp n("tutti.editSpeciesFrequencies.table.header.number")); public static final ColumnIdentifier<SpeciesFrequencyRowModel> WEIGHT = ColumnIdentifier.newId( - SpeciesFrequencyRowModel.PROPERTY_COMPUTED_WEIGHT, + SpeciesFrequencyRowModel.PROPERTY_WEIGHT, n("tutti.editSpeciesFrequencies.table.header.weight"), n("tutti.editSpeciesFrequencies.table.header.weight")); + public static final ColumnIdentifier<SpeciesFrequencyRowModel> RTP_COMPUTED_WEIGHT = ColumnIdentifier.newId( + SpeciesFrequencyRowModel.PROPERTY_RTP_COMPUTED_WEIGHT, + n("tutti.editSpeciesFrequencies.table.header.rtpComputedWeight"), + n("tutti.editSpeciesFrequencies.table.header.rtpComputedWeight")); + private final SpeciesFrequencyUIModel uiModel; private final SpeciesFrequencyUIModelCache modelCache; @@ -94,7 +99,7 @@ public class SpeciesFrequencyTableModel extends AbstractApplicationTableModel<Sp this.modelCache = uiModel.cache; this.frequenciesSeries = uiModel.frequenciesDataset.getSeries(0); this.averageWeightsSeries = uiModel.averageWeightsDataset.getSeries(0); - setNoneEditableCols(); + setNoneEditableCols(RTP_COMPUTED_WEIGHT); } @Override @@ -132,22 +137,20 @@ public class SpeciesFrequencyTableModel extends AbstractApplicationTableModel<Sp boolean result; CopyIndividualObservationMode copyIndividualObservationMode = uiModel.getCopyIndividualObservationMode(); - if (copyIndividualObservationMode == null) { - result = super.isCellEditable(rowIndex, columnIndex, propertyName); - } else { + result = super.isCellEditable(rowIndex, columnIndex, propertyName); + + if (result && copyIndividualObservationMode != null) { switch (copyIndividualObservationMode) { case ALL: result = false; break; case NOTHING: - result = true; + result = !(WEIGHT.equals(propertyName) && uiModel.isCopyRtpWeights()); break; case SIZE: - result = WEIGHT.equals(propertyName); + result = WEIGHT.equals(propertyName) && !uiModel.isCopyRtpWeights(); break; - default: - result = super.isCellEditable(rowIndex, columnIndex, propertyName); } } return result; @@ -339,6 +342,8 @@ public class SpeciesFrequencyTableModel extends AbstractApplicationTableModel<Sp // Can recompute total number and weight only after valid flag change uiModel.recomputeTotalNumberAndWeight(); + fireTableDataChanged(); + } }; } diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.jaxx b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.jaxx index 7398b80..f8e5990 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.jaxx +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.jaxx @@ -254,7 +254,7 @@ public SpeciesFrequencyUI(TuttiUI parentUI) { <JTextField id='totalNumberField'/> </cell> <cell> - <JCheckBox id='useRTPCheckBox' onItemStateChanged='handler.setBoolean(event, "useRTP")'/> + <JCheckBox id='copyRtpWeightsCheckBox' onItemStateChanged='handler.setBoolean(event, "copyRtpWeights")'/> </cell> </row> <row> diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.jcss b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.jcss index 1d7cacf..3535084 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.jcss +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.jcss @@ -365,11 +365,12 @@ ComputableDataEditor { _help: {"tutti.editSpeciesFrequencies.field.totalWeight.help"}; } -#useRTPCheckBox { - text: "tutti.editSpeciesFrequencies.field.useRtp"; - toolTipText: "tutti.editSpeciesFrequencies.field.useRtp.tip"; - enabled: { getModel().getRtp() != null }; - _help: {"tutti.editSpeciesFrequencies.field.useRtp.help"}; +#copyRtpWeightsCheckBox { + text: "tutti.editSpeciesFrequencies.field.copyRtpWeights"; + toolTipText: "tutti.editSpeciesFrequencies.field.copyRtpWeights.tip"; + enabled: { getModel().getRtp() != null && !getModel().isCopyIndividualObservationAll() }; + selected: { !getModel().isCopyIndividualObservationAll() && getModel().isCopyRtpWeights() }; + _help: {"tutti.editSpeciesFrequencies.field.copyRtpWeights.help"}; } #graphAverageWeightButton { diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java index 548da4f..c2123c2 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java @@ -66,7 +66,6 @@ import fr.ifremer.tutti.ui.swing.util.caracteristics.CaracteristicMapColumnUIHan import fr.ifremer.tutti.ui.swing.util.caracteristics.CaracteristicMapEditorUI; import fr.ifremer.tutti.ui.swing.util.comment.CommentCellEditor; import fr.ifremer.tutti.ui.swing.util.comment.CommentCellRenderer; -import fr.ifremer.tutti.ui.swing.util.computable.ComputableDataTableCell; import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler; import fr.ifremer.tutti.ui.swing.util.table.CaracteristicColumnIdentifier; import fr.ifremer.tutti.util.Weights; @@ -94,16 +93,20 @@ import org.nuiton.jaxx.application.ApplicationBusinessException; import javax.swing.JComponent; import javax.swing.JFrame; +import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JSplitPane; +import javax.swing.JTable; import javax.swing.JTextField; +import javax.swing.SwingConstants; import javax.swing.SwingUtilities; import javax.swing.event.TableModelEvent; import javax.swing.table.TableCellRenderer; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; +import java.awt.Font; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.awt.event.MouseAdapter; @@ -528,7 +531,7 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci ); }); - model.addPropertyChangeListener(SpeciesFrequencyUIModel.PROPERTY_USE_RTP, evt -> { + model.addPropertyChangeListener(SpeciesFrequencyUIModel.PROPERTY_COPY_RTP_WEIGHTS, evt -> { getModel().getRows().forEach(row -> getModel().computeRowWeightWithRtp(row)); getModel().reloadRows(); getTableModel().fireTableDataChanged(); @@ -552,13 +555,24 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci return; } - if (CopyIndividualObservationMode.NOTHING == oldCopyMode) { + // le seul mode où l'utilisateur ne peut rien saisir est le mode tout + if (CopyIndividualObservationMode.ALL != oldCopyMode) { - long rowsWithData = model.getRows().stream() - .filter(row -> row.getLengthStep() != null || row.withNumber() || row.withWeight()) - .count(); + long rowsWithUserData; - if (rowsWithData > 0) { + // si on etait en mode taille et que l'utilisateur avait saisi des tailles + if (oldCopyMode == CopyIndividualObservationMode.SIZE) { + rowsWithUserData = model.getRows().stream() + .filter(row -> row.withWeight()) + .count(); + + } else { + rowsWithUserData = model.getRows().stream() + .filter(row -> row.getLengthStep() != null || row.withNumber() || row.withWeight()) + .count(); + } + + if (rowsWithUserData > 0) { String htmlMessage = String.format( CONFIRMATION_FORMAT, @@ -586,10 +600,11 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci boolean nothingCopyMode = CopyIndividualObservationMode.NOTHING == newCopyMode; - if (initCopyIndividualObservationMode && nothingCopyMode) { + // si on est en initialisation, ca ne sert à rien de regénérer les lignes, elles sont sensées être chargées + if (initCopyIndividualObservationMode) { if (log.isInfoEnabled()) { - log.info("Skip recompute frequencies from indivudal observations for nothing mode (flag initCopyIndividualObservationMode is on), copyIndividualObservationMode changed from " + oldCopyMode + " to " + newCopyMode); + log.info("Skip recompute frequencies from indivudal observations (flag initCopyIndividualObservationMode is on), copyIndividualObservationMode changed from " + oldCopyMode + " to " + newCopyMode); } return; } @@ -722,6 +737,7 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci model.setMinStep(null); model.setMaxStep(null); model.setRtp(null); + model.setCopyRtpWeights(false); frequencyEditor = editor; @@ -967,6 +983,8 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci initCopyIndividualObservationMode = false; } + model.computeRowWeightWithRtp(); + if (getContext().isIchtyometerConnected()) { // let's listen the ichtyometer @@ -1069,17 +1087,31 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci } { // Weight + addFloatColumnToModel(columnModel, SpeciesFrequencyTableModel.WEIGHT, weightUnit, table); + } + + { // RTP computed Weight Color computedDataColor = getConfig().getColorComputedWeights(); - // create table column model - TableCellRenderer defaultRenderer = table.getDefaultRenderer(Object.class); + TableCellRenderer renderer = new TableCellRenderer() { + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + Component result = table.getDefaultRenderer(Number.class).getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); + if (result instanceof JLabel) { + JLabel jLabel = (JLabel) result; + jLabel.setHorizontalTextPosition(SwingConstants.RIGHT); + jLabel.setForeground(computedDataColor); + jLabel.setFont(jLabel.getFont().deriveFont(Font.ITALIC)); + + } + return result; + } + }; addColumnToModel(columnModel, - ComputableDataTableCell.newEditor( - Float.class, weightUnit, computedDataColor), - ComputableDataTableCell.newRender( - defaultRenderer, weightUnit, computedDataColor), - SpeciesFrequencyTableModel.WEIGHT, + null, + renderer, + SpeciesFrequencyTableModel.RTP_COMPUTED_WEIGHT, weightUnit); } @@ -1106,16 +1138,16 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci HighlightPredicate weightTooDifferentFromRtpPredicate = (Component renderer, ComponentAdapter adapter) -> { boolean result = false; - if (table.getModel() instanceof SpeciesFrequencyTableModel && getModel().isUseRTP()) { + if (table.getModel() instanceof SpeciesFrequencyTableModel) { SpeciesFrequencyTableModel tableModel = (SpeciesFrequencyTableModel) table.getModel(); int viewRow = adapter.row; int modelRow = adapter.convertRowIndexToModel(viewRow); SpeciesFrequencyRowModel row = tableModel.getEntry(modelRow); - Float weight = row.getWeight(); Float rate = getConfig().getDifferenceRateBetweenWeightAndRtpWeight(); - result = weight != null && Math.abs(weight - row.getComputedWeight()) >= weight * rate / 100; + result = row.withWeight() && row.withRtpComputedWeight() + && Math.abs(row.getWeight() - row.getRtpComputedWeight()) >= row.getWeight() * rate / 100; } return result; @@ -1124,7 +1156,6 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci // paint in a special color rows with weight in warning (not selected) Highlighter weightTooDifferentFromRtpHighlighter = TuttiUIUtil.newBackgroundColorHighlighter( new HighlightPredicate.AndHighlightPredicate( - HighlightPredicate.EDITABLE, notSelectedPredicate, weightTooDifferentFromRtpPredicate), getConfig().getColorWarningRow()); @@ -1133,7 +1164,6 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci // paint in a special color rows with weight in warning (selected) Highlighter weightTooDifferentFromRtpSelectedHighlighter = TuttiUIUtil.newBackgroundColorHighlighter( new HighlightPredicate.AndHighlightPredicate( - HighlightPredicate.EDITABLE, HighlightPredicate.IS_SELECTED, weightTooDifferentFromRtpPredicate), getConfig().getColorWarningRow().darker()); 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..836eb60 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 @@ -95,7 +95,7 @@ public class SpeciesFrequencyUIModel extends AbstractTuttiTableUIModel<SpeciesBa public static final String PROPERTY_TOTAL_COMPUTED_WEIGHT = "totalComputedWeight"; - public static final String PROPERTY_USE_RTP = "useRTP"; + public static final String PROPERTY_COPY_RTP_WEIGHTS = "copyRtpWeights"; public static final String PROPERTY_RTP = "rtp"; @@ -192,11 +192,11 @@ public class SpeciesFrequencyUIModel extends AbstractTuttiTableUIModel<SpeciesBa protected Rtp rtp; /** - * Use the RTPs of the protocol to compute the total weight + * copy the weigths computed with the RTPs of the protocol * * @since 4.5 */ - protected boolean useRTP; + protected boolean copyRtpWeights; /** * Add individual observation rows when a lengthstep is added with the rafale mode @@ -603,15 +603,15 @@ public class SpeciesFrequencyUIModel extends AbstractTuttiTableUIModel<SpeciesBa firePropertyChange(PROPERTY_RTP, oldValue, rtp); } - public boolean isUseRTP() { - return useRTP; + public boolean isCopyRtpWeights() { + return copyRtpWeights; } -// public void setUseRTP(boolean useRTP) { -// Object oldValue = isUseRTP(); -// this.useRTP = useRTP; -// firePropertyChange(PROPERTY_USE_RTP, oldValue, useRTP); -// } + public void setCopyRtpWeights(boolean copyRtpWeights) { + Object oldValue = isCopyRtpWeights(); + this.copyRtpWeights = copyRtpWeights; + firePropertyChange(PROPERTY_COPY_RTP_WEIGHTS, oldValue, copyRtpWeights); + } public boolean isAddIndividualObservationOnRafale() { return addIndividualObservationOnRafale; @@ -814,11 +814,15 @@ public class SpeciesFrequencyUIModel extends AbstractTuttiTableUIModel<SpeciesBa setCanEditLengthStep(result); } + public void computeRowWeightWithRtp() { + rows.forEach(this::computeRowWeightWithRtp); + } + public void computeRowWeightWithRtp(SpeciesFrequencyRowModel row) { - Integer number = row.getNumber(); - if (number != null && isUseRTP()) { + Float computedWeight = null; + if (row.withNumber()) { //Formule Poids (gramme) = a Taille (cm) ^ b Rtp rtp = getRtp(); @@ -827,15 +831,15 @@ public class SpeciesFrequencyUIModel extends AbstractTuttiTableUIModel<SpeciesBa // measurement in cm asked lengthStep = lengthStep / 10; } - - float weight = (float) (number * rtp.getA() * Math.pow(lengthStep, rtp.getB())); + computedWeight = (float) (row.getNumber() * rtp.getA() * Math.pow(lengthStep, rtp.getB())); if (weightUnit == WeightUnit.KG) { - weight = weight / 1000; + computedWeight = computedWeight / 1000; } - row.setComputedWeight(weight); + } - } else { - row.setComputedWeight(null); + row.setRtpComputedWeight(computedWeight); + if (isCopyRtpWeights()) { + row.setWeight(computedWeight); } } diff --git a/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties b/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties index e472d2c..6234059 100644 --- a/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties +++ b/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties @@ -1541,6 +1541,8 @@ tutti.editSpeciesFrequencies.error.itchyometer.bad.record= tutti.editSpeciesFrequencies.error.length.doublon= tutti.editSpeciesFrequencies.field.addIndividualObservationOnRafale= tutti.editSpeciesFrequencies.field.addIndividualObservationOnRafale.tip= +tutti.editSpeciesFrequencies.field.copyRtpWeights= +tutti.editSpeciesFrequencies.field.copyRtpWeights.tip= tutti.editSpeciesFrequencies.field.copyToSizeTableMode.all= tutti.editSpeciesFrequencies.field.copyToSizeTableMode.all.mnemonic= tutti.editSpeciesFrequencies.field.copyToSizeTableMode.all.tip= @@ -1606,6 +1608,7 @@ tutti.editSpeciesFrequencies.removeObservationRows.title= tutti.editSpeciesFrequencies.simpleCountingAndFrequencies= tutti.editSpeciesFrequencies.table.header.lengthStep= tutti.editSpeciesFrequencies.table.header.number= +tutti.editSpeciesFrequencies.table.header.rtpComputedWeight= tutti.editSpeciesFrequencies.table.header.weight= tutti.editSpeciesFrequencies.title= tutti.editSpeciesFrequencies.title.addLengthStepCaracteristic= diff --git a/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties b/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties index dd575aa..6ebd56d 100644 --- a/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties +++ b/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties @@ -1442,6 +1442,8 @@ tutti.editSpeciesFrequencies.error.itchyometer.bad.record=La mesure provenant de tutti.editSpeciesFrequencies.error.length.doublon=La classe de taille <strong>%s</strong> est utilisée plusieurs fois (deuxième occurrence trouvée à la ligne <strong>%s</strong>), ce qui n'est pas autorisé.<hr/>Veuillez corriger cela pour pouvoir enregistrer les mensurations. tutti.editSpeciesFrequencies.field.addIndividualObservationOnRafale=Ajouter aux observations individuelles tutti.editSpeciesFrequencies.field.addIndividualObservationOnRafale.tip=Ajouter une ligne d'observation individuelle avec la taille saisie +tutti.editSpeciesFrequencies.field.copyRtpWeights=Recopie des poids via RTP +tutti.editSpeciesFrequencies.field.copyRtpWeights.tip=Recopie des poids via RTP tutti.editSpeciesFrequencies.field.copyToSizeTableMode.all=Tout tutti.editSpeciesFrequencies.field.copyToSizeTableMode.all.mnemonic=T tutti.editSpeciesFrequencies.field.copyToSizeTableMode.all.tip=Tout recopier (tailles et poids) @@ -1493,6 +1495,7 @@ tutti.editSpeciesFrequencies.logTable.removeRow.confirm.title=Suppression d'une tutti.editSpeciesFrequencies.simpleCountingAndFrequencies=Des mensurations ont été saisies dans le tableau. Saisir un simple dénombrement les effacera. tutti.editSpeciesFrequencies.table.header.lengthStep=Classe de taille tutti.editSpeciesFrequencies.table.header.number=Nombre +tutti.editSpeciesFrequencies.table.header.rtpComputedWeight=Poids calculé par les RTP tutti.editSpeciesFrequencies.table.header.weight=Poids observé tutti.editSpeciesFrequencies.title=Mensuration tutti.editSpeciesFrequencies.title.addLengthStepCaracteristic=Choisir une autre caractéristique -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.