Tony CHEMIT pushed to branch develop-7.x at ultreiaio / ird-observe Commits: f96ea336 by Tony Chemit at 2021-01-14T23:10:27+01:00 Découplage case 'Horloge' et champ 'Horodatage de montée à bord' - Closes #1754 Clean timeSinceContact when timer is off. - - - - - 1 changed file: - client-core/src/main/java/fr/ird/observe/client/ui/content/data/longline/CatchLonglineUIHandler.java Changes: ===================================== client-core/src/main/java/fr/ird/observe/client/ui/content/data/longline/CatchLonglineUIHandler.java ===================================== @@ -60,6 +60,7 @@ import fr.ird.observe.dto.referential.longline.CatchFateLonglineReference; import fr.ird.observe.dto.referential.longline.HealthStatusReference; import fr.ird.observe.dto.result.SaveResultDto; import fr.ird.observe.spi.DtoModelHelper; +import io.ultreia.java4all.util.Dates; import org.apache.commons.lang3.BooleanUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -112,6 +113,7 @@ public class CatchLonglineUIHandler extends ContentTableUIHandler<SetLonglineCat private final PropertyChangeListener branchlineChanged; private final PropertyChangeListener depredatedChanged; + private final PropertyChangeListener timerChanged; private final PropertyChangeListener sizeTableModelModified; @@ -135,7 +137,7 @@ public class CatchLonglineUIHandler extends ContentTableUIHandler<SetLonglineCat weightTableModelModified = evt -> onWeightTableModelModified((Boolean) evt.getNewValue()); sizeTableModelModified = evt -> onSizeTableModelModified((Boolean) evt.getNewValue()); depredatedChanged = evt -> onDepredatedChanged((Boolean) evt.getNewValue(), (CatchLonglineDto) evt.getSource()); - + timerChanged = evt -> onTimerChanged((Boolean) evt.getNewValue()); addReferentialFilter(CatchLonglineDto.PROPERTY_SPECIES_CATCH, (ReferentialReferencesFilter<SpeciesDto, SpeciesReference>) incomingReferences -> { String speciesListId = ObserveSwingApplicationContext.get().getConfig().getSpeciesListLonglineCatchId(); String tripLonglineId = getDataContext().getSelectedTripLonglineId(); @@ -835,7 +837,7 @@ public class CatchLonglineUIHandler extends ContentTableUIHandler<SetLonglineCat if (log.isInfoEnabled()) { log.info("Remove branchline"); } - + branchline.removePropertyChangeListener(BranchlineDto.PROPERTY_TIMER, timerChanged); branchlineValidator.setBean(null); branchline.clear(); model.setBranchlineTimeSinceContact(null); @@ -845,7 +847,7 @@ public class CatchLonglineUIHandler extends ContentTableUIHandler<SetLonglineCat if (log.isInfoEnabled()) { log.info("Use branchline: " + newValue); } - + branchline.addPropertyChangeListener(BranchlineDto.PROPERTY_TIMER, timerChanged); String setLonglineId = getDataContext().getSelectedSetLonglineId(); Form<BranchlineDto> form = getBranchlineService().loadForm(setLonglineId, newValue.getId()); @@ -1038,7 +1040,15 @@ public class CatchLonglineUIHandler extends ContentTableUIHandler<SetLonglineCat model.setBranchlineTabValid(branchlineTabValid); } - + void onTimerChanged(Boolean newValue) { + if (Objects.equals(true, newValue)) { + // with timer + ui.getModel().setBranchlineTimeSinceContact(Dates.createDate(0, 0, 0, 0, 0, 0)); + } else { + // without timer + ui.getModel().setBranchlineTimeSinceContact(null); + } + } @Override protected CatchLonglineTableModel getTableModel() { return (CatchLonglineTableModel) super.getTableModel(); View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/commit/f96ea3362800bbf2772aee792b... -- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/commit/f96ea3362800bbf2772aee792b... You're receiving this email because of your account on gitlab.com.