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

Commits:

9 changed files:

Changes:

  • client-configuration/src/main/config/Client.ini
    ... ... @@ -608,6 +608,12 @@ key = ui.dcp.error.color
    608 608
     type = color
    
    609 609
     defaultValue = java.awt.Color[r=255,g=100,b=100]
    
    610 610
     
    
    611
    +[option floatingObjectMaterialNotEditableColor]
    
    612
    +description = observe.config.ui.dcp.not.editable.color
    
    613
    +key = ui.dcp.not.editable.color
    
    614
    +type = color
    
    615
    +defaultValue = java.awt.Color[r=193,g=250,b=250]
    
    616
    +
    
    611 617
     [option showMnemonic]
    
    612 618
     description = observe.config.ui.showMnemonic
    
    613 619
     key = ui.showMnemonic
    

  • client-configuration/src/main/i18n/getters/config.getter
    ... ... @@ -91,6 +91,7 @@ observe.config.temperature.format
    91 91
     observe.config.ui.autoPopupNumberEditor
    
    92 92
     observe.config.ui.changeSynchroSrc
    
    93 93
     observe.config.ui.dcp.error.color
    
    94
    +observe.config.ui.dcp.not.editable.color
    
    94 95
     observe.config.ui.focusBorderColor
    
    95 96
     observe.config.ui.fullscreen
    
    96 97
     observe.config.ui.loadLocalStorage
    

  • client-core/src/main/java/fr/ird/observe/client/ui/content/data/ps/observation/dcp/FloatingObjectPartsTableCellRenderer.java
    ... ... @@ -60,7 +60,7 @@ public class FloatingObjectPartsTableCellRenderer implements TableCellRenderer {
    60 60
             Objects.requireNonNull(node);
    
    61 61
             TableCellRenderer renderer = objectRenderer;
    
    62 62
             Object newValue = value;
    
    63
    -        boolean enabled = node.isEditable() && table.isCellEditable(row, column) && node.isEnabled();
    
    63
    +        boolean enabled = node.isEditable() && table.isCellEditable(row, column) && node.isEnabled(column);
    
    64 64
             if (node.isBoolean()) {
    
    65 65
                 if (node.isColumnEditable(column)) {
    
    66 66
                     newValue = value == null ? null : Boolean.valueOf(String.valueOf(value));
    

  • client-core/src/main/java/fr/ird/observe/client/ui/content/data/ps/observation/dcp/FloatingObjectPartsTreeNode.java
    ... ... @@ -98,10 +98,10 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im
    98 98
     
    
    99 99
         @Override
    
    100 100
         public boolean isEditable(int column) {
    
    101
    -        return column > 0 && getUserObject().enabled && getUserObject().editable && isColumnEditable(column);
    
    101
    +        return column > 0 && isEnabled(column) && getUserObject().editable && isColumnEditable(column);
    
    102 102
         }
    
    103 103
     
    
    104
    -    public boolean isColumnEditable(int column) {
    
    104
    +    boolean isColumnEditable(int column) {
    
    105 105
             return getUserObject().isColumnEditable(column);
    
    106 106
         }
    
    107 107
     
    
    ... ... @@ -132,6 +132,17 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im
    132 132
         public boolean isEnabled() {
    
    133 133
             return getUserObject().enabled;
    
    134 134
         }
    
    135
    +    public boolean isEnabled(int column) {
    
    136
    +        boolean result = getUserObject().enabled;
    
    137
    +        if (result) {
    
    138
    +            if (column==1) {
    
    139
    +                result = isRealEnabledOnArriving();
    
    140
    +            } else if (column==2) {
    
    141
    +                result = isRealEnabledOnLeaving();
    
    142
    +            }
    
    143
    +        }
    
    144
    +        return result;
    
    145
    +    }
    
    135 146
     
    
    136 147
         public String getId() {
    
    137 148
             return getUserObject().dto.getId();
    
    ... ... @@ -178,6 +189,38 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im
    178 189
             return (FloatingObjectPartsTreeNode) super.getParent();
    
    179 190
         }
    
    180 191
     
    
    192
    +    boolean isRealEnabledOnArriving() {
    
    193
    +        return getUserObject().isRealEnabledOnArriving();
    
    194
    +    }
    
    195
    +
    
    196
    +    boolean isRealEnabledOnLeaving() {
    
    197
    +        return getUserObject().isRealEnabledOnLeaving();
    
    198
    +    }
    
    199
    +
    
    200
    +    void setRealEnabledOnArriving(boolean realEnabled) {
    
    201
    +        FloatingObjectPartsTreeNode parent = getParent();
    
    202
    +        if (parent != null) {
    
    203
    +            if (realEnabled) {
    
    204
    +                parent.getUserObject().decSelectedChildCountOnArriving();
    
    205
    +            } else {
    
    206
    +                parent.getUserObject().incSelectedChildCountOnArriving();
    
    207
    +            }
    
    208
    +            parent.setRealEnabledOnArriving(realEnabled);
    
    209
    +        }
    
    210
    +    }
    
    211
    +
    
    212
    +    void setRealEnabledOnLeaving(boolean realEnabled) {
    
    213
    +        FloatingObjectPartsTreeNode parent = getParent();
    
    214
    +        if (parent != null) {
    
    215
    +            if (realEnabled) {
    
    216
    +                parent.getUserObject().decSelectedChildCountOnLeaving();
    
    217
    +            } else {
    
    218
    +                parent.getUserObject().incSelectedChildCountOnLeaving();
    
    219
    +            }
    
    220
    +            parent.setRealEnabledOnLeaving(realEnabled);
    
    221
    +        }
    
    222
    +    }
    
    223
    +
    
    181 224
         ImmutableSet<FloatingObjectPartsTreeNode> getShell() {
    
    182 225
     
    
    183 226
             ImmutableSet.Builder<FloatingObjectPartsTreeNode> allNodesBuilder = ImmutableSet.builder();
    
    ... ... @@ -192,7 +235,7 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im
    192 235
             }
    
    193 236
         }
    
    194 237
     
    
    195
    -    boolean withMandatoryConstraintsOnChildren() {
    
    238
    +    public boolean withMandatoryConstraintsOnChildren() {
    
    196 239
             ObjectMaterialHierarchyDto userObject = getUserObject().dto;
    
    197 240
             return userObject == null || userObject.isChildSelectionMandatory();
    
    198 241
         }
    
    ... ... @@ -212,18 +255,6 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im
    212 255
     
    
    213 256
         }
    
    214 257
     
    
    215
    -    private FloatingObjectPartsTreeNode getFirstAncestorNeedOneSelection(int column) {
    
    216
    -        if (withMandatoryConstraintsOnChildren()) {
    
    217
    -            if (parent == null) {
    
    218
    -                return this;
    
    219
    -            }
    
    220
    -            if (withValue(column)) {
    
    221
    -                return this;
    
    222
    -            }
    
    223
    -        }
    
    224
    -        return getParent().getFirstAncestorNeedOneSelection(column);
    
    225
    -    }
    
    226
    -
    
    227 258
         void computeMandatoryValidState(boolean whenArriving, boolean whenLeaving) {
    
    228 259
             FloatingObjectPartsTreeNodeContext userObject = getUserObject();
    
    229 260
             FloatingObjectPartsTreeNode parent = getParent();
    
    ... ... @@ -247,19 +278,26 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im
    247 278
             }
    
    248 279
         }
    
    249 280
     
    
    250
    -//    void computeFormulaValidState(boolean whenArriving, boolean whenLeaving) {
    
    251
    -//        FloatingObjectPartsTreeNodeContext userObject = getUserObject();
    
    252
    -//        ObjectMaterialHierarchyDto dto = Objects.requireNonNull(userObject.dto);
    
    253
    -//        if (whenArriving && userObject.validWhenArriving) {
    
    254
    -//            Object value = userObject.getValueAt(1);
    
    255
    -//            userObject.validWhenArriving = dto.isValid(value);
    
    256
    -//        }
    
    257
    -//        if (whenLeaving && userObject.validWhenLeaving) {
    
    258
    -//            Object value = userObject.getValueAt(2);
    
    259
    -//            userObject.validWhenLeaving = dto.isValid(value);
    
    260
    -//        }
    
    261
    -//
    
    262
    -//    }
    
    281
    +    void computeValidationValidState() {
    
    282
    +        getUserObject().computeValidationValidState();
    
    283
    +    }
    
    284
    +
    
    285
    +    void resetRealEnabled() {
    
    286
    +        getUserObject().selectedChildCountOnArriving = 0;
    
    287
    +        getUserObject().selectedChildCountOnLeaving = 0;
    
    288
    +    }
    
    289
    +
    
    290
    +    private FloatingObjectPartsTreeNode getFirstAncestorNeedOneSelection(int column) {
    
    291
    +        if (withMandatoryConstraintsOnChildren()) {
    
    292
    +            if (parent == null) {
    
    293
    +                return this;
    
    294
    +            }
    
    295
    +            if (withValue(column)) {
    
    296
    +                return this;
    
    297
    +            }
    
    298
    +        }
    
    299
    +        return getParent().getFirstAncestorNeedOneSelection(column);
    
    300
    +    }
    
    263 301
     
    
    264 302
         private void setCompanions(ImmutableSet.Builder<FloatingObjectPartsTreeNode> companionsBuilder) {
    
    265 303
             if (companionsBuilder != null) {
    
    ... ... @@ -308,10 +346,6 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im
    308 346
             return dto != null && !dto.isChildrenMultiSelectable() && !isLeaf();
    
    309 347
         }
    
    310 348
     
    
    311
    -    public void computeValidationValidState() {
    
    312
    -        getUserObject().computeValidationValidState();
    
    313
    -    }
    
    314
    -
    
    315 349
         //TODO Improve the design, we should not store anything in uiModel and separate leaving and arriving data
    
    316 350
         private static class FloatingObjectPartsTreeNodeContext {
    
    317 351
     
    
    ... ... @@ -319,7 +353,7 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im
    319 353
             private final FloatingObjectUIModel uiModel;
    
    320 354
             // dto (null for root)
    
    321 355
             private final ObjectMaterialHierarchyDto dto;
    
    322
    -        // Is the node is enabled (hierarchic value) ?
    
    356
    +        // Is the node is enabled (from hierarchic value) ?
    
    323 357
             private final boolean enabled;
    
    324 358
             // Is this node editable ?
    
    325 359
             private final boolean editable;
    
    ... ... @@ -327,6 +361,7 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im
    327 361
             private final boolean exclusive;
    
    328 362
             // Is the node use validation on his value ?
    
    329 363
             private final boolean useValidation;
    
    364
    +        // Referential locale to decorate
    
    330 365
             private final ReferentialLocale referentialLocale;
    
    331 366
             // Is this node (on arriving) need at least one child selected ? (if editable then node must be selected)
    
    332 367
             private boolean needOneSelectionOnLeaving;
    
    ... ... @@ -344,6 +379,9 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im
    344 379
             private ImmutableSet<FloatingObjectPartsTreeNode> companions;
    
    345 380
             // Internal to store debug node text
    
    346 381
             private String text;
    
    382
    +        // Count of children selected (if none is selected then the node can be edited (from GUI if a child is selected then any parent node is not enabled) ?
    
    383
    +        private int selectedChildCountOnArriving = 0;
    
    384
    +        private int selectedChildCountOnLeaving = 0;
    
    347 385
     
    
    348 386
             FloatingObjectPartsTreeNodeContext(FloatingObjectUIModel uiModel) {
    
    349 387
                 this.uiModel = Objects.requireNonNull(uiModel);
    
    ... ... @@ -431,7 +469,7 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im
    431 469
                 return text;
    
    432 470
             }
    
    433 471
     
    
    434
    -        public void computeValidationValidState() {
    
    472
    +        void computeValidationValidState() {
    
    435 473
                 if (uiModel.isArriving()) {
    
    436 474
                     Object value = uiModel.getWhenArriving(dto.getId());
    
    437 475
                     valueValidOnArriving = dto.isValid(value);
    
    ... ... @@ -441,5 +479,29 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im
    441 479
                     valueValidOnLeaving = dto.isValid(value);
    
    442 480
                 }
    
    443 481
             }
    
    482
    +
    
    483
    +        boolean isRealEnabledOnArriving() {
    
    484
    +            return selectedChildCountOnArriving == 0;
    
    485
    +        }
    
    486
    +
    
    487
    +        void incSelectedChildCountOnArriving() {
    
    488
    +            this.selectedChildCountOnArriving++;
    
    489
    +        }
    
    490
    +
    
    491
    +        void decSelectedChildCountOnArriving() {
    
    492
    +            this.selectedChildCountOnArriving--;
    
    493
    +        }
    
    494
    +
    
    495
    +        boolean isRealEnabledOnLeaving() {
    
    496
    +            return selectedChildCountOnLeaving == 0;
    
    497
    +        }
    
    498
    +
    
    499
    +        void incSelectedChildCountOnLeaving() {
    
    500
    +            this.selectedChildCountOnLeaving++;
    
    501
    +        }
    
    502
    +
    
    503
    +        void decSelectedChildCountOnLeaving() {
    
    504
    +            this.selectedChildCountOnLeaving--;
    
    505
    +        }
    
    444 506
         }
    
    445 507
     }

  • client-core/src/main/java/fr/ird/observe/client/ui/content/data/ps/observation/dcp/FloatingObjectPartsTreeTable.java
    ... ... @@ -83,6 +83,7 @@ public class FloatingObjectPartsTreeTable extends JXTreeTable {
    83 83
     
    
    84 84
             FloatingObjectPartsTreeTableModel treeTableModel = getTreeTableModel();
    
    85 85
             treeTableModel.reset(true);
    
    86
    +        treeTableModel.computeRealEnabledState();
    
    86 87
     
    
    87 88
             if (expandTree) {
    
    88 89
                 expandAll();
    
    ... ... @@ -172,6 +173,24 @@ public class FloatingObjectPartsTreeTable extends JXTreeTable {
    172 173
                 return true;
    
    173 174
             }, ObserveSwingApplicationContext.get().getConfig().getFloatingObjectMaterialErrorColor(), Color.WHITE));
    
    174 175
     
    
    176
    +        addHighlighter(new ColorHighlighter((renderer, adapter) -> {
    
    177
    +            JXTreeTable component = (JXTreeTable) adapter.getComponent();
    
    178
    +            int row = adapter.convertRowIndexToModel(adapter.row);
    
    179
    +            FloatingObjectPartsTreeNode node = (FloatingObjectPartsTreeNode) component.getPathForRow(row).getLastPathComponent();
    
    180
    +            boolean realEnabled1 = node.isRealEnabledOnArriving();
    
    181
    +            boolean realEnabled2 = node.isRealEnabledOnLeaving();
    
    182
    +            boolean nodeEditable = node.isEditable();
    
    183
    +            switch (adapter.convertRowIndexToModel(adapter.column)) {
    
    184
    +                case 0:
    
    185
    +                    return false;
    
    186
    +                case 1:
    
    187
    +                    return model.isArriving() && nodeEditable && !realEnabled1;
    
    188
    +                case 2:
    
    189
    +                    return model.isLeaving() && nodeEditable && !realEnabled2;
    
    190
    +            }
    
    191
    +            return true;
    
    192
    +        }, ObserveSwingApplicationContext.get().getConfig().getFloatingObjectMaterialNotEditableColor(), Color.BLACK));
    
    193
    +
    
    175 194
             InputMap inputMap = getInputMap(WHEN_IN_FOCUSED_WINDOW);
    
    176 195
             ActionMap actionMap = getActionMap();
    
    177 196
             inputMap.put(ObserveKeyStrokes.KEY_STROKE_EXPAND_TREE_TABLE_NODE,"expandNode");
    

  • client-core/src/main/java/fr/ird/observe/client/ui/content/data/ps/observation/dcp/FloatingObjectPartsTreeTableModel.java
    ... ... @@ -24,6 +24,7 @@ package fr.ird.observe.client.ui.content.data.ps.observation.dcp;
    24 24
     
    
    25 25
     import com.google.common.collect.ImmutableSet;
    
    26 26
     import fr.ird.observe.client.ui.content.data.ps.observation.FloatingObjectUIModel;
    
    27
    +import fr.ird.observe.dto.IdDto;
    
    27 28
     import fr.ird.observe.dto.data.ps.observation.ObjectMaterialHierarchyDto;
    
    28 29
     import io.ultreia.java4all.i18n.I18n;
    
    29 30
     import org.apache.logging.log4j.LogManager;
    
    ... ... @@ -33,6 +34,8 @@ import org.jdesktop.swingx.treetable.TreeTableNode;
    33 34
     
    
    34 35
     import java.util.Arrays;
    
    35 36
     import java.util.Optional;
    
    37
    +import java.util.Set;
    
    38
    +import java.util.stream.Collectors;
    
    36 39
     
    
    37 40
     /**
    
    38 41
      * Created by tchemit on 05/08/17.
    
    ... ... @@ -81,7 +84,6 @@ public class FloatingObjectPartsTreeTableModel extends DefaultTreeTableModel {
    81 84
                     continue;
    
    82 85
                 }
    
    83 86
                 mandatoryNodesBuilder.add(node);
    
    84
    -
    
    85 87
                 if (node.withMandatoryConstraintsOnChildren()) {
    
    86 88
                     needOneSelectionNodesBuilder.add(node);
    
    87 89
                 }
    
    ... ... @@ -123,6 +125,13 @@ public class FloatingObjectPartsTreeTableModel extends DefaultTreeTableModel {
    123 125
             previousNode.ifPresent(p -> log.info("Previous selected node: " + p));
    
    124 126
             super.setValueAt(value, node, column);
    
    125 127
             previousNode.ifPresent(t -> super.setValueAt(null, t, column));
    
    128
    +        boolean realEnabled = !"true".equals(value);
    
    129
    +        log.info(String.format("Real enabled? %s", realEnabled));
    
    130
    +        if (column == 1) {
    
    131
    +            treeNode.setRealEnabledOnArriving(realEnabled);
    
    132
    +        } else if (column == 2) {
    
    133
    +            treeNode.setRealEnabledOnLeaving(realEnabled);
    
    134
    +        }
    
    126 135
             if (adjusting) {
    
    127 136
                 return;
    
    128 137
             }
    
    ... ... @@ -146,6 +155,20 @@ public class FloatingObjectPartsTreeTableModel extends DefaultTreeTableModel {
    146 155
             uiModel.getBean().setMaterialsValid(!notValid);
    
    147 156
         }
    
    148 157
     
    
    158
    +    public void computeRealEnabledState() {
    
    159
    +        Set<String> whenArriving = uiModel.getWhenArriving().keySet().stream().map(IdDto::getId).collect(Collectors.toSet());
    
    160
    +        Set<String> whenLeaving = uiModel.getWhenLeaving().keySet().stream().map(IdDto::getId).collect(Collectors.toSet());
    
    161
    +        allNodes.forEach(FloatingObjectPartsTreeNode::resetRealEnabled);
    
    162
    +        for (FloatingObjectPartsTreeNode node : allNodes) {
    
    163
    +            if (whenArriving.contains(node.getId())) {
    
    164
    +                node.setRealEnabledOnArriving(false);
    
    165
    +            }
    
    166
    +            if (whenLeaving.contains(node.getId())) {
    
    167
    +                node.setRealEnabledOnLeaving(false);
    
    168
    +            }
    
    169
    +        }
    
    170
    +    }
    
    171
    +
    
    149 172
         public boolean isAdjusting() {
    
    150 173
             return adjusting;
    
    151 174
         }
    

  • observe-i18n/src/main/i18n/translations/observe_en_GB.properties
    ... ... @@ -2706,6 +2706,7 @@ observe.config.temperature.format=Default temperature format
    2706 2706
     observe.config.ui.autoPopupNumberEditor=Flag sets to true when number editor show automaticly popup
    
    2707 2707
     observe.config.ui.changeSynchroSrc=Flag sets to true if you can change local source in admin tasks
    
    2708 2708
     observe.config.ui.dcp.error.color=Color to notify errors while validating floating object materials.
    
    2709
    +observe.config.ui.dcp.not.editable.color=Color to notify not editable floating object material nodes.
    
    2709 2710
     observe.config.ui.focusBorderColor=Color of the focus container border
    
    2710 2711
     observe.config.ui.fullscreen=Flag sets to true to lauch application in full screen mode
    
    2711 2712
     observe.config.ui.loadLocalStorage=Flag sets to true to load local data source when application starts
    

  • observe-i18n/src/main/i18n/translations/observe_es_ES.properties
    ... ... @@ -2706,6 +2706,7 @@ observe.config.temperature.format=Unidad de temperatura
    2706 2706
     observe.config.ui.autoPopupNumberEditor=Para mostrar automáticamente el editor numérico durante la edición de un número
    
    2707 2707
     observe.config.ui.changeSynchroSrc=Para autorizar la seleción de la base fuente durante las operaciones sobre la base
    
    2708 2708
     observe.config.ui.dcp.error.color=Color para notificar los errores sobre la composición de dcps
    
    2709
    +observe.config.ui.dcp.not.editable.color=Color to notify not editable floating object material nodes \#TODO
    
    2709 2710
     observe.config.ui.focusBorderColor=Color del borde de la zona que tiene el foco
    
    2710 2711
     observe.config.ui.fullscreen=Para mostrar la aplicación en modo pantalla completa
    
    2711 2712
     observe.config.ui.loadLocalStorage=Cargar la base local al iniciar la aplicación
    

  • observe-i18n/src/main/i18n/translations/observe_fr_FR.properties
    ... ... @@ -2706,6 +2706,7 @@ observe.config.temperature.format=Unité de température
    2706 2706
     observe.config.ui.autoPopupNumberEditor=Pour afficher automatiquement l'éditeur numérique lors de l'édition d'un nombre
    
    2707 2707
     observe.config.ui.changeSynchroSrc=Pour autoriser la sélection de la base source dans les opérations sur base
    
    2708 2708
     observe.config.ui.dcp.error.color=Couleur pour notifier les erreurs sur la composition des dcps
    
    2709
    +observe.config.ui.dcp.not.editable.color=Couleur pour notifier les nœuds non éditables dans l'arbre des matériaux de dcp.
    
    2709 2710
     observe.config.ui.focusBorderColor=Couleur de la bordure de la zone qui a le focus
    
    2710 2711
     observe.config.ui.fullscreen=Pour afficher l'application en mode pleine écran
    
    2711 2712
     observe.config.ui.loadLocalStorage=Charger la base locale au démarrage de l'application