Пример #1
0
  /**
   * Update the test results tabs.
   *
   * @param selectedTreeItem
   * @param selectedTab
   */
  public void updateView(TreeItem selectedTreeItem, String selectedTab) {
    if (Utils.isEmpty(selectedTreeItem)
        || Utils.isEmpty(selectedTab)
        || Utils.isEmpty(runTestComposite)) {
      return;
    }

    // Only clear the right side because user will either select an item from the results tree
    // or a tab. We do not want to clear the tree (on the left side).
    runTestComposite.clearTabs();

    ApexTestResult testResult = (ApexTestResult) selectedTreeItem.getData(TREEDATA_TEST_RESULT);
    // If there is no test result, there is nothing to do on the right hand side so just
    // show the test file
    if (Utils.isEmpty(testResult)) {
      // Get the code location and open the file
      ApexCodeLocation location =
          (ApexCodeLocation) selectedTreeItem.getData(TREEDATA_CODE_LOCATION);
      highlightLine(location);
      return;
    }

    // If there is an ApexTestResult to work with, then check which tab is in focus
    // so we can update lazily.
    switch (selectedTab) {
      case RunTestViewComposite.STACK_TRACE:
        showStackTrace(testResult.getMessage(), testResult.getStackTrace());
        break;
      case RunTestViewComposite.SYSTEM_LOG:
        String systemLogId = testResult.getApexLogId();
        String systemApexLog = tryToGetApexLog(selectedTreeItem, systemLogId);
        showSystemLog(systemApexLog);
        break;
      case RunTestViewComposite.USER_LOG:
        String userLogId = testResult.getApexLogId();
        String userApexLog = tryToGetApexLog(selectedTreeItem, userLogId);
        showUserLog(selectedTreeItem, userApexLog);
        break;
    }

    // Show the file after updating the right hand side
    ApexCodeLocation location = (ApexCodeLocation) selectedTreeItem.getData(TREEDATA_CODE_LOCATION);
    highlightLine(location);
  }