This is an automated email from the git hooks/post-receive script. New commit to branch feature/8130 in repository tutti. See https://gitlab.nuiton.org/codelutin/tutti.git commit 5bd489fbf103db03bc70ca5f54474ab4e33187dd Author: Tony CHEMIT <chemit@codelutin.com> Date: Wed Mar 16 08:50:23 2016 +0100 Revue de la sauvegarde et intégration du mode de recopie --- .../frequency/SpeciesFrequencyCellComponent.java | 91 +++++++++++----------- 1 file changed, 47 insertions(+), 44 deletions(-) diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyCellComponent.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyCellComponent.java index 04ac9f2..e0a2d51 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyCellComponent.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyCellComponent.java @@ -23,7 +23,7 @@ package fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency; */ import com.google.common.base.Preconditions; -import com.google.common.collect.Lists; +import fr.ifremer.tutti.persistence.entities.data.CopyIndividualObservationMode; import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUI; import fr.ifremer.tutti.ui.swing.content.operation.catches.individualobservation.IndividualObservationBatchRowModel; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchRowModel; @@ -50,7 +50,9 @@ import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; +import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; /** * Component to render and edit frequency stuff from batch table. @@ -84,9 +86,7 @@ public class SpeciesFrequencyCellComponent extends DefaultTableCellRenderer { if (data != null && data.getData() != null) { text = String.valueOf(data.getData()); - } else if (data != null - && data.getComputedData() != null - && data.getComputedData() != 0) { + } else if (data != null && data.getComputedData() != null && data.getComputedData() != 0) { String blue = Integer.toHexString(computedDataColor.getRGB()).substring(2); text = "<html><em style='color: #" + blue + "'>" + data.getComputedData() + "</em></html>"; @@ -164,8 +164,7 @@ public class SpeciesFrequencyCellComponent extends DefaultTableCellRenderer { component.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { - if (e.getKeyCode() == KeyEvent.VK_ENTER || - e.getKeyCode() == KeyEvent.VK_SPACE) { + if (e.getKeyCode() == KeyEvent.VK_ENTER || e.getKeyCode() == KeyEvent.VK_SPACE) { e.consume(); startEdit(); } @@ -216,8 +215,8 @@ public class SpeciesFrequencyCellComponent extends DefaultTableCellRenderer { if (log.isDebugEnabled()) { log.debug("Will edit frequencies for row: " + rowIndex + - ", nextEditableRow: " + nextEditableRowIndex + - ", previous siblingRow: " + previousSiblingRow); + ", nextEditableRow: " + nextEditableRowIndex + + ", previous siblingRow: " + previousSiblingRow); } EditCatchesUI parent = @@ -230,58 +229,62 @@ public class SpeciesFrequencyCellComponent extends DefaultTableCellRenderer { if (frequencyModel.isValid()) { // at close, synch back frequencies - List<SpeciesFrequencyRowModel> frequency = Lists.newArrayList(); - List<IndividualObservationBatchRowModel> individualObservation = Lists.newArrayList(); + + // set the weigth + editRow.setWeight(frequencyModel.getTotalWeight()); if (frequencyModel.isSimpleCountingMode()) { + editRow.setNumber(frequencyModel.getSimpleCount()); + // DO THIS BEFORE SETTING THE FREQUENCIES AS THE FREQUENCIES MODIFICATIONS TRIGGERS THE SAVE + editRow.setIndividualObservation(new ArrayList<>()); + editRow.setFrequency(new ArrayList<>()); } else { - // transfer rows to editor - for (SpeciesFrequencyRowModel row : frequencyModel.getRows()) { - // the row is valid even if there is no data (just for the highlighter) - // but we save it only if there is data - if (row.isValid() - && !(row.getNumber() == null && row.getWeight() == null)) { + // push back to batch + editRow.setNumber(null); + + // + // transfert back individual observations + // - // can keep this row - frequency.add(row); - } - } - if (log.isDebugEnabled()) { - log.debug("Push back " + frequency.size() + - " frequency to batch " + frequencyModel.getBatch()); - } + List<IndividualObservationBatchRowModel> individualObservation = new ArrayList<>(); + CopyIndividualObservationMode copyIndividualObservationMode = frequencyModel.getCopyIndividualObservationMode(); for (IndividualObservationBatchRowModel row : frequencyModel.getIndividualObservationRows()) { - // the row is valid even if there is no data (just for the highlighter) - // but we save it only if there is data -// if (row.isValid() -// && !(row.getNumber() == null && row.getWeight() == null)) { - - // can keep this row - individualObservation.add(row); -// } + row.setCopyIndividualObservationMode(copyIndividualObservationMode); + individualObservation.add(row); } if (log.isDebugEnabled()) { - log.debug("Push back " + individualObservation.size() + - " observations to batch " + frequencyModel.getBatch()); + log.debug("Push back " + individualObservation.size() + " observations to batch " + frequencyModel.getBatch()); } - // push back to batch - editRow.setNumber(null); - } + // DO THIS BEFORE SETTING THE FREQUENCIES AS THE FREQUENCIES MODIFICATIONS TRIGGERS THE SAVE + // set individual observations to the incoming batch + editRow.setIndividualObservation(individualObservation); - // set the weigth - editRow.setWeight(frequencyModel.getTotalWeight()); + // + // transfert back frequencies + // - // DO THIS BEFORE SETTING THE FREQUENCIES AS THE FREQUENCIES MODIFICATIONS TRIGGERS THE SAVE - // set individual observations to the incoming batch - editRow.setIndividualObservation(individualObservation); + // the row is valid even if there is no data (just for the highlighter) + // but we save it only if there is data + // can keep this row + List<SpeciesFrequencyRowModel> frequency = + frequencyModel.getRows() + .stream() + .filter(row -> row.isValid() && row.withNumber() && row.withWeight()) + .collect(Collectors.toList()); - // set frequencies to the incoming batch - editRow.setFrequency(frequency); + if (log.isDebugEnabled()) { + log.debug("Push back " + frequency.size() + " frequencies to batch " + frequencyModel.getBatch()); + } + + // set frequencies to the incoming batch + editRow.setFrequency(frequency); + + } // update frequencies total ui.getHandler().updateTotalFromFrequencies(editRow); -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.