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();
}
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);
}
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.
}
Aggregations