branch develop updated (13263c3 -> 7bd7807)
This is an automated email from the git hooks/post-receive script. New change to branch develop in repository tutti. See http://git.codelutin.com/tutti.git from 13263c3 fixes #6145 [IMPORT] pupitri depuis especes, si des espèces ne sont pas importées, lister les codes non importés pour aider à identifier le problème Merge branch 'feature/5737' into develop new 7bd7807 fixes #6146: [CAPTURE] Pouvoir effectuer du melag sur un lot catégorisé The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 7bd7807a7520fe8315f8084738ceda5aaee91d41 Author: Tony CHEMIT <chemit@codelutin.com> Date: Fri Nov 21 09:13:56 2014 +0100 fixes #6146: [CAPTURE] Pouvoir effectuer du melag sur un lot catégorisé Summary of changes: .../ui/swing/action/CreateBenthosMelagAction.java | 154 ++++++++++++++------ .../ui/swing/action/CreateSpeciesMelagAction.java | 158 ++++++++++++++------- .../catches/SpeciesAbleBatchRowHelper.java | 41 +++++- .../catches/benthos/BenthosBatchUIHandler.java | 20 +-- .../catches/species/SpeciesBatchUIHandler.java | 20 +-- 5 files changed, 259 insertions(+), 134 deletions(-) -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository tutti. See http://git.codelutin.com/tutti.git commit 7bd7807a7520fe8315f8084738ceda5aaee91d41 Author: Tony CHEMIT <chemit@codelutin.com> Date: Fri Nov 21 09:13:56 2014 +0100 fixes #6146: [CAPTURE] Pouvoir effectuer du melag sur un lot catégorisé --- .../ui/swing/action/CreateBenthosMelagAction.java | 154 ++++++++++++++------ .../ui/swing/action/CreateSpeciesMelagAction.java | 158 ++++++++++++++------- .../catches/SpeciesAbleBatchRowHelper.java | 41 +++++- .../catches/benthos/BenthosBatchUIHandler.java | 20 +-- .../catches/species/SpeciesBatchUIHandler.java | 20 +-- 5 files changed, 259 insertions(+), 134 deletions(-) diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/CreateBenthosMelagAction.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/CreateBenthosMelagAction.java index f6fc993..86e5fd7 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/CreateBenthosMelagAction.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/CreateBenthosMelagAction.java @@ -23,15 +23,15 @@ package fr.ifremer.tutti.ui.swing.action; */ import com.google.common.collect.Maps; -import fr.ifremer.tutti.util.Weights; import fr.ifremer.tutti.type.WeightUnit; +import fr.ifremer.tutti.ui.swing.content.operation.catches.SpeciesAbleBatchRowHelper; import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.BenthosBatchRowModel; import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.BenthosBatchTableModel; import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.BenthosBatchUI; import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.BenthosBatchUIHandler; import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.BenthosBatchUIModel; -import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.frequency.BenthosFrequencyRowModel; import fr.ifremer.tutti.ui.swing.util.species.EnterMelagWeightUI; +import fr.ifremer.tutti.util.Weights; import jaxx.runtime.SwingUtil; import org.apache.commons.lang3.StringUtils; @@ -46,13 +46,31 @@ import static org.nuiton.i18n.I18n.t; */ public class CreateBenthosMelagAction extends AbstractTuttiAction<BenthosBatchUIModel, BenthosBatchUI, BenthosBatchUIHandler> { + /** + * Dictionnaire des lots du melag associé a leur poids d'echantillonnage (si un lot possède un poids de categorisation, + * alors on lui associe la valeur {@code null} ici. + */ protected Map<BenthosBatchRowModel, Float> selectedRows = Maps.newHashMap(); - protected Float melagWeight = null; + /** + * Poids du melag renseigne par l'utilisateur une fois les controles passés sur les lots du melag. + */ + protected Float melagWeight; - protected Float sampleMelagWeight = null; + /** + * Poids du melag moins la somme des poids de categorisations pour les lots du melag qui possede une poids de categorisation. + * + * Ce poids permet ensuite d'elever le poids d'echantillonage des lots du melag a leur poids de categorisation. + */ + protected Float sampleMelagWeight; - protected Float sortedWeight = null; + /** + * Somme des poids d'echantillonage pour les lots du melag qui ne possède pas de poids de categorisation + * mais un poids d'echantillonnage. + * + * Ce poids permet ensuite + */ + protected Float sortedWeight; /** * Weight unit. @@ -68,6 +86,7 @@ public class CreateBenthosMelagAction extends AbstractTuttiAction<BenthosBatchUI @Override public boolean prepareAction() throws Exception { + boolean result = super.prepareAction(); int[] selectedRowIndexes = SwingUtil.getSelectedModelRows(handler.getTable()); @@ -79,60 +98,84 @@ public class CreateBenthosMelagAction extends AbstractTuttiAction<BenthosBatchUI sortedWeight = 0f; for (int selectedRowIndex : selectedRowIndexes) { - BenthosBatchRowModel selectedRow = - tableModel.getEntry(selectedRowIndex); - Float sampleWeight = null; + BenthosBatchRowModel selectedRow = tableModel.getEntry(selectedRowIndex); + if (selectedRow.getFinestCategory().getNotNullWeight() != null) { + + // le lot possede un poid de categorisation, aucun traitement ne sera fait dessus + // on conserve alors le poid connu alreadyKnownWeights += selectedRow.getFinestCategory().getNotNullWeight(); + // on conserve aussi le lot sans poids d'echantillonnage + selectedRows.put(selectedRow, null); + // on peut directement passer au lot suivant + continue; + + } - } else if (selectedRow.getWeight() != null) { + // on recherche le poids d'échantillonnage + Float sampleWeight; + + if (selectedRow.getWeight() != null) { + + // le lot a un poids de sous echantillon sampleWeight = selectedRow.getWeight(); } else { - sampleWeight = 0f; - if (selectedRow.getFrequency() != null) { - for (BenthosFrequencyRowModel frequency : selectedRow.getFrequency()) { - if (frequency.getWeight() == null) { - sampleWeight = 0f; - break; - } - sampleWeight += frequency.getWeight(); - } - } + + // on calcule la somme des individus peses s'il existent + sampleWeight = SpeciesAbleBatchRowHelper.getFrequenciesTotalWeight(selectedRow.getFrequency()); + } - if (sampleWeight != null) { - if (sampleWeight == 0f) { - JOptionPane.showMessageDialog( - getUI(), - t("tutti.createBenthosMelag.error.message", selectedRowIndex + 1), - t("tutti.createBenthosMelag.error.title"), - JOptionPane.ERROR_MESSAGE); - - SwingUtil.setSelectionInterval(handler.getTable(), selectedRowIndex); - result = false; - break; - - } else { - sortedWeight += sampleWeight; - } + if (sampleWeight == null) { + + // pas de poids de sous-echantillon sur le lot + // impossible de calculer le melag + JOptionPane.showMessageDialog( + getUI(), + t("tutti.createBenthosMelag.error.message", selectedRowIndex + 1), + t("tutti.createBenthosMelag.error.title"), + JOptionPane.ERROR_MESSAGE); + + SwingUtil.setSelectionInterval(handler.getTable(), selectedRowIndex); + result = false; + // pas besoin de continuer a inspecter les autres lots + break; + } + // le lot est utilisable dans le melag + // on cumule le poids de sous echantillon + sortedWeight += sampleWeight; + + // on conserve ce lot avec son poids de sous echantillon selectedRows.put(selectedRow, sampleWeight); + } if (result) { - melagWeight = openMelagWeightDialog(); - if (melagWeight != null) { - // substract the weights that the user already entered - // they must not be used to compute the other weights - sampleMelagWeight = melagWeight - alreadyKnownWeights; - } + // tous les lots indiques permettent le calcul du melag + // on demande a l'utilisateur de saisir le poids total du melag + EnterMelagWeightUI dialog = new EnterMelagWeightUI(getContext()); + melagWeight = dialog.openAndGetWeightValue(weightUnit); + + // on peut continuer l'action uniquement si l'utilisateur a saisi un poids + result = melagWeight != null; + } - return result && melagWeight != null; + if (result) { + + // substract the weights that the user already entered + // they must not be used to compute the other weights + sampleMelagWeight = melagWeight - alreadyKnownWeights; + + } + + return result; + } protected Float openMelagWeightDialog() { @@ -143,40 +186,57 @@ public class CreateBenthosMelagAction extends AbstractTuttiAction<BenthosBatchUI @Override public void doAction() throws Exception { + String unitLabel = weightUnit.getShortLabel(); String melagComment = t("tutti.createBenthosMelag.comment.part1") + "\n"; + + // ecriture du commentaire a positionner sur chaque lot qui fait parti du melag + // et calcul du poids de categorisation sur les lots qui ont un poids de sous-echantillon precedemment renseigne for (BenthosBatchRowModel batch : selectedRows.keySet()) { + Float sampleWeight = selectedRows.get(batch); - if (sampleWeight != null) { - Float weight = Weights.roundKiloGram(sampleMelagWeight * sampleWeight / sortedWeight); - batch.getFinestCategory().setCategoryWeight(weight); - } else { + if (sampleWeight == null) { + + // on considere que le poids de sous echantillon est le poids de categorisation ? sampleWeight = batch.getFinestCategory().getNotNullWeight(); + + } else { + + // ce lot possede un poids d'echantillonage mais pas de poids de categorisation + // on calcul ce poids de categorisation et on lui affecte + float categoryWeight = Weights.roundKiloGram(sampleMelagWeight * sampleWeight / sortedWeight); + batch.getFinestCategory().setCategoryWeight(categoryWeight); + } melagComment += t("tutti.createBenthosMelag.comment.part2", sampleWeight, unitLabel, decorate(batch.getSpecies())) + "\n"; + } melagComment += t("tutti.createBenthosMelag.comment.part3", melagWeight, unitLabel); + // concatenation du commentaire sur chaque lot du melag + for (BenthosBatchRowModel batch : selectedRows.keySet()) { String comment = batch.getComment(); if (StringUtils.isBlank(comment)) { comment = ""; - } else { comment += "\n"; } comment += melagComment; batch.setComment(comment); } + + // sauvegarde des lots getHandler().saveRows(selectedRows.keySet()); } @Override public void releaseAction() { - super.releaseAction(); selectedRows.clear(); + sampleMelagWeight = null; melagWeight = null; sortedWeight = null; + super.releaseAction(); } @Override diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/CreateSpeciesMelagAction.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/CreateSpeciesMelagAction.java index 2271e3c..eab0d18 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/CreateSpeciesMelagAction.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/CreateSpeciesMelagAction.java @@ -23,15 +23,15 @@ package fr.ifremer.tutti.ui.swing.action; */ import com.google.common.collect.Maps; -import fr.ifremer.tutti.util.Weights; import fr.ifremer.tutti.type.WeightUnit; +import fr.ifremer.tutti.ui.swing.content.operation.catches.SpeciesAbleBatchRowHelper; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchRowModel; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchTableModel; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUI; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUIHandler; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUIModel; -import fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency.SpeciesFrequencyRowModel; import fr.ifremer.tutti.ui.swing.util.species.EnterMelagWeightUI; +import fr.ifremer.tutti.util.Weights; import jaxx.runtime.SwingUtil; import org.apache.commons.lang3.StringUtils; @@ -46,13 +46,31 @@ import static org.nuiton.i18n.I18n.t; */ public class CreateSpeciesMelagAction extends AbstractTuttiAction<SpeciesBatchUIModel, SpeciesBatchUI, SpeciesBatchUIHandler> { + /** + * Dictionnaire des lots du melag associé a leur poids d'echantillonnage (si un lot possède un poids de categorisation, + * alors on lui associe la valeur {@code null} ici. + */ protected Map<SpeciesBatchRowModel, Float> selectedRows = Maps.newHashMap(); - protected Float melagWeight = null; + /** + * Poids du melag renseigne par l'utilisateur une fois les controles passés sur les lots du melag. + */ + protected Float melagWeight; - protected Float sampleMelagWeight = null; + /** + * Poids du melag moins la somme des poids de categorisations pour les lots du melag qui possede une poids de categorisation. + * + * Ce poids permet ensuite d'elever le poids d'echantillonage des lots du melag a leur poids de categorisation. + */ + protected Float sampleMelagWeight; - protected Float sortedWeight = null; + /** + * Somme des poids d'echantillonage pour les lots du melag qui ne possède pas de poids de categorisation + * mais un poids d'echantillonnage. + * + * Ce poids permet ensuite + */ + protected Float sortedWeight; /** * Weight unit. @@ -68,6 +86,7 @@ public class CreateSpeciesMelagAction extends AbstractTuttiAction<SpeciesBatchUI @Override public boolean prepareAction() throws Exception { + boolean result = super.prepareAction(); int[] selectedRowIndexes = SwingUtil.getSelectedModelRows(handler.getTable()); @@ -79,105 +98,140 @@ public class CreateSpeciesMelagAction extends AbstractTuttiAction<SpeciesBatchUI sortedWeight = 0f; for (int selectedRowIndex : selectedRowIndexes) { - SpeciesBatchRowModel selectedRow = - tableModel.getEntry(selectedRowIndex); - Float sampleWeight = null; + SpeciesBatchRowModel selectedRow = tableModel.getEntry(selectedRowIndex); + if (selectedRow.getFinestCategory().getNotNullWeight() != null) { + + // le lot possede un poid de categorisation, aucun traitement ne sera fait dessus + // on conserve alors le poid connu alreadyKnownWeights += selectedRow.getFinestCategory().getNotNullWeight(); + // on conserve aussi le lot sans poids d'echantillonnage + selectedRows.put(selectedRow, null); + // on peut directement passer au lot suivant + continue; + + } - } else if (selectedRow.getWeight() != null) { + // on recherche le poids d'échantillonnage + Float sampleWeight; + + if (selectedRow.getWeight() != null) { + + // le lot a un poids de sous echantillon sampleWeight = selectedRow.getWeight(); } else { - sampleWeight = 0f; - if (selectedRow.getFrequency() != null) { - for (SpeciesFrequencyRowModel frequency : selectedRow.getFrequency()) { - if (frequency.getWeight() == null) { - sampleWeight = 0f; - break; - } - sampleWeight += frequency.getWeight(); - } - } + + // on calcule la somme des individus peses s'il existent + sampleWeight = SpeciesAbleBatchRowHelper.getFrequenciesTotalWeight(selectedRow.getFrequency()); + } - if (sampleWeight != null) { - if (sampleWeight == 0f) { - JOptionPane.showMessageDialog( - getUI(), - t("tutti.createSpeciesMelag.error.message", selectedRowIndex + 1), - t("tutti.createSpeciesMelag.error.title"), - JOptionPane.ERROR_MESSAGE); - - SwingUtil.setSelectionInterval(handler.getTable(), selectedRowIndex); - result = false; - break; - - } else { - sortedWeight += sampleWeight; - } + if (sampleWeight == null) { + + // pas de poids de sous-echantillon sur le lot + // impossible de calculer le melag + JOptionPane.showMessageDialog( + getUI(), + t("tutti.createSpeciesMelag.error.message", selectedRowIndex + 1), + t("tutti.createSpeciesMelag.error.title"), + JOptionPane.ERROR_MESSAGE); + + SwingUtil.setSelectionInterval(handler.getTable(), selectedRowIndex); + result = false; + // pas besoin de continuer a inspecter les autres lots + break; + } + // le lot est utilisable dans le melag + // on cumule le poids de sous echantillon + sortedWeight += sampleWeight; + + // on conserve ce lot avec son poids de sous echantillon selectedRows.put(selectedRow, sampleWeight); + } if (result) { - melagWeight = openMelagWeightDialog(); - if (melagWeight != null) { - // substract the weights that the user already entered - // they must not be used to compute the other weights - sampleMelagWeight = melagWeight - alreadyKnownWeights; - } + // tous les lots indiques permettent le calcul du melag + // on demande a l'utilisateur de saisir le poids total du melag + EnterMelagWeightUI dialog = new EnterMelagWeightUI(getContext()); + melagWeight = dialog.openAndGetWeightValue(weightUnit); + + // on peut continuer l'action uniquement si l'utilisateur a saisi un poids + result = melagWeight != null; + } - return result && melagWeight != null; - } + if (result) { + + // substract the weights that the user already entered + // they must not be used to compute the other weights + sampleMelagWeight = melagWeight - alreadyKnownWeights; + + } - protected Float openMelagWeightDialog() { - EnterMelagWeightUI dialog = new EnterMelagWeightUI(getContext()); - Float result = dialog.openAndGetWeightValue(weightUnit); return result; + } @Override public void doAction() throws Exception { + String unitLabel = weightUnit.getShortLabel(); String melagComment = t("tutti.createSpeciesMelag.comment.part1") + "\n"; + + // ecriture du commentaire a positionner sur chaque lot qui fait parti du melag + // et calcul du poids de categorisation sur les lots qui ont un poids de sous-echantillon precedemment renseigne for (SpeciesBatchRowModel batch : selectedRows.keySet()) { + Float sampleWeight = selectedRows.get(batch); - if (sampleWeight != null) { - float notRoundWeight = sampleMelagWeight * sampleWeight / sortedWeight; - float weight = Weights.roundKiloGram(notRoundWeight); - batch.getFinestCategory().setCategoryWeight(weight); - } else { + if (sampleWeight == null) { + + // on considere que le poids de sous echantillon est le poids de categorisation ? sampleWeight = batch.getFinestCategory().getNotNullWeight(); + + } else { + + // ce lot possede un poids d'echantillonage mais pas de poids de categorisation + // on calcul ce poids de categorisation et on lui affecte + float categoryWeight = Weights.roundKiloGram(sampleMelagWeight * sampleWeight / sortedWeight); + batch.getFinestCategory().setCategoryWeight(categoryWeight); + } melagComment += t("tutti.createSpeciesMelag.comment.part2", sampleWeight, unitLabel, decorate(batch.getSpecies())) + "\n"; + } melagComment += t("tutti.createSpeciesMelag.comment.part3", melagWeight, unitLabel); + // concatenation du commentaire sur chaque lot du melag + for (SpeciesBatchRowModel batch : selectedRows.keySet()) { String comment = batch.getComment(); if (StringUtils.isBlank(comment)) { comment = ""; - } else { comment += "\n"; } comment += melagComment; batch.setComment(comment); } + + // sauvegarde des lots getHandler().saveRows(selectedRows.keySet()); + } @Override public void releaseAction() { - super.releaseAction(); selectedRows.clear(); + sampleMelagWeight = null; melagWeight = null; sortedWeight = null; + super.releaseAction(); } @Override diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SpeciesAbleBatchRowHelper.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SpeciesAbleBatchRowHelper.java index 49228d7..871b08a 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SpeciesAbleBatchRowHelper.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SpeciesAbleBatchRowHelper.java @@ -25,16 +25,18 @@ package fr.ifremer.tutti.ui.swing.content.operation.catches; import com.google.common.base.Joiner; import com.google.common.collect.Lists; import com.google.common.collect.Sets; -import org.nuiton.jaxx.application.swing.table.AbstractApplicationTableModel; import fr.ifremer.tutti.persistence.entities.data.SpeciesAbleBatch; +import fr.ifremer.tutti.persistence.entities.data.SpeciesAbleBatchFrequency; import fr.ifremer.tutti.persistence.entities.referential.Species; import fr.ifremer.tutti.service.TuttiDecorator; import jaxx.runtime.SwingUtil; +import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.jdesktop.swingx.JXTable; import org.jdesktop.swingx.table.TableColumnExt; import org.nuiton.decorator.DecoratorUtil; +import org.nuiton.jaxx.application.swing.table.AbstractApplicationTableModel; import javax.swing.ButtonGroup; import javax.swing.JLabel; @@ -49,6 +51,7 @@ import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.io.Serializable; +import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Set; @@ -214,6 +217,42 @@ public class SpeciesAbleBatchRowHelper { return (TableColumnExt) table.getColumns().get(1); } + /** + * Calcule le poids total des mensurations. + * + * S'il n'y a pas de meunsration retourne {@code null}, idem si l'une des mensurations n'a pas de poids. + * + * @return la somme des poids des mensurations + * @since 3.10 + */ + public static <F extends SpeciesAbleBatchFrequency> Float getFrequenciesTotalWeight(Collection<F> frequency) { + + if (CollectionUtils.isEmpty(frequency)) { + + // pas de mensuration, donc poids total {@code null} + return null; + + } + + float frequencyTotalWeight = 0; + for (F aFrequency : frequency) { + + if (aFrequency.getWeight() == null) { + + // on a trouve une mensuration sans poids, on ne peut donc pas calcule + // de poids total + // on retourne {@code null} + return null; + } + + frequencyTotalWeight += aFrequency.getWeight(); + + } + + return frequencyTotalWeight; + + } + protected static class SpeciesDecoratorListener<R extends Serializable, T extends AbstractApplicationTableModel<R>> implements ActionListener { protected final JXTable table; diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java index 1d4f50f..093175f 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java @@ -499,11 +499,13 @@ public class BenthosBatchUIHandler extends AbstractTuttiBatchTableUIHandler<Bent enableRemove = selectedRowCount == 1; enableRemoveSub = selectedRowCount == 1; enableRename = selectedRowCount == 1; - enableCreateMelag = selectedRowCount > 1; enableEditFrequencies = selectedRowCount == 1; enableChangeSampleCategory = selectedRowCount == 1 && tableModel.isCellEditable(rowIndex, columnIndex); enableAddSampleCategory = selectedRowCount == 1 && tableModel.isCellEditable(rowIndex, columnIndex); + // action with multi-selection + enableCreateMelag = selectedRowCount > 1; + if (enableSplit) { // can split if selected batch is a leaf @@ -616,22 +618,6 @@ public class BenthosBatchUIHandler extends AbstractTuttiBatchTableUIHandler<Bent enableRemoveSub = !row.isBatchLeaf(); } - if (enableCreateMelag) { - - JXTable table = getTable(); - - // can add species to a melag if several root are selected - int[] selectedRows = SwingUtil.getSelectedModelRows(table); - for (int selectedRowIndex : selectedRows) { - BenthosBatchRowModel selectedRow = - tableModel.getEntry(selectedRowIndex); - - if (!selectedRow.isBatchRoot()) { - enableCreateMelag = false; - break; - } - } - } } BenthosBatchUIModel model = getModel(); model.setSplitBatchEnabled(enableSplit); diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java index 50993e9..9c146ca 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java @@ -455,11 +455,13 @@ public class SpeciesBatchUIHandler extends AbstractTuttiBatchTableUIHandler<Spec enableRemove = selectedRowCount == 1; enableRemoveSub = selectedRowCount == 1; enableRename = selectedRowCount == 1; - enableCreateMelag = selectedRowCount > 1; enableEditFrequencies = selectedRowCount == 1; enableChangeSampleCategory = selectedRowCount == 1 && tableModel.isCellEditable(rowIndex, columnIndex); enableAddSampleCategory = selectedRowCount == 1 && tableModel.isCellEditable(rowIndex, columnIndex); + // action with multi-selection + enableCreateMelag = selectedRowCount > 1; + if (enableSplit) { // can split if selected batch is a leaf @@ -573,22 +575,6 @@ public class SpeciesBatchUIHandler extends AbstractTuttiBatchTableUIHandler<Spec enableRemoveSub = !row.isBatchLeaf(); } - if (enableCreateMelag) { - - JXTable table = getTable(); - - // can add species to a melag if several root are selected - int[] selectedRows = SwingUtil.getSelectedModelRows(table); - for (int selectedRowIndex : selectedRows) { - SpeciesBatchRowModel selectedRow = - tableModel.getEntry(selectedRowIndex); - - if (!selectedRow.isBatchRoot()) { - enableCreateMelag = false; - break; - } - } - } } SpeciesBatchUIModel model = getModel(); model.setSplitBatchEnabled(enableSplit); -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
participants (1)
-
codelutin.com scm