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

Commits:

9 changed files:

Changes:

  • client-configuration/src/main/config/Client.ini
    ... ... @@ -537,6 +537,12 @@ key = ui.dcp.error.color
    537 537
     type = color
    
    538 538
     defaultValue = java.awt.Color[r=255,g=100,b=100]
    
    539 539
     
    
    540
    +[option floatingObjectMaterialNotEditableColor]
    
    541
    +description = observe.config.ui.dcp.not.editable.color
    
    542
    +key = ui.dcp.not.editable.color
    
    543
    +type = color
    
    544
    +defaultValue = java.awt.Color[r=193,g=250,b=250]
    
    545
    +
    
    540 546
     [option showMnemonic]
    
    541 547
     description = observe.config.ui.showMnemonic
    
    542 548
     key = ui.showMnemonic
    

  • client-configuration/src/main/i18n/getters/config.getter
    ... ... @@ -80,6 +80,7 @@ observe.config.temperature.format
    80 80
     observe.config.ui.autoPopupNumberEditor
    
    81 81
     observe.config.ui.changeSynchroSrc
    
    82 82
     observe.config.ui.dcp.error.color
    
    83
    +observe.config.ui.dcp.not.editable.color
    
    83 84
     observe.config.ui.focusBorderColor
    
    84 85
     observe.config.ui.fullscreen
    
    85 86
     observe.config.ui.loadLocalStorage
    

  • client-core/src/main/java/fr/ird/observe/client/ui/content/data/seine/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/seine/dcp/FloatingObjectPartsTreeNode.java
    ... ... @@ -28,8 +28,8 @@ import fr.ird.observe.client.ui.content.data.seine.FloatingObjectUIModel;
    28 28
     import fr.ird.observe.dto.data.seine.ObjectMaterialHierarchyDto;
    
    29 29
     import fr.ird.observe.dto.referential.ReferentialLocale;
    
    30 30
     import fr.ird.observe.dto.referential.seine.ObjectMaterialTypeReference;
    
    31
    -import org.apache.logging.log4j.Logger;
    
    32 31
     import org.apache.logging.log4j.LogManager;
    
    32
    +import org.apache.logging.log4j.Logger;
    
    33 33
     import org.jdesktop.swingx.treetable.AbstractMutableTreeTableNode;
    
    34 34
     import org.jetbrains.annotations.NotNull;
    
    35 35
     
    
    ... ... @@ -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();
    
    ... ... @@ -153,7 +164,7 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im
    153 164
             return getUserObject().dto.isFloat();
    
    154 165
         }
    
    155 166
     
    
    156
    -    public boolean withValidation() {
    
    167
    +    boolean withValidation() {
    
    157 168
             return getUserObject().dto.withValidation();
    
    158 169
         }
    
    159 170
     
    
    ... ... @@ -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();
    
    ... ... @@ -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) {
    
    ... ... @@ -303,16 +341,11 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im
    303 341
             setCompanions(childCompanionsBuilder);
    
    304 342
         }
    
    305 343
     
    
    306
    -
    
    307 344
         private boolean needCompanions() {
    
    308 345
             ObjectMaterialHierarchyDto dto = getUserObject().dto;
    
    309 346
             return dto != null && !dto.isChildrenMultiSelectable() && !isLeaf();
    
    310 347
         }
    
    311 348
     
    
    312
    -    public void computeValidationValidState() {
    
    313
    -        getUserObject().computeValidationValidState();
    
    314
    -    }
    
    315
    -
    
    316 349
         //TODO Improve the design, we should not store anything in uiModel and separate leaving and arriving data
    
    317 350
         private static class FloatingObjectPartsTreeNodeContext {
    
    318 351
     
    
    ... ... @@ -320,7 +353,7 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im
    320 353
             private final FloatingObjectUIModel uiModel;
    
    321 354
             // dto (null for root)
    
    322 355
             private final ObjectMaterialHierarchyDto dto;
    
    323
    -        // Is the node is enabled (hierarchic value) ?
    
    356
    +        // Is the node is enabled (from hierarchic value) ?
    
    324 357
             private final boolean enabled;
    
    325 358
             // Is this node editable ?
    
    326 359
             private final boolean editable;
    
    ... ... @@ -328,6 +361,7 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im
    328 361
             private final boolean exclusive;
    
    329 362
             // Is the node use validation on his value ?
    
    330 363
             private final boolean useValidation;
    
    364
    +        // Referential locale to decorate
    
    331 365
             private final ReferentialLocale referentialLocale;
    
    332 366
             // Is this node (on arriving) need at least one child selected ? (if editable then node must be selected)
    
    333 367
             private boolean needOneSelectionOnLeaving;
    
    ... ... @@ -345,6 +379,9 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im
    345 379
             private ImmutableSet<FloatingObjectPartsTreeNode> companions;
    
    346 380
             // Internal to store debug node text
    
    347 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;
    
    348 385
     
    
    349 386
             FloatingObjectPartsTreeNodeContext(FloatingObjectUIModel uiModel) {
    
    350 387
                 this.uiModel = Objects.requireNonNull(uiModel);
    
    ... ... @@ -432,7 +469,7 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im
    432 469
                 return text;
    
    433 470
             }
    
    434 471
     
    
    435
    -        public void computeValidationValidState() {
    
    472
    +        void computeValidationValidState() {
    
    436 473
                 if (uiModel.isArriving()) {
    
    437 474
                     Object value = uiModel.getWhenArriving(dto.getId());
    
    438 475
                     valueValidOnArriving = dto.isValid(value);
    
    ... ... @@ -442,5 +479,29 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im
    442 479
                     valueValidOnLeaving = dto.isValid(value);
    
    443 480
                 }
    
    444 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
    +        }
    
    445 506
         }
    
    446 507
     }

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

  • client-core/src/main/java/fr/ird/observe/client/ui/content/data/seine/dcp/FloatingObjectPartsTreeTableModel.java
    ... ... @@ -24,15 +24,18 @@ package fr.ird.observe.client.ui.content.data.seine.dcp;
    24 24
     
    
    25 25
     import com.google.common.collect.ImmutableSet;
    
    26 26
     import fr.ird.observe.client.ui.content.data.seine.FloatingObjectUIModel;
    
    27
    +import fr.ird.observe.dto.IdDto;
    
    27 28
     import fr.ird.observe.dto.data.seine.ObjectMaterialHierarchyDto;
    
    28
    -import org.apache.logging.log4j.Logger;
    
    29
    +import io.ultreia.java4all.i18n.I18n;
    
    29 30
     import org.apache.logging.log4j.LogManager;
    
    31
    +import org.apache.logging.log4j.Logger;
    
    30 32
     import org.jdesktop.swingx.treetable.DefaultTreeTableModel;
    
    31 33
     import org.jdesktop.swingx.treetable.TreeTableNode;
    
    32
    -import io.ultreia.java4all.i18n.I18n;
    
    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.
    
    ... ... @@ -115,6 +118,11 @@ public class FloatingObjectPartsTreeTableModel extends DefaultTreeTableModel {
    115 118
             throw new IllegalStateException();
    
    116 119
         }
    
    117 120
     
    
    121
    +    @Override
    
    122
    +    public boolean isCellEditable(Object node, int column) {
    
    123
    +        return super.isCellEditable(node, column);
    
    124
    +    }
    
    125
    +
    
    118 126
         @Override
    
    119 127
         public void setValueAt(Object value, Object node, int column) {
    
    120 128
             FloatingObjectPartsTreeNode treeNode = (FloatingObjectPartsTreeNode) node;
    
    ... ... @@ -122,6 +130,13 @@ public class FloatingObjectPartsTreeTableModel extends DefaultTreeTableModel {
    122 130
             previousNode.ifPresent(p -> log.info("Previous selected node: " + p));
    
    123 131
             super.setValueAt(value, node, column);
    
    124 132
             previousNode.ifPresent(t -> super.setValueAt(null, t, column));
    
    133
    +        boolean realEnabled = !"true".equals(value);
    
    134
    +        log.info(String.format("Real enabled? %s", realEnabled));
    
    135
    +        if (column == 1) {
    
    136
    +            treeNode.setRealEnabledOnArriving(realEnabled);
    
    137
    +        } else if (column == 2) {
    
    138
    +            treeNode.setRealEnabledOnLeaving(realEnabled);
    
    139
    +        }
    
    125 140
             if (adjusting) {
    
    126 141
                 return;
    
    127 142
             }
    
    ... ... @@ -145,6 +160,20 @@ public class FloatingObjectPartsTreeTableModel extends DefaultTreeTableModel {
    145 160
             uiModel.getBean().setMaterialsValid(!notValid);
    
    146 161
         }
    
    147 162
     
    
    163
    +    public void computeRealEnabledState() {
    
    164
    +        Set<String> whenArriving = uiModel.getWhenArriving().keySet().stream().map(IdDto::getId).collect(Collectors.toSet());
    
    165
    +        Set<String> whenLeaving = uiModel.getWhenLeaving().keySet().stream().map(IdDto::getId).collect(Collectors.toSet());
    
    166
    +        allNodes.forEach(FloatingObjectPartsTreeNode::resetRealEnabled);
    
    167
    +        for (FloatingObjectPartsTreeNode node : allNodes) {
    
    168
    +            if (whenArriving.contains(node.getId())) {
    
    169
    +                node.setRealEnabledOnArriving(false);
    
    170
    +            }
    
    171
    +            if (whenLeaving.contains(node.getId())) {
    
    172
    +                node.setRealEnabledOnLeaving(false);
    
    173
    +            }
    
    174
    +        }
    
    175
    +    }
    
    176
    +
    
    148 177
         public boolean isAdjusting() {
    
    149 178
             return adjusting;
    
    150 179
         }
    

  • observe-i18n/src/main/i18n/translations/observe_en_GB.properties
    ... ... @@ -1753,6 +1753,7 @@ observe.config.temperature.format=Default temperature format
    1753 1753
     observe.config.ui.autoPopupNumberEditor=Flag sets to true when number editor show automaticly popup
    
    1754 1754
     observe.config.ui.changeSynchroSrc=Flag sets to true if you can change local source in admin tasks
    
    1755 1755
     observe.config.ui.dcp.error.color=Color to notify errors while validating floating object materials.
    
    1756
    +observe.config.ui.dcp.not.editable.color=Color to notify not editable floating object material nodes.
    
    1756 1757
     observe.config.ui.focusBorderColor=Color of the focus container border
    
    1757 1758
     observe.config.ui.fullscreen=Flag sets to true to lauch application in full screen mode
    
    1758 1759
     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
    ... ... @@ -1753,6 +1753,7 @@ observe.config.temperature.format=Unidad de temperatura
    1753 1753
     observe.config.ui.autoPopupNumberEditor=Para mostrar automáticamente el editor numérico durante la edición de un número
    
    1754 1754
     observe.config.ui.changeSynchroSrc=Para autorizar la seleción de la base fuente durante las operaciones sobre la base
    
    1755 1755
     observe.config.ui.dcp.error.color=Color para notificar los errores sobre la composición de dcps
    
    1756
    +observe.config.ui.dcp.not.editable.color=Color to notify not editable floating object material nodes \#TODO
    
    1756 1757
     observe.config.ui.focusBorderColor=Color del borde de la zona que tiene el foco
    
    1757 1758
     observe.config.ui.fullscreen=Para mostrar la aplicación en modo pantalla completa
    
    1758 1759
     observe.config.ui.loadLocalStorage=Cargar la base local al iniciar la aplicación
    

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