Commit c8fa6eab authored by PECQUOT's avatar PECQUOT

[fix] Regression of #51520: Postpone calculation also if no row sorting (Mantis #51586)

Signed-off-by: PECQUOT's avatarlp1ee9d <ludovic.pecquot@e-is.pro>
parent 71481fae
## Sprint 90 - v3.9.8
- Pas de mise à jour de modèle
## Sprint 89 - v3.9.7 ## Sprint 89 - v3.9.7
- Pas de mise à jour de modèle - Pas de mise à jour de modèle
......
...@@ -30,6 +30,7 @@ import com.google.common.collect.Maps; ...@@ -30,6 +30,7 @@ import com.google.common.collect.Maps;
import fr.ifremer.quadrige3.core.dao.technical.Assert; import fr.ifremer.quadrige3.core.dao.technical.Assert;
import fr.ifremer.quadrige3.core.dao.technical.factorization.pmfm.AllowedQualitativeValuesMap; import fr.ifremer.quadrige3.core.dao.technical.factorization.pmfm.AllowedQualitativeValuesMap;
import fr.ifremer.quadrige3.ui.core.dto.DirtyAware; import fr.ifremer.quadrige3.ui.core.dto.DirtyAware;
import fr.ifremer.quadrige3.ui.swing.table.AbstractTableUIModel;
import fr.ifremer.quadrige3.ui.swing.table.SwingTable; import fr.ifremer.quadrige3.ui.swing.table.SwingTable;
import fr.ifremer.quadrige3.ui.swing.table.editor.ExtendedComboBoxCellEditor; import fr.ifremer.quadrige3.ui.swing.table.editor.ExtendedComboBoxCellEditor;
import fr.ifremer.reefdb.decorator.DecoratorService; import fr.ifremer.reefdb.decorator.DecoratorService;
...@@ -454,7 +455,8 @@ public abstract class AbstractMeasurementsGroupedTableUIHandler< ...@@ -454,7 +455,8 @@ public abstract class AbstractMeasurementsGroupedTableUIHandler<
// now calculate individual id after table is sorted // now calculate individual id after table is sorted
if (getTable().getRowSorter().getSortKeys().isEmpty()) { if (getTable().getRowSorter().getSortKeys().isEmpty()) {
calculateIndividualIds(newRow); // Also use a OneShotListener (Mantis #51586)
OneShotListener.create(getModel(), AbstractTableUIModel.PROPERTY_ROWS, propertyChangeEvent -> calculateIndividualIds(newRow));
} else { } else {
OneShotListener.create(getTable(), SwingTable.PROPERTY_SORTED, propertyChangeEvent -> calculateIndividualIds(newRow)); OneShotListener.create(getTable(), SwingTable.PROPERTY_SORTED, propertyChangeEvent -> calculateIndividualIds(newRow));
} }
......
...@@ -23,6 +23,8 @@ package fr.ifremer.reefdb.ui.swing.util; ...@@ -23,6 +23,8 @@ package fr.ifremer.reefdb.ui.swing.util;
* #L% * #L%
*/ */
import org.jdesktop.beans.AbstractBean;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import java.awt.Component; import java.awt.Component;
import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeEvent;
...@@ -36,7 +38,8 @@ import java.util.function.Consumer; ...@@ -36,7 +38,8 @@ import java.util.function.Consumer;
*/ */
public class OneShotListener implements PropertyChangeListener { public class OneShotListener implements PropertyChangeListener {
private final Component parent; private final Component parentComponent;
private final AbstractBean parentBean;
private final String propertyName; private final String propertyName;
private final Consumer<PropertyChangeEvent> consumer; private final Consumer<PropertyChangeEvent> consumer;
...@@ -52,8 +55,28 @@ public class OneShotListener implements PropertyChangeListener { ...@@ -52,8 +55,28 @@ public class OneShotListener implements PropertyChangeListener {
parent.addPropertyChangeListener(propertyName, listener); parent.addPropertyChangeListener(propertyName, listener);
} }
private OneShotListener(Component parent, String propertyName, Consumer<PropertyChangeEvent> consumer) { /**
this.parent = parent; * Create and add to parent object
*
* @param parent the bean on which this listener will be added
* @param propertyName the property to listen to
* @param consumer the consumer function
*/
public static void create(@Nonnull AbstractBean parent, @Nonnull String propertyName, @Nonnull Consumer<PropertyChangeEvent> consumer) {
OneShotListener listener = new OneShotListener(parent, propertyName, consumer);
parent.addPropertyChangeListener(propertyName, listener);
}
private OneShotListener(Component parentComponent, String propertyName, Consumer<PropertyChangeEvent> consumer) {
this.parentComponent = parentComponent;
this.parentBean = null;
this.propertyName = propertyName;
this.consumer = consumer;
}
private OneShotListener(AbstractBean parentBean, String propertyName, Consumer<PropertyChangeEvent> consumer) {
this.parentComponent = null;
this.parentBean = parentBean;
this.propertyName = propertyName; this.propertyName = propertyName;
this.consumer = consumer; this.consumer = consumer;
} }
...@@ -61,6 +84,9 @@ public class OneShotListener implements PropertyChangeListener { ...@@ -61,6 +84,9 @@ public class OneShotListener implements PropertyChangeListener {
@Override @Override
public void propertyChange(PropertyChangeEvent evt) { public void propertyChange(PropertyChangeEvent evt) {
consumer.accept(evt); consumer.accept(evt);
parent.removePropertyChangeListener(propertyName, this); if (parentComponent != null)
parentComponent.removePropertyChangeListener(propertyName, this);
if (parentBean != null)
parentBean.removePropertyChangeListener(propertyName, this);
} }
} }
...@@ -31,6 +31,12 @@ ...@@ -31,6 +31,12 @@
</properties> </properties>
<body> <body>
<release version="3.9.8" date="2020-03-30" description="Stable release">
<action dev="ludovic.pecquot@e-is.pro" type="fix" issue="51586">
Regression of #51520: Postpone calculation also if no row sorting
</action>
</release>
<release version="3.9.7" date="2020-03-23" description="Stable release"> <release version="3.9.7" date="2020-03-23" description="Stable release">
<action dev="ludovic.pecquot@e-is.pro" type="fix" issue="51520"> <action dev="ludovic.pecquot@e-is.pro" type="fix" issue="51520">
Rework the calculation of individual ids on grouped measurements, now use table sorting if possible Rework the calculation of individual ids on grouped measurements, now use table sorting if possible
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment