Author: tchemit Date: 2013-11-17 18:39:59 +0100 (Sun, 17 Nov 2013) New Revision: 1360 Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1360 Log: fixes #3808: [CAPTURE] erreur suite suppression d'un lot esp?\195?\168ce et fermeture de l'?\195?\169cran de saisie. A analyser 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/RemoveBenthosSubBatchAction.java 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/RemoveSpeciesSubBatchAction.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-11-17 17:12:02 UTC (rev 1359) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RemoveBenthosBatchAction.java 2013-11-17 17:39:59 UTC (rev 1360) @@ -31,8 +31,6 @@ import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil; import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction; import jaxx.runtime.SwingUtil; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.jdesktop.swingx.JXTable; import javax.swing.JOptionPane; @@ -48,10 +46,6 @@ */ public class RemoveBenthosBatchAction extends AbstractTuttiAction<BenthosBatchUIModel, BenthosBatchUI, BenthosBatchUIHandler> { - /** Logger. */ - private static final Log log = - LogFactory.getLog(RemoveBenthosBatchAction.class); - /** * Selected row to treat. * @@ -59,6 +53,13 @@ */ protected int rowIndex; + /** + * Rows to delete after all. + * + * @since 2.10 + */ + protected Set<BenthosBatchRowModel> rowToRemove; + public RemoveBenthosBatchAction(BenthosBatchUIHandler handler) { super(handler, false); } @@ -115,21 +116,10 @@ } // collect of rows to remove from model - Set<BenthosBatchRowModel> rowToRemove = Sets.newHashSet(); + rowToRemove = Sets.newHashSet(); rowToRemove.add(selectedBatch); handler.collectChildren(selectedBatch, rowToRemove); - -//FIXME TC-2013-10-14 Comment this line, don't see the point -// table.clearSelection(); - - // remove all rows from the model - getModel().getRows().removeAll(rowToRemove); - -// // refresh table from parent batch row index to the end -// tableModel.fireTableDataChanged(); -// -// TuttiUIUtil.selectFirstCellOnFirstRowAndStopEditing(table); } @Override @@ -138,6 +128,9 @@ JXTable table = handler.getTable(); + // remove all rows from the model + getModel().getRows().removeAll(rowToRemove); + // refresh table from parent batch row index to the end handler.getTableModel().fireTableDataChanged(); Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RemoveBenthosSubBatchAction.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RemoveBenthosSubBatchAction.java 2013-11-17 17:12:02 UTC (rev 1359) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RemoveBenthosSubBatchAction.java 2013-11-17 17:39:59 UTC (rev 1360) @@ -53,6 +53,20 @@ */ protected int rowIndex; + /** + * Rows to delete after all. + * + * @since 2.10 + */ + protected Set<BenthosBatchRowModel> rowToRemove; + + /** + * Parent batch of rows to delete. + * + * @since 2.10 + */ + protected BenthosBatchRowModel parentBatch; + public RemoveBenthosSubBatchAction(BenthosBatchUIHandler handler) { super(handler, false); } @@ -87,7 +101,7 @@ Preconditions.checkState(rowIndex != -1, "Cant remove sub batch if no batch selected"); - BenthosBatchRowModel parentBatch = handler.getTableModel().getEntry(rowIndex); + parentBatch = handler.getTableModel().getEntry(rowIndex); Preconditions.checkState(!TuttiEntities.isNew(parentBatch), "Can't remove sub batch if batch is not persisted"); @@ -96,30 +110,9 @@ persistenceService.deleteSpeciesSubBatch(parentBatch.getId()); // collect of rows to remove from model - Set<BenthosBatchRowModel> rowToRemove = Sets.newHashSet(); + rowToRemove = Sets.newHashSet(); handler.collectChildren(parentBatch, rowToRemove); - -//FIXME TC-2013-10-14 Comment this line, don't see the point -// table.clearSelection(); - - // remove all rows from the model - getModel().getRows().removeAll(rowToRemove); - - // remove childs from parent batch - parentBatch.setChildBatch(null); - -// // refresh table from parent batch row index to the end -// handler.getTableModel().fireTableDataChanged(); -// -// // select parent batch row -// AbstractSelectTableAction.doSelectCell(table, rowIndex, 0); -// -// if (table.isEditing()) { -// -// // but no edit it -// table.getCellEditor().stopCellEditing(); -// } } @Override @@ -128,6 +121,12 @@ JXTable table = handler.getTable(); + // remove all rows from the model + getModel().getRows().removeAll(rowToRemove); + + // remove childs from parent batch + parentBatch.setChildBatch(null); + // refresh table from parent batch row index to the end handler.getTableModel().fireTableDataChanged(); 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-11-17 17:12:02 UTC (rev 1359) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesBatchAction.java 2013-11-17 17:39:59 UTC (rev 1360) @@ -31,8 +31,6 @@ import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil; import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction; import jaxx.runtime.SwingUtil; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.jdesktop.swingx.JXTable; import javax.swing.JOptionPane; @@ -48,9 +46,12 @@ */ public class RemoveSpeciesBatchAction extends AbstractTuttiAction<SpeciesBatchUIModel, SpeciesBatchUI, SpeciesBatchUIHandler> { - /** Logger. */ - private static final Log log = - LogFactory.getLog(RemoveSpeciesBatchAction.class); + /** + * Rows to delete after all. + * + * @since 2.10 + */ + protected Set<SpeciesBatchRowModel> rowToRemove; public RemoveSpeciesBatchAction(SpeciesBatchUIHandler handler) { super(handler, false); @@ -85,6 +86,7 @@ "Cant remove batch if no batch selected"); SpeciesBatchTableModel tableModel = handler.getTableModel(); + SpeciesBatchRowModel selectedBatch = tableModel.getEntry(rowIndex); Preconditions.checkState(!TuttiEntities.isNew(selectedBatch), @@ -106,32 +108,10 @@ } // collect of rows to remove from model - Set<SpeciesBatchRowModel> rowToRemove = Sets.newHashSet(); + rowToRemove = Sets.newHashSet(); rowToRemove.add(selectedBatch); handler.collectChildren(selectedBatch, rowToRemove); - -//FIXME TC-2013-10-14 Comment this line, don't see the point -// table.clearSelection(); - - // remove all rows from the model - getModel().getRows().removeAll(rowToRemove); - -// // refresh table from parent batch row index to the end -// tableModel.fireTableDataChanged(); -// -// if (!getModel().getRows().isEmpty()) { -// -// // select first row -// AbstractSelectTableAction.doSelectCell(table, 0, 0); -// -// } -// -// if (table.isEditing()) { -// -// // but no edit it -// table.getCellEditor().stopCellEditing(); -// } } @Override @@ -140,6 +120,9 @@ JXTable table = handler.getTable(); + // remove all rows from the model + getModel().getRows().removeAll(rowToRemove); + // refresh table from parent batch row index to the end handler.getTableModel().fireTableDataChanged(); Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesSubBatchAction.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesSubBatchAction.java 2013-11-17 17:12:02 UTC (rev 1359) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesSubBatchAction.java 2013-11-17 17:39:59 UTC (rev 1360) @@ -53,6 +53,20 @@ */ protected int rowIndex; + /** + * Rows to delete after all. + * + * @since 2.10 + */ + protected Set<SpeciesBatchRowModel> rowToRemove; + + /** + * Parent batch of rows to delete. + * + * @since 2.10 + */ + protected SpeciesBatchRowModel parentBatch; + public RemoveSpeciesSubBatchAction(SpeciesBatchUIHandler handler) { super(handler, false); } @@ -87,8 +101,9 @@ Preconditions.checkState(rowIndex != -1, "Cant remove sub batch if no batch selected"); - SpeciesBatchRowModel parentBatch = handler.getTableModel().getEntry(rowIndex); + parentBatch = handler.getTableModel().getEntry(rowIndex); + Preconditions.checkState(!TuttiEntities.isNew(parentBatch), "Can't remove sub batch if batch is not persisted"); @@ -96,38 +111,24 @@ persistenceService.deleteSpeciesSubBatch(parentBatch.getId()); // collect of rows to remove from model - Set<SpeciesBatchRowModel> rowToRemove = Sets.newHashSet(); + rowToRemove = Sets.newHashSet(); + handler.collectChildren(parentBatch, rowToRemove); + } -//FIXME TC-2013-10-14 Comment this line, don't see the point -// table.clearSelection(); + @Override + public void postSuccessAction() { + super.postSuccessAction(); + JXTable table = handler.getTable(); + // remove all rows from the model getModel().getRows().removeAll(rowToRemove); // remove childs from parent batch parentBatch.setChildBatch(null); -// // refresh table from parent batch row index to the end -// handler.getTableModel().fireTableDataChanged(); -// -// // select parent batch row -// TuttiUIUtil.selectFirstCellOnRow(table, rowIndex); -// -// if (table.isEditing()) { -// -// // but no edit it -// table.getCellEditor().stopCellEditing(); -// } - } - - @Override - public void postSuccessAction() { - super.postSuccessAction(); - - JXTable table = handler.getTable(); - // refresh table from parent batch row index to the end handler.getTableModel().fireTableDataChanged();