Example usage for com.intellij.openapi.ui ThreeComponentsSplitter ThreeComponentsSplitter

List of usage examples for com.intellij.openapi.ui ThreeComponentsSplitter ThreeComponentsSplitter

Introduction

In this page you can find the example usage for com.intellij.openapi.ui ThreeComponentsSplitter ThreeComponentsSplitter.

Prototype

@Deprecated
public ThreeComponentsSplitter(boolean vertical) 

Source Link

Usage

From source file:com.android.tools.idea.profiling.view.AnalysisContentsDelegate.java

License:Apache License

public AnalysisContentsDelegate(@NotNull CapturePanel capturePanel) {
    myCapturePanel = capturePanel;//from  ww  w.j  a va  2  s. co m
    mySplitter = new ThreeComponentsSplitter(true);
    mySplitter.setDividerWidth(10);
    Disposer.register(this, mySplitter);

    myTaskPanel = new JPanel(new LayoutManager() {
        @Override
        public void addLayoutComponent(String s, Component component) {

        }

        @Override
        public void removeLayoutComponent(Component component) {

        }

        @Override
        public Dimension preferredLayoutSize(Container container) {
            return minimumLayoutSize(container);
        }

        @Override
        public Dimension minimumLayoutSize(Container container) {
            int width = 0;
            int height = 0;

            for (Component component : container.getComponents()) {
                Dimension componentSize = component.getPreferredSize();
                width = Math.max(componentSize.width, width);
                height += componentSize.height;
            }

            Insets insets = container.getInsets();
            return new Dimension(width + insets.left + insets.right, height + insets.top + insets.bottom);
        }

        @Override
        public void layoutContainer(Container container) {
            Insets insets = container.getInsets();
            int width = container.getWidth() - insets.left - insets.right;
            int startY = insets.top;

            for (Component component : container.getComponents()) {
                int componentHeight = component.getPreferredSize().height;
                component.setBounds(0, startY, width, componentHeight);
                startY += componentHeight;
            }
        }
    });
    myTaskPanel.setBackground(UIUtil.getListBackground());

    JScrollPane topScrollPane = ScrollPaneFactory.createScrollPane(myTaskPanel,
            ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    topScrollPane.setBorder(new MatteBorder(0, 0, 1, 0, JBColor.border()));

    JLabel resultsTitle = new JLabel(AndroidBundle.message("android.captures.analysis.results.title"),
            SwingConstants.LEFT);
    resultsTitle.setFont(UIUtil.getLabelFont(UIUtil.FontSize.SMALL));
    resultsTitle.setBorder(BorderFactory.createEmptyBorder(2, 5, 5, 10));

    myResultsTree = new Tree(new DefaultTreeModel(new DefaultMutableTreeNode(null)));
    myResultsTree.setRootVisible(false);
    myResultsTree.setShowsRootHandles(true);
    myResultsTree.setRowHeight(19);
    JScrollPane middleScrollPane = ScrollPaneFactory.createScrollPane(myResultsTree,
            ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    middleScrollPane.setBorder(new MatteBorder(1, 0, 1, 0, JBColor.border()));

    JPanel middlePanel = new JPanel(new BorderLayout());
    middlePanel.add(resultsTitle, BorderLayout.NORTH);
    middlePanel.add(middleScrollPane, BorderLayout.CENTER);

    JLabel explanationTitle = new JLabel(AndroidBundle.message("android.captures.analysis.explanation.title"),
            SwingConstants.LEFT);
    explanationTitle.setFont(UIUtil.getLabelFont(UIUtil.FontSize.SMALL));
    explanationTitle.setBorder(BorderFactory.createEmptyBorder(2, 5, 5, 10));

    myResultExplanationArea = new JTextPane();
    myResultExplanationArea.setBorder(new MatteBorder(1, 0, 0, 0, JBColor.border()));
    JScrollPane bottomScrollPane = ScrollPaneFactory.createScrollPane(myResultExplanationArea,
            ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    bottomScrollPane.setBorder(BorderFactory.createEmptyBorder());

    JPanel bottomPanel = new JPanel(new BorderLayout());
    bottomPanel.add(explanationTitle, BorderLayout.NORTH);
    bottomPanel.add(bottomScrollPane, BorderLayout.CENTER);

    mySplitter.setFirstComponent(topScrollPane);
    mySplitter.setInnerComponent(middlePanel);
    mySplitter.setLastComponent(bottomPanel);

    mySplitter.setFirstSize(128);
    mySplitter.setLastSize(128);

    myResultsTree.setCellRenderer(this);
    myCanRunAnalysis = myCapturePanel.getAnalyzerTasks().length > 0;
    for (final AnalyzerTask task : myCapturePanel.getAnalyzerTasks()) {
        final JBCheckBox taskCheckbox = new JBCheckBox(task.getTaskName(), true);
        taskCheckbox.addItemListener(new ItemListener() {
            @Override
            public void itemStateChanged(ItemEvent itemEvent) {
                if (itemEvent.getStateChange() == ItemEvent.SELECTED) {
                    myEnabledTasks.add(task);
                    myCanRunAnalysis = true;
                } else if (itemEvent.getStateChange() == ItemEvent.DESELECTED) {
                    myEnabledTasks.remove(task);
                }
            }
        });
        myTaskPanel.add(taskCheckbox);
        myEnabledTasks.add(task);
    }
}

From source file:com.android.tools.idea.profiling.view.CapturePanel.java

License:Apache License

public CapturePanel(@NotNull Project project, @NotNull CaptureEditor editor, @NotNull AnalyzerTask[] tasks,
        boolean startAsLoading) {
    myProject = project;/*  w ww .ja v a  2s .c  o  m*/
    myEditor = editor;
    myTasks = tasks;

    myThreeComponentsSplitter = new ThreeComponentsSplitter(false);
    myThreeComponentsSplitter.setHonorComponentsMinimumSize(true);
    Disposer.register(editor, myThreeComponentsSplitter);

    if (startAsLoading) {
        TaskInfo taskInfo = new TaskInfo() {
            @NotNull
            @Override
            public String getTitle() {
                return "";
            }

            @Override
            public String getCancelText() {
                return null;
            }

            @Override
            public String getCancelTooltipText() {
                return null;
            }

            @Override
            public boolean isCancellable() {
                return false;
            }

            @Override
            public String getProcessId() {
                return null;
            }
        };

        myProgressIndicator = new InlineProgressIndicator(true, taskInfo) {
            @Override
            protected void queueRunningUpdate(@NotNull Runnable update) {
                ApplicationManager.getApplication().invokeLater(update);
            }
        };

        setLayout(new GridBagLayout());
        add(myProgressIndicator.getComponent());
    }
}