Search in sources :

Example 1 with JavaCoverageEngine

use of com.intellij.coverage.JavaCoverageEngine in project intellij-community by JetBrains.

the class CoverageConfigurable method createEditor.

@NotNull
protected JComponent createEditor() {
    JPanel result = new JPanel(new GridBagLayout());
    final DefaultComboBoxModel runnersModel = new DefaultComboBoxModel();
    myCoverageRunnerCb = new JComboBox(runnersModel);
    final JavaCoverageEnabledConfiguration javaCoverageEnabledConfiguration = JavaCoverageEnabledConfiguration.getFrom(myConfig);
    LOG.assertTrue(javaCoverageEnabledConfiguration != null);
    final JavaCoverageEngine provider = javaCoverageEnabledConfiguration.getCoverageProvider();
    for (CoverageRunner runner : Extensions.getExtensions(CoverageRunner.EP_NAME)) {
        if (runner.acceptsCoverageEngine(provider)) {
            runnersModel.addElement(new CoverageRunnerItem(runner));
        }
    }
    myCoverageRunnerCb.setRenderer(new ListCellRendererWrapper<CoverageRunnerItem>() {

        @Override
        public void customize(JList list, CoverageRunnerItem value, int index, boolean selected, boolean hasFocus) {
            if (value != null) {
                setText(value.getPresentableName());
            }
        }
    });
    myCoverageRunnerCb.addActionListener(new ActionListener() {

        public void actionPerformed(final ActionEvent e) {
            final CoverageRunner runner = getSelectedRunner();
            enableTracingPanel(runner != null && runner.isCoverageByTestApplicable());
            myTrackPerTestCoverageCb.setEnabled(myTracingRb.isSelected() && canHavePerTestCoverage() && runner != null && runner.isCoverageByTestApplicable());
        }
    });
    myRunnerPanel = new JPanel(new GridBagLayout());
    myRunnerPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    myRunnerPanel.add(new JLabel("Choose coverage runner:"), new GridBagConstraints(0, 0, 1, 1, 0, 1, GridBagConstraints.WEST, GridBagConstraints.NONE, JBUI.insetsRight(10), 0, 0));
    myRunnerPanel.add(myCoverageRunnerCb, new GridBagConstraints(1, 0, 1, 1, 1, 1, GridBagConstraints.WEST, GridBagConstraints.NONE, JBUI.emptyInsets(), 0, 0));
    final JPanel cPanel = new JPanel(new VerticalFlowLayout());
    mySamplingRb = new JRadioButton("Sampling");
    cPanel.add(mySamplingRb);
    myTracingRb = new JRadioButton("Tracing");
    cPanel.add(myTracingRb);
    final ButtonGroup group = new ButtonGroup();
    group.add(mySamplingRb);
    group.add(myTracingRb);
    ActionListener samplingListener = new ActionListener() {

        public void actionPerformed(final ActionEvent e) {
            final CoverageRunner runner = getSelectedRunner();
            myTrackPerTestCoverageCb.setEnabled(canHavePerTestCoverage() && myTracingRb.isSelected() && runner != null && runner.isCoverageByTestApplicable());
        }
    };
    mySamplingRb.addActionListener(samplingListener);
    myTracingRb.addActionListener(samplingListener);
    myTrackPerTestCoverageCb = new JCheckBox("Track per test coverage");
    final JBPanel tracingPanel = JBUI.Panels.simplePanel(myTrackPerTestCoverageCb).withBorder(JBUI.Borders.emptyLeft(15));
    cPanel.add(tracingPanel);
    myRunnerPanel.add(cPanel, new GridBagConstraints(0, 1, GridBagConstraints.REMAINDER, 1, 1, 1, GridBagConstraints.WEST, GridBagConstraints.NONE, JBUI.emptyInsets(), 0, 0));
    final GridBagConstraints gc = new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, JBUI.emptyInsets(), 0, 0);
    result.add(myRunnerPanel, gc);
    JPanel panel = new JPanel(new GridBagLayout());
    panel.setBorder(IdeBorderFactory.createTitledBorder(ExecutionBundle.message("record.coverage.filters.title"), false));
    myClassFilterEditor = new MyClassFilterEditor(myProject);
    final GridBagConstraints bagConstraints = new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1, 1, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, JBUI.emptyInsets(), 0, 0);
    panel.add(myClassFilterEditor, bagConstraints);
    bagConstraints.weighty = 0;
    myTrackTestSourcesCb = new JCheckBox("Enable coverage in test folders");
    panel.add(myTrackTestSourcesCb, bagConstraints);
    gc.weighty = 1;
    gc.fill = GridBagConstraints.BOTH;
    result.add(panel, gc);
    myCoverageNotSupportedLabel = new JLabel(CodeInsightBundle.message("code.coverage.is.not.supported"));
    myCoverageNotSupportedLabel.setIcon(AllIcons.General.WarningDialog);
    result.add(myCoverageNotSupportedLabel, gc);
    return result;
}
Also used : JavaCoverageEngine(com.intellij.coverage.JavaCoverageEngine) CoverageRunner(com.intellij.coverage.CoverageRunner) ActionEvent(java.awt.event.ActionEvent) JBPanel(com.intellij.ui.components.JBPanel) ActionListener(java.awt.event.ActionListener) VerticalFlowLayout(com.intellij.openapi.ui.VerticalFlowLayout) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

CoverageRunner (com.intellij.coverage.CoverageRunner)1 JavaCoverageEngine (com.intellij.coverage.JavaCoverageEngine)1 VerticalFlowLayout (com.intellij.openapi.ui.VerticalFlowLayout)1 JBPanel (com.intellij.ui.components.JBPanel)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 NotNull (org.jetbrains.annotations.NotNull)1