Logo Search packages:      
Sourcecode: visualvm version File versions  Download package

void org::netbeans::lib::profiler::ui::cpu::ReverseCallGraphPanel::prepareResults (  ) [inline, virtual]

Generate the data that can then be presented in this panel

!! FIX THIS! if (pNode instanceof PresoCPUCCTClassNode) { PresoCPUCCTClassNode.Extended extNode = (PresoCPUCCTClassNode.Extended)pNode; return StringUtils.mcsTimeToString(extNode.getTotalTime1()) + " ms"; } else {

!! FIX THIS! if (pRoot instanceof PrestimeCPUCCTClassNode) { pRoot.sortChildren(PrestimeCPUCCTClassNode.Extended.SORT_BY_TIME_1, order); } else {

Implements org::netbeans::lib::profiler::ui::ResultsPanel.

Definition at line 318 of file ReverseCallGraphPanel.java.

References org::netbeans::lib::profiler::ui::UIUtils::autoExpandRoot(), org::netbeans::lib::profiler::ui::components::treetable::ExtendedTreeTableModel::getColumnCount(), org::netbeans::lib::profiler::ui::components::JTreeTable::getTree(), org::netbeans::lib::profiler::ui::components::treetable::ExtendedTreeTableModel::isLeaf(), org::netbeans::lib::profiler::ui::UIUtils::makeTreeAutoExpandable(), org::netbeans::lib::profiler::utils::StringUtils::mcsTimeToString(), org::netbeans::lib::profiler::ui::components::JTreeTable::setRowHeight(), org::netbeans::lib::profiler::ui::UIConstants::SHOW_TABLE_HORIZONTAL_GRID, org::netbeans::lib::profiler::ui::UIConstants::SHOW_TABLE_VERTICAL_GRID, org::netbeans::lib::profiler::results::cpu::PrestimeCPUCCTNode::sortChildren(), org::netbeans::lib::profiler::ui::UIConstants::TABLE_SELECTION_BACKGROUND_COLOR, org::netbeans::lib::profiler::ui::UIConstants::TABLE_SELECTION_FOREGROUND_COLOR, and org::netbeans::lib::profiler::ui::UIConstants::TABLE_VERTICAL_GRID_COLOR.

                                 {
        initColumnsData();

        PrestimeCPUCCTNode rootNode = snapshot.getReverseCCT(threadId, selectedMethodId, currentView);

        initFirstColumnName();

        abstractTreeTableModel = new AbstractTreeTableModel(rootNode, sortingColumn, sortOrder) {
                public int getColumnCount() {
                    return columnCount;
                }

                public String getColumnName(int column) {
                    return columnNames[column];
                }

                public Class getColumnClass(int column) {
                    if (column == 0) {
                        return TreeTableModel.class;
                    } else {
                        return Object.class;
                    }
                }

                public Object getValueAt(Object node, int column) {
                    if (!snapshot.isCollectingTwoTimeStamps()) {
                        if (column > 2) {
                            column += 1;
                        }
                    }

                    PrestimeCPUCCTNode pNode = (PrestimeCPUCCTNode) node;

                    switch (column) {
                        case 0:
                            return getNodeName(pNode);
                        case 1:
                            return getNodeTimeRel(pNode);
                        case 2:
                            return getNodeTime(pNode);
                        case 3:
                            return getNodeSecondaryTime(pNode);
                        case 4:
                            return getNodeInvocations(pNode);
                    }

                    return null;
                }

                public String getColumnToolTipText(int col) {
                    return columnToolTips[col];
                }

                private String getNodeName(PrestimeCPUCCTNode pNode) {
                    return pNode.toString();
                }

                private Float getNodeTimeRel(PrestimeCPUCCTNode pNode) {
                    return new Float(pNode.getTotalTime0InPerCent());
                }

                private String getNodeTime(PrestimeCPUCCTNode pNode) {
                    return StringUtils.mcsTimeToString(pNode.getTotalTime0()) + " ms (" // NOI18N
                           + percentFormat.format(pNode.getTotalTime0InPerCent() / 100) + ")"; // NOI18N
                }

                private String getNodeSecondaryTime(PrestimeCPUCCTNode pNode) {
                    /*!!! FIX THIS! if (pNode instanceof PresoCPUCCTClassNode) {
                       PresoCPUCCTClassNode.Extended extNode = (PresoCPUCCTClassNode.Extended)pNode;
                       return StringUtils.mcsTimeToString(extNode.getTotalTime1()) + " ms";
                       } else {*/
                    return StringUtils.mcsTimeToString(pNode.getTotalTime1()) + " ms"; // NOI18N
                }

                private Integer getNodeInvocations(PrestimeCPUCCTNode pNode) {
                    return new Integer(pNode.getNCalls());
                }

                public void sortByColumn(int column, boolean order) {
                    sortOrder = order;

                    if (!snapshot.isCollectingTwoTimeStamps()) {
                        if (column > 2) {
                            column += 1;
                        }
                    }

                    PrestimeCPUCCTNode pRoot = (PrestimeCPUCCTNode) root;

                    switch (column) {
                        case 0:
                            pRoot.sortChildren(PrestimeCPUCCTNode.SORT_BY_NAME, order);

                            break;
                        case 1:
                            pRoot.sortChildren(PrestimeCPUCCTNode.SORT_BY_TIME_0, order);

                            break;
                        case 2:
                            pRoot.sortChildren(PrestimeCPUCCTNode.SORT_BY_TIME_0, order);

                            break;
                        case 3:
                            /*!!! FIX THIS! if (pRoot instanceof PrestimeCPUCCTClassNode) {
                               pRoot.sortChildren(PrestimeCPUCCTClassNode.Extended.SORT_BY_TIME_1, order);
                               } else { */
                            pRoot.sortChildren(PrestimeCPUCCTNode.SORT_BY_TIME_1, order);

                            break;
                        case 4:
                            pRoot.sortChildren(PrestimeCPUCCTNode.SORT_BY_INVOCATIONS, order);

                            break;
                    }
                }
                ;
                public boolean getInitialSorting(int column) {
                    return (column == 0);
                }
            };

        treeTableModel = new ExtendedTreeTableModel(abstractTreeTableModel);

        if (columnsVisibility != null) {
            treeTableModel.setColumnsVisibility(columnsVisibility);
        }

        treeTable = new JTreeTable(treeTableModel) {
                public void doLayout() {
                    int columnsWidthsSum = 0;
                    int realFirstColumn = -1;

                    int index;
                    TableColumnModel colModel = getColumnModel();

                    for (int i = 0; i < treeTableModel.getColumnCount(); i++) {
                        index = treeTableModel.getRealColumn(i);

                        if (index == 0) {
                            realFirstColumn = i;
                        } else {
                            columnsWidthsSum += colModel.getColumn(i).getPreferredWidth();
                        }
                    }

                    if (realFirstColumn != -1) {
                        colModel.getColumn(realFirstColumn)
                                .setPreferredWidth(Math.max(getWidth() - columnsWidthsSum, minNamesColumnWidth));
                    }

                    super.doLayout();
                }
                ;
            };
        treeTable.getAccessibleContext().setAccessibleName(TREETABLE_ACCESS_NAME);

        treeTable.setRowSelectionAllowed(true);
        treeTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        treeTable.setGridColor(UIConstants.TABLE_VERTICAL_GRID_COLOR);
        treeTable.setSelectionBackground(UIConstants.TABLE_SELECTION_BACKGROUND_COLOR);
        treeTable.setSelectionForeground(UIConstants.TABLE_SELECTION_FOREGROUND_COLOR);
        treeTable.setShowHorizontalLines(UIConstants.SHOW_TABLE_HORIZONTAL_GRID);
        treeTable.setShowVerticalLines(UIConstants.SHOW_TABLE_VERTICAL_GRID);
        treeTable.setRowMargin(UIConstants.TABLE_ROW_MARGIN);
        treeTable.setRowHeight(UIUtils.getDefaultRowHeight() + 2);
        treeTable.getInputMap(JTable.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
                 .put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "DEFAULT_ACTION"); // NOI18N
        treeTable.getActionMap().put("DEFAULT_ACTION",
                                     new AbstractAction() {
                public void actionPerformed(ActionEvent e) {
                    performDefaultAction();
                }
            }); // NOI18N

        // Disable traversing table cells using TAB and Shift+TAB
        Set keys = new HashSet(treeTable.getFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS));
        keys.add(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0));
        treeTable.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, keys);

        keys = new HashSet(treeTable.getFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS));
        keys.add(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.SHIFT_MASK));
        treeTable.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, keys);

        setColumnsData();

        UIUtils.autoExpandRoot(treeTable.getTree(), 2);
        UIUtils.makeTreeAutoExpandable(treeTable.getTree(), 2);

        treeTable.addKeyListener(new KeyAdapter() {
                public void keyPressed(KeyEvent e) {
                    if ((e.getKeyCode() == KeyEvent.VK_CONTEXT_MENU)
                            || ((e.getKeyCode() == KeyEvent.VK_F10) && (e.getModifiers() == InputEvent.SHIFT_MASK))) {
                        int selectedRow = treeTable.getSelectedRow();

                        if (selectedRow != -1) {
                            popupPath = treeTable.getTree().getPathForRow(selectedRow);

                            Rectangle cellRect = treeTable.getCellRect(selectedRow, 0, false);
                            callGraphPopupMenu.show(e.getComponent(), ((cellRect.x + treeTable.getSize().width) > 50) ? 50 : 5,
                                                    cellRect.y);
                        }
                    }
                }
            });

        treeTable.addMouseListener(new MouseAdapter() {
                public void mousePressed(MouseEvent e) {
                    if (e.getModifiers() == InputEvent.BUTTON3_MASK) {
                        popupPath = treeTable.getTree().getPathForRow(treeTable.rowAtPoint(e.getPoint()));

                        if (popupPath != null) {
                            treeTable.getTree().setSelectionPath(popupPath);
                        }
                    }
                }

                public void mouseClicked(MouseEvent e) {
                    popupPath = treeTable.getTree().getPathForRow(treeTable.rowAtPoint(e.getPoint()));

                    if (popupPath == null) {
                        if (e.getModifiers() == InputEvent.BUTTON3_MASK) {
                            treeTable.getTree().clearSelection();
                        }
                    } else {
                        if (e.getModifiers() == InputEvent.BUTTON3_MASK) {
                            callGraphPopupMenu.show(e.getComponent(), e.getX(), e.getY());
                        } else if ((e.getModifiers() == InputEvent.BUTTON1_MASK) && (e.getClickCount() == 2)) {
                            if (treeTableModel.isLeaf(popupPath.getPath()[popupPath.getPath().length - 1])) {
                                showSourceForMethod(popupPath);
                            }
                        }
                    }
                }
            });

        treeTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
                public void valueChanged(ListSelectionEvent e) {
                    int selectedRow = treeTable.getSelectedRow();

                    if (selectedRow == -1) {
                        return;
                    }

                    popupPath = treeTable.getTree().getPathForRow(selectedRow);
                }
            });

        treeTablePanel = new JTreeTablePanel(treeTable);
        treeTablePanel.setCorner(JScrollPane.UPPER_RIGHT_CORNER, cornerButton);
        add(treeTablePanel, BorderLayout.CENTER);
    }

Here is the call graph for this function:


Generated by  Doxygen 1.6.0   Back to index