Exemple #1
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);
  }
Exemple #2
0
  public void valueChanged(ListSelectionEvent e) {
    if (e.getValueIsAdjusting()) {
      return;
    }

    JipMethod method = null;
    ListSelectionModel selectionModel = mMethods.getSelectionModel();
    if (!selectionModel.isSelectionEmpty()) {
      int iSelected = selectionModel.getMinSelectionIndex();
      iSelected = mAllMethodsSorterModel.modelIndex(iSelected);
      MethodRow row = mAllMethodsModel.getRow(iSelected);
      method = row.getMethod();
    }
    // System.out.println("valueChanged("+perMethod+")");
    mMethodModel.setValue(method);
  }
Exemple #3
0
  public JipViewer(String title, JipRun run) {
    super(title);

    addKeyListener(this);
    mMethodModel.addChangeListener(this);

    // build the call tree
    mCallTreeRoot = new TreeNode(title);
    buildTree(run, mCallTreeRoot);

    mCallTree = new JTree(mCallTreeRoot);
    mCallTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    mCallTree.addTreeSelectionListener(this);
    mCallTree.addKeyListener(this);

    // build the allMethods table
    Collection<JipRun.PerMethodInfo> perMethodInfos = run.perMethodsInTotalTimeOrder();
    long totalTimeForAllThreads = run.getTotalTimeForAllThreads();
    for (JipRun.PerMethodInfo perMethod : perMethodInfos) {
      MethodRow row = new MethodRow(perMethod.getMethod());
      for (JipFrame frame : perMethod.allFrames()) {
        if (!frame.isReentrant()) {
          row.addFrame(frame);
        }
        row.setTimeDenominator(totalTimeForAllThreads);
      }
      mAllMethodsModel.add(row);
    }
    mMethods = MethodViewer.makeTableForMethodRows(mAllMethodsModel);
    mMethods.getSelectionModel().addListSelectionListener(this);
    mMethods.addKeyListener(this);
    mAllMethodsSorterModel = (TableSorter) mMethods.getModel();

    // make the ByPackageViewer
    mPkgViewer = new ByPackageViewer(run);
    mPkgViewer.addKeyListener(this);

    // make the RemoteController
    mRemoteController = new RemoteController();
    mRemoteController.addKeyListener(this);

    // make the methodViewer
    MethodViewer methodViewer = new MethodViewer(run, mMethodModel);

    // combine all the views
    JTabbedPane tabPane = new JTabbedPane();
    tabPane.addTab("call tree", new JScrollPane(mCallTree));
    tabPane.addTab("methods", new JScrollPane(mMethods));
    tabPane.addTab("by package", new JScrollPane(mPkgViewer));
    tabPane.addTab("remote control", mRemoteController);
    tabPane.addTab("help", new HelpViewer());
    tabPane.addKeyListener(this);
    tabPane.setMinimumSize(new Dimension(100, 200));

    JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT, tabPane, methodViewer);
    setContentPane(split);

    pack();
    setSize(new Dimension(1024, 768));
    setVisible(true);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  }
Exemple #4
0
  public JipViewer(String title, JipRun run) {
    super(title);

    addKeyListener(this);
    mMethodModel.addChangeListener(this);

    // build the call tree
    mCallTreeRoot = new TreeNode(title);
    buildTree(run, mCallTreeRoot);

    mCallTree = new JTree(mCallTreeRoot);
    mCallTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    mCallTree.addTreeSelectionListener(this);
    mCallTree.addKeyListener(this);

    // build the allMethods table
    Collection<JipRun.PerMethodInfo> perMethodInfos = run.perMethodsInTotalTimeOrder();
    long totalTimeForAllThreads = run.getTotalTimeForAllThreads();
    for (JipRun.PerMethodInfo perMethod : perMethodInfos) {
      MethodRow row = new MethodRow(perMethod.getMethod());
      for (JipFrame frame : perMethod.allFrames()) {
        if (!frame.isReentrant()) {
          row.addFrame(frame);
        }
        row.setTimeDenominator(totalTimeForAllThreads);
      }
      mAllMethodsModel.add(row);
    }
    mAllMethodsModel.sort();
    mMethods = MethodViewer.makeTableForMethodRows(mAllMethodsModel);
    mMethods.getSelectionModel().addListSelectionListener(this);
    mMethods.addKeyListener(this);
    mAllMethodsSorterModel = (TableSorter) mMethods.getModel();

    // make the ByPackageViewer
    mPkgViewer = new ByPackageViewer(run);
    mPkgViewer.addKeyListener(this);

    // Make the classs count viewer

    mClassAllocationViewer = new ClassAllocationViewer(run);
    mClassAllocationViewer.addKeyListener(this);

    if (instanceNumero == 0) {
      // make the RemoteController only if root
      mRemoteController = new RemoteController();
      mRemoteController.addKeyListener(this);
    }

    // make the methodViewer
    MethodViewer methodViewerMethods = new MethodViewer(run, mMethodModel);
    MethodViewer methodViewerCallTree = new MethodViewer(run, mMethodModel);

    // combine all the views
    JTabbedPane tabPane = new JTabbedPane();
    if (instanceNumero != 0 || FIRST_HAS_DATA) {
      JSplitPane splitPane =
          new JSplitPane(
              JSplitPane.VERTICAL_SPLIT, new JScrollPane(mCallTree), methodViewerCallTree);
      splitPane.setLayout(new BoxLayout(splitPane, BoxLayout.Y_AXIS));
      tabPane.addTab("call tree", splitPane);
      splitPane =
          new JSplitPane(JSplitPane.VERTICAL_SPLIT, new JScrollPane(mMethods), methodViewerMethods);
      splitPane.setLayout(new BoxLayout(splitPane, BoxLayout.Y_AXIS));
      tabPane.addTab("methods", splitPane);
      tabPane.addTab("by package", new JScrollPane(mPkgViewer));
      tabPane.addTab("class allocation", mClassAllocationViewer);
    }

    if (instanceNumero == 0) {
      tabPane.addTab("remote control", mRemoteController);
    }

    tabPane.addTab("help", new HelpViewer());
    tabPane.addKeyListener(this);
    setContentPane(tabPane);
    pack();
    setSize(new Dimension(1024, 768));
    setVisible(true);

    if (instanceNumero == 0) {
      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    } else {
      setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    }
    instanceNumero++;
  }