Tony CHEMIT pushed to branch develop-7.x at ultreiaio / ird-observe Commits: 35aae06f by tchemit at 2019-02-19T11:19:47Z [PS] Formulaire FOB : les contrôles de saisie ne sont pas appliqués - Closes #1234 - - - - - 5 changed files: - client-core/src/main/java/fr/ird/observe/client/ui/content/data/seine/FloatingObjectUIHandler.java - client-core/src/main/java/fr/ird/observe/client/ui/content/data/seine/FloatingObjectUIModel.java - client-core/src/main/java/fr/ird/observe/client/ui/content/data/seine/dcp/FloatingObjectPartsTreeNode.java - client-core/src/main/java/fr/ird/observe/client/ui/content/data/seine/dcp/FloatingObjectPartsTreeTable.java - client-core/src/main/java/fr/ird/observe/client/ui/content/data/seine/dcp/FloatingObjectPartsTreeTableModel.java Changes: ===================================== client-core/src/main/java/fr/ird/observe/client/ui/content/data/seine/FloatingObjectUIHandler.java ===================================== @@ -375,7 +375,7 @@ public class FloatingObjectUIHandler extends ContentUIHandler<FloatingObjectDto, getModel().setLeaving(operation.isWhenLeaving()); } FloatingObjectPartsTreeTableModel treeModel = getUi().getTable().getTreeTableModel(); - treeModel.reset(); + treeModel.reset(true); } protected void computeTabValidState(SwingValidatorMessageTableModel errorTableModel) { ===================================== client-core/src/main/java/fr/ird/observe/client/ui/content/data/seine/FloatingObjectUIModel.java ===================================== @@ -240,4 +240,13 @@ public class FloatingObjectUIModel extends ContentUIModel<FloatingObjectDto> { firePropertyChange(PROPERTY_LEAVING, leaving); } + public Object getWhenArriving(String id) { + ObjectMaterialDto dto = Objects.requireNonNull(referentialMap.get(id)); + return whenArriving.get(dto); + } + + public Object getWhenLeaving(String id) { + ObjectMaterialDto dto = Objects.requireNonNull(referentialMap.get(id)); + return whenLeaving.get(dto); + } } ===================================== client-core/src/main/java/fr/ird/observe/client/ui/content/data/seine/dcp/FloatingObjectPartsTreeNode.java ===================================== @@ -73,7 +73,7 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im } boolean isNotValid() { - return !(getUserObject().validWhenArriving && getUserObject().validWhenLeaving); + return !(isValid(1) && isValid(2)); } @Override @@ -153,6 +153,10 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im return getUserObject().dto.isFloat(); } + public boolean withValidation() { + return getUserObject().dto.withValidation(); + } + ObjectMaterialTypeReference getObjectMaterialType() { return getUserObject().dto.getObjectMaterialType(); } @@ -305,6 +309,10 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im return dto != null && !dto.isChildrenMultiSelectable() && !isLeaf(); } + public void computeValidationValidState() { + getUserObject().computeValidationValidState(); + } + //TODO Improve the design, we should not store anything in uiModel and separate leaving and arriving data private static class FloatingObjectPartsTreeNodeContext { @@ -345,8 +353,6 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im this.editable = false; this.exclusive = false; this.useValidation = false; - this.valueValidOnArriving = true; - this.valueValidOnLeaving = true; this.referentialLocale = ObserveSwingApplicationContext.get().getDecoratorService().getReferentialLocale(); } @@ -358,10 +364,6 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im // editable if dto is selectable (we also make sure that the object material type is here too) this.editable = dto.getObjectMaterialType() != null; this.useValidation = enabled && editable && dto.withValidation(); - if (!useValidation) { - valueValidOnArriving = true; - valueValidOnLeaving = true; - } // exclusive if his parent requires it this.exclusive = parent.dto != null && !parent.dto.isChildrenMultiSelectable(); this.referentialLocale = ObserveSwingApplicationContext.get().getDecoratorService().getReferentialLocale(); @@ -412,9 +414,9 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im boolean isValid(int column) { switch (column) { case 1: // when arriving - return validWhenArriving; + return validWhenArriving && (!useValidation || valueValidOnArriving); case 2: // when leaving - return validWhenLeaving; + return validWhenLeaving && (!useValidation || valueValidOnLeaving); } throw new IllegalStateException(); } @@ -430,5 +432,15 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im return text; } + public void computeValidationValidState() { + if (uiModel.isArriving()) { + Object value = uiModel.getWhenArriving(dto.getId()); + valueValidOnArriving = dto.isValid(value); + } + if (uiModel.isLeaving()) { + Object value = uiModel.getWhenLeaving(dto.getId()); + valueValidOnLeaving = dto.isValid(value); + } + } } } ===================================== client-core/src/main/java/fr/ird/observe/client/ui/content/data/seine/dcp/FloatingObjectPartsTreeTable.java ===================================== @@ -83,7 +83,7 @@ public class FloatingObjectPartsTreeTable extends JXTreeTable { } FloatingObjectPartsTreeTableModel treeTableModel = getTreeTableModel(); - treeTableModel.reset(); + treeTableModel.reset(true); if (expandTree) { expandAll(); ===================================== client-core/src/main/java/fr/ird/observe/client/ui/content/data/seine/dcp/FloatingObjectPartsTreeTableModel.java ===================================== @@ -50,6 +50,7 @@ public class FloatingObjectPartsTreeTableModel extends DefaultTreeTableModel { private ImmutableSet<FloatingObjectPartsTreeNode> allNodes; private ImmutableSet<FloatingObjectPartsTreeNode> needOneSelectionNodes; private ImmutableSet<FloatingObjectPartsTreeNode> mandatoryNodes; + private ImmutableSet<FloatingObjectPartsTreeNode> validationNodes; private boolean adjusting; public FloatingObjectPartsTreeTableModel(FloatingObjectUIModel uiModel) { @@ -73,6 +74,7 @@ public class FloatingObjectPartsTreeTableModel extends DefaultTreeTableModel { ImmutableSet.Builder<FloatingObjectPartsTreeNode> needOneSelectionNodesBuilder = ImmutableSet.builder(); ImmutableSet.Builder<FloatingObjectPartsTreeNode> mandatoryNodesBuilder = ImmutableSet.builder(); + ImmutableSet.Builder<FloatingObjectPartsTreeNode> validationNodesBuilder = ImmutableSet.builder(); for (FloatingObjectPartsTreeNode node : allNodes) { if (!node.isEnabled()) { @@ -82,9 +84,13 @@ public class FloatingObjectPartsTreeTableModel extends DefaultTreeTableModel { if (node.withMandatoryConstraintsOnChildren()) { needOneSelectionNodesBuilder.add(node); } + if (node.withValidation()) { + validationNodesBuilder.add(node); + } } needOneSelectionNodes = needOneSelectionNodesBuilder.build(); mandatoryNodes = mandatoryNodesBuilder.build(); + validationNodes = validationNodesBuilder.build(); } public void rebuildRootNode(ObjectMaterialHierarchyDto materials) { @@ -119,12 +125,15 @@ public class FloatingObjectPartsTreeTableModel extends DefaultTreeTableModel { if (adjusting) { return; } - reset(); + reset(false); uiModel.setModified(true); } - public void reset() { + public void reset(boolean computeValidation) { allNodes.forEach(FloatingObjectPartsTreeNode::resetStates); + if (computeValidation) { + validationNodes.forEach(FloatingObjectPartsTreeNode::computeValidationValidState); + } boolean whenArriving = uiModel.isArriving(); boolean whenLeaving = uiModel.isLeaving(); @@ -143,7 +152,7 @@ public class FloatingObjectPartsTreeTableModel extends DefaultTreeTableModel { public void setAdjusting(boolean adjusting) { this.adjusting = adjusting; if (!adjusting) { - reset(); + reset(false); uiModel.setModified(true); } } View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/commit/35aae06ffcac36f928db16091c4b... -- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/commit/35aae06ffcac36f928db16091c4b... You're receiving this email because of your account on gitlab.com.
participants (1)
-
Tony CHEMIT