branch feature/8113 created (now c6f5ff3)
This is an automated email from the git hooks/post-receive script. New change to branch feature/8113 in repository tutti. See http://git.codelutin.com/tutti.git at c6f5ff3 on calcule pas les poids si tous ne sont pas renseignés (refs #8113) This branch includes the following new commits: new c6f5ff3 on calcule pas les poids si tous ne sont pas renseignés (refs #8113) The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit c6f5ff3b0d2774beb61f005f90cd746fdcd4e1f9 Author: Kevin Morin <morin@codelutin.com> Date: Mon Mar 14 15:05:07 2016 +0100 on calcule pas les poids si tous ne sont pas renseignés (refs #8113) -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/8113 in repository tutti. See http://git.codelutin.com/tutti.git commit c6f5ff3b0d2774beb61f005f90cd746fdcd4e1f9 Author: Kevin Morin <morin@codelutin.com> Date: Mon Mar 14 15:05:07 2016 +0100 on calcule pas les poids si tous ne sont pas renseignés (refs #8113) --- .../IndividualObservationBatchRowModel.java | 8 + .../frequency/SpeciesFrequencyUIHandler.java | 161 +++++++++++---------- .../species/frequency/SpeciesFrequencyUIModel.java | 38 ++++- 3 files changed, 123 insertions(+), 84 deletions(-) diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchRowModel.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchRowModel.java index 2efea20..107b1d7 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchRowModel.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchRowModel.java @@ -247,6 +247,10 @@ public class IndividualObservationBatchRowModel extends AbstractTuttiBeanUIModel firePropertyChange(PROPERTY_WEIGHT, oldValue, weight); } + public boolean withWeight() { + return getWeight() != null; + } + @Override public Species getSpecies() { return editObject.getSpecies(); @@ -271,6 +275,10 @@ public class IndividualObservationBatchRowModel extends AbstractTuttiBeanUIModel firePropertyChange(PROPERTY_SIZE, oldValue, size); } + public boolean withSize() { + return getSize() != null; + } + @Override public Caracteristic getLengthStepCaracteristic() { return editObject.getLengthStepCaracteristic(); 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 5744459..d523767 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 @@ -69,7 +69,6 @@ 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; import jaxx.runtime.swing.editor.bean.BeanFilterableComboBox; import jaxx.runtime.validator.swing.SwingValidator; import org.apache.commons.collections4.CollectionUtils; @@ -203,7 +202,7 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci String propertyName = evt.getPropertyName(); // we only update the frequencies if the row is valid - if (row.isValid()) { +// if (row.isValid()) { if (getModel().mustCopyIndividualObservationSize() && IndividualObservationBatchRowModel.PROPERTY_SIZE.equals(propertyName)) { @@ -239,27 +238,27 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci updateFrequencyRowsWeights(row.getSize(), weightToAdd); } } - } +// } // if the row's valid state changes, then remove or readd it to the frequencies - if (!getModel().isRowComputationInProgress() - && IndividualObservationBatchRowModel.PROPERTY_VALID.equals(propertyName)) { - - boolean oldValue = (boolean) evt.getOldValue(); - boolean newValue = (boolean) evt.getNewValue(); - - if (oldValue && getModel().mustCopyIndividualObservationSize()) { - updateFrequencyRowsNumbers(row.getSize(), null); - } - if (newValue) { - if (getModel().mustCopyIndividualObservationSize()) { - updateFrequencyRowsNumbers(null, row.getSize()); - } - if (getModel().mustCopyIndividualObservationWeight()) { - updateFrequencyRowsWeights(row.getSize(), row.getWeight()); - } - } - } +// if (!getModel().isRowComputationInProgress() +// && IndividualObservationBatchRowModel.PROPERTY_VALID.equals(propertyName)) { +// +// boolean oldValue = (boolean) evt.getOldValue(); +// boolean newValue = (boolean) evt.getNewValue(); +// +// if (oldValue && getModel().mustCopyIndividualObservationSize()) { +// updateFrequencyRowsNumbers(row.getSize(), null); +// } +// if (newValue) { +// if (getModel().mustCopyIndividualObservationSize()) { +// updateFrequencyRowsNumbers(null, row.getSize()); +// } +// if (getModel().mustCopyIndividualObservationWeight()) { +// updateFrequencyRowsWeights(row.getSize(), row.getWeight()); +// } +// } +// } getModel().recomputeIndividualObservationRowValidState(row); getModel().recomputeCanEditLengthStep(); @@ -522,6 +521,9 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci getObsTableModel().setRows((List<IndividualObservationBatchRowModel>) evt.getNewValue()); }); + model.addPropertyChangeListener(SpeciesFrequencyUIModel.PROPERTY_ROWS_IN_ERROR_WITH_LENGTH_STEP, evt -> { + reloadRowsFromIndividualObservations(); + }); // model.addPropertyChangeListener(SpeciesFrequencyUIModel.PROPERTY_INDIVIDUAL_OBSERVATION_ROWS_IN_ERROR, evt -> { // Set<IndividualObservationBatchRowModel> obsRowsInError = // (Set<IndividualObservationBatchRowModel>) evt.getNewValue(); @@ -572,23 +574,7 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci ui.getRafaleModeButton().setSelected(true); ui.getAddIndividualObservationCheckBox().setSelected(true); - model.setRowComputationInProgress(true); - - try { - - model.getRows().clear(); - model.getRowsInError().clear(); - model.reloadRows(); - model.recomputeIndividualObservationRowsValidateState(); - reloadRowsFromIndividualObservations(); - - } finally { - model.setRowComputationInProgress(false); - } - - getTableModel().fireTableDataChanged(); - getObsTableModel().fireTableDataChanged(); - + reloadRowsFromIndividualObservations(); }); // set the pattern to the weight in simple counting mode according to the weight unit @@ -963,14 +949,14 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci weight = weightUnit.fromEntity(getConfig().getIndividualObservationWeightUnit().toEntity(weight)); row.addToWeight(weight); - if (Weights.isNullOrZero(row.getWeight())) { - int rowIndex = tableModel.getRowIndex(row); - tableModel.removeRow(rowIndex); - getModel().getRowCache().remove(lengthStep); - - } else { +// if (Weights.isNullOrZero(row.getWeight())) { +// int rowIndex = tableModel.getRowIndex(row); +// tableModel.removeRow(rowIndex); +// getModel().getRowCache().remove(lengthStep); +// +// } else { tableModel.updateRow(row); - } +// } } } @@ -1533,55 +1519,70 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci protected void reloadRowsFromIndividualObservations() { SpeciesFrequencyUIModel model = getModel(); - CopyIndividualObservationMode copyMode = model.getCopyIndividualObservationMode(); - if (CopyIndividualObservationMode.NOTHING != copyMode) { + model.setRowComputationInProgress(true); - Caracteristic lengthStepCaracteristic = model.getLengthStepCaracteristic(); + try { - List<IndividualObservationBatchRowModel> validObsRow = new ArrayList<>(model.getIndividualObservationRows()); - validObsRow.removeAll(model.getIndividualObservationRowsInError()); + model.getRows().clear(); + model.getRowsInError().clear(); + model.reloadRows(); + model.recomputeIndividualObservationRowsValidateState(); - WeightUnit individualObservationWeightUnit = getConfig().getIndividualObservationWeightUnit(); + CopyIndividualObservationMode copyMode = model.getCopyIndividualObservationMode(); - for (IndividualObservationBatchRowModel obsRow : validObsRow) { + if (CopyIndividualObservationMode.NOTHING != copyMode) { - Float size = obsRow.getSize(); - if (size != null) { - size = model.getLengthStep(size); - if (log.isInfoEnabled()) { - log.info("size : " + size); - } - SpeciesFrequencyRowModel row = model.getRowCache().get(size); - if (row == null) { - row = getTableModel().createNewRow(); - row.setLengthStep(size); - row.setLengthStepCaracteristic(lengthStepCaracteristic); - model.getRows().add(row); - model.getRowCache().put(size, row); - } - row.incNumber(); - Float weight = obsRow.getWeight(); - if (CopyIndividualObservationMode.ALL == copyMode && weight != null) { - // conversion de poids - weight = weightUnit.fromEntity(individualObservationWeightUnit.toEntity(weight)); - row.addToWeight(weight); + Caracteristic lengthStepCaracteristic = model.getLengthStepCaracteristic(); + + WeightUnit individualObservationWeightUnit = getConfig().getIndividualObservationWeightUnit(); + + for (IndividualObservationBatchRowModel obsRow : model.getIndividualObservationRows()) { + + if (obsRow.withSize()) { + Float size = obsRow.getSize(); + if (size != null) { + size = model.getLengthStep(size); + SpeciesFrequencyRowModel row = model.getRowCache().get(size); + if (row == null) { + row = getTableModel().createNewRow(); + row.setLengthStep(size); + row.setLengthStepCaracteristic(lengthStepCaracteristic); + model.getRows().add(row); + model.getRowCache().put(size, row); + } + row.incNumber(); + if (CopyIndividualObservationMode.ALL == copyMode + && !model.isRowsInErrorWithLengthStep() + && obsRow.withWeight()) { + // conversion de poids + Float weight = obsRow.getWeight(); + weight = weightUnit.fromEntity(individualObservationWeightUnit.toEntity(weight)); + row.addToWeight(weight); + } + } } } - } - if (model.getRowCount() == 0) { - getTableModel().addNewRow(); + if (model.getRowCount() == 0) { + getTableModel().addNewRow(); - } else { - Collections.sort(model.getRows()); + } else { + Collections.sort(model.getRows()); + } + + } else if (getTableModel().getRowCount() == 0) { + getTableModel().addNewRow(); } - } else if (getTableModel().getRowCount() == 0) { - getTableModel().addNewRow(); + model.reloadRows(); + + } finally { + model.setRowComputationInProgress(false); } - model.reloadRows(); + getTableModel().fireTableDataChanged(); + getObsTableModel().fireTableDataChanged(); } @Override 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 3ddc475..600bd32 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 @@ -118,6 +118,8 @@ public class SpeciesFrequencyUIModel extends AbstractTuttiTableUIModel<SpeciesBa public static final String PROPERTY_INDIVIDUAL_OBSERVATION_ROWS_IN_ERROR = "individualObservationRowsInError"; + public static final String PROPERTY_ROWS_IN_ERROR_WITH_LENGTH_STEP = "rowsInErrorWithLengthStep"; + /** * Fill mode. * @@ -289,6 +291,8 @@ public class SpeciesFrequencyUIModel extends AbstractTuttiTableUIModel<SpeciesBa */ protected Set<IndividualObservationBatchRowModel> individualObservationRowsInError; + protected boolean rowsInErrorWithLengthStep; + protected boolean rowComputationInProgress; public SpeciesFrequencyUIModel(WeightUnit weightUnit, @@ -316,6 +320,7 @@ public class SpeciesFrequencyUIModel extends AbstractTuttiTableUIModel<SpeciesBa Lists.<Caracteristic>newArrayList() : Lists.newArrayList(defaultCaracteristic); + setRowsInErrorWithLengthStep(false); setIndividualObservationRowsInError(new HashSet<>()); } @@ -655,7 +660,7 @@ public class SpeciesFrequencyUIModel extends AbstractTuttiTableUIModel<SpeciesBa } public boolean mustCopyIndividualObservationWeight() { - return isCopyIndividualObservationAll(); + return isCopyIndividualObservationAll() && !isRowsInErrorWithLengthStep(); } public boolean isCopyIndividualObservationAll() { @@ -853,6 +858,7 @@ public class SpeciesFrequencyUIModel extends AbstractTuttiTableUIModel<SpeciesBa } } setIndividualObservationRowsInError(individualObservationRowsInError); + recomputeRowsInErrorWithLengthStep(); } public Set<IndividualObservationBatchRowModel> getIndividualObservationRowsInError() { @@ -876,6 +882,16 @@ public class SpeciesFrequencyUIModel extends AbstractTuttiTableUIModel<SpeciesBa firePropertyChange(PROPERTY_INDIVIDUAL_OBSERVATION_ROWS_IN_ERROR, oldValue, individualObservationRowsInError); } + public boolean isRowsInErrorWithLengthStep() { + return rowsInErrorWithLengthStep; + } + + public void setRowsInErrorWithLengthStep(boolean rowsInErrorWithLengthStep) { + Object oldValue = isRowsInErrorWithLengthStep(); + this.rowsInErrorWithLengthStep = rowsInErrorWithLengthStep; + firePropertyChange(PROPERTY_ROWS_IN_ERROR_WITH_LENGTH_STEP, oldValue, rowsInErrorWithLengthStep); + } + public void recomputeRowsValidateState() { if (log.isInfoEnabled()) { @@ -903,10 +919,10 @@ public class SpeciesFrequencyUIModel extends AbstractTuttiTableUIModel<SpeciesBa public boolean isIndividualObservationRowValid(IndividualObservationBatchRowModel row) { return copyIndividualObservationMode == CopyIndividualObservationMode.NOTHING || copyIndividualObservationMode == CopyIndividualObservationMode.SIZE - && row.getSize() != null + && row.withSize() || copyIndividualObservationMode == CopyIndividualObservationMode.ALL - && row.getSize() != null - && row.getWeight() != null; + && row.withSize() + && row.withWeight(); } public void setDataSetIntervalWidth(float step) { @@ -952,10 +968,24 @@ public class SpeciesFrequencyUIModel extends AbstractTuttiTableUIModel<SpeciesBa if (valid) { removeIndividualObservationRowInError(row); + + if (rowsInErrorWithLengthStep) { + recomputeRowsInErrorWithLengthStep(); + } + } else { addIndividualObservationRowInError(row); + + if (!rowsInErrorWithLengthStep) { + recomputeRowsInErrorWithLengthStep(); + } } } + protected final void recomputeRowsInErrorWithLengthStep() { + setRowsInErrorWithLengthStep(!individualObservationRowsInError.isEmpty() && + individualObservationRowsInError.stream().anyMatch(row -> row.withSize() && !row.withWeight())); + } + } -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
participants (1)
-
codelutin.com scm