r1237 - trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol
Author: tchemit Date: 2013-09-26 22:27:36 +0200 (Thu, 26 Sep 2013) New Revision: 1237 Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1237 Log: fixes #3327: [PROTOCOLE] tableau esp?\195?\168ces : impossible de s?\195?\169lectionner plusieurs lignes d'esp?\195?\168ces pour supprimer Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/RemoveBenthosProtocolAction.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/RemoveSpeciesProtocolAction.java Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/RemoveBenthosProtocolAction.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/RemoveBenthosProtocolAction.java 2013-09-26 20:24:48 UTC (rev 1236) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/RemoveBenthosProtocolAction.java 2013-09-26 20:27:36 UTC (rev 1237) @@ -24,20 +24,19 @@ * #L% */ -import com.google.common.base.Preconditions; import com.google.common.collect.Lists; import fr.ifremer.tutti.persistence.entities.TuttiEntities; import fr.ifremer.tutti.persistence.entities.referential.Species; import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction; -import org.jdesktop.swingx.JXTable; +import javax.swing.JTable; import java.util.Collections; import java.util.List; import static org.nuiton.i18n.I18n._; /** - * To add a new species protocol. + * To remove all the selected benthos rows from protocol. * * @author tchemit <chemit@codelutin.com> * @since 1.0 @@ -51,15 +50,28 @@ @Override public void doAction() throws Exception { - JXTable table = handler.getBenthosTable(); + JTable table = handler.getSpeciesTable(); - int rowIndex = table.getSelectedRow(); + EditProtocolSpeciesTableModel tableModel = handler.getSpeciesTableModel(); - Preconditions.checkState(rowIndex != -1, - "Cant remove benthos if no benthos selected"); + int[] rowIndex = table.getSelectedRows(); - EditProtocolSpeciesTableModel tableModel = handler.getBenthosTableModel(); + for (int i = rowIndex.length - 1; i > -1; i--) { + int index = rowIndex[i]; + removeRow(tableModel, index); + } + EditProtocolUIModel model = getModel(); + + // reorder the list by name, otherwise, + // all the species without a reftax code will be at the end + Collections.sort(model.getAllSynonyms(), TuttiEntities.SPECIES_BY_NAME_COMPARATOR); + + table.clearSelection(); + } + + protected void removeRow(EditProtocolSpeciesTableModel tableModel, int rowIndex) { + EditProtocolSpeciesRowModel selectedRow = tableModel.getEntry(rowIndex); // re-add all synonym of this taxon to the species / benthos combobox @@ -73,13 +85,8 @@ model.getAllSynonyms(String.valueOf(taxonId))); allSynonyms.remove(species); model.getAllSynonyms().addAll(allSynonyms); - // reorder the list by name, otherwise, - // all the species without a reftax code will be at the end - Collections.sort(model.getAllSynonyms(), TuttiEntities.SPECIES_BY_NAME_COMPARATOR); - - table.clearSelection(); - // remove the row from the model(do it after treating the comboBox which can be long) + // remove the row from the model tableModel.removeRow(rowIndex); String speciesStr = decorate(selectedRow.getSpecies()); Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/RemoveSpeciesProtocolAction.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/RemoveSpeciesProtocolAction.java 2013-09-26 20:24:48 UTC (rev 1236) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/RemoveSpeciesProtocolAction.java 2013-09-26 20:27:36 UTC (rev 1237) @@ -36,7 +36,7 @@ import static org.nuiton.i18n.I18n._; /** - * To add a new species protocol. + * To remove all the selected species rows from protocol. * * @author tchemit <chemit@codelutin.com> * @since 1.0
participants (1)
-
tchemit@users.forge.codelutin.com