@@ -40,6 +40,7 @@ public class ConfigurationDialog extends AbstractDialog {
4040 private LabeledComponent <TextFieldWithBrowseButton > modulePath ;
4141 private LabeledComponent <TextFieldWithBrowseButton > additionalPath ;
4242 private JCheckBox ignoreCurrentVersion ;
43+ private JCheckBox hasAdditionalPath ;
4344 private JComboBox <ComboBoxItemData > currentVersion ;
4445 private JComboBox <ComboBoxItemData > targetVersion ;
4546 private JComboBox <ComboBoxItemData > issueSeverityLevel ;
@@ -54,7 +55,6 @@ public class ConfigurationDialog extends AbstractDialog {
5455 private JLabel modulePathError ;//NOPMD
5556 private JLabel enableComment ;//NOPMD
5657 private JLabel enableCommentPath ;//NOPMD
57- private JCheckBox hasAdditionalPath ;
5858 private JLabel additionalPathLabel ;//NOPMD
5959 private JLabel additionalPathError ;//NOPMD
6060
@@ -103,6 +103,7 @@ public void windowClosing(final WindowEvent event) {
103103 enableComment .setForeground (JBColor .blue );
104104 enableCommentPath .setForeground (JBColor .blue );
105105 setDefaultValues ();
106+ refreshAdditionalFields (hasAdditionalPath .isSelected ());
106107 }
107108
108109 /**
@@ -129,8 +130,9 @@ private void onOK() {
129130 modulePathError .setText ("The `Path To Analyse` field is empty or invalid" );
130131 return ;
131132 }
132- if (additionalPath .getComponent ().getText ().isEmpty ()
133- || !UctModulePathValidatorUtil .validate (additionalPath .getComponent ().getText ())) {
133+ if (hasAdditionalPath .isSelected () && additionalPath .getComponent ().getText ().isEmpty ()
134+ || hasAdditionalPath .isSelected ()
135+ && !UctModulePathValidatorUtil .validate (additionalPath .getComponent ().getText ())) {
134136 additionalPathError .setText ("The `Path To Analyse` field is empty or invalid" );
135137 return ;
136138 }
@@ -232,17 +234,11 @@ private void setDefaultValues() {
232234 ignoreCurrentVersion .setSelected (Objects .requireNonNullElse (shouldIgnore , false ));
233235
234236 final Boolean isShowAdditionalPath = settingsService .getHasAdditionalPath ();
235- additionalPath . setEnabled (
237+ hasAdditionalPath . setSelected (
236238 Objects .requireNonNullElse (isShowAdditionalPath , false )
237239 );
238240
239- if (settingsService .getAdditionalPath () == null ) {
240- final String basePath = Settings .getMagentoPath (project );
241-
242- if (basePath != null ) {
243- additionalPath .getComponent ().setText (basePath );
244- }
245- } else {
241+ if (settingsService .getAdditionalPath () != null ) {
246242 additionalPath .getComponent ().setText (settingsService .getAdditionalPath ());
247243 }
248244 }
@@ -307,5 +303,8 @@ private void createUIComponents() {
307303
308304 private void refreshAdditionalFields (final boolean isEnabled ) {
309305 additionalPath .setEnabled (isEnabled );
306+ additionalPath .setVisible (isEnabled );
307+ additionalPathLabel .setVisible (isEnabled );
308+ additionalPathError .setVisible (isEnabled );
310309 }
311310}
0 commit comments