|
11 | 11 | import org.argmap.client.ArgMapService.NodeChangesMaps; |
12 | 12 | import org.argmap.client.ArgMapService.NodeChangesMapsAndRootChanges; |
13 | 13 | import org.argmap.client.ArgMapService.NodeWithChanges; |
| 14 | +import org.argmap.client.Change.ChangeType; |
14 | 15 |
|
15 | 16 | import com.google.gwt.dom.client.Style; |
16 | 17 | import com.google.gwt.dom.client.Style.Unit; |
@@ -372,7 +373,8 @@ private SortedMultiMap<Date, ViewChange> prepTreeWithDeletedNodesAndChangesAndBu |
372 | 373 | for (int i = 0; i < treeClone.getItemCount(); i++) { |
373 | 374 | ViewPropVer viewPropVer = (ViewPropVer) treeClone.getItem(i); |
374 | 375 | recursivePrepAndBuild(viewPropVer, timeMachineMap, changesMaps, log); |
375 | | - recursiveHideLinkedSubtreesDuringUnlinkedPeriods(viewPropVer); |
| 376 | + recursiveHideLinkedSubtreesDuringUnlinkedPeriods(viewPropVer, |
| 377 | + new TimePeriods()); |
376 | 378 | } |
377 | 379 | log.finish(); |
378 | 380 | return timeMachineMap; |
@@ -499,20 +501,109 @@ private void loadChangesIntoNodeAndMap(ViewNodeVer viewNode, |
499 | 501 | } |
500 | 502 | } |
501 | 503 |
|
502 | | - public void recursiveHideLinkedSubtreesDuringUnlinkedPeriods( |
503 | | - ViewNodeVer viewPNodeVer, List list) { |
| 504 | + /* |
| 505 | + * TODO still need to make alwaysHidden Changes actually hidden when |
| 506 | + * building the change list. |
| 507 | + * |
| 508 | + * TODO this just does the initial hide... need to redo this every time the |
| 509 | + * user opens and loads unloaded children for the first time... right? |
| 510 | + * |
| 511 | + * TODO explain what this function does in a comment here |
| 512 | + */ |
| 513 | + private void recursiveHideLinkedSubtreesDuringUnlinkedPeriods( |
| 514 | + ViewNodeVer viewNodeVer, TimePeriods hidePeriods) { |
| 515 | + if (viewNodeVer instanceof ViewDummyVer) { |
| 516 | + return; |
| 517 | + } |
| 518 | + |
| 519 | + List<ViewChange> viewChangeList = viewNodeVer.getViewChangeList(); |
| 520 | + |
504 | 521 | // hide all changes of this node that occur within a period in list |
| 522 | + for (ViewChange viewChange : viewChangeList) { |
| 523 | + if (hidePeriods.covers(viewChange.change.date)) { |
| 524 | + viewChange.alwaysHidden = true; |
| 525 | + } |
| 526 | + } |
505 | 527 |
|
506 | | - // * for each child node |
| 528 | + if (viewNodeVer instanceof ViewArgVer) { |
| 529 | + // sort the node's viewChangeList |
| 530 | + Collections.sort(viewChangeList, ViewChange.DATE_COMPARATOR); |
507 | 531 |
|
508 | | - // * * if this is an argument and the child is a linked node |
509 | | - // * * * build a list of periods that the node is unlinked |
510 | | - // * * * build a newList of periods that the node is unlinked including |
511 | | - // * * * * those from the argument and those from the list just build |
| 532 | + /* |
| 533 | + * start building more restrictive hidePeriods for the children that |
| 534 | + * need them |
| 535 | + */ |
| 536 | + Map<Long, TimePeriods> newPeriods = new HashMap<Long, TimePeriods>(); |
| 537 | + Map<Long, ViewChange> lastChanges = new HashMap<Long, ViewChange>(); |
| 538 | + for (ViewChange viewChange : viewChangeList) { |
| 539 | + Long propID = viewChange.change.propID; |
| 540 | + if (viewChange.change.changeType == ChangeType.PROP_LINK) { |
| 541 | + |
| 542 | + TimePeriods newPeriod = newPeriods.get(propID); |
| 543 | + if (newPeriod == null) { |
| 544 | + newPeriod = hidePeriods.copy(); |
| 545 | + newPeriods.put(propID, newPeriod); |
| 546 | + } |
512 | 547 |
|
513 | | - // * * recursiveHideLinkedSubtreesDuringUnlinkedPeriods( either list or |
514 | | - // * * * newList) |
| 548 | + ViewChange lastViewChange = lastChanges.get(propID); |
| 549 | + if (lastViewChange != null |
| 550 | + && lastViewChange.change.changeType == ChangeType.PROP_UNLINK) { |
| 551 | + newPeriod.addPeriod(lastViewChange.change.date, |
| 552 | + viewChange.change.date); |
| 553 | + } else { |
| 554 | + newPeriod.addPeriod(TimePeriods.THIRTY_YEARS_AGO, |
| 555 | + viewChange.change.date); |
| 556 | + } |
515 | 557 |
|
| 558 | + lastChanges.put(propID, viewChange); |
| 559 | + } else if (viewChange.change.changeType == ChangeType.PROP_UNLINK) { |
| 560 | + lastChanges.put(propID, viewChange); |
| 561 | + } |
| 562 | + } |
| 563 | + |
| 564 | + // for each child node |
| 565 | + for (ViewNodeVer child : new ViewNodeVer.CombinedViewIterator( |
| 566 | + viewNodeVer)) { |
| 567 | + Long propID = child.getNodeID(); |
| 568 | + |
| 569 | + /* |
| 570 | + * finish building a more restrictive hide period if this child |
| 571 | + * needs it |
| 572 | + */ |
| 573 | + ViewChange lastViewChange = lastChanges.get(propID); |
| 574 | + if (lastViewChange != null |
| 575 | + && lastViewChange.change.changeType == ChangeType.PROP_UNLINK) { |
| 576 | + TimePeriods newPeriod = newPeriods.get(propID); |
| 577 | + if (newPeriod == null) { |
| 578 | + newPeriod = hidePeriods.copy(); |
| 579 | + newPeriods.put(propID, newPeriod); |
| 580 | + } |
| 581 | + /* |
| 582 | + * we got here because lastChanges for propID was never set |
| 583 | + * to a Change of type PROP_LINK, which means we had a |
| 584 | + * PROP_UNLINK with no following link, which means that all |
| 585 | + * subsequent changes should be hidden. So we add a hide |
| 586 | + * period from the last change to 100 years from now. |
| 587 | + */ |
| 588 | + newPeriod.addPeriod(lastViewChange.change.date, |
| 589 | + TimePeriods.ONE_HUNDRED_YEARS_FROM_NOW); |
| 590 | + } |
| 591 | + |
| 592 | + if (newPeriods.containsKey(propID)) { |
| 593 | + recursiveHideLinkedSubtreesDuringUnlinkedPeriods(child, |
| 594 | + newPeriods.get(propID)); |
| 595 | + } else { |
| 596 | + recursiveHideLinkedSubtreesDuringUnlinkedPeriods(child, |
| 597 | + hidePeriods); |
| 598 | + } |
| 599 | + } |
| 600 | + } else { |
| 601 | + for (ViewNodeVer child : new ViewNodeVer.CombinedViewIterator( |
| 602 | + viewNodeVer)) { |
| 603 | + recursiveHideLinkedSubtreesDuringUnlinkedPeriods(child, |
| 604 | + hidePeriods); |
| 605 | + } |
| 606 | + } |
516 | 607 | } |
517 | 608 |
|
518 | 609 | private void loadVersionListFromTimeMachine() { |
|
0 commit comments