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

Commits:

5 changed files:

Changes:

  • client-core/src/main/java/fr/ird/observe/client/ui/content/data/ps/observation/FloatingObjectUIHandler.java
    ... ... @@ -209,6 +209,6 @@ public class FloatingObjectUIHandler extends ContentEditUIHandler<FloatingObject
    209 209
                 getModel().setLeaving(operation.isWhenLeaving());
    
    210 210
             }
    
    211 211
             FloatingObjectPartsTreeTableModel treeModel = getUi().getTable().getTreeTableModel();
    
    212
    -        treeModel.reset();
    
    212
    +        treeModel.reset(true);
    
    213 213
         }
    
    214 214
     }

  • client-core/src/main/java/fr/ird/observe/client/ui/content/data/ps/observation/FloatingObjectUIModel.java
    ... ... @@ -159,6 +159,16 @@ public class FloatingObjectUIModel extends ContentEditUIModel<FloatingObjectDto,
    159 159
             whenLeaving.put(dto, value);
    
    160 160
         }
    
    161 161
     
    
    162
    +    public Object getWhenArriving(String id) {
    
    163
    +        ObjectMaterialDto dto = Objects.requireNonNull(referentialMap.get(id));
    
    164
    +        return whenArriving.get(dto);
    
    165
    +    }
    
    166
    +
    
    167
    +    public Object getWhenLeaving(String id) {
    
    168
    +        ObjectMaterialDto dto = Objects.requireNonNull(referentialMap.get(id));
    
    169
    +        return whenLeaving.get(dto);
    
    170
    +    }
    
    171
    +
    
    162 172
         public Optional<FloatingObjectPreset> getReference() {
    
    163 173
             return Optional.ofNullable(reference);
    
    164 174
         }
    

  • client-core/src/main/java/fr/ird/observe/client/ui/content/data/ps/observation/dcp/FloatingObjectPartsTreeNode.java
    ... ... @@ -73,7 +73,7 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im
    73 73
         }
    
    74 74
     
    
    75 75
         boolean isNotValid() {
    
    76
    -        return !(getUserObject().validWhenArriving && getUserObject().validWhenLeaving);
    
    76
    +        return !(isValid(1) && isValid(2));
    
    77 77
         }
    
    78 78
     
    
    79 79
         @Override
    
    ... ... @@ -153,6 +153,10 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im
    153 153
             return getUserObject().dto.isFloat();
    
    154 154
         }
    
    155 155
     
    
    156
    +    public boolean withValidation() {
    
    157
    +        return getUserObject().dto.withValidation();
    
    158
    +    }
    
    159
    +
    
    156 160
         ObjectMaterialTypeReference getObjectMaterialType() {
    
    157 161
             return getUserObject().dto.getObjectMaterialType();
    
    158 162
         }
    
    ... ... @@ -304,6 +308,10 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im
    304 308
             return dto != null && !dto.isChildrenMultiSelectable() && !isLeaf();
    
    305 309
         }
    
    306 310
     
    
    311
    +    public void computeValidationValidState() {
    
    312
    +        getUserObject().computeValidationValidState();
    
    313
    +    }
    
    314
    +
    
    307 315
         //TODO Improve the design, we should not store anything in uiModel and separate leaving and arriving data
    
    308 316
         private static class FloatingObjectPartsTreeNodeContext {
    
    309 317
     
    
    ... ... @@ -344,8 +352,6 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im
    344 352
                 this.editable = false;
    
    345 353
                 this.exclusive = false;
    
    346 354
                 this.useValidation = false;
    
    347
    -            this.valueValidOnArriving = true;
    
    348
    -            this.valueValidOnLeaving = true;
    
    349 355
                 this.referentialLocale = ObserveSwingApplicationContext.get().getDecoratorService().getReferentialLocale();
    
    350 356
             }
    
    351 357
     
    
    ... ... @@ -357,10 +363,6 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im
    357 363
                 // editable if dto is selectable (we also make sure that the object material type is here too)
    
    358 364
                 this.editable = dto.getObjectMaterialType() != null;
    
    359 365
                 this.useValidation = enabled && editable && dto.withValidation();
    
    360
    -            if (!useValidation) {
    
    361
    -                valueValidOnArriving = true;
    
    362
    -                valueValidOnLeaving = true;
    
    363
    -            }
    
    364 366
                 // exclusive if his parent requires it
    
    365 367
                 this.exclusive = parent.dto != null && !parent.dto.isChildrenMultiSelectable();
    
    366 368
                 this.referentialLocale = ObserveSwingApplicationContext.get().getDecoratorService().getReferentialLocale();
    
    ... ... @@ -411,9 +413,9 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im
    411 413
             boolean isValid(int column) {
    
    412 414
                 switch (column) {
    
    413 415
                     case 1: // when arriving
    
    414
    -                    return validWhenArriving;
    
    416
    +                    return validWhenArriving && (!useValidation || valueValidOnArriving);
    
    415 417
                     case 2: // when leaving
    
    416
    -                    return validWhenLeaving;
    
    418
    +                    return validWhenLeaving && (!useValidation || valueValidOnLeaving);
    
    417 419
                 }
    
    418 420
                 throw new IllegalStateException();
    
    419 421
             }
    
    ... ... @@ -429,5 +431,15 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im
    429 431
                 return text;
    
    430 432
             }
    
    431 433
     
    
    434
    +        public void computeValidationValidState() {
    
    435
    +            if (uiModel.isArriving()) {
    
    436
    +                Object value = uiModel.getWhenArriving(dto.getId());
    
    437
    +                valueValidOnArriving = dto.isValid(value);
    
    438
    +            }
    
    439
    +            if (uiModel.isLeaving()) {
    
    440
    +                Object value = uiModel.getWhenLeaving(dto.getId());
    
    441
    +                valueValidOnLeaving = dto.isValid(value);
    
    442
    +            }
    
    443
    +        }
    
    432 444
         }
    
    433 445
     }

  • client-core/src/main/java/fr/ird/observe/client/ui/content/data/ps/observation/dcp/FloatingObjectPartsTreeTable.java
    ... ... @@ -83,7 +83,7 @@ public class FloatingObjectPartsTreeTable extends JXTreeTable {
    83 83
             }
    
    84 84
     
    
    85 85
             FloatingObjectPartsTreeTableModel treeTableModel = getTreeTableModel();
    
    86
    -        treeTableModel.reset();
    
    86
    +        treeTableModel.reset(true);
    
    87 87
     
    
    88 88
             if (expandTree) {
    
    89 89
                 expandAll();
    

  • client-core/src/main/java/fr/ird/observe/client/ui/content/data/ps/observation/dcp/FloatingObjectPartsTreeTableModel.java
    ... ... @@ -50,6 +50,7 @@ public class FloatingObjectPartsTreeTableModel extends DefaultTreeTableModel {
    50 50
         private ImmutableSet<FloatingObjectPartsTreeNode> allNodes;
    
    51 51
         private ImmutableSet<FloatingObjectPartsTreeNode> needOneSelectionNodes;
    
    52 52
         private ImmutableSet<FloatingObjectPartsTreeNode> mandatoryNodes;
    
    53
    +    private ImmutableSet<FloatingObjectPartsTreeNode> validationNodes;
    
    53 54
         private boolean adjusting;
    
    54 55
     
    
    55 56
         public FloatingObjectPartsTreeTableModel(FloatingObjectUIModel uiModel) {
    
    ... ... @@ -73,6 +74,7 @@ public class FloatingObjectPartsTreeTableModel extends DefaultTreeTableModel {
    73 74
     
    
    74 75
             ImmutableSet.Builder<FloatingObjectPartsTreeNode> needOneSelectionNodesBuilder = ImmutableSet.builder();
    
    75 76
             ImmutableSet.Builder<FloatingObjectPartsTreeNode> mandatoryNodesBuilder = ImmutableSet.builder();
    
    77
    +        ImmutableSet.Builder<FloatingObjectPartsTreeNode> validationNodesBuilder = ImmutableSet.builder();
    
    76 78
     
    
    77 79
             for (FloatingObjectPartsTreeNode node : allNodes) {
    
    78 80
                 if (!node.isEnabled()) {
    
    ... ... @@ -83,9 +85,13 @@ public class FloatingObjectPartsTreeTableModel extends DefaultTreeTableModel {
    83 85
                 if (node.withMandatoryConstraintsOnChildren()) {
    
    84 86
                     needOneSelectionNodesBuilder.add(node);
    
    85 87
                 }
    
    88
    +            if (node.withValidation()) {
    
    89
    +                validationNodesBuilder.add(node);
    
    90
    +            }
    
    86 91
             }
    
    87 92
             needOneSelectionNodes = needOneSelectionNodesBuilder.build();
    
    88 93
             mandatoryNodes = mandatoryNodesBuilder.build();
    
    94
    +        validationNodes = validationNodesBuilder.build();
    
    89 95
         }
    
    90 96
     
    
    91 97
         public void rebuildRootNode(ObjectMaterialHierarchyDto materials) {
    
    ... ... @@ -120,12 +126,15 @@ public class FloatingObjectPartsTreeTableModel extends DefaultTreeTableModel {
    120 126
             if (adjusting) {
    
    121 127
                 return;
    
    122 128
             }
    
    123
    -        reset();
    
    129
    +        reset(false);
    
    124 130
             uiModel.setModified(true);
    
    125 131
         }
    
    126 132
     
    
    127
    -    public void reset() {
    
    133
    +    public void reset(boolean computeValidation) {
    
    128 134
             allNodes.forEach(FloatingObjectPartsTreeNode::resetStates);
    
    135
    +        if (computeValidation) {
    
    136
    +            validationNodes.forEach(FloatingObjectPartsTreeNode::computeValidationValidState);
    
    137
    +        }
    
    129 138
     
    
    130 139
             boolean whenArriving = uiModel.isArriving();
    
    131 140
             boolean whenLeaving = uiModel.isLeaving();
    
    ... ... @@ -144,7 +153,7 @@ public class FloatingObjectPartsTreeTableModel extends DefaultTreeTableModel {
    144 153
         public void setAdjusting(boolean adjusting) {
    
    145 154
             this.adjusting = adjusting;
    
    146 155
             if (!adjusting) {
    
    147
    -            reset();
    
    156
    +            reset(false);
    
    148 157
                 uiModel.setModified(true);
    
    149 158
             }
    
    150 159
         }