use of com.android.tools.profilers.memory.adapters.CaptureObject in project android by JetBrains.
the class MemoryProfilerStageView method captureObjectChanged.
private void captureObjectChanged() {
CaptureObject captureObject = getStage().getSelectedCaptureObject();
if (myClassView.getCurrentCapture() != captureObject) {
myClassView.reset();
myChartClassesSplitter.setSecondComponent(null);
myMainSplitter.setSecondComponent(null);
if (captureObject != null) {
// TODO don't rebuild the component, but update it
myChartClassesSplitter.setSecondComponent(myClassView.buildComponent(captureObject));
}
}
}
use of com.android.tools.profilers.memory.adapters.CaptureObject in project android by JetBrains.
the class MemoryClassView method buildComponent.
@Nullable
public JComponent buildComponent(@NotNull CaptureObject captureObject) {
myCaptureObject = captureObject;
JPanel classesPanel = new JPanel(new BorderLayout());
JPanel headingPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 0));
headingPanel.add(new JLabel(captureObject.toString()));
JToolBar toolBar = new JToolBar();
toolBar.setFloatable(false);
List<HeapObject> heaps = captureObject.getHeaps();
ComboBoxModel<HeapObject> comboBoxModel = new DefaultComboBoxModel<>(heaps.toArray(new HeapObject[heaps.size()]));
ComboBox<HeapObject> comboBox = new ComboBox<>(comboBoxModel);
comboBox.addActionListener(e -> {
Object item = comboBox.getSelectedItem();
if (item != null && item instanceof HeapObject) {
HeapObject heap = (HeapObject) item;
buildTree(classesPanel, heap);
myStage.selectHeap(heap);
}
});
toolBar.add(comboBox);
headingPanel.add(toolBar);
classesPanel.add(headingPanel, BorderLayout.PAGE_START);
boolean selected = false;
// TODO provide a default selection in the model API?
for (HeapObject heap : heaps) {
if (heap.getHeapName().equals("app")) {
comboBox.setSelectedItem(heap);
myStage.selectHeap(heap);
selected = true;
break;
}
}
if (!selected) {
HeapObject heap = heaps.get(0);
comboBox.setSelectedItem(heap);
myStage.selectHeap(heap);
}
return classesPanel;
}
Aggregations