Example #1
0
  private void selectInCallTree(JipMethod selectedMethod) {

    if (selectedMethod == null) {
      mCallTree.clearSelection();
      return;
    }

    // is this method already selected?
    TreePath curPath = mCallTree.getSelectionPath();
    if (curPath != null) {
      TreeNode curNode = (TreeNode) curPath.getLastPathComponent();
      JipMethod curMethod = curNode.getMethodOrNull();
      if (curMethod != null && curMethod.equals(selectedMethod)) {
        // we're done.
        return;
      }
    }

    TreePath newPath = mCallTreeRoot.findPathForMethod(selectedMethod);
    if (newPath == null) {
      System.out.println("no path to " + selectedMethod);
      return;
    }

    mCallTree.setSelectionPath(newPath);
    mCallTree.scrollPathToVisible(newPath);
  }
Example #2
0
  private void selectInAllMethods(JipMethod selectedMethod) {

    if (selectedMethod == null) {
      mMethods.clearSelection();
      return;
    }

    // which row should we select?
    boolean foundIt = false;
    int nRow = mAllMethodsModel.getRowCount();
    int iRow;
    for (iRow = 0; iRow < nRow; iRow++) {
      MethodRow scan = mAllMethodsModel.getRow(iRow);
      if (scan.getMethod().equals(selectedMethod)) {
        foundIt = true;
        break;
      }
    }
    if (!foundIt) {
      System.out.println("couldn't find " + selectedMethod.getName());
      return;
    }

    // update the listSelectionModel
    int iRowInView = mAllMethodsSorterModel.viewIndex(iRow);
    mMethods.getSelectionModel().setSelectionInterval(iRowInView, iRowInView);

    // scroll to contain the new selection
    Rectangle selectionRect = mMethods.getCellRect(iRowInView, 0, true);
    mMethods.scrollRectToVisible(selectionRect);
  }
Example #3
0
    // returns the first node that has the given method (or null if none)
    private TreeNode findNodeForMethod(TreeNode node, JipMethod seekingMethod) {
      JipMethod method = node.getMethodOrNull();
      if ((method != null) && method.equals(seekingMethod)) {
        return node;
      }

      int nKid = node.getChildCount();
      for (int iKid = 0; iKid < nKid; iKid++) {
        TreeNode kidNode = (TreeNode) node.getChildAt(iKid);
        TreeNode match = findNodeForMethod(kidNode, seekingMethod);
        if (match != null) {
          return match;
        }
      }

      return null;
    }