This is an automated email from the git hooks/post-receive script. New commit to branch feature/revue_algorithme in repository tutti. See https://gitlab.nuiton.org/codelutin/tutti.git commit 7de63b3196d6cab28a601e6d1d7cfd88b589b0b6 Author: Tony CHEMIT <chemit@codelutin.com> Date: Wed Apr 20 02:27:52 2016 +0200 Normalement on a le bon flow pour la rafraichissement de la zone de notification des prélèvements + nettoyage de code --- .../IndividualObservationBatchTableHandler.java | 139 +++++---------------- .../IndividualObservationBatchUIModel.java | 7 ++ .../frequency/SpeciesFrequencyUIHandler.java | 11 +- 3 files changed, 39 insertions(+), 118 deletions(-) diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/IndividualObservationBatchTableHandler.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/IndividualObservationBatchTableHandler.java index c68e7d3..37eacb1 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/IndividualObservationBatchTableHandler.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/IndividualObservationBatchTableHandler.java @@ -103,7 +103,7 @@ public class IndividualObservationBatchTableHandler implements Closeable { if (!optionalCruiseCache.isPresent()) { throw new IllegalStateException("Can't find cruise cache"); } - this.individualObservationUICache = new IndividualObservationUICache(optionalCruiseCache.get(), model, uiHandler.getDataContext()); + this.individualObservationUICache = new IndividualObservationUICache(optionalCruiseCache.get(), model, dataContext); this.individualObservationTable = ui.getObsTable(); this.frequencyTableModel = uiHandler.getTableModel(); this.individualObservationToFrequencyEngine = new IndividualObservationToFrequencyEngine(model2.getIndividualObservationWeightUnit()); @@ -120,6 +120,7 @@ public class IndividualObservationBatchTableHandler implements Closeable { CaracteristicQualitativeValue gender = model2.getGender(row); CaracteristicQualitativeValue maturity = model2.getMaturityValue(row); + boolean recomputeSamplingNotificationZone = false; switch (propertyName) { case IndividualObservationBatchRowModel.PROPERTY_INDIVIDUAL_OBSERVATION_BATCH_ROW_STATE: { @@ -139,6 +140,7 @@ public class IndividualObservationBatchTableHandler implements Closeable { float lengthStepToDecrement = optionalDecrementSize.get(); frequencyTableModel.decrementFrequencyRowsNumbers(lengthStepToDecrement); individualObservationUICache.decrementsObservationNb(gender, maturity, lengthStepToDecrement, row.getSamplingCode()); + recomputeSamplingNotificationZone = true; } Optional<Float> optionalIncrementSize = frequencyUpdate.getIncrementSize(); @@ -146,6 +148,7 @@ public class IndividualObservationBatchTableHandler implements Closeable { float lengthStepToIncrement = optionalIncrementSize.get(); frequencyTableModel.incrementFrequencyRowsNumbers(lengthStepToIncrement); individualObservationUICache.incrementsObservationNb(gender, maturity, lengthStepToIncrement, row.getSamplingCode()); + recomputeSamplingNotificationZone = true; } Optional<Pair<Float, Float>> optionalSubstractWeight = frequencyUpdate.getSubstractWeight(); @@ -176,73 +179,11 @@ public class IndividualObservationBatchTableHandler implements Closeable { } break; -// case IndividualObservationBatchRowModel.PROPERTY_SIZE: { -// -// Float oldValue = (Float) evt.getOldValue(); -// Float newValue = (Float) evt.getNewValue(); -// -// if (oldValue != null) { -// individualObservationUICache.decrementsObservationNb(gender, maturity, oldValue, row.getSamplingCode()); -// } -// if (newValue != null) { -// individualObservationUICache.incrementsObservationNb(gender, maturity, newValue, row.getSamplingCode()); -// } -// -// // we only update the frequencies if the row is valid -// if (row.isValid() && model.mustCopyIndividualObservationSize()) { -// -// if (oldValue != null) { -// frequencyTableModel.decrementFrequencyRowsNumbers(oldValue); -// } -// if (newValue != null) { -// frequencyTableModel.incrementFrequencyRowsNumbers(newValue); -// } -// -// if (model.isCopyIndividualObservationAll() && row.withWeight()) { -// float weight = row.getWeight(); -// if (oldValue != null) { -// frequencyTableModel.removeWeightToFrequencyRow(oldValue, weight); -// } -// if (newValue != null) { -// frequencyTableModel.addWeightToFrequencyRow(newValue, weight); -// } -// } -// } -// } -// break; -// -// case IndividualObservationBatchRowModel.PROPERTY_WEIGHT: -// if (row.isValid() && model.isCopyIndividualObservationAll()) { -// -// Float oldValue = (Float) evt.getOldValue(); -// Float newValue = (Float) evt.getNewValue(); -// Float weightToAdd; -// -// if (oldValue == null) { -// weightToAdd = newValue; -// -// } else if (newValue == null) { -// weightToAdd = -oldValue; -// -// } else { -// weightToAdd = newValue - oldValue; -// } -// -// WeightUnit weightUnit = model.getWeightUnit(); -// -// if (weightUnit.isNotNullNorZero(weightToAdd)) { -// if (weightUnit.isGreaterThanZero(weightToAdd)) { -// frequencyTableModel.addWeightToFrequencyRow(row, weightToAdd); -// } else { -// frequencyTableModel.removeWeightToFrequencyRow(row, -weightToAdd); -// } -// } -// } -// break; - case IndividualObservationBatchRowModel.PROPERTY_DEFAULT_CARACTERISTICS: case IndividualObservationBatchRowModel.PROPERTY_CARACTERISTICS: + if (row.withSize()) { + CaracteristicMap oldValue = (CaracteristicMap) evt.getOldValue(); CaracteristicMap newValue = (CaracteristicMap) evt.getNewValue(); @@ -259,6 +200,7 @@ public class IndividualObservationBatchTableHandler implements Closeable { if (!Objects.equals(oldMaturity, newMaturity)) { individualObservationUICache.decrementsObservationNb(gender, oldMaturity, row.getSize()); individualObservationUICache.incrementsObservationNb(gender, newMaturity, row.getSize(), row.getSamplingCode()); + recomputeSamplingNotificationZone = true; } } @@ -267,8 +209,11 @@ public class IndividualObservationBatchTableHandler implements Closeable { if (!Objects.equals(oldGender, newGender)) { individualObservationUICache.decrementsObservationNb(oldGender, maturity, row.getSize()); individualObservationUICache.incrementsObservationNb(newGender, maturity, row.getSize(), row.getSamplingCode()); + recomputeSamplingNotificationZone = true; } + } + break; case IndividualObservationBatchRowModel.PROPERTY_SAMPLING_CODE: @@ -288,39 +233,31 @@ public class IndividualObservationBatchTableHandler implements Closeable { if (row.withSize()) { - float size = row.getSize(); + boolean removeSampling = withOldSamplingCode && !withNewSamplingCode; + boolean addSampling = withNewSamplingCode && !withOldSamplingCode; + + if (removeSampling) { + + individualObservationUICache.decrementsSamplingNb(gender, maturity, row.getSize()); + recomputeSamplingNotificationZone = true; + + } else if (addSampling) { + + individualObservationUICache.incrementsSamplingNb(gender, maturity, row.getSize()); + recomputeSamplingNotificationZone = true; - if (withOldSamplingCode) { - individualObservationUICache.decrementsSamplingNb(gender, maturity, size); - } - if (withNewSamplingCode) { - individualObservationUICache.incrementsSamplingNb(gender, maturity, size); } } + break; -// case IndividualObservationBatchRowModel.PROPERTY_VALID: -// // if the row's valid state changes, then remove or readd it to the frequencies -// if (!model.isRowComputationInProgress()) { -// -// boolean oldValue = (boolean) evt.getOldValue(); -// boolean newValue = (boolean) evt.getNewValue(); -// -// if (oldValue && model.mustCopyIndividualObservationSize()) { -// -// frequencyTableModel.decrementFrequencyRowsNumbers(row); -// } -// if (newValue) { -// if (model.mustCopyIndividualObservationSize()) { -// frequencyTableModel.incrementFrequencyRowsNumbers(row); -// } -// if (model.isCopyIndividualObservationAll() && row.withWeight()) { -// frequencyTableModel.addWeightToFrequencyRow(row, row.getWeight()); -// } -// } -// } -// break; + } + + if (recomputeSamplingNotificationZone) { + + // recalcul de la zone de notification + model2.getSamplingNotificationZoneModel().setSelectedRow(row); } // model2.recomputeRowValidState(row); @@ -479,24 +416,6 @@ public class IndividualObservationBatchTableHandler implements Closeable { }); -// individualObservationTable.getSelectionModel().addListSelectionListener(e -> { -// -// if (!model.isInRafaleRowCreation()) { -// uiHandler.resetSamplingLabel(); -// } -// -// IndividualObservationBatchRowModel selectedRow = null; -// -// if (!individualObservationTable.getSelectionModel().isSelectionEmpty()) { -// if (individualObservationTable.getSelectedRowCount() == 1) { -// selectedRow = individualObservationTableModel.getEntry(individualObservationTable.getSelectedRow()); -// -// } -// } -// -// individualObservationUICache.updateSelectedRow(selectedRow); -// }); - model2.addPropertyChangeListener(IndividualObservationBatchUIModel.PROPERTY_ROWS, evt -> individualObservationTableModel.setRows((List<IndividualObservationBatchRowModel>) evt.getNewValue())); // Pour bloquer le changement du mode de recopie des observations individuelles → mensurations diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/IndividualObservationBatchUIModel.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/IndividualObservationBatchUIModel.java index d5f1d0c..7c7f4b6 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/IndividualObservationBatchUIModel.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/IndividualObservationBatchUIModel.java @@ -54,6 +54,8 @@ public class IndividualObservationBatchUIModel extends AbstractTuttiTableUIModel */ private Collection<Caracteristic> notEditableCaracteristic; + private final SamplingNotificationZoneModel samplingNotificationZoneModel; + @Override protected SpeciesBatchRowModel newEntity() { return null; // Jamais utilisé! @@ -64,6 +66,11 @@ public class IndividualObservationBatchUIModel extends AbstractTuttiTableUIModel this.sexCaracteristic = sexCaracteristic; this.individualObservationWeightUnit = individualObservationWeightUnit; this.defaultCaracteristic = defaultCaracteristic == null ? new ArrayList<>() : new ArrayList<>(defaultCaracteristic); + this.samplingNotificationZoneModel = new SamplingNotificationZoneModel(); + } + + public SamplingNotificationZoneModel getSamplingNotificationZoneModel() { + return samplingNotificationZoneModel; } public WeightUnit getIndividualObservationWeightUnit() { 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 d400df7..5e9960f 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 @@ -481,7 +481,7 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci this.individualObservationBatchTableHandler = new IndividualObservationBatchTableHandler(ui); this.averageWeightsHistogramHandler = new AverageWeightsHistogramHandler(ui); this.frequenciesHistogramHandler = new FrequenciesHistogramHandler(ui); - this.samplingNotificationZoneHandler = new SamplingNotificationZoneHandler(ui); + this.samplingNotificationZoneHandler = new SamplingNotificationZoneHandler(ui, model.getIndividualObservationModel().getSamplingNotificationZoneModel()); listenValidatorValid(ui.getValidator(), model); @@ -510,9 +510,7 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci IOUtils.closeQuietly(individualObservationBatchTableHandler); IOUtils.closeQuietly(averageWeightsHistogramHandler); IOUtils.closeQuietly(frequenciesHistogramHandler); - IOUtils.closeQuietly(individualObservationBatchTableHandler); - -// resetSamplingLabel(); + IOUtils.closeQuietly(samplingNotificationZoneHandler); frequencyEditor = null; @@ -535,10 +533,9 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci EditSpeciesBatchPanelUI parent = getParentContainer(EditSpeciesBatchPanelUI.class); parent.switchToEditBatch(); + //FIXME Voir si on doit encore faire ça après le switch ? je pense que oui... // // on supprime la colonne maturité en fermant, pour avoir les même colonnes qu'à la création de l'écran (important pour la swing session) // removeMaturityColumnIfPresent(); -// -// individualObservationUICache.close(); } @@ -1083,8 +1080,6 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci boolean sampleCodeMenusEnabled = individualObservationBatchTableHandler.isSampleCodeMenusEnabled(modelRowIndex); -// boolean sampleCodeMenusEnabled = modelRowIndex >= 0 && ui.getObsTable().getSelectedRowCount() == 1 -// && getObsTableModel().getRows().get(ui.getObsTable().getSelectedRow()).withSamplingCode(); ui.getEditSampleCodeMenu().setEnabled(sampleCodeMenusEnabled); ui.getDeleteSampleCodeMenu().setEnabled(sampleCodeMenusEnabled); } -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.