Search in sources :

Example 1 with ClassObject

use of com.android.tools.profilers.memory.adapters.ClassObject in project android by JetBrains.

the class MemoryClassView method buildTree.

private void buildTree(@NotNull JPanel parentPanel, @NotNull HeapObject heapObject) {
    ensureTreeInitialized(parentPanel, heapObject);
    assert myClassesTreeRoot != null && myClassesTreeModel != null;
    myClassesTreeRoot.removeAll();
    for (ClassObject classObject : heapObject.getClasses()) {
        // TODO handle package view
        myClassesTreeRoot.add(new MemoryObjectTreeNode<>(classObject));
    }
    myClassesTreeModel.nodeChanged(myClassesTreeRoot);
    myClassesTreeModel.reload();
}
Also used : ClassObject(com.android.tools.profilers.memory.adapters.ClassObject)

Example 2 with ClassObject

use of com.android.tools.profilers.memory.adapters.ClassObject in project android by JetBrains.

the class MemoryClassView method ensureTreeInitialized.

private void ensureTreeInitialized(@NotNull JPanel parentPanel, @NotNull HeapObject heapObject) {
    if (myClassesTree != null) {
        assert myClassesTreeModel != null && myClassesTreeRoot != null;
        return;
    }
    myClassesTreeRoot = new MemoryObjectTreeNode<>(new ClassObject() {

        @NotNull
        @Override
        public List<InstanceAttribute> getInstanceAttributes() {
            return Collections.emptyList();
        }
    });
    myClassesTreeModel = new DefaultTreeModel(myClassesTreeRoot);
    JTree tree = new Tree(myClassesTreeModel);
    tree.setRootVisible(false);
    tree.setShowsRootHandles(true);
    tree.addTreeSelectionListener(e -> {
        TreePath path = e.getPath();
        if (!e.isAddedPath()) {
            return;
        }
        assert path.getLastPathComponent() instanceof MemoryObjectTreeNode;
        MemoryObjectTreeNode classObject = (MemoryObjectTreeNode) path.getLastPathComponent();
        assert classObject.getAdapter() instanceof ClassObject;
        myStage.selectClass((ClassObject) classObject.getAdapter());
    });
    List<HeapObject.ClassAttribute> attributes = heapObject.getClassAttributes();
    ColumnTreeBuilder builder = new ColumnTreeBuilder(tree);
    for (ClassAttribute attribute : attributes) {
        builder.addColumn(myAttributeColumns.get(attribute).getBuilder());
    }
    builder.setTreeSorter((Comparator<MemoryObjectTreeNode<ClassObject>> comparator, SortOrder sortOrder) -> {
        myClassesTreeRoot.sort(comparator);
        myClassesTreeModel.nodeStructureChanged(myClassesTreeRoot);
    });
    builder.setBackground(ProfilerColors.MONITOR_BACKGROUND);
    myClassesTree = builder.build();
    parentPanel.add(myClassesTree, BorderLayout.CENTER);
}
Also used : ClassObject(com.android.tools.profilers.memory.adapters.ClassObject) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) Comparator(java.util.Comparator) ClassAttribute(com.android.tools.profilers.memory.adapters.HeapObject.ClassAttribute) TreePath(javax.swing.tree.TreePath) ColumnTreeBuilder(com.android.tools.adtui.common.ColumnTreeBuilder) Tree(com.intellij.ui.treeStructure.Tree)

Example 3 with ClassObject

use of com.android.tools.profilers.memory.adapters.ClassObject in project android by JetBrains.

the class MemoryProfilerStageView method classObjectChanged.

private void classObjectChanged() {
    ClassObject classObject = getStage().getSelectedClass();
    if (myInstanceView.getCurrentClassObject() != classObject) {
        myInstanceView.reset();
        myMainSplitter.setSecondComponent(null);
        if (classObject != null) {
            // TODO don't rebuild the component, but update it
            myMainSplitter.setSecondComponent(myInstanceView.buildComponent(classObject));
        }
    }
// TODO setup instance detail view.
}
Also used : ClassObject(com.android.tools.profilers.memory.adapters.ClassObject)

Aggregations

ClassObject (com.android.tools.profilers.memory.adapters.ClassObject)3 ColumnTreeBuilder (com.android.tools.adtui.common.ColumnTreeBuilder)1 ClassAttribute (com.android.tools.profilers.memory.adapters.HeapObject.ClassAttribute)1 Tree (com.intellij.ui.treeStructure.Tree)1 Comparator (java.util.Comparator)1 DefaultTreeModel (javax.swing.tree.DefaultTreeModel)1 TreePath (javax.swing.tree.TreePath)1