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

Commits:

5 changed files:

Changes:

  • client/core/src/main/java/fr/ird/observe/client/datasource/api/cache/ReferencesCache.java
    ... ... @@ -128,9 +128,13 @@ public class ReferencesCache {
    128 128
         public void loadReferentialReferenceSetsInModel(FormDefinition<?> formDefinition, boolean clear) {
    
    129 129
             Class<? extends IdDto> dtoType = formDefinition.getType();
    
    130 130
             ImmutableMap.Builder<String, ReferentialDtoReferenceSet<?>> modelReferentialReferenceSets = ImmutableMap.builder();
    
    131
    +        Set<String> existingProperties;
    
    131 132
             if (!clear) {
    
    132 133
                 // keep existing sets
    
    133 134
                 modelReferentialReferenceSets.putAll(referentialReferenceSetsByPropertyName);
    
    135
    +            existingProperties = referentialReferenceSetsByPropertyName.keySet();
    
    136
    +        } else {
    
    137
    +            existingProperties = Collections.emptySet();
    
    134 138
             }
    
    135 139
             log.debug("Update referential reference sets for: " + dtoType);
    
    136 140
             // mettre à jour le cache de référentiel
    
    ... ... @@ -138,6 +142,10 @@ public class ReferencesCache {
    138 142
             // calculer les listes de référentiels à utiliser dans le modèle
    
    139 143
             for (Map.Entry<String, ReferentialDtoReferenceDefinition<?, ?>> entry : formDefinition.getProperties().entrySet()) {
    
    140 144
                 String propertyName = entry.getKey();
    
    145
    +            if (existingProperties.contains(propertyName)) {
    
    146
    +                // already in cache
    
    147
    +                continue;
    
    148
    +            }
    
    141 149
                 ReferentialDtoReferenceDefinition definition = entry.getValue();
    
    142 150
                 ReferentialDtoReferenceSet<?> referentialReferenceSet = referentialReferenceSetsByType.get(definition.getType());
    
    143 151
                 ReferentialDtoReferenceSet<?> filteredReferentialReferenceSet = filterReferentialReferenceSet(propertyName, definition, referentialReferenceSet);
    

  • client/datasource/editor/ll/src/main/java/fr/ird/observe/client/datasource/editor/ll/data/observation/SetDetailCompositionUI.jaxx
    ... ... @@ -63,9 +63,9 @@
    63 63
       <BasketTableModel id='basketsTableModel' initializer="getStates().getBasketsTableModel()"/>
    
    64 64
       <BranchlineTableModel id='branchlinesTableModel' initializer="getStates().getBranchlinesTableModel()"/>
    
    65 65
     
    
    66
    -  <BeanValidator id='validator' autoField='true'
    
    67
    -                 beanClass='fr.ird.observe.dto.data.ll.observation.SetDetailCompositionDto'
    
    68
    -                 errorTableModel='{getErrorTableModel()}' context='update-detailComposition'>
    
    66
    +  <BeanValidator id='validator' beanClass='fr.ird.observe.dto.data.ll.observation.SetDetailCompositionDto'
    
    67
    +                 errorTableModel='{getErrorTableModel()}' context='update'>
    
    68
    +    <field name='comment' component='contentBody'/>
    
    69 69
       </BeanValidator>
    
    70 70
     
    
    71 71
       <BeanValidator id='generateValidator'
    
    ... ... @@ -88,9 +88,13 @@
    88 88
     
    
    89 89
       <BeanValidator id='branchlineValidator' beanClass='fr.ird.observe.dto.data.ll.observation.BranchlineDto'
    
    90 90
                      errorTableModel='{getErrorTableModel()}' context='update'>
    
    91
    -    <field name='settingIdentifier' component='branchlinesPane'/>
    
    92
    -    <field name='tracelineLength' component='branchlinesPane'/>
    
    93
    -    <field name='branchlineLength' component='branchlinesPane'/>
    
    91
    +    <field name='settingIdentifier' component='branchlinesTable'/>
    
    92
    +    <field name='tracelineLength' component='branchlinesTable'/>
    
    93
    +    <field name='branchlineLength' component='branchlinesTable'/>
    
    94
    +  </BeanValidator>
    
    95
    +
    
    96
    +  <BeanValidator id='branchlineDetailValidator' autoField="true" beanClass='fr.ird.observe.dto.data.ll.observation.BranchlineDto'
    
    97
    +                 errorTableModel='{getErrorTableModel()}' context='update'>
    
    94 98
       </BeanValidator>
    
    95 99
     
    
    96 100
       <JPopupMenu id='sectionTemplatesPopup'>
    
    ... ... @@ -326,7 +330,7 @@
    326 330
                   </cell>
    
    327 331
                 </row>
    
    328 332
                 <row>
    
    329
    -              <cell>
    
    333
    +              <cell weighty="1" fill="both">
    
    330 334
                     <BigTextEditor id="comment"/>
    
    331 335
                   </cell>
    
    332 336
                 </row>
    

  • client/datasource/editor/ll/src/main/java/fr/ird/observe/client/datasource/editor/ll/data/observation/SetDetailCompositionUI.jcss
    ... ... @@ -25,7 +25,7 @@
    25 25
       valid:{states.isCompositionTabValid() && states.isBranchlineDetailTabValid()};
    
    26 26
       generateTabValid: {!states.isCanGenerate() || sectionTemplatesTableModel.isValid()};
    
    27 27
       compositionTabValid: {sectionsTableModel.isValid() && basketsTableModel.isValid() && branchlinesTableModel.isValid()};
    
    28
    -  branchlineDetailTabValid: {branchlineValidator.isValid()};
    
    28
    +  branchlineDetailTabValid: {branchlineDetailValidator.isValid()};
    
    29 29
     }
    
    30 30
     
    
    31 31
     #mainTabbedPane {
    
    ... ... @@ -117,7 +117,7 @@
    117 117
     /* ***************************************************************************** */
    
    118 118
     
    
    119 119
     #branchlineTab {
    
    120
    -  enabled: {compositionTab.isEnabled() && states.isCompositionTabValid() && !branchlinesTableModel.isSelectionEmpty()};
    
    120
    +  enabled: {compositionTab.isEnabled() && states.isCompositionTabValid() && branchlinesTableModel.getSelectedRowIndex() != -1};
    
    121 121
     }
    
    122 122
     
    
    123 123
     #noBranchlineSelected {
    
    ... ... @@ -146,9 +146,9 @@
    146 146
     }
    
    147 147
     
    
    148 148
     #resetBranchline {
    
    149
    -  enabled:{branchlineValidator.isChanged()};
    
    149
    +  enabled:{branchlineDetailValidator.isChanged()};
    
    150 150
     }
    
    151 151
     
    
    152 152
     #saveBranchline {
    
    153
    -  enabled:{branchlineValidator.isChanged() && branchlineValidator.isValid()};
    
    153
    +  enabled:{branchlineDetailValidator.isChanged() && branchlineDetailValidator.isValid()};
    
    154 154
     }

  • client/datasource/editor/ll/src/main/java/fr/ird/observe/client/datasource/editor/ll/data/observation/SetDetailCompositionUIHandler.java
    ... ... @@ -105,11 +105,12 @@ public class SetDetailCompositionUIHandler extends GeneratedSetDetailComposition
    105 105
             ResetAction.installAction(ui, ui.getReset(), new DefaultResetAdapter<>() {
    
    106 106
                 @Override
    
    107 107
                 public void onUpdate(SetDetailCompositionUI ui) {
    
    108
    -                BranchlineDto branchline = ui.getBranchlinesTableModel().getSelectedRow();
    
    108
    +//                BranchlineDto branchline = ui.getBranchlinesTableModel().getSelectedRow();
    
    109
    +                onBranchlineChanged(null);
    
    110
    +                ui.getSectionsTableModel().clear();
    
    111
    +                ui.getBasketsTableModel().clear();
    
    112
    +                ui.getBranchlinesTableModel().clear();
    
    109 113
                     super.onUpdate(ui);
    
    110
    -                if (branchline != null) {
    
    111
    -                    onBranchlineChanged(branchline);
    
    112
    -                }
    
    113 114
                 }
    
    114 115
             });
    
    115 116
             ResetAction<SetDetailCompositionUI> action = ResetAction.prepareAction(new DefaultResetAdapter<>() {
    
    ... ... @@ -145,7 +146,9 @@ public class SetDetailCompositionUIHandler extends GeneratedSetDetailComposition
    145 146
             model.getStates().getSectionTemplatesTableModel().setData(new ArrayList<>());
    
    146 147
     
    
    147 148
             BranchlineDto selectedRow = model.getStates().getBranchlinesTableModel().getSelectedRow();
    
    148
    -        onBranchlineChanged(selectedRow);
    
    149
    +        if (ui.getMainTabbedPane().getSelectedIndex() == 2) {
    
    150
    +            onBranchlineChanged(selectedRow);
    
    151
    +        }
    
    149 152
         }
    
    150 153
     
    
    151 154
         @Override
    
    ... ... @@ -171,6 +174,9 @@ public class SetDetailCompositionUIHandler extends GeneratedSetDetailComposition
    171 174
         public void onInstallValidators(IdDto editBean) {
    
    172 175
             super.onInstallValidators(editBean);
    
    173 176
             ui.getGenerateValidator().setBean(getModel().getStates());
    
    177
    +        if (ui.getMainTabbedPane().getSelectedIndex() == 2 && getModel().getStates().getBranchlinesTableModel().getSelectedRow() != null) {
    
    178
    +            ui.getBranchlineDetailValidator().setBean(ui.getBranchlineBean());
    
    179
    +        }
    
    174 180
         }
    
    175 181
     
    
    176 182
         @Override
    
    ... ... @@ -280,7 +286,7 @@ public class SetDetailCompositionUIHandler extends GeneratedSetDetailComposition
    280 286
         }
    
    281 287
     
    
    282 288
         public void onBranchlineChanged(BranchlineDto newValue) {
    
    283
    -        boolean changed = ui.getValidator().isChanged();
    
    289
    +        boolean changed = ui.getValidator().isChanged() || ui.getModel().getStates().isModified();
    
    284 290
     
    
    285 291
             String oldId = null;
    
    286 292
             BranchlineDto branchlineBean = ui.getModel().getStates().getBranchlineBean();
    
    ... ... @@ -296,8 +302,7 @@ public class SetDetailCompositionUIHandler extends GeneratedSetDetailComposition
    296 302
                 return;
    
    297 303
             }
    
    298 304
     
    
    299
    -        SwingValidator<BranchlineDto> branchlineValidator = ui.getBranchlineValidator();
    
    300
    -        SetDetailCompositionUIModel model = getModel();
    
    305
    +        SwingValidator<BranchlineDto> branchlineValidator = ui.getBranchlineDetailValidator();
    
    301 306
             if (newValue == null) {
    
    302 307
                 log.info(String.format("%s Remove branchline", prefix));
    
    303 308
                 branchlineValidator.setBean(null);
    
    ... ... @@ -314,9 +319,9 @@ public class SetDetailCompositionUIHandler extends GeneratedSetDetailComposition
    314 319
     
    
    315 320
         void updateBranchlineAccessibility(boolean withBranchline) {
    
    316 321
             if (withBranchline) {
    
    317
    -            ui.getMainTabbedPane().setComponentAt(5, ui.getBranchlinePanel());
    
    322
    +            ui.getMainTabbedPane().setComponentAt(2, ui.getBranchlinePanel());
    
    318 323
             } else {
    
    319
    -            ui.getMainTabbedPane().setComponentAt(5, ui.getNoBranchlineForm());
    
    324
    +            ui.getMainTabbedPane().setComponentAt(2, ui.getNoBranchlineForm());
    
    320 325
             }
    
    321 326
         }
    
    322 327
     
    
    ... ... @@ -324,7 +329,7 @@ public class SetDetailCompositionUIHandler extends GeneratedSetDetailComposition
    324 329
             boolean canContinue;
    
    325 330
             SetDetailCompositionUIModel model = getModel();
    
    326 331
             SetDetailCompositionUIModelStates states = model.getStates();
    
    327
    -        if (states.isEditing() && ui.getBranchlineValidator().isChanged()) {
    
    332
    +        if (states.isEditing() && ui.getBranchlineDetailValidator().isChanged()) {
    
    328 333
                 canContinue = false;
    
    329 334
                 if (states.isBranchlineDetailTabValid()) {
    
    330 335
                     // le formulaire est valide, on demande a l'utilisateur s'il
    
    ... ... @@ -384,8 +389,9 @@ public class SetDetailCompositionUIHandler extends GeneratedSetDetailComposition
    384 389
         public void doSaveBranchline() {
    
    385 390
             BranchlineDto beanToSave = ui.getModel().getStates().getBranchlineBean();
    
    386 391
             beanToSave.copy(ui.getModel().getStates().getBranchlinesTableModel().getSelectedRow());
    
    387
    -        ui.getBranchlineValidator().setChanged(false);
    
    388
    -        ui.getBranchlineValidator().setValid(true);
    
    392
    +        ui.getBranchlineDetailValidator().setChanged(false);
    
    393
    +        ui.getBranchlineDetailValidator().setValid(true);
    
    394
    +        ui.getValidator().setChanged(true);
    
    389 395
         }
    
    390 396
     
    
    391 397
         void onTimerChanged(Boolean newValue) {
    

  • client/datasource/editor/ll/src/main/java/fr/ird/observe/client/datasource/editor/ll/data/observation/composition/SetDetailCompositionUIValidationHelper.java
    ... ... @@ -35,6 +35,7 @@ import org.apache.logging.log4j.LogManager;
    35 35
     import org.apache.logging.log4j.Logger;
    
    36 36
     import org.nuiton.jaxx.validator.swing.SwingValidator;
    
    37 37
     import org.nuiton.jaxx.validator.swing.SwingValidatorMessage;
    
    38
    +import org.nuiton.validator.NuitonValidatorScope;
    
    38 39
     import org.nuiton.validator.bean.simple.SimpleBeanValidator;
    
    39 40
     
    
    40 41
     import javax.swing.JComponent;
    
    ... ... @@ -79,7 +80,8 @@ public class SetDetailCompositionUIValidationHelper {
    79 80
                 List<SwingValidatorMessage> messages = validatorService.validateSections(notEmptyData);
    
    80 81
                 removeOldMessages();
    
    81 82
                 errorTableModel.addMessages(messages);
    
    82
    -            model.getStates().setCompositionTabValid(messages.isEmpty());
    
    83
    +            long errorMessagesCount = messages.stream().filter(m -> m.getScope() == NuitonValidatorScope.ERROR).count();
    
    84
    +            model.getStates().setCompositionTabValid(errorMessagesCount == 0);
    
    83 85
             }
    
    84 86
         }
    
    85 87
     
    
    ... ... @@ -90,7 +92,8 @@ public class SetDetailCompositionUIValidationHelper {
    90 92
                 List<SwingValidatorMessage> messages = validatorService.validateSections(notEmptyData);
    
    91 93
                 removeOldMessages();
    
    92 94
                 errorTableModel.addMessages(messages);
    
    93
    -            model.getStates().setCompositionTabValid(messages.isEmpty());
    
    95
    +            long errorMessagesCount = messages.stream().filter(m -> m.getScope() == NuitonValidatorScope.ERROR).count();
    
    96
    +            model.getStates().setCompositionTabValid(errorMessagesCount == 0);
    
    94 97
             }
    
    95 98
         }
    
    96 99
     
    
    ... ... @@ -101,7 +104,8 @@ public class SetDetailCompositionUIValidationHelper {
    101 104
                 List<SwingValidatorMessage> messages = validatorService.validateSections(notEmptyData);
    
    102 105
                 removeOldMessages();
    
    103 106
                 errorTableModel.addMessages(messages);
    
    104
    -            model.getStates().setCompositionTabValid(messages.isEmpty());
    
    107
    +            long errorMessagesCount = messages.stream().filter(m -> m.getScope() == NuitonValidatorScope.ERROR).count();
    
    108
    +            model.getStates().setCompositionTabValid(errorMessagesCount == 0);
    
    105 109
             }
    
    106 110
         }
    
    107 111