Author: tchemit Date: 2013-09-26 08:20:09 +0200 (Thu, 26 Sep 2013) New Revision: 1229 Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1229 Log: fixes #3360: [MENSURATION] Mauvais rafraichissement des valeurs dans le tableau des esp?\195?\168ces fixes #3329: [MENSURATION] - Renseigner le champ "Type de mesure" ?\195?\160 la saisie des mensuration avec la valeur du lot fr?\195?\168re Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchTableModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyCellComponent.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTableModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyCellComponent.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchTableModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchTableModel.java 2013-09-25 17:12:02 UTC (rev 1228) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchTableModel.java 2013-09-26 06:20:09 UTC (rev 1229) @@ -39,6 +39,7 @@ import javax.swing.table.TableColumn; import java.io.Serializable; import java.util.Enumeration; +import java.util.List; import java.util.Set; import static org.nuiton.i18n.I18n.n_; @@ -286,6 +287,26 @@ updateShell(row, columnIndex); } + /** + * Return previous sibling row, or {@code null} if not exist. + * + * @param row where to start + * @return the previous sibling row, or {@code null} if not exist. + * @since 2.6 + */ + public BenthosBatchRowModel getPreviousSibling(BenthosBatchRowModel row) { + BenthosBatchRowModel result = null; + BenthosBatchRowModel parentBatch = row.getParentBatch(); + if (parentBatch != null) { + List<BenthosBatchRowModel> childBatch = parentBatch.getChildBatch(); + int i = childBatch.indexOf(row); + if (i > 0) { + result = childBatch.get(i - 1); + } + } + return result; + } + protected void updateShell(BenthosBatchRowModel entry, int columnIndex) { Set<BenthosBatchRowModel> shell = Sets.newHashSet(); Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyCellComponent.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyCellComponent.java 2013-09-25 17:12:02 UTC (rev 1228) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyCellComponent.java 2013-09-26 06:20:09 UTC (rev 1229) @@ -123,6 +123,8 @@ protected Integer columnIndex; + protected BenthosBatchRowModel previousSiblingRow; + public FrequencyCellEditor(BenthosBatchUI ui, Color computedDataColor) { this.ui = ui; component = new BenthosFrequencyCellComponent(computedDataColor); @@ -155,6 +157,10 @@ return nextEditableRowIndex; } + public BenthosBatchRowModel getPreviousSiblingRow() { + return previousSiblingRow; + } + public void startEdit() { Preconditions.checkNotNull(tableModel, "No table model assigned."); @@ -164,9 +170,13 @@ nextEditableRowIndex = tableModel.getNextEditableFrequencyRow(rowIndex + 1); + // compute the previous sibling row + previousSiblingRow = tableModel.getPreviousSibling(editRow); + if (log.isDebugEnabled()) { log.debug("Will edit frequencies for row: " + rowIndex + - ", nextEditableRow: " + nextEditableRowIndex); + ", nextEditableRow: " + nextEditableRowIndex + + ", previous siblingRow: " + previousSiblingRow); } EditCatchesUI parent = @@ -226,14 +236,22 @@ } else { + // keep next cell to edit + int r = rowIndex; + int nextR = nextEditableRowIndex; + int c = columnIndex; + + // stop edition of this row + stopCellEditing(); + // use now the next row data - rowIndex = nextEditableRowIndex; + rowIndex = nextR; // load the row editRow = tableModel.getEntry(rowIndex); - // will save the row in the species row - AbstractSelectTableAction.doSelectCell(table, rowIndex, columnIndex); + // will save the previous row in the species row + AbstractSelectTableAction.doSelectCell(table, rowIndex, c); // start edit startEdit(); Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUIHandler.java 2013-09-25 17:12:02 UTC (rev 1228) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUIHandler.java 2013-09-26 06:20:09 UTC (rev 1229) @@ -549,6 +549,31 @@ } } + BenthosBatchRowModel previousSiblingRow = + frequencyEditor.getPreviousSiblingRow(); + + if (lengthStepCaracteristic == null && previousSiblingRow != null) { + + // try to get it from his previous brother row + List<BenthosFrequencyRowModel> previousFrequency = + previousSiblingRow.getFrequency(); + + if (CollectionUtils.isNotEmpty(previousFrequency)) { + + // use the first frequency length step caracteristic / step + BenthosFrequencyRowModel rowModel = previousFrequency.get(0); + lengthStepCaracteristic = + rowModel.getLengthStepCaracteristic(); + lengthStep = rowModel.getLengthStep(); + if (log.isInfoEnabled()) { + log.info("Use previous sibling existing lengthStep " + + "caracteristic / step " + + decorate(lengthStepCaracteristic) + " / " + + lengthStep); + } + } + } + if (lengthStepCaracteristic == null && protocol != null) { Species species = speciesBatch.getSpecies(); Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTableModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTableModel.java 2013-09-25 17:12:02 UTC (rev 1228) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTableModel.java 2013-09-26 06:20:09 UTC (rev 1229) @@ -39,6 +39,7 @@ import javax.swing.table.TableColumn; import java.io.Serializable; import java.util.Enumeration; +import java.util.List; import java.util.Set; import static org.nuiton.i18n.I18n.n_; @@ -266,7 +267,7 @@ /** * Update the sample category value of the given {@code row}. * - * @param row the row to walk through + * @param row the row to walk through * @param columnIndex index of the column where the sample category is * @param newValue new sample category value to set * @since 2.6 @@ -285,6 +286,26 @@ updateShell(row, columnIndex); } + /** + * Return previous sibling row, or {@code null} if not exist. + * + * @param row where to start + * @return the previous sibling row, or {@code null} if not exist. + * @since 2.6 + */ + public SpeciesBatchRowModel getPreviousSibling(SpeciesBatchRowModel row) { + SpeciesBatchRowModel result = null; + SpeciesBatchRowModel parentBatch = row.getParentBatch(); + if (parentBatch != null) { + List<SpeciesBatchRowModel> childBatch = parentBatch.getChildBatch(); + int i = childBatch.indexOf(row); + if (i > 0) { + result = childBatch.get(i - 1); + } + } + return result; + } + protected void updateShell(SpeciesBatchRowModel entry, int columnIndex) { Set<SpeciesBatchRowModel> shell = Sets.newHashSet(); Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyCellComponent.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyCellComponent.java 2013-09-25 17:12:02 UTC (rev 1228) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyCellComponent.java 2013-09-26 06:20:09 UTC (rev 1229) @@ -123,6 +123,8 @@ protected Integer columnIndex; + protected SpeciesBatchRowModel previousSiblingRow; + public FrequencyCellEditor(SpeciesBatchUI ui, Color computedDataColor) { this.ui = ui; component = new SpeciesFrequencyCellComponent(computedDataColor); @@ -155,6 +157,10 @@ return nextEditableRowIndex; } + public SpeciesBatchRowModel getPreviousSiblingRow() { + return previousSiblingRow; + } + public void startEdit() { Preconditions.checkNotNull(tableModel, "No table model assigned."); @@ -164,9 +170,13 @@ nextEditableRowIndex = tableModel.getNextEditableFrequencyRow(rowIndex + 1); + // compute the previous sibling row + previousSiblingRow = tableModel.getPreviousSibling(editRow); + if (log.isDebugEnabled()) { log.debug("Will edit frequencies for row: " + rowIndex + - ", nextEditableRow: " + nextEditableRowIndex); + ", nextEditableRow: " + nextEditableRowIndex + + ", previous siblingRow: " + previousSiblingRow); } EditCatchesUI parent = @@ -226,14 +236,22 @@ } else { + // keep next cell to edit + int r = rowIndex; + int nextR = nextEditableRowIndex; + int c = columnIndex; + + // stop edition of this row + stopCellEditing(); + // use now the next row data - rowIndex = nextEditableRowIndex; + rowIndex = nextR; // load the row editRow = tableModel.getEntry(rowIndex); - // will save the row in the species row - AbstractSelectTableAction.doSelectCell(table, rowIndex, columnIndex); + // will save the previous row in the species row + AbstractSelectTableAction.doSelectCell(table, rowIndex, c); // start edit startEdit(); Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java 2013-09-25 17:12:02 UTC (rev 1228) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java 2013-09-26 06:20:09 UTC (rev 1229) @@ -548,6 +548,31 @@ } } + SpeciesBatchRowModel previousSiblingRow = + frequencyEditor.getPreviousSiblingRow(); + + if (lengthStepCaracteristic == null && previousSiblingRow != null) { + + // try to get it from his previous brother row + List<SpeciesFrequencyRowModel> previousFrequency = + previousSiblingRow.getFrequency(); + + if (CollectionUtils.isNotEmpty(previousFrequency)) { + + // use the first frequency length step caracteristic / step + SpeciesFrequencyRowModel rowModel = previousFrequency.get(0); + lengthStepCaracteristic = + rowModel.getLengthStepCaracteristic(); + lengthStep = rowModel.getLengthStep(); + if (log.isInfoEnabled()) { + log.info("Use previous sibling existing lengthStep " + + "caracteristic / step " + + decorate(lengthStepCaracteristic) + " / " + + lengthStep); + } + } + } + if (lengthStepCaracteristic == null && protocol != null) { Species species = speciesBatch.getSpecies(); Modified: trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties =================================================================== --- trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties 2013-09-25 17:12:02 UTC (rev 1228) +++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties 2013-09-26 06:20:09 UTC (rev 1229) @@ -1029,6 +1029,7 @@ tutti.exportDb.step.createArchive= tutti.exportDb.step.openDb= tutti.exportDb.step.reloadApplication= +tutti.exportProgram.action.exportErrors= tutti.exportProgram.action.success= tutti.exportProtocol.action.success= tutti.fishingOperations.action.deleteFishingOperation.mnemonic= Modified: trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties =================================================================== --- trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-09-25 17:12:02 UTC (rev 1228) +++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-09-26 06:20:09 UTC (rev 1229) @@ -1023,7 +1023,6 @@ tutti.error.update.could.not.reach.url=Mise à jour impossible (l'url <strong>%s</strong> n'est pas joignable) tutti.error.write.startActionFile=impossible d'écrire dans le fichier %s tutti.exportCruise.action.exportErrors=Des erreurs sont apparues pendant l'élévation des poids de la campagne <strong>%s</strong>.<br/>L'export a cependant été réalisé.<hr/>Erreur(s) rencontrée(s) \: <br/>%s -tutti.exportProgram.action.exportErrors=Des erreurs sont apparues pendant l'élévation des poids d'une campagne de la série <strong>%s</strong>.<br/>L'export a cependant été réalisé.<hr/>Erreur(s) rencontrée(s) \: <br/>%s tutti.exportCruise.action.success=La campagne <strong>%s</strong> a été exportée dans le fichier <strong>%s</strong>. tutti.exportCruiseForSumatra.action.chooseFile=Choisir le fichier d'export tutti.exportCruiseForSumatra.action.success=Les captures ont correctement été exporté dans le fichier %s @@ -1032,6 +1031,7 @@ tutti.exportDb.step.createArchive=Création de l'archive %s tutti.exportDb.step.openDb=Réouverture de la base courante tutti.exportDb.step.reloadApplication=Redémarrage de l'application +tutti.exportProgram.action.exportErrors=Des erreurs sont apparues pendant l'élévation des poids d'une campagne de la série <strong>%s</strong>.<br/>L'export a cependant été réalisé.<hr/>Erreur(s) rencontrée(s) \: <br/>%s tutti.exportProgram.action.success=La série de campagne <strong>%s</strong> a été exportée dans le fichier <strong>%s</strong>. tutti.exportProtocol.action.success=Protocole [%1s] exporté dans le fichier <strong>%2s</strong>. tutti.fishingOperations.action.deleteFishingOperation.mnemonic=S