r975 - in trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches: benthos species
Author: kmorin Date: 2013-05-21 19:12:55 +0200 (Tue, 21 May 2013) New Revision: 975 Url: http://forge.codelutin.com/projects/tutti/repository/revisions/975 Log: fixes #2480 [ESPECES] Suppression d'un lot cat?\195?\169goris?\195?\169 : tous les lots du m?\195?\170me niveau sont supprim?\195?\169s Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RemoveBenthosBatchAction.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesBatchAction.java Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RemoveBenthosBatchAction.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RemoveBenthosBatchAction.java 2013-05-21 17:06:00 UTC (rev 974) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RemoveBenthosBatchAction.java 2013-05-21 17:12:55 UTC (rev 975) @@ -76,57 +76,41 @@ Preconditions.checkState(!TuttiEntities.isNew(selectedBatch), "Can't remove batch if batch is not persisted"); - if (!selectedBatch.isBatchRoot()) { + // remove selected batch and all his children - // remove all sub batches of his parent - BenthosBatchRowModel parentBatch = selectedBatch.getParentBatch(); + // remove parent batch (will destroy all his childs from db) + persistenceService.deleteBenthosBatch(selectedBatch.getId()); - // get parent row index - int parentIndex = tableModel.getRowIndex(parentBatch); - - // select it - table.setRowSelectionInterval(parentIndex, parentIndex); - - // remove all his children - TuttiActionHelper.runInternalAction(removeSpeciesSubBatchAction); - - } else { - - // remove selected batch and all his children - - // remove parent batch (will destroy all his childs from db) - persistenceService.deleteBenthosBatch(selectedBatch.getId()); - + if (selectedBatch.isBatchRoot()) { // update speciesUsed handler.removeFromSpeciesUsed(selectedBatch); + } - // collect of rows to remove from model - Set<BenthosBatchRowModel> rowToRemove = - Sets.newHashSet(selectedBatch); + // collect of rows to remove from model + Set<BenthosBatchRowModel> rowToRemove = + Sets.newHashSet(selectedBatch); - handler.collectChildren(selectedBatch, rowToRemove); + handler.collectChildren(selectedBatch, rowToRemove); - table.clearSelection(); + table.clearSelection(); - // remove all rows from the model - getModel().getRows().removeAll(rowToRemove); + // remove all rows from the model + getModel().getRows().removeAll(rowToRemove); - // refresh table from parent batch row index to the end - tableModel.fireTableDataChanged(); + // refresh table from parent batch row index to the end + tableModel.fireTableDataChanged(); - if (!getModel().getRows().isEmpty()) { + if (!getModel().getRows().isEmpty()) { - // select first row - AbstractSelectTableAction.doSelectCell(table, 0, 0); + // select first row + AbstractSelectTableAction.doSelectCell(table, 0, 0); - } + } - if (table.isEditing()) { + if (table.isEditing()) { - // but no edit it - table.getCellEditor().stopCellEditing(); - } - + // but no edit it + table.getCellEditor().stopCellEditing(); } } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesBatchAction.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesBatchAction.java 2013-05-21 17:06:00 UTC (rev 974) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesBatchAction.java 2013-05-21 17:12:55 UTC (rev 975) @@ -76,58 +76,43 @@ Preconditions.checkState(!TuttiEntities.isNew(selectedBatch), "Can't remove batch if batch is not persisted"); - if (!selectedBatch.isBatchRoot()) { + // remove selected batch and all his children - // remove all sub batches of his parent - SpeciesBatchRowModel parentBatch = selectedBatch.getParentBatch(); + // remove parent batch (will destroy all his childs from db) + persistenceService.deleteSpeciesBatch(selectedBatch.getId()); - // get parent row index - int parentIndex = tableModel.getRowIndex(parentBatch); - - // select it - table.setRowSelectionInterval(parentIndex, parentIndex); - - // remove all his children - TuttiActionHelper.runInternalAction(removeSpeciesSubBatchAction); - - } else { - - // remove selected batch and all his children - - // remove parent batch (will destroy all his childs from db) - persistenceService.deleteSpeciesBatch(selectedBatch.getId()); - + if (selectedBatch.isBatchRoot()) { // update speciesUsed handler.removeFromSpeciesUsed(selectedBatch); + } - // collect of rows to remove from model - Set<SpeciesBatchRowModel> rowToRemove = - Sets.newHashSet(selectedBatch); + // collect of rows to remove from model + Set<SpeciesBatchRowModel> rowToRemove = + Sets.newHashSet(selectedBatch); - handler.collectChildren(selectedBatch, rowToRemove); + handler.collectChildren(selectedBatch, rowToRemove); - table.clearSelection(); + table.clearSelection(); - // remove all rows from the model - getModel().getRows().removeAll(rowToRemove); + // remove all rows from the model + getModel().getRows().removeAll(rowToRemove); - // refresh table from parent batch row index to the end - tableModel.fireTableDataChanged(); + // refresh table from parent batch row index to the end + tableModel.fireTableDataChanged(); - if (!getModel().getRows().isEmpty()) { + if (!getModel().getRows().isEmpty()) { - // select first row - AbstractSelectTableAction.doSelectCell(table, 0, 0); + // select first row + AbstractSelectTableAction.doSelectCell(table, 0, 0); - } + } - if (table.isEditing()) { + if (table.isEditing()) { - // but no edit it - table.getCellEditor().stopCellEditing(); - } - + // but no edit it + table.getCellEditor().stopCellEditing(); } + } }
participants (1)
-
kmorin@users.forge.codelutin.com