Tony CHEMIT pushed to branch develop-7.x at ultreiaio / ird-observe

Commits:

1 changed file:

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;
    60 60
     import fr.ird.observe.dto.referential.longline.HealthStatusReference;
    
    61 61
     import fr.ird.observe.dto.result.SaveResultDto;
    
    62 62
     import fr.ird.observe.spi.DtoModelHelper;
    
    63
    +import io.ultreia.java4all.util.Dates;
    
    63 64
     import org.apache.commons.lang3.BooleanUtils;
    
    64 65
     import org.apache.logging.log4j.LogManager;
    
    65 66
     import org.apache.logging.log4j.Logger;
    
    ... ... @@ -112,6 +113,7 @@ public class CatchLonglineUIHandler extends ContentTableUIHandler<SetLonglineCat
    112 113
         private final PropertyChangeListener branchlineChanged;
    
    113 114
     
    
    114 115
         private final PropertyChangeListener depredatedChanged;
    
    116
    +    private final PropertyChangeListener timerChanged;
    
    115 117
     
    
    116 118
         private final PropertyChangeListener sizeTableModelModified;
    
    117 119
     
    
    ... ... @@ -135,7 +137,7 @@ public class CatchLonglineUIHandler extends ContentTableUIHandler<SetLonglineCat
    135 137
             weightTableModelModified = evt -> onWeightTableModelModified((Boolean) evt.getNewValue());
    
    136 138
             sizeTableModelModified = evt -> onSizeTableModelModified((Boolean) evt.getNewValue());
    
    137 139
             depredatedChanged = evt -> onDepredatedChanged((Boolean) evt.getNewValue(), (CatchLonglineDto) evt.getSource());
    
    138
    -
    
    140
    +        timerChanged = evt -> onTimerChanged((Boolean) evt.getNewValue());
    
    139 141
             addReferentialFilter(CatchLonglineDto.PROPERTY_SPECIES_CATCH, (ReferentialReferencesFilter<SpeciesDto, SpeciesReference>) incomingReferences -> {
    
    140 142
                 String speciesListId = ObserveSwingApplicationContext.get().getConfig().getSpeciesListLonglineCatchId();
    
    141 143
                 String tripLonglineId = getDataContext().getSelectedTripLonglineId();
    
    ... ... @@ -835,7 +837,7 @@ public class CatchLonglineUIHandler extends ContentTableUIHandler<SetLonglineCat
    835 837
                 if (log.isInfoEnabled()) {
    
    836 838
                     log.info("Remove branchline");
    
    837 839
                 }
    
    838
    -
    
    840
    +            branchline.removePropertyChangeListener(BranchlineDto.PROPERTY_TIMER, timerChanged);
    
    839 841
                 branchlineValidator.setBean(null);
    
    840 842
                 branchline.clear();
    
    841 843
                 model.setBranchlineTimeSinceContact(null);
    
    ... ... @@ -845,7 +847,7 @@ public class CatchLonglineUIHandler extends ContentTableUIHandler<SetLonglineCat
    845 847
                 if (log.isInfoEnabled()) {
    
    846 848
                     log.info("Use branchline: " + newValue);
    
    847 849
                 }
    
    848
    -
    
    850
    +            branchline.addPropertyChangeListener(BranchlineDto.PROPERTY_TIMER, timerChanged);
    
    849 851
                 String setLonglineId = getDataContext().getSelectedSetLonglineId();
    
    850 852
     
    
    851 853
                 Form<BranchlineDto> form = getBranchlineService().loadForm(setLonglineId, newValue.getId());
    
    ... ... @@ -1038,7 +1040,15 @@ public class CatchLonglineUIHandler extends ContentTableUIHandler<SetLonglineCat
    1038 1040
             model.setBranchlineTabValid(branchlineTabValid);
    
    1039 1041
     
    
    1040 1042
         }
    
    1041
    -
    
    1043
    +    void onTimerChanged(Boolean newValue) {
    
    1044
    +        if (Objects.equals(true, newValue)) {
    
    1045
    +            // with timer
    
    1046
    +            ui.getModel().setBranchlineTimeSinceContact(Dates.createDate(0, 0, 0, 0, 0, 0));
    
    1047
    +        } else {
    
    1048
    +            // without timer
    
    1049
    +            ui.getModel().setBranchlineTimeSinceContact(null);
    
    1050
    +        }
    
    1051
    +    }
    
    1042 1052
         @Override
    
    1043 1053
         protected CatchLonglineTableModel getTableModel() {
    
    1044 1054
             return (CatchLonglineTableModel) super.getTableModel();