コード例 #1
0
  /** 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);
  }
コード例 #2
0
  /** 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);
  }