• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Camelcade / Perl5-IDEA / #525521581

06 Jun 2025 08:26AM UTC coverage: 82.33% (-0.02%) from 82.354%
#525521581

push

github

hurricup
Moved debugger properties to the respective bundle

18 of 26 new or added lines in 8 files covered. (69.23%)

158 existing lines in 31 files now uncovered.

30858 of 37481 relevant lines covered (82.33%)

0.82 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/plugin/core/src/main/java/com/perl5/lang/perl/idea/sdk/versionManager/PerlInstallForm.java
1
/*
2
 * Copyright 2015-2025 Alexandr Evstigneev
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 * http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16

17
package com.perl5.lang.perl.idea.sdk.versionManager;
18

19
import com.intellij.openapi.util.NlsSafe;
20
import com.intellij.ui.CollectionComboBoxModel;
21
import com.intellij.ui.ColoredListCellRenderer;
22
import com.intellij.ui.ComboboxSpeedSearch;
23
import com.intellij.ui.SimpleTextAttributes;
24
import com.intellij.util.ObjectUtils;
25
import com.perl5.PerlBundle;
26
import org.jetbrains.annotations.Nls;
27
import org.jetbrains.annotations.NotNull;
28
import org.jetbrains.annotations.Nullable;
29

30
import javax.swing.*;
31
import java.awt.*;
32
import java.util.ArrayList;
33
import java.util.Comparator;
34
import java.util.List;
35

36
public class PerlInstallForm {
37
  private final @NotNull InstallFormHelper myHelper;
38

39
  private JComboBox<String> myDistributionsComboBox;
40
  private JPanel myRootPanel;
41
  private JPanel myOptionsPanel;
42
  private JCheckBox myAddInstalledPerl5ToCheckBox;
43
  private JCheckBox mySetInstalledPerl5ForCheckBox;
44

45
  public PerlInstallForm(@Nullable PerlInstallFormOptions optionsForm,
46
                         @NotNull InstallFormHelper helper,
UNCOV
47
                         @NotNull List<String> distributionsList) {
×
48
    if (optionsForm != null) {
×
UNCOV
49
      myOptionsPanel.add(optionsForm.getRootPanel(), BorderLayout.CENTER);
×
50
    }
UNCOV
51
    myHelper = helper;
×
52

53
    distributionsList.sort(helper);
×
54

UNCOV
55
    myDistributionsComboBox.setModel(new CollectionComboBoxModel<>(distributionsList));
×
UNCOV
56
    myDistributionsComboBox.addActionListener(e -> updateState());
×
UNCOV
57
    myDistributionsComboBox.setRenderer(new ColoredListCellRenderer<>() {
×
58
      @Override
59
      protected void customizeCellRenderer(@NotNull JList<? extends String> list,
60
                                           @Nls @Nullable String value,
61
                                           int index,
62
                                           boolean selected,
63
                                           boolean hasFocus) {
64
        if (value == null) {
×
65
          return;
×
66
        }
UNCOV
67
        setIcon(myHelper.getIcon(value));
×
UNCOV
68
        if (myHelper.isInstalled(value)) {
×
69
          append(myHelper.cleanDistributionItem(value)).append(PerlBundle.message("installed"), SimpleTextAttributes.GRAY_ATTRIBUTES);
×
70
        }
71
        else {
UNCOV
72
          append(value);
×
73
        }
74
      }
×
75
    });
76
    ComboboxSpeedSearch.installSpeedSearch(myDistributionsComboBox, it -> it);
×
UNCOV
77
    myAddInstalledPerl5ToCheckBox.addChangeListener(e -> updateState());
×
UNCOV
78
    updateState();
×
79
  }
×
80

81
  public void disableChooseCheckbox() {
UNCOV
82
    mySetInstalledPerl5ForCheckBox.setEnabled(false);
×
83
  }
×
84

85
  protected void updateState() {
UNCOV
86
    myAddInstalledPerl5ToCheckBox.setEnabled(isAddInstalledPerl());
×
UNCOV
87
    myHelper.changed(this);
×
88
  }
×
89

90
  public boolean isAddInstalledPerl() {
UNCOV
91
    return myAddInstalledPerl5ToCheckBox.isSelected();
×
92
  }
93

94
  public boolean isChooseInstalledPerl() {
UNCOV
95
    return mySetInstalledPerl5ForCheckBox.isSelected();
×
96
  }
97

98
  public @NotNull String getSelectedDistributionId() {
UNCOV
99
    return myHelper.cleanDistributionItem(ObjectUtils.notNull((String)myDistributionsComboBox.getSelectedItem(), ""));
×
100
  }
101

102
  public JPanel getRootPanel() {
UNCOV
103
    return myRootPanel;
×
104
  }
105

106
  public static void configureThreadsCombobox(@NotNull JComboBox<Integer> threadsComboBox) {
107
    var coresCount = Runtime.getRuntime().availableProcessors();
×
UNCOV
108
    List<Integer> threadsList = new ArrayList<>(coresCount);
×
109
    for (int i = 1; i <= coresCount; i++) {
×
110
      threadsList.add(i);
×
111
    }
UNCOV
112
    threadsComboBox.setModel(new CollectionComboBoxModel<>(threadsList));
×
UNCOV
113
    threadsComboBox.setRenderer(new ColoredListCellRenderer<>() {
×
114
      @Override
115
      protected void customizeCellRenderer(@NotNull JList<? extends Integer> list,
116
                                           Integer value,
117
                                           int index,
118
                                           boolean selected,
119
                                           boolean hasFocus) {
UNCOV
120
        if (value == 1) {
×
121
          append(PerlBundle.message("single.thread"));
×
122
        }
123
        else {
UNCOV
124
          append(Integer.toString(value)).append(PerlBundle.message("threads"));
×
125
        }
126
      }
×
127
    });
UNCOV
128
    threadsComboBox.setSelectedIndex(0);
×
UNCOV
129
    ComboboxSpeedSearch.installSpeedSearch(threadsComboBox, Object::toString);
×
UNCOV
130
  }
×
131

132
  public interface InstallFormHelper extends Comparator<String> {
133
    /**
134
     * Invoked on sdk combobox change
135
     */
136
    void changed(@NotNull PerlInstallForm form);
137

138
    /**
139
     * Cleans {@code rawItem} from tech information, like {@code '(installed)'}
140
     */
141
    @NlsSafe
142
    String cleanDistributionItem(@NotNull String rawItem);
143

144
    /**
145
     * @return true iff rawItem is marked as installed
146
     */
147
    boolean isInstalled(@NotNull String rawItem);
148

149
    @Nullable
150
    Icon getIcon(@NotNull String distribution);
151
  }
152
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc