Tony CHEMIT pushed to branch develop-7.x at ultreiaio / ird-observe
Commits:
-
35aae06f
by tchemit at 2019-02-19T11:19:47Z
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:
| ... | ... | @@ -375,7 +375,7 @@ public class FloatingObjectUIHandler extends ContentUIHandler<FloatingObjectDto, |
| 375 | 375 |
getModel().setLeaving(operation.isWhenLeaving());
|
| 376 | 376 |
}
|
| 377 | 377 |
FloatingObjectPartsTreeTableModel treeModel = getUi().getTable().getTreeTableModel();
|
| 378 |
- treeModel.reset();
|
|
| 378 |
+ treeModel.reset(true);
|
|
| 379 | 379 |
}
|
| 380 | 380 |
|
| 381 | 381 |
protected void computeTabValidState(SwingValidatorMessageTableModel errorTableModel) {
|
| ... | ... | @@ -240,4 +240,13 @@ public class FloatingObjectUIModel extends ContentUIModel<FloatingObjectDto> { |
| 240 | 240 |
firePropertyChange(PROPERTY_LEAVING, leaving);
|
| 241 | 241 |
}
|
| 242 | 242 |
|
| 243 |
+ public Object getWhenArriving(String id) {
|
|
| 244 |
+ ObjectMaterialDto dto = Objects.requireNonNull(referentialMap.get(id));
|
|
| 245 |
+ return whenArriving.get(dto);
|
|
| 246 |
+ }
|
|
| 247 |
+ |
|
| 248 |
+ public Object getWhenLeaving(String id) {
|
|
| 249 |
+ ObjectMaterialDto dto = Objects.requireNonNull(referentialMap.get(id));
|
|
| 250 |
+ return whenLeaving.get(dto);
|
|
| 251 |
+ }
|
|
| 243 | 252 |
}
|
| ... | ... | @@ -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 |
}
|
| ... | ... | @@ -305,6 +309,10 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im |
| 305 | 309 |
return dto != null && !dto.isChildrenMultiSelectable() && !isLeaf();
|
| 306 | 310 |
}
|
| 307 | 311 |
|
| 312 |
+ public void computeValidationValidState() {
|
|
| 313 |
+ getUserObject().computeValidationValidState();
|
|
| 314 |
+ }
|
|
| 315 |
+ |
|
| 308 | 316 |
//TODO Improve the design, we should not store anything in uiModel and separate leaving and arriving data
|
| 309 | 317 |
private static class FloatingObjectPartsTreeNodeContext {
|
| 310 | 318 |
|
| ... | ... | @@ -345,8 +353,6 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im |
| 345 | 353 |
this.editable = false;
|
| 346 | 354 |
this.exclusive = false;
|
| 347 | 355 |
this.useValidation = false;
|
| 348 |
- this.valueValidOnArriving = true;
|
|
| 349 |
- this.valueValidOnLeaving = true;
|
|
| 350 | 356 |
this.referentialLocale = ObserveSwingApplicationContext.get().getDecoratorService().getReferentialLocale();
|
| 351 | 357 |
}
|
| 352 | 358 |
|
| ... | ... | @@ -358,10 +364,6 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im |
| 358 | 364 |
// editable if dto is selectable (we also make sure that the object material type is here too)
|
| 359 | 365 |
this.editable = dto.getObjectMaterialType() != null;
|
| 360 | 366 |
this.useValidation = enabled && editable && dto.withValidation();
|
| 361 |
- if (!useValidation) {
|
|
| 362 |
- valueValidOnArriving = true;
|
|
| 363 |
- valueValidOnLeaving = true;
|
|
| 364 |
- }
|
|
| 365 | 367 |
// exclusive if his parent requires it
|
| 366 | 368 |
this.exclusive = parent.dto != null && !parent.dto.isChildrenMultiSelectable();
|
| 367 | 369 |
this.referentialLocale = ObserveSwingApplicationContext.get().getDecoratorService().getReferentialLocale();
|
| ... | ... | @@ -412,9 +414,9 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im |
| 412 | 414 |
boolean isValid(int column) {
|
| 413 | 415 |
switch (column) {
|
| 414 | 416 |
case 1: // when arriving
|
| 415 |
- return validWhenArriving;
|
|
| 417 |
+ return validWhenArriving && (!useValidation || valueValidOnArriving);
|
|
| 416 | 418 |
case 2: // when leaving
|
| 417 |
- return validWhenLeaving;
|
|
| 419 |
+ return validWhenLeaving && (!useValidation || valueValidOnLeaving);
|
|
| 418 | 420 |
}
|
| 419 | 421 |
throw new IllegalStateException();
|
| 420 | 422 |
}
|
| ... | ... | @@ -430,5 +432,15 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im |
| 430 | 432 |
return text;
|
| 431 | 433 |
}
|
| 432 | 434 |
|
| 435 |
+ public void computeValidationValidState() {
|
|
| 436 |
+ if (uiModel.isArriving()) {
|
|
| 437 |
+ Object value = uiModel.getWhenArriving(dto.getId());
|
|
| 438 |
+ valueValidOnArriving = dto.isValid(value);
|
|
| 439 |
+ }
|
|
| 440 |
+ if (uiModel.isLeaving()) {
|
|
| 441 |
+ Object value = uiModel.getWhenLeaving(dto.getId());
|
|
| 442 |
+ valueValidOnLeaving = dto.isValid(value);
|
|
| 443 |
+ }
|
|
| 444 |
+ }
|
|
| 433 | 445 |
}
|
| 434 | 446 |
}
|
| ... | ... | @@ -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();
|
| ... | ... | @@ -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()) {
|
| ... | ... | @@ -82,9 +84,13 @@ public class FloatingObjectPartsTreeTableModel extends DefaultTreeTableModel { |
| 82 | 84 |
if (node.withMandatoryConstraintsOnChildren()) {
|
| 83 | 85 |
needOneSelectionNodesBuilder.add(node);
|
| 84 | 86 |
}
|
| 87 |
+ if (node.withValidation()) {
|
|
| 88 |
+ validationNodesBuilder.add(node);
|
|
| 89 |
+ }
|
|
| 85 | 90 |
}
|
| 86 | 91 |
needOneSelectionNodes = needOneSelectionNodesBuilder.build();
|
| 87 | 92 |
mandatoryNodes = mandatoryNodesBuilder.build();
|
| 93 |
+ validationNodes = validationNodesBuilder.build();
|
|
| 88 | 94 |
}
|
| 89 | 95 |
|
| 90 | 96 |
public void rebuildRootNode(ObjectMaterialHierarchyDto materials) {
|
| ... | ... | @@ -119,12 +125,15 @@ public class FloatingObjectPartsTreeTableModel extends DefaultTreeTableModel { |
| 119 | 125 |
if (adjusting) {
|
| 120 | 126 |
return;
|
| 121 | 127 |
}
|
| 122 |
- reset();
|
|
| 128 |
+ reset(false);
|
|
| 123 | 129 |
uiModel.setModified(true);
|
| 124 | 130 |
}
|
| 125 | 131 |
|
| 126 |
- public void reset() {
|
|
| 132 |
+ public void reset(boolean computeValidation) {
|
|
| 127 | 133 |
allNodes.forEach(FloatingObjectPartsTreeNode::resetStates);
|
| 134 |
+ if (computeValidation) {
|
|
| 135 |
+ validationNodes.forEach(FloatingObjectPartsTreeNode::computeValidationValidState);
|
|
| 136 |
+ }
|
|
| 128 | 137 |
|
| 129 | 138 |
boolean whenArriving = uiModel.isArriving();
|
| 130 | 139 |
boolean whenLeaving = uiModel.isLeaving();
|
| ... | ... | @@ -143,7 +152,7 @@ public class FloatingObjectPartsTreeTableModel extends DefaultTreeTableModel { |
| 143 | 152 |
public void setAdjusting(boolean adjusting) {
|
| 144 | 153 |
this.adjusting = adjusting;
|
| 145 | 154 |
if (!adjusting) {
|
| 146 |
- reset();
|
|
| 155 |
+ reset(false);
|
|
| 147 | 156 |
uiModel.setModified(true);
|
| 148 | 157 |
}
|
| 149 | 158 |
}
|