/** Method setViewTreeTable. */
  public void setViewTreeTable() {
    final Object[] expandedElements = getExpandedElements();

    // Create Columns
    createPathColumn();
    createAssignmentColumn();
    createNumChangesColumn();
    createNumAnomaliesColumn();
    getTree().setHeaderVisible(true);

    // Reset Layout to adjust Columns widths
    fTreeColumnLayout.setColumnData(
        fElementColumn.getColumn(), new ColumnWeightData(fElementColumnWeight, true));
    fTreeColumnLayout.setColumnData(
        fPathColumn.getColumn(), new ColumnWeightData(fPathColumnWeight, true));
    fTreeColumnLayout.setColumnData(
        fAssignColumn.getColumn(), new ColumnWeightData(fAssignColumnWeight, true));
    fTreeColumnLayout.setColumnData(
        fNumChangesColumn.getColumn(), new ColumnWeightData(fNumChangesColumnWeight, true));
    fTreeColumnLayout.setColumnData(
        fNumAnomaliesColumn.getColumn(), new ColumnWeightData(fNumAnomaliesColumnWeight, true));

    final R4EUIReviewBasic activeReview = R4EUIModelController.getActiveReview();
    if (null != activeReview) {
      fElementColumn.getColumn().setText(activeReview.getReview().getName());
      fElementColumn
          .getColumn()
          .setToolTipText(
              REVIEW_GROUP_COLUMN_TOOLTIP
                  + activeReview.getParent().getName()
                  + R4EUIConstants.LINE_FEED
                  + REVIEW_COLUMN_LABEL
                  + activeReview.getName());
    }

    // Set Tree Table Filters (shows only Review Items and Files for current review
    final TreeTableFilter filter =
        ((ReviewNavigatorActionGroup) R4EUIModelController.getNavigatorView().getActionSet())
            .getTreeTableFilter();
    fIsDefaultDisplay = false;

    // Save Default Tree input and adjust Tree Table input
    fDefaultInput = this.getInput();
    if (fDefaultInput instanceof R4EUIRootElement || fDefaultInput instanceof R4EUIReviewGroup) {
      this.setInput(R4EUIModelController.getActiveReview());
    }
    this.addFilter(filter);

    // Set Default sorter
    fTreeComparator = getComparator();
    setComparator(fTreeTableComparator);

    // Refresh Display
    this.getTree().getParent().layout();
    setExpandedElements(expandedElements);
  }
  /** Method progressReview */
  private void progressReview() {
    Assert.assertEquals(
        TestConstants.REVIEW_EXIT_DECISION_ACCEPTED,
        fReview.getReview().getDecision().getValue()); // Test the default exit decision

    fProxy.getReviewProxy().progressReview(fReview);
    Assert.assertEquals(
        R4EReviewPhase.COMPLETED, ((R4EReviewState) fReview.getReview().getState()).getState());
    Assert.assertNotNull(fReview.getReview().getEndDate());
  }
 /** Method createParticipants */
 private void createParticipants() {
   List<R4EParticipant> participants = new ArrayList<R4EParticipant>(1);
   R4EParticipant participant = RModelFactory.eINSTANCE.createR4EParticipant();
   participant.setId(TestConstants.PARTICIPANT_TEST_ID);
   participant.setEmail(TestConstants.PARTICIPANT_TEST_EMAIL);
   participants.add(participant);
   fParticipant =
       fProxy
           .getParticipantProxy()
           .createParticipant(fReview.getParticipantContainer(), participants);
   Assert.assertNotNull(fParticipant);
   Assert.assertEquals(TestConstants.PARTICIPANT_TEST_ID, fParticipant.getParticipant().getId());
   Assert.assertEquals(
       TestConstants.PARTICIPANT_TEST_EMAIL, fParticipant.getParticipant().getEmail());
   Assert.assertEquals(R4EUserRole.REVIEWER, fParticipant.getParticipant().getRoles().get(0));
 }
 /**
  * Method showPostponedElements.
  *
  * @param aReview R4EUIReviewBasic
  * @throws ResourceHandlingException
  * @throws OutOfSyncException
  * @throws CompatibilityException
  */
 public static void showPostponedElements(R4EUIReviewBasic aReview)
     throws ResourceHandlingException, OutOfSyncException, CompatibilityException {
   if (null != aReview) {
     final R4EUIPostponedContainer container = aReview.getPostponedContainer();
     if (null != container) {
       boolean containerEnabled = false;
       for (IR4EUIModelElement element : container.getChildren()) {
         if (null != element) {
           if (element instanceof R4EUIPostponedFile) {
             R4EUIPostponedFile postFile = (R4EUIPostponedFile) element;
             for (IR4EUIModelElement anomaly : postFile.getChildren()) {
               if ((null != anomaly) && !anomaly.isEnabled()) {
                 element.removeChildren(anomaly, false);
               }
             }
             if (!element.hasChildren()) {
               element.close();
             } else {
               containerEnabled = true; // At least one file contains postponed anomaly(ies)
             }
           } else if (element instanceof R4EUIPostponedAnomalyContainer) {
             for (IR4EUIModelElement anomaly : element.getChildren()) {
               if ((null != anomaly) && !anomaly.isEnabled()) {
                 element.removeChildren(anomaly, false);
               }
             }
             if (!element.hasChildren()) {
               element.close();
               container.removeChildren(element, false);
             } else {
               containerEnabled = true; // At least one global postponed anomaly exists
             }
           }
         }
       }
       if (!containerEnabled) {
         container.close();
       }
     }
   }
 }
  /** Method createReviewItems */
  private void createReviewItems() throws CoreException {
    fItem = fProxy.getItemProxy().createCommitItem(TestUtils.FJavaIProject, 0);
    // close and re-open, so the validation takes de-serialized information
    String itemName = fItem.getName();
    fProxy.getCommandProxy().closeElement(fReview);
    fProxy.getCommandProxy().openElement(fReview);
    for (IR4EUIModelElement elem : fReview.getChildren()) {
      if (elem.getName().equals(itemName)) {
        fItem = (R4EUIReviewItem) elem;
      }
    }

    // Now validate
    Assert.assertNotNull(fItem);
    Assert.assertEquals(R4EUIModelController.getReviewer(), fItem.getItem().getAddedById());
    Assert.assertEquals("*****@*****.**", fItem.getItem().getAuthorRep());
    Assert.assertEquals("second Java Commit", fItem.getItem().getDescription());
    Assert.assertEquals(4, fItem.getChildren().length);
    for (int i = 0; i < fItem.getChildren().length; i++) {
      if (((R4EUIFileContext) fItem.getChildren()[i])
          .getName()
          .equals(TestUtils.JAVA_FILE1_PROJ_NAME)) {
        fAnomalyFileIndex = i; // Used later to add anomalies
        Assert.assertEquals(
            TestUtils.JAVA_FILE1_PROJ_NAME,
            fItem.getItem().getFileContextList().get(i).getBase().getName());
        Assert.assertEquals(
            TestUtils.JAVA_FILE1_PROJ_NAME,
            fItem.getItem().getFileContextList().get(i).getTarget().getName());
        Assert.assertEquals(
            606,
            ((R4ETextPosition)
                    fItem
                        .getItem()
                        .getFileContextList()
                        .get(i)
                        .getDeltas()
                        .get(0)
                        .getTarget()
                        .getLocation())
                .getStartPosition());
        Assert.assertEquals(
            25,
            ((R4ETextPosition)
                    fItem
                        .getItem()
                        .getFileContextList()
                        .get(i)
                        .getDeltas()
                        .get(0)
                        .getTarget()
                        .getLocation())
                .getLength());
        Assert.assertEquals(
            665,
            ((R4ETextPosition)
                    fItem
                        .getItem()
                        .getFileContextList()
                        .get(i)
                        .getDeltas()
                        .get(1)
                        .getTarget()
                        .getLocation())
                .getStartPosition());
        Assert.assertEquals(
            63,
            ((R4ETextPosition)
                    fItem
                        .getItem()
                        .getFileContextList()
                        .get(i)
                        .getDeltas()
                        .get(1)
                        .getTarget()
                        .getLocation())
                .getLength());
        Assert.assertEquals(
            733,
            ((R4ETextPosition)
                    fItem
                        .getItem()
                        .getFileContextList()
                        .get(i)
                        .getDeltas()
                        .get(2)
                        .getTarget()
                        .getLocation())
                .getStartPosition());
        Assert.assertEquals(
            61,
            ((R4ETextPosition)
                    fItem
                        .getItem()
                        .getFileContextList()
                        .get(i)
                        .getDeltas()
                        .get(2)
                        .getTarget()
                        .getLocation())
                .getLength());
        Assert.assertTrue(
            fProxy
                .getCommandProxy()
                .verifyAnnotations(
                    ((R4EUIFileContext) fItem.getChildren()[i])
                        .getContentsContainerElement()
                        .getChildren(),
                    true,
                    R4EUIConstants.DELTA_ANNOTATION_ID));
      } else if (((R4EUIFileContext) fItem.getChildren()[i])
          .getName()
          .equals(TestUtils.JAVA_FILE4_PROJ_NAME)) {
        Assert.assertNull(fItem.getItem().getFileContextList().get(i).getBase());
        Assert.assertEquals(
            TestUtils.JAVA_FILE4_PROJ_NAME,
            fItem.getItem().getFileContextList().get(i).getTarget().getName());
      } else if (((R4EUIFileContext) fItem.getChildren()[i])
          .getName()
          .equals(TestUtils.JAVA_FILE3_PROJ_NAME)) {
        Assert.assertNull(fItem.getItem().getFileContextList().get(i).getBase());
        Assert.assertEquals(
            TestUtils.JAVA_FILE3_PROJ_NAME,
            fItem.getItem().getFileContextList().get(i).getTarget().getName());
      } else if (((R4EUIFileContext) fItem.getChildren()[i])
          .getName()
          .equals(TestUtils.JAVA_FILE2_PROJ_NAME)) {
        Assert.assertEquals(
            TestUtils.JAVA_FILE2_PROJ_NAME,
            fItem.getItem().getFileContextList().get(i).getBase().getName());
        Assert.assertNull(fItem.getItem().getFileContextList().get(i).getTarget());
      }
    }

    fItem2 = fProxy.getItemProxy().createManualTreeItem(TestUtils.FJavaFile3);
    Assert.assertNotNull(fItem2);
    Assert.assertEquals(R4EUIModelController.getReviewer(), fItem2.getItem().getAddedById());
    Assert.assertEquals(
        TestUtils.JAVA_FILE3_PROJ_NAME,
        fItem2.getItem().getFileContextList().get(0).getBase().getName());
    Assert.assertEquals(
        TestUtils.JAVA_FILE3_PROJ_NAME,
        fItem2.getItem().getFileContextList().get(0).getTarget().getName());
    Assert.assertEquals(
        0,
        ((R4ETextPosition)
                fItem2
                    .getItem()
                    .getFileContextList()
                    .get(0)
                    .getDeltas()
                    .get(0)
                    .getTarget()
                    .getLocation())
            .getStartPosition());
    Assert.assertEquals(
        755,
        ((R4ETextPosition)
                fItem2
                    .getItem()
                    .getFileContextList()
                    .get(0)
                    .getDeltas()
                    .get(0)
                    .getTarget()
                    .getLocation())
            .getLength());
    Assert.assertTrue(
        fProxy
            .getCommandProxy()
            .verifyAnnotations(
                ((R4EUIFileContext) fItem2.getChildren()[0])
                    .getContentsContainerElement()
                    .getChildren(),
                false,
                R4EUIConstants.SELECTION_ANNOTATION_ID));

    fItem3 = fProxy.getItemProxy().createManualTextItem(TestUtils.FJavaFile4, 50, 20);
    Assert.assertNotNull(fItem3);
    Assert.assertEquals(R4EUIModelController.getReviewer(), fItem3.getItem().getAddedById());
    Assert.assertEquals(
        TestUtils.JAVA_FILE4_PROJ_NAME,
        fItem3.getItem().getFileContextList().get(0).getBase().getName());
    Assert.assertEquals(
        TestUtils.JAVA_FILE4_PROJ_NAME,
        fItem3.getItem().getFileContextList().get(0).getTarget().getName());
    Assert.assertEquals(
        50,
        ((R4ETextPosition)
                fItem3
                    .getItem()
                    .getFileContextList()
                    .get(0)
                    .getDeltas()
                    .get(0)
                    .getTarget()
                    .getLocation())
            .getStartPosition());
    Assert.assertEquals(
        20,
        ((R4ETextPosition)
                fItem3
                    .getItem()
                    .getFileContextList()
                    .get(0)
                    .getDeltas()
                    .get(0)
                    .getTarget()
                    .getLocation())
            .getLength());
    Assert.assertTrue(
        fProxy
            .getCommandProxy()
            .verifyAnnotations(
                ((R4EUIFileContext) fItem3.getChildren()[0])
                    .getContentsContainerElement()
                    .getChildren(),
                true,
                R4EUIConstants.SELECTION_ANNOTATION_ID));
  }
  /** Method createReviews */
  private void createReviews() {
    // Update Review Group handle
    for (IR4EUIModelElement elem : R4EUIModelController.getRootElement().getChildren()) {
      if (fGroupName.equals(elem.getName())) {
        fGroup = (R4EUIReviewGroup) elem;
      }
    }
    if (!fGroup.isOpen()) {
      fProxy.getCommandProxy().openElement(fGroup);
    }
    Assert.assertTrue(fGroup.isOpen());

    fReview =
        fProxy
            .getReviewProxy()
            .createReview(
                fGroup,
                TestConstants.REVIEW_TEST_TYPE_INFORMAL,
                TestConstants.REVIEW_TEST_NAME_INF,
                TestConstants.REVIEW_TEST_DESCRIPTION,
                TestConstants.REVIEW_TEST_DUE_DATE,
                TestConstants.REVIEW_TEST_PROJECT,
                TestConstants.REVIEW_TEST_COMPONENTS,
                TestConstants.REVIEW_TEST_ENTRY_CRITERIA,
                TestConstants.REVIEW_TEST_OBJECTIVES,
                TestConstants.REVIEW_TEST_REFERENCE_MATERIALS);
    Assert.assertNotNull(fReview);
    Assert.assertNotNull(fReview.getParticipantContainer());
    Assert.assertNotNull(fReview.getAnomalyContainer());
    Assert.assertEquals(TestConstants.REVIEW_TEST_TYPE_INFORMAL, fReview.getReview().getType());
    Assert.assertEquals(TestConstants.REVIEW_TEST_NAME_INF, fReview.getReview().getName());
    Assert.assertEquals(TestConstants.REVIEW_TEST_DESCRIPTION, fReview.getReview().getExtraNotes());
    Assert.assertEquals(TestConstants.REVIEW_TEST_DUE_DATE, fReview.getReview().getDueDate());
    Assert.assertEquals(TestConstants.REVIEW_TEST_PROJECT, fReview.getReview().getProject());
    for (int i = 0; i < TestConstants.REVIEW_TEST_COMPONENTS.length; i++) {
      Assert.assertEquals(
          TestConstants.REVIEW_TEST_COMPONENTS[i], fReview.getReview().getComponents().get(i));
    }
    Assert.assertEquals(
        TestConstants.REVIEW_TEST_ENTRY_CRITERIA, fReview.getReview().getEntryCriteria());
    Assert.assertEquals(TestConstants.REVIEW_TEST_OBJECTIVES, fReview.getReview().getObjectives());
    Assert.assertEquals(
        TestConstants.REVIEW_TEST_REFERENCE_MATERIALS, fReview.getReview().getReferenceMaterial());
    Assert.assertTrue(fReview.isOpen());
  }
  /** Method setViewTree. */
  public void setViewTree() {
    final Object[] expandedElements = getExpandedElements();

    double elementColumnWidth = R4EUIConstants.INVALID_VALUE;
    double pathColumnWidth = R4EUIConstants.INVALID_VALUE;
    double assignColumnWidth = R4EUIConstants.INVALID_VALUE;
    double numChangesColumnWidth = R4EUIConstants.INVALID_VALUE;
    double numAnomaliesColumnWidth = R4EUIConstants.INVALID_VALUE;

    if (null != fElementColumn) {
      elementColumnWidth = fElementColumn.getColumn().getWidth();
    }
    createElementsColumn();
    getTree().setHeaderVisible(false);
    if (null != fPathColumn) {
      pathColumnWidth = fPathColumn.getColumn().getWidth();
      fPathColumn.getColumn().dispose();
      fPathColumn = null;
    }
    if (null != fAssignColumn) {
      assignColumnWidth = fAssignColumn.getColumn().getWidth();
      fAssignColumn.getColumn().dispose();
      fAssignColumn = null;
    }
    if (null != fNumChangesColumn) {
      numChangesColumnWidth = fNumChangesColumn.getColumn().getWidth();
      fNumChangesColumn.getColumn().dispose();
      fNumChangesColumn = null;
    }
    if (null != fNumAnomaliesColumn) {
      numAnomaliesColumnWidth = fNumAnomaliesColumn.getColumn().getWidth();
      fNumAnomaliesColumn.getColumn().dispose();
      fNumAnomaliesColumn = null;
    }
    fTreeColumnLayout.setColumnData(fElementColumn.getColumn(), new ColumnWeightData(100, true));

    // Calculate column weights to preserve (if any)
    if (elementColumnWidth != R4EUIConstants.INVALID_VALUE
        && pathColumnWidth != R4EUIConstants.INVALID_VALUE
        && assignColumnWidth != R4EUIConstants.INVALID_VALUE
        && numChangesColumnWidth != R4EUIConstants.INVALID_VALUE
        && numAnomaliesColumnWidth != R4EUIConstants.INVALID_VALUE) {
      final double totalWidth =
          elementColumnWidth
              + pathColumnWidth
              + assignColumnWidth
              + numChangesColumnWidth
              + numAnomaliesColumnWidth;
      fElementColumnWeight = (int) ((elementColumnWidth / totalWidth) * 100);
      fPathColumnWeight = (int) ((pathColumnWidth / totalWidth) * 100);
      fAssignColumnWeight = (int) ((assignColumnWidth / totalWidth) * 100);
      fNumChangesColumnWeight = (int) ((numChangesColumnWidth / totalWidth) * 100);
      fNumAnomaliesColumnWeight = (int) ((numAnomaliesColumnWidth / totalWidth) * 100);
      fElementColumn
          .getColumn()
          .setWidth((int) totalWidth); // make sure width is reset to full treeViewer width
    }
    fIsDefaultDisplay = true;

    // Remove Tree Table filters
    final TreeTableFilter filter =
        ((ReviewNavigatorActionGroup) R4EUIModelController.getNavigatorView().getActionSet())
            .getTreeTableFilter();
    this.removeFilter(filter);

    // Restore Tree sorters (if any)
    setComparator(fTreeComparator);

    // Restore Default Tree input
    this.setInput(fDefaultInput);

    // Set Expanded states correctly
    final List<Object> updatedExpandedElements = new ArrayList<Object>();
    if (expandedElements.length > 0) {
      if (null != expandedElements[0]
          && null != ((IR4EUIModelElement) expandedElements[0]).getParent()) {
        updatedExpandedElements.add(((IR4EUIModelElement) expandedElements[0]).getParent());
        if (null != ((IR4EUIModelElement) expandedElements[0]).getParent().getParent()) {
          updatedExpandedElements.add(
              ((IR4EUIModelElement) expandedElements[0]).getParent().getParent());
        }
      }
      for (Object expandedElement : expandedElements) {
        if (null != expandedElement) {
          updatedExpandedElements.add(expandedElement);
        }
      }
    } else {
      final R4EUIReviewBasic activeReview = R4EUIModelController.getActiveReview();
      if (null != activeReview) {
        updatedExpandedElements.add(activeReview);
        if (null != activeReview.getParent()) {
          updatedExpandedElements.add(activeReview.getParent());
        }
      }
    }
    Object[] elementsToExpand =
        updatedExpandedElements.toArray(new Object[updatedExpandedElements.size()]);
    setExpandedElements(elementsToExpand);
  }