2727import java .awt .event .WindowAdapter ;
2828import java .awt .event .WindowEvent ;
2929import java .util .Objects ;
30- import javax .swing .JButton ;
31- import javax .swing .JCheckBox ;
32- import javax .swing .JComboBox ;
33- import javax .swing .JComponent ;
34- import javax .swing .JLabel ;
35- import javax .swing .JPanel ;
36- import javax .swing .KeyStroke ;
30+ import javax .swing .*;
3731import org .jetbrains .annotations .NotNull ;
3832
3933@ SuppressWarnings ({"PMD.TooManyFields" , "PMD.ExcessiveImports" })
@@ -44,7 +38,9 @@ public class ConfigurationDialog extends AbstractDialog {
4438
4539 private JCheckBox enable ;
4640 private LabeledComponent <TextFieldWithBrowseButton > modulePath ;
41+ private LabeledComponent <TextFieldWithBrowseButton > additionalPath ;
4742 private JCheckBox ignoreCurrentVersion ;
43+ private JCheckBox hasAdditionalPath ;
4844 private JComboBox <ComboBoxItemData > currentVersion ;
4945 private JComboBox <ComboBoxItemData > targetVersion ;
5046 private JComboBox <ComboBoxItemData > issueSeverityLevel ;
@@ -59,6 +55,8 @@ public class ConfigurationDialog extends AbstractDialog {
5955 private JLabel modulePathError ;//NOPMD
6056 private JLabel enableComment ;//NOPMD
6157 private JLabel enableCommentPath ;//NOPMD
58+ private JLabel additionalPathLabel ;//NOPMD
59+ private JLabel additionalPathError ;//NOPMD
6260
6361 /**
6462 * Configuration dialog.
@@ -76,6 +74,7 @@ public ConfigurationDialog(final @NotNull Project project) {
7674 setTitle (ConfigureUctAction .ACTION_NAME );
7775 getRootPane ().setDefaultButton (buttonOk );
7876
77+ hasAdditionalPath .addActionListener (event -> refreshAdditionalFields (hasAdditionalPath .isSelected ()));
7978 buttonOk .addActionListener (event -> onOK ());
8079 buttonCancel .addActionListener (event -> onCancel ());
8180
@@ -98,9 +97,13 @@ public void windowClosing(final WindowEvent event) {
9897 modulePathError .setText ("" );
9998 modulePathError .setFont (UIUtil .getLabelFont (UIUtil .FontSize .SMALL ));
10099 modulePathError .setForeground (new Color (252 , 119 , 83 ));
100+ additionalPathError .setText ("" );
101+ additionalPathError .setFont (UIUtil .getLabelFont (UIUtil .FontSize .SMALL ));
102+ additionalPathError .setForeground (new Color (252 , 119 , 83 ));
101103 enableComment .setForeground (JBColor .blue );
102104 enableCommentPath .setForeground (JBColor .blue );
103105 setDefaultValues ();
106+ refreshAdditionalFields (hasAdditionalPath .isSelected ());
104107 }
105108
106109 /**
@@ -120,12 +123,19 @@ public static void open(final @NotNull Project project) {
120123 */
121124 private void onOK () {
122125 modulePathError .setText ("" );
126+ additionalPathError .setText ("" );
123127
124128 if (modulePath .getComponent ().getText ().isEmpty ()
125129 || !UctModulePathValidatorUtil .validate (modulePath .getComponent ().getText ())) {
126130 modulePathError .setText ("The `Path To Analyse` field is empty or invalid" );
127131 return ;
128132 }
133+ if (hasAdditionalPath .isSelected () && additionalPath .getComponent ().getText ().isEmpty ()
134+ || hasAdditionalPath .isSelected ()
135+ && !UctModulePathValidatorUtil .validate (additionalPath .getComponent ().getText ())) {
136+ additionalPathError .setText ("The `Path To Analyse` field is empty or invalid" );
137+ return ;
138+ }
129139 settingsService .setEnabled (enable .isSelected ());
130140
131141 final ComboBoxItemData currentVersionItemData =
@@ -155,7 +165,8 @@ private void onOK() {
155165 )
156166 );
157167 settingsService .setIgnoreCurrentVersion (ignoreCurrentVersion .isSelected ());
158-
168+ settingsService .setHasAdditionalPath (hasAdditionalPath .isSelected ());
169+ settingsService .setAdditionalPath (additionalPath .getComponent ().getText ());
159170 exit ();
160171 }
161172
@@ -221,6 +232,15 @@ private void setDefaultValues() {
221232 }
222233 final Boolean shouldIgnore = settingsService .shouldIgnoreCurrentVersion ();
223234 ignoreCurrentVersion .setSelected (Objects .requireNonNullElse (shouldIgnore , false ));
235+
236+ final Boolean isShowAdditionalPath = settingsService .getHasAdditionalPath ();
237+ hasAdditionalPath .setSelected (
238+ Objects .requireNonNullElse (isShowAdditionalPath , false )
239+ );
240+
241+ if (settingsService .getAdditionalPath () != null ) {
242+ additionalPath .getComponent ().setText (settingsService .getAdditionalPath ());
243+ }
224244 }
225245
226246 /**
@@ -271,5 +291,20 @@ private void createUIComponents() {
271291 new FileChooserDescriptor (false , true , false , false , false , false )
272292 )
273293 );
294+
295+ additionalPath = new LabeledComponent <>();
296+ additionalPath .setComponent (new TextFieldWithBrowseButton ());
297+ additionalPath .getComponent ().addBrowseFolderListener (
298+ new TextBrowseFolderListener (
299+ new FileChooserDescriptor (false , true , false , false , false , false )
300+ )
301+ );
302+ }
303+
304+ private void refreshAdditionalFields (final boolean isEnabled ) {
305+ additionalPath .setEnabled (isEnabled );
306+ additionalPath .setVisible (isEnabled );
307+ additionalPathLabel .setVisible (isEnabled );
308+ additionalPathError .setVisible (isEnabled );
274309 }
275310}
0 commit comments