This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository tutti. See http://git.codelutin.com/tutti.git commit ac1e009bbfd23b2525a2ab8d2e57ba4a66dc8cda Author: Kevin Morin <morin@codelutin.com> Date: Mon Feb 29 16:04:42 2016 +0100 - copie des donnees d'observation individuelles dans le tableau des mensurations en fonction du mode - suppression ou ecrasement des données au changement de mode de copie refs #8019 --- .../IndividualObservationBatchTableModel.java | 27 +- .../frequency/SpeciesFrequencyRowModel.java | 30 +++ .../species/frequency/SpeciesFrequencyUI.jcss | 7 +- .../frequency/SpeciesFrequencyUIHandler.java | 288 ++++++++++++++++++--- .../species/frequency/SpeciesFrequencyUIModel.java | 25 +- .../frequency/actions/RemoveObservationAction.java | 11 + .../resources/i18n/tutti-ui-swing_en_GB.properties | 2 + .../resources/i18n/tutti-ui-swing_fr_FR.properties | 3 + 8 files changed, 348 insertions(+), 45 deletions(-) diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchTableModel.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchTableModel.java index c59fd4a..d71cdb7 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchTableModel.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchTableModel.java @@ -22,6 +22,8 @@ package fr.ifremer.tutti.ui.swing.content.operation.catches.individualobservatio * #L% */ +import fr.ifremer.tutti.persistence.entities.referential.Caracteristic; +import fr.ifremer.tutti.persistence.entities.referential.Species; import fr.ifremer.tutti.type.WeightUnit; import org.jdesktop.swingx.table.TableColumnModelExt; import org.nuiton.jaxx.application.swing.table.AbstractApplicationTableModel; @@ -52,11 +54,6 @@ public class IndividualObservationBatchTableModel extends AbstractApplicationTab n("tutti.editIndividualObservationBatch.table.header.size"), n("tutti.editIndividualObservationBatch.table.header.size.tip")); - public static final ColumnIdentifier<IndividualObservationBatchRowModel> LENGTH_STEP_CARACTERISTIC = ColumnIdentifier.newId( - IndividualObservationBatchRowModel.PROPERTY_LENGTH_STEP_CARACTERISTIC, - n("tutti.editIndividualObservationBatch.table.header.lengthStepCaracteristic"), - n("tutti.editIndividualObservationBatch.table.header.lengthStepCaracteristic.tip")); - public static final ColumnIdentifier<IndividualObservationBatchRowModel> OTHER_CARACTERISTICS = ColumnIdentifier.newId( IndividualObservationBatchRowModel.PROPERTY_CARACTERISTICS, n("tutti.editIndividualObservationBatch.table.header.otherCaracteristics"), @@ -79,6 +76,10 @@ public class IndividualObservationBatchTableModel extends AbstractApplicationTab */ protected final WeightUnit weightUnit; + protected Species species; + + protected Caracteristic lengthstepCaracteristic; + public IndividualObservationBatchTableModel(WeightUnit weightUnit, TableColumnModelExt columnModel) { super(columnModel, true, true); @@ -87,6 +88,20 @@ public class IndividualObservationBatchTableModel extends AbstractApplicationTab setNoneEditableCols(RANK); } + public void setSpecies(Species species) { + this.species = species; + if (rows != null) { + rows.forEach(row -> row.setSpecies(species)); + } + } + + public void setLengthstepCaracteristic(Caracteristic lengthstepCaracteristic) { + this.lengthstepCaracteristic = lengthstepCaracteristic; + if (rows != null) { + rows.forEach(row -> row.setLengthStepCaracteristic(lengthstepCaracteristic)); + } + } + @Override public IndividualObservationBatchRowModel createNewRow() { IndividualObservationBatchRowModel result = @@ -95,6 +110,8 @@ public class IndividualObservationBatchTableModel extends AbstractApplicationTab // by default empty row is not valid result.setValid(false); result.setRankOrder(getRowCount() + 1); + result.setSpecies(species); + result.setLengthStepCaracteristic(lengthstepCaracteristic); return result; } 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 89e625d..0fdf044 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 @@ -191,6 +191,23 @@ public class SpeciesFrequencyRowModel extends AbstractTuttiBeanUIModel<SpeciesBa firePropertyChange(PROPERTY_NUMBER, oldValue, number); } + public void incNumber() { + if (number == null) { + number = 0; + } + setNumber(number + 1); + } + + public void decNumber() { + decNumber(1); + } + + public void decNumber(int nb) { + if (number != null && number >= nb) { + setNumber(number - nb); + } + } + @Override public Float getWeight() { return computedOrNotWeight.getData(); @@ -203,6 +220,19 @@ public class SpeciesFrequencyRowModel extends AbstractTuttiBeanUIModel<SpeciesBa firePropertyChange(PROPERTY_WEIGHT, oldValue, weight); } + /** + * @param weightToAdd weight (can be negative) to add + */ + public void addToWeight(float weightToAdd) { + Float weight = computedOrNotWeight.getData(); + if (weight == null) { + weight = 0f; + } + if (weight + weightToAdd >= 0) { + setWeight(weight + weightToAdd); + } + } + public Float getComputedWeight() { return computedOrNotWeight.getComputedData(); } 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 c51fe03..e66d35e 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 @@ -223,7 +223,6 @@ ComputableDataEditor { #samplingWarningLabel { foreground: {Color.RED}; - text: "Prélèvement"; } #dataFieldPanel { @@ -326,7 +325,7 @@ ComputableDataEditor { toolTipText: "tutti.editSpeciesFrequencies.field.copyToSizeTableMode.all.tip"; i18nMnemonic: "tutti.editSpeciesFrequencies.field.copyToSizeTableMode.all.mnemonic"; value: "all"; - //selected: {model.isSimpleCountingMode()}; + selected: {model.isCopyIndividualObservationAll()}; buttonGroup: "copyToSizeTableMode"; _help: {"tutti.editSpeciesFrequencies.field.copyToSizeTableMode.all.help"}; } @@ -336,7 +335,7 @@ ComputableDataEditor { toolTipText: "tutti.editSpeciesFrequencies.field.copyToSizeTableMode.nothing.tip"; i18nMnemonic: "tutti.editSpeciesFrequencies.field.copyToSizeTableMode.nothing.mnemonic"; value: "nothing"; - //selected: {model.isSimpleCountingMode()}; + selected: {model.isCopyIndividualObservationNothing()}; buttonGroup: "copyToSizeTableMode"; _help: {"tutti.editSpeciesFrequencies.field.copyToSizeTableMode.nothing.help"}; } @@ -346,7 +345,7 @@ ComputableDataEditor { toolTipText: "tutti.editSpeciesFrequencies.field.copyToSizeTableMode.size.tip"; i18nMnemonic: "tutti.editSpeciesFrequencies.field.copyToSizeTableMode.size.mnemonic"; value: "size"; - //selected: {model.isSimpleCountingMode()}; + selected: {model.isCopyIndividualObservationSize()}; buttonGroup: "copyToSizeTableMode"; _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/SpeciesFrequencyUIHandler.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java index ac7f38d..7b93051 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 @@ -25,6 +25,7 @@ package fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import fr.ifremer.adagio.core.dao.referential.pmfm.QualitativeValueId; +import fr.ifremer.tutti.ichtyometer.feed.event.FeedReaderEvent; import fr.ifremer.tutti.ichtyometer.feed.event.FeedReaderListener; import fr.ifremer.tutti.ichtyometer.feed.record.FeedReaderMeasureRecord; import fr.ifremer.tutti.persistence.entities.TuttiEntities; @@ -44,6 +45,7 @@ import fr.ifremer.tutti.ui.swing.TuttiUIContext; import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUI; import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIHandler; import fr.ifremer.tutti.ui.swing.content.operation.catches.FrequencyConfigurationMode; +import fr.ifremer.tutti.ui.swing.content.operation.catches.individualobservation.CopyIndividualObservationMode; import fr.ifremer.tutti.ui.swing.content.operation.catches.individualobservation.IndividualObservationBatchRowModel; import fr.ifremer.tutti.ui.swing.content.operation.catches.individualobservation.IndividualObservationBatchTableModel; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchRowModel; @@ -62,6 +64,7 @@ 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; @@ -83,6 +86,7 @@ import org.nuiton.jaxx.application.ApplicationBusinessException; import javax.swing.JComponent; import javax.swing.JFrame; +import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JSplitPane; import javax.swing.JTextField; @@ -96,6 +100,8 @@ import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -144,25 +150,76 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci protected ApplySpeciesFrequencyRafaleAction applySpeciesFrequencyRafaleAction; + protected PropertyChangeListener obsChangedListener; + public SpeciesFrequencyUIHandler() { super(SpeciesFrequencyRowModel.PROPERTY_LENGTH_STEP, SpeciesFrequencyRowModel.PROPERTY_NUMBER, SpeciesFrequencyRowModel.PROPERTY_WEIGHT); - this.feedReaderListener = event -> { + this.feedReaderListener = new FeedReaderListener() { - final FeedReaderMeasureRecord record = event.getRecord(); + @Override + public void recordRead(FeedReaderEvent event) { + final FeedReaderMeasureRecord record = event.getRecord(); - SwingUtilities.invokeLater( - () -> { - if (!getModel().isSimpleCountingMode()) { + SwingUtilities.invokeLater( + () -> { + if (!getModel().isSimpleCountingMode()) { - // can try to consume value - consumeFeedRecord(record); + // can try to consume value + consumeFeedRecord(record); + } } + ); + } + }; + + this.obsChangedListener = new PropertyChangeListener() { + + @Override + public void propertyChange(PropertyChangeEvent evt) { + IndividualObservationBatchRowModel row = (IndividualObservationBatchRowModel) evt.getSource(); + String propertyName = evt.getPropertyName(); + + if (getModel().mustCopyIndividualObservationSize() + && IndividualObservationBatchRowModel.PROPERTY_SIZE.equals(propertyName)) { + + Float oldValue = (Float) evt.getOldValue(); + Float newValue = (Float) evt.getNewValue(); + updateFrequencyRowsNumbers(oldValue, newValue); + + Float weight = row.getWeight(); + if (getModel().mustCopyIndividualObservationWeight() && weight != null) { + updateFrequencyRowsWeights(oldValue, -weight); + updateFrequencyRowsWeights(newValue, weight); } - ); + } + + if (getModel().mustCopyIndividualObservationWeight() + && IndividualObservationBatchRowModel.PROPERTY_WEIGHT.equals(propertyName)) { + + 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; + } + + if (weightToAdd != null) { + updateFrequencyRowsWeights(row.getSize(), weightToAdd); + } + } + } + }; } @@ -322,8 +379,8 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci Caracteristic newValue = (Caracteristic) evt.getNewValue(); // get step from the pmfm float step1 = getStep(newValue); - getModel().setStep(step1); - getModel().setDataSetIntervalWidth(step1); + model.setStep(step1); + model.setDataSetIntervalWidth(step1); frequenciesChart.getXYPlot().getDomainAxis().setStandardTickUnits(new TuttiNumberTickUnitSource(step1 == 1f)); averageWeightsChart.getXYPlot().getDomainAxis().setStandardTickUnits(new TuttiNumberTickUnitSource(step1 == 1f)); if (CollectionUtils.isNotEmpty(getModel().getRows())) { @@ -333,6 +390,8 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci } } SpeciesFrequencyUIHandler.this.ui.getValidator().doValidate(); + + ((IndividualObservationBatchTableModel) ui.getObsTable().getModel()).setLengthstepCaracteristic(newValue); }); // when lengthStepCaracteristicUnit changed, let's updates the label of some fields @@ -385,6 +444,82 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci obsTableModel.setRows((List<IndividualObservationBatchRowModel>) evt.getNewValue()); }); + model.addPropertyChangeListener(SpeciesFrequencyUIModel.PROPERTY_COPY_INDIVIDUAL_OBSERVATION_MODE, evt -> { + + CopyIndividualObservationMode newCopyMode = (CopyIndividualObservationMode) evt.getNewValue(); + CopyIndividualObservationMode oldCopyMode = (CopyIndividualObservationMode) evt.getOldValue(); + + if (oldCopyMode == CopyIndividualObservationMode.NOTHING) { + + long rowsWithData = model.getRows().stream() + .filter(row -> row.getLengthStep() != null + || row.getNumber() != null + || row.getWeight() != null) + .count(); + + if (rowsWithData > 0) { + + String htmlMessage = String.format( + CONFIRMATION_FORMAT, + t("tutti.editSpeciesFrequencies.changeCopyMode.confirm.message"), + t("tutti.editSpeciesFrequencies.changeCopyMode.confirm.help")); + int i = JOptionPane.showConfirmDialog( + getTopestUI(), + htmlMessage, + t("tutti.editSpeciesFrequencies.changeCopyMode.confirm.title"), + JOptionPane.OK_CANCEL_OPTION, + JOptionPane.QUESTION_MESSAGE); + + if (i == JOptionPane.CANCEL_OPTION) { + return; + } + } + } + + model.getRows().clear(); + model.reloadRows(); + + if (newCopyMode != null) { + if (newCopyMode != CopyIndividualObservationMode.NOTHING) { + + Caracteristic lengthStepCaracteristic = model.getLengthStepCaracteristic(); + for (IndividualObservationBatchRowModel obsRow : model.getIndividualObservationRows()) { + + 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(); + if (newCopyMode == CopyIndividualObservationMode.ALL && obsRow.getWeight() != null) { + row.addToWeight(obsRow.getWeight()); + } + } + } + + Collections.sort(model.getRows()); + + } else { + getTableModel().addNewRow(); + } + + model.reloadRows(); + + } + + getTableModel().fireTableDataChanged(); + + }); + // set the pattern to the weight in simple counting mode according to the weight unit ui.getSimpleCountingWeightField().setNumberPattern(weightUnit.getNumberEditorPattern()); @@ -469,7 +604,15 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci model.setMinStep(null); model.setMaxStep(null); model.setRtp(null); - model.setIndividualObservationRows(new ArrayList<>()); + + ((IndividualObservationBatchTableModel) ui.getObsTable().getModel()).setSpecies(speciesBatch.getSpecies()); + + ArrayList<IndividualObservationBatchRowModel> individualObservationRows = new ArrayList<>(); + IndividualObservationBatchRowModel emptyRow = + ((IndividualObservationBatchTableModel) ui.getObsTable().getModel()).createNewRow(); + emptyRow.addPropertyChangeListener(obsChangedListener); + individualObservationRows.add(emptyRow); + model.setIndividualObservationRows(individualObservationRows); frequencyEditor = editor; @@ -641,6 +784,62 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci } + public void updateFrequencyRowsNumbers(Float lengthStepToDec, Float lengthStepToInc) { + if (log.isInfoEnabled()) { + log.info("updateFrequencyRowsNumbers " + lengthStepToDec + ", " + lengthStepToInc); + } + + SpeciesFrequencyTableModel tableModel = getTableModel(); + + if (lengthStepToDec != null) { + lengthStepToDec = getModel().getLengthStep(lengthStepToDec); + + SpeciesFrequencyRowModel row = getRowForLengthstep(lengthStepToDec); + row.decNumber(); + + if (row.getNumber() == 0) { + int rowIndex = tableModel.getRowIndex(row); + tableModel.removeRow(rowIndex); + getModel().getRowCache().remove(lengthStepToDec); + + } else { + tableModel.updateRow(row); + } + } + + if (lengthStepToInc != null) { + lengthStepToInc = getModel().getLengthStep(lengthStepToInc); + + SpeciesFrequencyRowModel row = getRowForLengthstep(lengthStepToInc); + row.incNumber(); + tableModel.updateRow(row); + } + } + + public void updateFrequencyRowsWeights(Float lengthStep, Float weight) { + if (log.isInfoEnabled()) { + log.info("updateFrequencyRowsWeights " + lengthStep + ", " + weight); + } + if (lengthStep != null && weight != null) { + + SpeciesFrequencyTableModel tableModel = getTableModel(); + + lengthStep = getModel().getLengthStep(lengthStep); + + SpeciesFrequencyRowModel row = getRowForLengthstep(lengthStep); + row.addToWeight(weight); + + if (Weights.isNullOrZero(row.getWeight())) { + int rowIndex = tableModel.getRowIndex(row); + tableModel.removeRow(rowIndex); + getModel().getRowCache().remove(lengthStep); + + } else { + tableModel.updateRow(row); + } + } + } + //------------------------------------------------------------------------// //-- Internal methods --// //------------------------------------------------------------------------// @@ -870,14 +1069,6 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci } - { // Weight column - - addFloatColumnToModel(columnModel, - IndividualObservationBatchTableModel.WEIGHT, - weightUnit, - obsTable); - } - { // Size column addFloatColumnToModel(columnModel, @@ -886,18 +1077,16 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci obsTable); } - { // Length step caracteristic column - - addComboDataColumnToModel(columnModel, - IndividualObservationBatchTableModel.LENGTH_STEP_CARACTERISTIC, - getDecorator(Caracteristic.class, null), - getDataContext().getLengthStepCaracteristics()); + { // Weight column + addFloatColumnToModel(columnModel, + IndividualObservationBatchTableModel.WEIGHT, + weightUnit, + obsTable); } List<Caracteristic> defaultCaracteristic = getModel().getDefaultCaracteristic(); - for (Caracteristic caracteristic : defaultCaracteristic) { String header = caracteristicDecorator.toString(caracteristic); String headerTip = caracteristicTipDecorator.toString(caracteristic); @@ -978,14 +1167,27 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci tableModel.addTableModelListener(e -> { - if (e.getType() == TableModelEvent.DELETE) { - int firstRow = e.getFirstRow(); - for (int i = firstRow ; i < tableModel.getRowCount() ; i++) { - tableModel.getRows().get(i).setRankOrder(i + 1); - } + int firstRow = e.getFirstRow(); + int lastRow = e.getLastRow(); + + switch (e.getType()) { + case TableModelEvent.DELETE: + for (int i = firstRow ; i < tableModel.getRowCount() ; i++) { + tableModel.getRows().get(i).setRankOrder(i + 1); + } + break; + + case TableModelEvent.INSERT: + for (int i = firstRow ; i <= lastRow ; i++) { + IndividualObservationBatchRowModel newRow = tableModel.getRows().get(i); + newRow.addPropertyChangeListener(obsChangedListener); + + if (getModel().mustCopyIndividualObservationSize()) { + updateFrequencyRowsNumbers(null, newRow.getSize()); + } + } } }); - } protected void consumeFeedRecord(FeedReaderMeasureRecord record) { @@ -1096,6 +1298,28 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci return label + " (" + unit + ")"; } + protected SpeciesFrequencyRowModel getRowForLengthstep(float lengthstep) { + Map<Float, SpeciesFrequencyRowModel> rowCache = getModel().getRowCache(); + + SpeciesFrequencyRowModel row = rowCache.get(lengthstep); + + if (row == null) { + row = getTableModel().createNewRow(); + row.setLengthStep(lengthstep); + rowCache.put(lengthstep, row); + + // get new index + List<Float> steps = Lists.newArrayList(rowCache.keySet()); + steps.add(lengthstep); + Collections.sort(steps); + + int indexToInsert = steps.indexOf(lengthstep); + getTableModel().addNewRow(indexToInsert, row); + } + + return row; + } + @Override public <E> void initBeanFilterableComboBox(BeanFilterableComboBox<E> comboBox, List<E> data, E selectedData) { super.initBeanFilterableComboBox(comboBox, data, selectedData); 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 f6ed524..6997915 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 @@ -242,7 +242,7 @@ public class SpeciesFrequencyUIModel extends AbstractTuttiTableUIModel<SpeciesBa * What to copy from the individual observations to the data table * @since 4.5 */ - protected CopyIndividualObservationMode copyIndividualObservationMode; + protected CopyIndividualObservationMode copyIndividualObservationMode = CopyIndividualObservationMode.NOTHING; /** * To store frequencies graph series. @@ -326,11 +326,8 @@ public class SpeciesFrequencyUIModel extends AbstractTuttiTableUIModel<SpeciesBa if (averageWeight != null) { averageWeightsSeries.addOrUpdate(lengthStep, averageWeight); } - } - } - } recomputeTotalNumberAndWeight(); @@ -604,6 +601,26 @@ public class SpeciesFrequencyUIModel extends AbstractTuttiTableUIModel<SpeciesBa firePropertyChange(PROPERTY_COPY_INDIVIDUAL_OBSERVATION_MODE, oldValue, copyIndividualObservationMode); } + public boolean mustCopyIndividualObservationSize() { + return isCopyIndividualObservationAll() || isCopyIndividualObservationSize(); + } + + public boolean mustCopyIndividualObservationWeight() { + return isCopyIndividualObservationAll(); + } + + public boolean isCopyIndividualObservationAll() { + return copyIndividualObservationMode == CopyIndividualObservationMode.ALL; + } + + public boolean isCopyIndividualObservationNothing() { + return copyIndividualObservationMode == CopyIndividualObservationMode.NOTHING; + } + + public boolean isCopyIndividualObservationSize() { + return copyIndividualObservationMode == CopyIndividualObservationMode.SIZE; + } + public Set<SpeciesFrequencyRowModel> getEmptyRows() { return emptyRows; } diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/actions/RemoveObservationAction.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/actions/RemoveObservationAction.java index ed32fd8..61bb6fc 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/actions/RemoveObservationAction.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/actions/RemoveObservationAction.java @@ -3,6 +3,8 @@ package fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency.ac import fr.ifremer.tutti.ui.swing.content.operation.catches.individualobservation.IndividualObservationBatchRowModel; import fr.ifremer.tutti.ui.swing.content.operation.catches.individualobservation.IndividualObservationBatchTableModel; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency.SpeciesFrequencyUI; +import fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency.SpeciesFrequencyUIHandler; +import fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency.SpeciesFrequencyUIModel; import fr.ifremer.tutti.ui.swing.util.actions.SimpleActionSupport; import org.jdesktop.swingx.JXTable; @@ -50,6 +52,15 @@ public class RemoveObservationAction extends SimpleActionSupport<SpeciesFrequenc if (answer == JOptionPane.YES_OPTION) { + SpeciesFrequencyUIModel model = ui.getModel(); + SpeciesFrequencyUIHandler handler = ui.getHandler(); + + rowsToDelete.forEach(row -> { + if (model.mustCopyIndividualObservationSize()) { + handler.updateFrequencyRowsNumbers(row.getSize(), null); + } + }); + int minSelection = obsTable.getSelectionModel().getMinSelectionIndex(); int maxSelection = obsTable.getSelectionModel().getMaxSelectionIndex(); obsTableModel.getRows().removeAll(rowsToDelete); 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 dc695d3..c4312f6 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 @@ -978,6 +978,8 @@ tutti.editIndividualObservationBatch.table.header.lengthStepCaracteristic= tutti.editIndividualObservationBatch.table.header.lengthStepCaracteristic.tip= tutti.editIndividualObservationBatch.table.header.otherCaracteristics= tutti.editIndividualObservationBatch.table.header.otherCaracteristics.tip= +tutti.editIndividualObservationBatch.table.header.rank= +tutti.editIndividualObservationBatch.table.header.rank.tip= tutti.editIndividualObservationBatch.table.header.size= tutti.editIndividualObservationBatch.table.header.size.tip= tutti.editIndividualObservationBatch.table.header.species= 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 af31f3d..85a1a53 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 @@ -1376,6 +1376,9 @@ tutti.editSpeciesFrequencies.askBeforeSave.help=Que voulez-vous faire?<ul><li><s tutti.editSpeciesFrequencies.askBeforeSave.message=La saisie comporte des classes de taille avec et sans poids associés.<br/><strong>Seules les classes de taille avec poids seront dans ce cas sauvegardées.</strong> tutti.editSpeciesFrequencies.askBeforeSave.title=Confirmer l'enregistrement des mensurations tutti.editSpeciesFrequencies.averageWeight.label=Poids moyen +tutti.editSpeciesFrequencies.changeCopyMode.confirm.help=Que voulez-vous faire ?<ul><li><strong>Annuler</strong> pour ne pas changer de mode de copie</li><li><strong>OK</strong> pour changer de mode de copie et supprimer les données saisies</li></ul> +tutti.editSpeciesFrequencies.changeCopyMode.confirm.message=Vous êtes sur le point de changer de mode de copie alors que des données ont été saisies dans les mensurations.<br/>Si vous changez de mode, les données vont être supprimées. +tutti.editSpeciesFrequencies.changeCopyMode.confirm.title=Changement de mode de copie tutti.editSpeciesFrequencies.error.itchyometer.bad.record=La mesure provenant de l'ichtyomètre n'est pas valide (la donnée est peut-être corrompue) \:<br/><ul><li>Enregistrement \: <strong>%s</strong></li><li>CRC \: <strong>%s</strong></li><li>CRC calculé \: <strong>%s</strong></li></ul> 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 -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.