use of com.android.tools.profilers.memory.adapters.HeapObject.ClassAttribute 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);
}
Aggregations