Search in sources :

Example 1 with CaptureObject

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));
        }
    }
}
Also used : CaptureObject(com.android.tools.profilers.memory.adapters.CaptureObject)

Example 2 with 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;
}
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)2 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