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

Camelcade / Perl5-IDEA / #525521541

22 May 2025 06:26AM UTC coverage: 82.228% (-0.06%) from 82.29%
#525521541

push

github

hurricup
Fail if SDK is null

30870 of 37542 relevant lines covered (82.23%)

0.82 hits per line

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

92.98
/plugin/core/src/main/java/com/perl5/lang/perl/idea/run/PerlConfigurationEditorBase.java
1
/*
2
 * Copyright 2015-2020 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.run;
18

19
import com.intellij.openapi.editor.Document;
20
import com.intellij.openapi.options.ConfigurationException;
21
import com.intellij.openapi.options.SettingsEditor;
22
import com.intellij.openapi.project.Project;
23
import com.intellij.openapi.ui.ComboBox;
24
import com.intellij.openapi.ui.LabeledComponent;
25
import com.intellij.openapi.ui.VerticalFlowLayout;
26
import com.intellij.psi.PsiDocumentManager;
27
import com.intellij.psi.PsiFile;
28
import com.intellij.psi.PsiFileFactory;
29
import com.intellij.ui.CollectionComboBoxModel;
30
import com.intellij.ui.ColoredListCellRenderer;
31
import com.intellij.ui.EditorTextField;
32
import com.intellij.ui.components.JBTabbedPane;
33
import com.perl5.PerlBundle;
34
import com.perl5.lang.perl.fileTypes.PerlFileTypeScript;
35
import com.perl5.lang.perl.idea.run.debugger.PerlDebugOptions;
36
import com.perl5.lang.perl.idea.run.debugger.PerlDebugOptionsSets;
37
import org.jetbrains.annotations.NotNull;
38
import org.jetbrains.annotations.Nullable;
39

40
import javax.swing.*;
41
import java.awt.*;
42
import java.util.ArrayList;
43
import java.util.Objects;
44

45

46
public abstract class PerlConfigurationEditorBase<Settings extends PerlDebugOptions> extends SettingsEditor<Settings> {
47
  protected Project myProject;
48

49
  private JTextField myScriptCharset;
50
  private ComboBox<String> myStartMode;
51
  private JCheckBox myIsNonInteractiveModeEnabled;
52
  private JCheckBox myIsCompileTimeBreakpointsEnabled;
53
  private EditorTextField myInitCodeTextField;
54

55
  public PerlConfigurationEditorBase(Project project) {
1✔
56
    myProject = project;
1✔
57
  }
1✔
58

59
  @Override
60
  protected void resetEditorFrom(@NotNull Settings perlConfiguration) {
61
    myScriptCharset.setText(perlConfiguration.getScriptCharset());
1✔
62
    myIsCompileTimeBreakpointsEnabled.setSelected(perlConfiguration.isCompileTimeBreakpointsEnabled());
1✔
63
    myIsNonInteractiveModeEnabled.setSelected(perlConfiguration.isNonInteractiveModeEnabled());
1✔
64
    myInitCodeTextField.setText(perlConfiguration.getInitCode());
1✔
65
    myStartMode.setSelectedItem(perlConfiguration.getStartMode());
1✔
66
  }
1✔
67

68
  @Override
69
  protected void applyEditorTo(@NotNull Settings perlConfiguration) throws ConfigurationException {
70
    perlConfiguration.setScriptCharset(myScriptCharset.getText());
1✔
71
    perlConfiguration.setStartMode(Objects.requireNonNull(myStartMode.getSelectedItem()).toString());
1✔
72
    perlConfiguration.setNonInteractiveModeEnabled(myIsNonInteractiveModeEnabled.isSelected());
1✔
73
    perlConfiguration.setCompileTimeBreakpointsEnabled(myIsCompileTimeBreakpointsEnabled.isSelected());
1✔
74
    perlConfiguration.setInitCode(myInitCodeTextField.getText());
1✔
75
  }
1✔
76

77
  protected @Nullable JComponent getGeneralComponent() {
78
    return null;
1✔
79
  }
80

81
  protected @Nullable JComponent getDebuggingComponent() {
82
    JPanel panel = new JPanel();
1✔
83
    panel.setLayout(new VerticalFlowLayout(VerticalFlowLayout.TOP, 0, 5, true, false));
1✔
84

85
    myScriptCharset = new JTextField();
1✔
86
    LabeledComponent<JTextField> scriptCharset =
1✔
87
      LabeledComponent.create(myScriptCharset, PerlBundle.message("perl.run.option.script.encoding"));
1✔
88
    scriptCharset.setLabelLocation(BorderLayout.WEST);
1✔
89
    panel.add(scriptCharset);
1✔
90

91
    myStartMode = new ComboBox<>(new CollectionComboBoxModel<>(new ArrayList<>(PerlDebugOptionsSets.STARTUP_OPTIONS.keySet()))) {
1✔
92
      @Override
93
      public void setRenderer(ListCellRenderer renderer) {
94
        super.setRenderer(new ColoredListCellRenderer<>() {
1✔
95
          @Override
96
          protected void customizeCellRenderer(@NotNull JList list, String value, int index, boolean selected, boolean hasFocus) {
97
            append(PerlDebugOptionsSets.STARTUP_OPTIONS.get(value));
×
98
          }
×
99
        });
100
      }
1✔
101
    };
102

103
    LabeledComponent<?> startMode = LabeledComponent.create(myStartMode, PerlBundle.message("perl.run.option.debugger.startup.mode"));
1✔
104
    startMode.setLabelLocation(BorderLayout.WEST);
1✔
105
    panel.add(startMode);
1✔
106

107
    myIsNonInteractiveModeEnabled = new JCheckBox(PerlBundle.message("perl.run.option.debugger.noninteractive.mode"));
1✔
108
    panel.add(myIsNonInteractiveModeEnabled);
1✔
109

110
    myIsCompileTimeBreakpointsEnabled = new JCheckBox(PerlBundle.message("perl.run.option.debugger.compile.time.breakpoints"));
1✔
111
    panel.add(myIsCompileTimeBreakpointsEnabled);
1✔
112

113
    PsiFile fileFromText = PsiFileFactory.getInstance(myProject).createFileFromText("file.dummy", PerlFileTypeScript.INSTANCE, "", 0, true);
1✔
114
    Document document = PsiDocumentManager.getInstance(myProject).getDocument(fileFromText);
1✔
115
    myInitCodeTextField = new EditorTextField(document, myProject, PerlFileTypeScript.INSTANCE);
1✔
116
    myInitCodeTextField.setOneLineMode(false);
1✔
117
    myInitCodeTextField.setPreferredSize(new Dimension(0, 100));
1✔
118
    LabeledComponent<EditorTextField> initCode =
1✔
119
      LabeledComponent.create(myInitCodeTextField, PerlBundle.message("perl.run.option.debugger.init.code"));
1✔
120
    initCode.setLabelLocation(BorderLayout.NORTH);
1✔
121
    panel.add(initCode);
1✔
122

123
    return panel;
1✔
124
  }
125

126

127
  @Override
128
  protected @NotNull JComponent createEditor() {
129
    JComponent generalComponent = getGeneralComponent();
1✔
130
    JComponent debuggingComponent = getDebuggingComponent();
1✔
131

132
    if (generalComponent != null && debuggingComponent != null) {
1✔
133
      JBTabbedPane tabbedPaneWrapper = new JBTabbedPane();
1✔
134
      tabbedPaneWrapper.addTab(PerlBundle.message("perl.run.option.tab.general"), generalComponent);
1✔
135
      tabbedPaneWrapper.addTab(PerlBundle.message("perl.run.option.tab.debugging"), debuggingComponent);
1✔
136
      return tabbedPaneWrapper;
1✔
137
    }
138
    else if (generalComponent != null) {
1✔
139
      return generalComponent;
×
140
    }
141
    else if (debuggingComponent != null) {
1✔
142
      return debuggingComponent;
1✔
143
    }
144

145
    throw new RuntimeException("No components created for settings editor");
×
146
  }
147
}
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