Search in sources :

Example 1 with HeapObject

use of com.android.tools.profilers.memory.adapters.HeapObject 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;
}
Also used : ComboBox(com.intellij.openapi.ui.ComboBox) HeapObject(com.android.tools.profilers.memory.adapters.HeapObject) HeapObject(com.android.tools.profilers.memory.adapters.HeapObject) ClassObject(com.android.tools.profilers.memory.adapters.ClassObject) CaptureObject(com.android.tools.profilers.memory.adapters.CaptureObject) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

CaptureObject (com.android.tools.profilers.memory.adapters.CaptureObject)1 ClassObject (com.android.tools.profilers.memory.adapters.ClassObject)1 HeapObject (com.android.tools.profilers.memory.adapters.HeapObject)1 ComboBox (com.intellij.openapi.ui.ComboBox)1 Nullable (org.jetbrains.annotations.Nullable)1