Search in sources :

Example 1 with NetworkSegment

use of com.android.tools.idea.monitor.ui.network.view.NetworkSegment in project android by JetBrains.

the class NetworkProfilerVisualTest method createComponentsList.

@Override
protected List<Animatable> createComponentsList() {
    long startTimeUs = myDataStore.getLatestTimeUs();
    Range timeCurrentRangeUs = new Range(startTimeUs - RangeScrollbar.DEFAULT_VIEW_LENGTH_US, startTimeUs);
    AnimatedTimeRange animatedTimeRange = new AnimatedTimeRange(timeCurrentRangeUs, 0);
    EventDispatcher<ProfilerEventListener> dummyDispatcher = EventDispatcher.create(ProfilerEventListener.class);
    mySegment = new NetworkSegment(timeCurrentRangeUs, myDataStore, dummyDispatcher);
    myDetailedView = new NetworkDetailedView();
    myDetailedView.setVisible(false);
    generateNetworkCaptureData(startTimeUs);
    myCaptureSegment = new NetworkCaptureSegment(timeCurrentRangeUs, new TestNetworkCaptureModel(), httpData -> myDetailedView.setVisible(true), dummyDispatcher);
    myRadioSegment = new NetworkRadioSegment(timeCurrentRangeUs, myDataStore, dummyDispatcher);
    List<Animatable> animatables = new ArrayList<>();
    animatables.add(animatedTimeRange);
    mySegment.createComponentsList(animatables);
    myCaptureSegment.createComponentsList(animatables);
    myRadioSegment.createComponentsList(animatables);
    animatables.add(myCaptureSegment);
    return animatables;
}
Also used : AnimatedTimeRange(com.android.tools.adtui.AnimatedTimeRange) NetworkCaptureModel(com.android.tools.idea.monitor.ui.network.model.NetworkCaptureModel) Range(com.android.tools.adtui.model.Range) NetworkSegment(com.android.tools.idea.monitor.ui.network.view.NetworkSegment) EventDispatcher(com.intellij.util.EventDispatcher) Animatable(com.android.tools.adtui.Animatable) AnimatedTimeRange(com.android.tools.adtui.AnimatedTimeRange) ProfilerEventListener(com.android.tools.idea.monitor.tool.ProfilerEventListener) RangeScrollbar(com.android.tools.adtui.RangeScrollbar) NetworkDetailedView(com.android.tools.idea.monitor.ui.network.view.NetworkDetailedView) ArrayList(java.util.ArrayList) java.awt(java.awt) VisualTest(com.android.tools.adtui.visualtests.VisualTest) HttpData(com.android.tools.idea.monitor.ui.network.model.HttpData) List(java.util.List) NonNull(com.android.annotations.NonNull) NetworkRadioSegment(com.android.tools.idea.monitor.ui.network.view.NetworkRadioSegment) NotNull(org.jetbrains.annotations.NotNull) SeriesDataStore(com.android.tools.datastore.SeriesDataStore) NetworkCaptureSegment(com.android.tools.idea.monitor.ui.network.view.NetworkCaptureSegment) javax.swing(javax.swing) ArrayList(java.util.ArrayList) NetworkCaptureSegment(com.android.tools.idea.monitor.ui.network.view.NetworkCaptureSegment) NetworkDetailedView(com.android.tools.idea.monitor.ui.network.view.NetworkDetailedView) Range(com.android.tools.adtui.model.Range) AnimatedTimeRange(com.android.tools.adtui.AnimatedTimeRange) Animatable(com.android.tools.adtui.Animatable) NetworkSegment(com.android.tools.idea.monitor.ui.network.view.NetworkSegment) ProfilerEventListener(com.android.tools.idea.monitor.tool.ProfilerEventListener) NetworkRadioSegment(com.android.tools.idea.monitor.ui.network.view.NetworkRadioSegment)

Example 2 with NetworkSegment

use of com.android.tools.idea.monitor.ui.network.view.NetworkSegment in project android by JetBrains.

the class ProfilerOverviewVisualTest method populateUi.

@Override
public void populateUi(JPanel panel) {
    GridBagLayout gbl = new GridBagLayout();
    GridBagConstraints gbc = new GridBagConstraints();
    JBPanel gridBagPanel = new JBPanel();
    gridBagPanel.setBorder(BorderFactory.createLineBorder(AdtUiUtils.DEFAULT_BORDER_COLOR, 1));
    gridBagPanel.setLayout(gbl);
    // TODO create some controls.
    final JPanel controls = VisualTest.createControlledPane(panel, gridBagPanel);
    // Add Mock Toolbar
    gbc.fill = GridBagConstraints.BOTH;
    gbc.gridy = 0;
    gbc.gridx = 0;
    gbc.gridwidth = 4;
    gbc.weightx = 0;
    gbc.weighty = 0;
    gridBagPanel.add(createToolbarPanel(), gbc);
    // Add Selection Overlay
    // TODO define sizes for x columns 0 and 1
    gbc.fill = GridBagConstraints.BOTH;
    gbc.gridy = 1;
    gbc.gridx = 2;
    gbc.gridwidth = 1;
    gbc.weightx = 1;
    gbc.weighty = 1;
    gridBagPanel.add(mSelection, gbc);
    // Add Accordion Control
    gbc.gridx = 0;
    gbc.gridwidth = 4;
    gbc.gridy = 1;
    gbc.weighty = 0;
    gbc.weightx = 0;
    gridBagPanel.add(mSegmentsContainer, gbc);
    // Add Scrollbar
    gbc.gridy = 2;
    gridBagPanel.add(mScrollbar, gbc);
    // TODO: fix me, currently it's throwing IllegalArgumentException, the reason is:
    // EventSegment is using {@code DeviceProfilerService} which doesn't exist in visual test concept.
    // Mock event segment
    //BaseSegment eventSegment = new EventSegment(mTimeCurrentRange, mDataStore, ICONS, mEventDispatcher);
    //setupAndRegisterSegment(eventSegment, EVENT_MIN_HEIGHT, MONITOR_PREFERRED_HEIGHT, MONITOR_MAX_HEIGHT);
    // Mock monitor segments
    BaseSegment networkSegment = new NetworkSegment(mTimeCurrentRange, mDataStore, mEventDispatcher);
    setupAndRegisterSegment(networkSegment, 0, MONITOR_PREFERRED_HEIGHT, MONITOR_MAX_HEIGHT);
    BaseSegment memorySegment = new MemorySegment(mTimeCurrentRange, mDataStore, mEventDispatcher);
    setupAndRegisterSegment(memorySegment, 0, MONITOR_PREFERRED_HEIGHT, MONITOR_MAX_HEIGHT);
    BaseSegment cpuSegment = new CpuUsageSegment(mTimeCurrentRange, mDataStore, mEventDispatcher);
    setupAndRegisterSegment(cpuSegment, 0, MONITOR_PREFERRED_HEIGHT, MONITOR_MAX_HEIGHT);
    // Timeline segment
    BaseSegment timeSegment = new TimeAxisSegment(mTimeCurrentRange, mTimeAxis, mEventDispatcher);
    setupAndRegisterSegment(timeSegment, TIME_AXIS_HEIGHT, TIME_AXIS_HEIGHT, TIME_AXIS_HEIGHT);
    // Add left spacer
    Dimension leftSpacer = new Dimension(BaseSegment.getSpacerWidth() + networkSegment.getLabelColumnWidth(), 0);
    gbc.gridy = 0;
    gbc.gridx = 0;
    gbc.gridwidth = 2;
    gbc.weightx = 0;
    gbc.weighty = 0;
    gridBagPanel.add(new Box.Filler(leftSpacer, leftSpacer, leftSpacer), gbc);
    // Add right spacer
    Dimension rightSpacerWidth = new Dimension(BaseSegment.getSpacerWidth(), 0);
    Box.Filler rightSpacer = new Box.Filler(rightSpacerWidth, rightSpacerWidth, rightSpacerWidth);
    gbc.gridy = 0;
    gbc.gridx = 3;
    gbc.gridwidth = 1;
    gbc.weightx = 0;
    gbc.weighty = 0;
    gridBagPanel.add(rightSpacer, gbc);
    // hide right space in L1 by default.
    rightSpacer.setVisible(false);
    // Resize the SelectionComponent based on whether we are in L1 or L2 view.
    // TODO construct/destroyed Level3 segment/elements as we expand/collapse segments
    mEventDispatcher.addListener(new ProfilerEventListener() {

        @Override
        public void profilerExpanded(@NotNull BaseProfilerUiManager.ProfilerType profilerType) {
            switch(profilerType) {
                case NETWORK:
                    maximizeSegment(networkSegment);
                    break;
                case CPU:
                    maximizeSegment(cpuSegment);
                    break;
                case MEMORY:
                    maximizeSegment(memorySegment);
                    break;
            }
            rightSpacer.setVisible(true);
            mResetProfilersButton.setEnabled(true);
        }

        @Override
        public void profilersReset() {
            // Sets all the components back to their preferred states.
            mLayout.resetComponents();
            rightSpacer.setVisible(false);
            mResetProfilersButton.setEnabled(false);
            backProfilersToL1();
        }

        private void maximizeSegment(BaseSegment segment) {
            mLayout.setState(segment, AccordionLayout.AccordionState.MAXIMIZE);
            segment.toggleView(true);
        }

        private void backProfilersToL1() {
            networkSegment.toggleView(false);
            cpuSegment.toggleView(false);
            memorySegment.toggleView(false);
        }
    });
}
Also used : CpuUsageSegment(com.android.tools.idea.monitor.ui.cpu.view.CpuUsageSegment) BaseProfilerUiManager(com.android.tools.idea.monitor.ui.BaseProfilerUiManager) JBPanel(com.intellij.ui.components.JBPanel) MemorySegment(com.android.tools.idea.monitor.ui.memory.view.MemorySegment) TimeAxisSegment(com.android.tools.idea.monitor.ui.TimeAxisSegment) BaseSegment(com.android.tools.idea.monitor.ui.BaseSegment) NetworkSegment(com.android.tools.idea.monitor.ui.network.view.NetworkSegment) ProfilerEventListener(com.android.tools.idea.monitor.tool.ProfilerEventListener)

Aggregations

ProfilerEventListener (com.android.tools.idea.monitor.tool.ProfilerEventListener)2 NetworkSegment (com.android.tools.idea.monitor.ui.network.view.NetworkSegment)2 NonNull (com.android.annotations.NonNull)1 Animatable (com.android.tools.adtui.Animatable)1 AnimatedTimeRange (com.android.tools.adtui.AnimatedTimeRange)1 RangeScrollbar (com.android.tools.adtui.RangeScrollbar)1 Range (com.android.tools.adtui.model.Range)1 VisualTest (com.android.tools.adtui.visualtests.VisualTest)1 SeriesDataStore (com.android.tools.datastore.SeriesDataStore)1 BaseProfilerUiManager (com.android.tools.idea.monitor.ui.BaseProfilerUiManager)1 BaseSegment (com.android.tools.idea.monitor.ui.BaseSegment)1 TimeAxisSegment (com.android.tools.idea.monitor.ui.TimeAxisSegment)1 CpuUsageSegment (com.android.tools.idea.monitor.ui.cpu.view.CpuUsageSegment)1 MemorySegment (com.android.tools.idea.monitor.ui.memory.view.MemorySegment)1 HttpData (com.android.tools.idea.monitor.ui.network.model.HttpData)1 NetworkCaptureModel (com.android.tools.idea.monitor.ui.network.model.NetworkCaptureModel)1 NetworkCaptureSegment (com.android.tools.idea.monitor.ui.network.view.NetworkCaptureSegment)1 NetworkDetailedView (com.android.tools.idea.monitor.ui.network.view.NetworkDetailedView)1 NetworkRadioSegment (com.android.tools.idea.monitor.ui.network.view.NetworkRadioSegment)1 JBPanel (com.intellij.ui.components.JBPanel)1