branch feature/8238 updated (41f51b7 -> 7868450)
This is an automated email from the git hooks/post-receive script. New change to branch feature/8238 in repository tutti. See https://gitlab.nuiton.org/codelutin/tutti.git from 41f51b7 - Quand on supprime des lignes d'espece ou benthos du protocole, on enlève leur maturité des maturités utilisées. - On met à jour l'état des boutons de la double liste de maturité quand on arrive sur l'onglet des caractéristiques. Sinon, si la maturité sélectionné a été ajoutée ou supprimée, le bouton n'est plus dans le bon état. fixes #8238 new 7868450 idem pour les classes de taille (fixes #8238) 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 78684501f3f2beac7b9c6f01eeb77514e9ebe63a Author: Kevin Morin <morin@codelutin.com> Date: Mon Apr 25 18:43:59 2016 +0200 idem pour les classes de taille (fixes #8238) Summary of changes: .../protocol/EditProtocolSpeciesTableModel.java | 69 +++++++++++++++++----- .../content/protocol/EditProtocolUIHandler.java | 65 +++++++++++++++----- .../actions/RemoveBenthosProtocolAction.java | 8 ++- .../actions/RemoveSpeciesProtocolAction.java | 7 ++- 4 files changed, 115 insertions(+), 34 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 feature/8238 in repository tutti. See https://gitlab.nuiton.org/codelutin/tutti.git commit 78684501f3f2beac7b9c6f01eeb77514e9ebe63a Author: Kevin Morin <morin@codelutin.com> Date: Mon Apr 25 18:43:59 2016 +0200 idem pour les classes de taille (fixes #8238) --- .../protocol/EditProtocolSpeciesTableModel.java | 69 +++++++++++++++++----- .../content/protocol/EditProtocolUIHandler.java | 65 +++++++++++++++----- .../actions/RemoveBenthosProtocolAction.java | 8 ++- .../actions/RemoveSpeciesProtocolAction.java | 7 ++- 4 files changed, 115 insertions(+), 34 deletions(-) diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolSpeciesTableModel.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolSpeciesTableModel.java index 936aab4..356e7ba 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolSpeciesTableModel.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolSpeciesTableModel.java @@ -85,7 +85,8 @@ public class EditProtocolSpeciesTableModel extends AbstractApplicationTableModel protected final SampleCategoryModel sampleCategoryModel; // FIXME check if ok to add benthos AND species together - private static final List<Caracteristic> maturitiesUsed = new ArrayList<>(); + private static final List<Caracteristic> lengthStepPmfmUsed = new ArrayList<>(); + private static final List<Caracteristic> maturitiesPmfmUsed = new ArrayList<>(); private static final long serialVersionUID = 1L; @@ -111,7 +112,10 @@ public class EditProtocolSpeciesTableModel extends AbstractApplicationTableModel result.addPropertyChangeListener(EditProtocolSpeciesRowModel.PROPERTY_LENGTH_STEP_PMFM, evt -> { - + // update the used lengthstep caracteristic + if (evt.getOldValue() != null) { + removeUsedLengthStepPmfm((Caracteristic) evt.getOldValue()); + } if (evt.getNewValue() == null) { EditProtocolSpeciesRowModel rowModel = (EditProtocolSpeciesRowModel) evt.getSource(); @@ -119,19 +123,20 @@ public class EditProtocolSpeciesTableModel extends AbstractApplicationTableModel rowModel.setRtpFemale(null); rowModel.setRtpUndefined(null); + } else { + addUsedLengthStepPmfm((Caracteristic) evt.getNewValue()); } }); - //FIXME gérer les maturités des lignes suprpimées result.addPropertyChangeListener(EditProtocolSpeciesRowModel.PROPERTY_MATURITY_PMFM, evt -> { // update the used maturities if (evt.getOldValue() != null) { - removeUsedMaturity((Caracteristic) evt.getOldValue()); + removeUsedMaturityPmfm((Caracteristic) evt.getOldValue()); } if (evt.getNewValue() != null) { - addUsedMaturity((Caracteristic) evt.getNewValue()); + addUsedMaturityPmfm((Caracteristic) evt.getNewValue()); } }); @@ -189,18 +194,50 @@ public class EditProtocolSpeciesTableModel extends AbstractApplicationTableModel return result; } - // operations on the used maturities + // operations on the used lengthstep pmfms + + public static void addUsedLengthStepPmfm(Caracteristic maturity) { + lengthStepPmfmUsed.add(maturity); + } + + public static void removeUsedLengthStepPmfm(Caracteristic maturity) { + lengthStepPmfmUsed.remove(maturity); + } + + public static void removeUsedLengthStepPmfms(Collection<Caracteristic> maturities) { + lengthStepPmfmUsed.removeAll(maturities); + } + + /** + * Check if the caracteristics are used in the maturity caracteristics of the species or benthos + * @param caracteristics the list of caracteristics to check + * @return true if none of the maturities are used + */ + public static boolean isNoneOfTheLengthStepPmfmsUsed(Collection<Caracteristic> caracteristics) { + return lengthStepPmfmUsed.stream().noneMatch(caracteristics::contains); + } + + /** + * Check if the caracteristic is used in the maturity caracteristics of the species or benthos + * @param caracteristic the caracteristic to check + * @return true if the maturity is used + */ + public static boolean isLengthStepPmfmUsed(Caracteristic caracteristic) { + return lengthStepPmfmUsed.contains(caracteristic); + } + + // operations on the used maturity pfmfs - public static void addUsedMaturity(Caracteristic maturity) { - maturitiesUsed.add(maturity); + public static void addUsedMaturityPmfm(Caracteristic maturity) { + maturitiesPmfmUsed.add(maturity); } - public static void removeUsedMaturity(Caracteristic maturity) { - maturitiesUsed.remove(maturity); + public static void removeUsedMaturityPmfm(Caracteristic maturity) { + maturitiesPmfmUsed.remove(maturity); } - public static void removeUsedMaturities(Collection<Caracteristic> maturities) { - maturitiesUsed.removeAll(maturities); + public static void removeUsedMaturityPmfms(Collection<Caracteristic> maturities) { + maturitiesPmfmUsed.removeAll(maturities); } /** @@ -208,8 +245,8 @@ public class EditProtocolSpeciesTableModel extends AbstractApplicationTableModel * @param caracteristics the list of caracteristics to check * @return true if none of the maturities are used */ - public static boolean isNoneOfTheMaturitiesUsed(Collection<Caracteristic> caracteristics) { - return maturitiesUsed.stream().noneMatch(caracteristics::contains); + public static boolean isNoneOfTheMaturityPmfmsUsed(Collection<Caracteristic> caracteristics) { + return maturitiesPmfmUsed.stream().noneMatch(caracteristics::contains); } /** @@ -217,7 +254,7 @@ public class EditProtocolSpeciesTableModel extends AbstractApplicationTableModel * @param caracteristic the caracteristic to check * @return true if the maturity is used */ - public static boolean isMaturityUsed(Caracteristic caracteristic) { - return maturitiesUsed.contains(caracteristic); + public static boolean isMaturityPmfmUsed(Caracteristic caracteristic) { + return maturitiesPmfmUsed.contains(caracteristic); } } diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java index 58ea42d..b00f796 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java @@ -530,17 +530,26 @@ public class EditProtocolUIHandler extends AbstractTuttiUIHandler<EditProtocolUI } BeanDoubleList<Caracteristic> maturityList = this.ui.getMaturityList(); + BeanDoubleList<Caracteristic> lengthClassesList = this.ui.getLengthClassesList(); + allDoubleLists = Lists.newArrayList( - this.ui.getLengthClassesList(), + lengthClassesList, this.ui.getIndividualObservationList(), maturityList ); initDoubleList(EditProtocolUIModel.PROPERTY_LENGTH_CLASSES_PMFM_ID, - this.ui.getLengthClassesList(), + lengthClassesList, Lists.newArrayList(model.getCaracteristics()), model.getLengthClassesPmfmId()); + JList lengthClassesSelectedList = lengthClassesList.getSelectedList(); + lengthClassesList.getModel().addCanRemoveItemsPredicate( + input -> EditProtocolSpeciesTableModel.isNoneOfTheLengthStepPmfmsUsed(lengthClassesSelectedList.getSelectedValuesList())); + + ListCellRenderer lengthClassesDefaultRenderer = lengthClassesSelectedList.getCellRenderer(); + lengthClassesSelectedList.setCellRenderer(new LengthStepCaracteristicCellRenderer(lengthClassesDefaultRenderer)); + initDoubleList(EditProtocolUIModel.PROPERTY_INDIVIDUAL_OBSERVATION_PMFM_ID, this.ui.getIndividualObservationList(), Lists.newArrayList(model.getCaracteristics()), @@ -551,30 +560,32 @@ public class EditProtocolUIHandler extends AbstractTuttiUIHandler<EditProtocolUI model.getCaracteristics().stream().filter(caracteristic -> !caracteristic.isQualitativeValueEmpty()).collect(Collectors.toList()), model.getMaturityPmfmId()); + JList maturitySelectedList = maturityList.getSelectedList(); maturityList.getModel().addCanRemoveItemsPredicate( - input -> EditProtocolSpeciesTableModel.isNoneOfTheMaturitiesUsed(maturityList.getSelectedList().getSelectedValuesList())); - - // update maturity list button states when the user goes back to the caracteristic panel - // to update the remove state in case the selected maturity has been added or removed from the species or benthos - ui.getTabPanel().addChangeListener(e -> { - JTabbedPane source = (JTabbedPane) e.getSource(); - if (ui.getCaracteristicPanel().equals(source.getSelectedComponent())) { - maturityList.getHandler().recomputeButtonStates(); - } - }); + input -> EditProtocolSpeciesTableModel.isNoneOfTheMaturityPmfmsUsed(maturityList.getSelectedList().getSelectedValuesList())); JMenuItem editMaturity = ui.getEditMaturityCaracteristicAction(); maturityList.getSelectedListPopup().add(editMaturity); // add listener to enable the maturity edition - JList maturitySelectedList = maturityList.getSelectedList(); maturitySelectedList.addListSelectionListener(e -> { boolean editMaturityEnabled = maturitySelectedList.getSelectedIndices().length == 1; editMaturity.setEnabled(editMaturityEnabled); }); - ListCellRenderer defaultRenderer = maturitySelectedList.getCellRenderer(); - maturitySelectedList.setCellRenderer(new MaturityCaracteristicCellRenderer(defaultRenderer)); + ListCellRenderer maturityDefaultRenderer = maturitySelectedList.getCellRenderer(); + maturitySelectedList.setCellRenderer(new MaturityCaracteristicCellRenderer(maturityDefaultRenderer)); + + + // update lengthstep and maturity list button states when the user goes back to the caracteristic panel + // to update the remove state in case the selected maturity has been added or removed from the species or benthos + ui.getTabPanel().addChangeListener(e -> { + JTabbedPane source = (JTabbedPane) e.getSource(); + if (ui.getCaracteristicPanel().equals(source.getSelectedComponent())) { + lengthClassesList.getHandler().recomputeButtonStates(); + maturityList.getHandler().recomputeButtonStates(); + } + }); // init caracteristics mappingtable { @@ -1656,6 +1667,28 @@ public class EditProtocolUIHandler extends AbstractTuttiUIHandler<EditProtocolUI } + private class LengthStepCaracteristicCellRenderer implements ListCellRenderer { + + private final ListCellRenderer defaultRenderer; + + private Color notRemovableColor = getConfig().getColorWarningRow(); + + LengthStepCaracteristicCellRenderer(ListCellRenderer defaultRenderer) { + this.defaultRenderer = defaultRenderer; + } + + @Override + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + Component result = defaultRenderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + Caracteristic caracteristic = (Caracteristic) value; + + if (isSelected && EditProtocolSpeciesTableModel.isLengthStepPmfmUsed(caracteristic)) { + result.setBackground(notRemovableColor.darker()); + } + return result; + } + } + private class MaturityCaracteristicCellRenderer implements ListCellRenderer { public static final String TEXT_PATTERN = "<html><body><strong>%s</strong> :<ul><li>%s</li></ul><strong>%s</strong> :<ul><li>%s</li></ul></body></html>"; @@ -1678,7 +1711,7 @@ public class EditProtocolUIHandler extends AbstractTuttiUIHandler<EditProtocolUI Caracteristic maturityCaracteristic = (Caracteristic) value; Color backgroud; - if (isSelected && EditProtocolSpeciesTableModel.isMaturityUsed((Caracteristic) value)) { + if (isSelected && EditProtocolSpeciesTableModel.isMaturityPmfmUsed(maturityCaracteristic)) { backgroud= notRemovableColor; } else if (!EditProtocolUIHandler.this.getModel().isMaturityValid(maturityCaracteristic)) { diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/actions/RemoveBenthosProtocolAction.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/actions/RemoveBenthosProtocolAction.java index 0568fe2..171f7d4 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/actions/RemoveBenthosProtocolAction.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/actions/RemoveBenthosProtocolAction.java @@ -153,8 +153,14 @@ public class RemoveBenthosProtocolAction extends LongActionSupport<EditProtocolU // remove all rows from model getModel().getBenthosRow().removeAll(removedRows); + + // remove the lengthstep pmfm of the rows from the used lengthstep pmfm + EditProtocolSpeciesTableModel.removeUsedLengthStepPmfms(removedRows.stream() + .map(EditProtocolSpeciesRowModel::getLengthStepPmfm) + .collect(Collectors.toList())); + // remove the maturities of the rows from the used maturities - EditProtocolSpeciesTableModel.removeUsedMaturities(removedRows.stream() + EditProtocolSpeciesTableModel.removeUsedMaturityPmfms(removedRows.stream() .map(EditProtocolSpeciesRowModel::getMaturityPmfm) .collect(Collectors.toList())); diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/actions/RemoveSpeciesProtocolAction.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/actions/RemoveSpeciesProtocolAction.java index 049f602..7bd7624 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/actions/RemoveSpeciesProtocolAction.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/actions/RemoveSpeciesProtocolAction.java @@ -150,8 +150,13 @@ public class RemoveSpeciesProtocolAction extends LongActionSupport<EditProtocolU // remove all rows from model getModel().getSpeciesRow().removeAll(removedRows); + // remove the lengthstep pmfm of the rows from the used lengthstep pmfm + EditProtocolSpeciesTableModel.removeUsedLengthStepPmfms(removedRows.stream() + .map(EditProtocolSpeciesRowModel::getLengthStepPmfm) + .collect(Collectors.toList())); + // remove the maturities of the rows from the used maturities - EditProtocolSpeciesTableModel.removeUsedMaturities(removedRows.stream() + EditProtocolSpeciesTableModel.removeUsedMaturityPmfms(removedRows.stream() .map(EditProtocolSpeciesRowModel::getMaturityPmfm) .collect(Collectors.toList())); -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
participants (1)
-
codelutin.com scm