......@@ -336,4 +336,24 @@ public class SurveyMeasurementsTabUIHandler extends AbstractReefDbUIHandler<Surv
public boolean onRemoveTab() {
return false;
}
public void save() {
try {
// Disable filter
getModel().getGroupedTableUIModel().setMeasurementFilter(new MeasurementsFilter());
// save ungrouped measurements
getUI().getUngroupedTable().getHandler().save();
// save grouped measurements
getUI().getGroupedTable().getHandler().save();
} finally {
doSearch();
}
}
}
......@@ -27,7 +27,6 @@ import com.google.common.collect.ImmutableList;
import fr.ifremer.quadrige3.ui.swing.table.ColumnIdentifier;
import fr.ifremer.quadrige3.ui.swing.table.SwingTable;
import fr.ifremer.reefdb.dto.data.measurement.MeasurementAware;
import fr.ifremer.reefdb.dto.data.measurement.MeasurementDTO;
import fr.ifremer.reefdb.ui.swing.content.observation.shared.AbstractMeasurementsGroupedTableModel;
import fr.ifremer.reefdb.ui.swing.content.observation.shared.AbstractMeasurementsGroupedTableUIHandler;
import fr.ifremer.reefdb.ui.swing.content.observation.survey.measurement.grouped.multiedit.SurveyMeasurementsMultiEditUI;
......@@ -211,17 +210,6 @@ public class SurveyMeasurementsGroupedTableUIHandler
addEditionPanelBorder();
}
@Override
protected void removeIndividualMeasurements(List<MeasurementDTO> measurementToDelete) {
// Remove from model
getModel().getSurvey().removeAllIndividualMeasurements(measurementToDelete);
getModel().getSurvey().setDirty(true);
getModel().setModify(true);
}
public void editSelectedMeasurements() {
editSelectedMeasurements(new SurveyMeasurementsMultiEditUI(getUI()));
......
......@@ -31,6 +31,7 @@ import fr.ifremer.reefdb.dto.data.measurement.MeasurementDTO;
import fr.ifremer.reefdb.dto.data.survey.SurveyDTO;
import fr.ifremer.reefdb.dto.enums.FilterTypeValues;
import fr.ifremer.reefdb.dto.referential.DepartmentDTO;
import fr.ifremer.reefdb.service.ReefDbTechnicalException;
import fr.ifremer.reefdb.ui.swing.util.table.AbstractReefDbTableUIHandler;
import jaxx.runtime.SwingUtil;
import org.apache.commons.collections4.CollectionUtils;
......@@ -148,13 +149,12 @@ public class SurveyMeasurementsUngroupedTableUIHandler
// tell the table model is editable or not
getTableModel().setReadOnly(!getModel().getSurvey().isEditable());
// getModel().setBean(getModel().getSurvey());
getModel().setRows(null);
if (notEmpty) {
// affect row
SurveyMeasurementsUngroupedRowModel row = getModel().addNewRow(getModel().getSurvey()); //getModel().getRows().get(0);
SurveyMeasurementsUngroupedRowModel row = getModel().addNewRow(getModel().getSurvey());
// set analyst from first non null measurement
Optional<MeasurementDTO> measurementFound = getModel().getSurvey().getMeasurements().stream().filter(measurement -> measurement.getAnalyst() != null).findFirst();
......@@ -199,12 +199,25 @@ public class SurveyMeasurementsUngroupedTableUIHandler
super.onRowModified(rowIndex, row, propertyName, propertyIndex, oldValue, newValue);
getModel().getSurvey().setDirty(true);
}
public void save() {
if (getModel().getRowCount() == 0)
return;
if (getModel().getRowCount() > 1)
throw new ReefDbTechnicalException("Should be only 1 row of survey ungrouped measurements");
SurveyMeasurementsUngroupedRowModel row = getModel().getRows().get(0);
// update all measurements
row.getMeasurements().forEach(measurement -> measurement.setAnalyst(row.getAnalyst()));
// save modifications to parent model
getModel().getSurvey().setMeasurements(row.getMeasurements());
getModel().getSurvey().setDirty(true);
}
......
package fr.ifremer.reefdb.ui.swing.util;
/*-
* #%L
* Reef DB :: UI
* $Id:$
* $HeadURL:$
* %%
* Copyright (C) 2014 - 2020 Ifremer
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
import org.jdesktop.beans.AbstractBean;
import javax.annotation.Nonnull;
import java.awt.Component;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.function.Consumer;
/**
* a PropertyChangeListener that auto remove after fired
*
* @author peck7 on 20/03/2020.
*/
public class OneShotListener implements PropertyChangeListener {
private final Component parentComponent;
private final AbstractBean parentBean;
private final String propertyName;
private final Consumer<PropertyChangeEvent> consumer;
/**
* Create and add to parent object
*
* @param parent the component on which this listener will be added
* @param propertyName the property to listen to
* @param consumer the consumer function
*/
public static void create(@Nonnull Component parent, @Nonnull String propertyName, @Nonnull Consumer<PropertyChangeEvent> consumer) {
OneShotListener listener = new OneShotListener(parent, propertyName, consumer);
parent.addPropertyChangeListener(propertyName, listener);
}
/**
* 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.consumer = consumer;
}
@Override
public void propertyChange(PropertyChangeEvent evt) {
consumer.accept(evt);
if (parentComponent != null)
parentComponent.removePropertyChangeListener(propertyName, this);
if (parentBean != null)
parentBean.removePropertyChangeListener(propertyName, this);
}
}
......@@ -529,6 +529,7 @@ public abstract class AbstractReefDbTableUIHandler<R extends AbstractReefDbRowUI
protected void removePmfmColumns() {
removeColumns(getModel().getPmfmColumns());
getModel().getPmfmColumns().clear();
}
/**
......
......@@ -31,6 +31,18 @@
</properties>
<body>
<release version="3.9.9" date="2020-04-07" description="Stable release">
<action dev="ludovic.pecquot@e-is.pro" type="fix" issue="51725,51737">
Grouped measurements: automatic calculation and saving into parent beans has been replaced by unique function executed at observation saving
</action>
<action dev="ludovic.pecquot@e-is.pro" type="fix" issue="51710">
PIT protocol: section calculation fixed
</action>
<action dev="ludovic.pecquot@e-is.pro" type="fix" issue="51731">
Upgrade quadrige3-core to version 3.6.14
</action>
</release>
<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
......