@@ -35,8 +35,8 @@ public class ConfigDialog extends DialogWrapper {
3535 private final JPanel panel = new JPanel ();
3636 private static List <JTextField > labelAreas = new ArrayList <>();
3737
38- private static final TextFieldWithBrowseButton pythonInterpreterTextField = new TextFieldWithBrowseButton () ;
39- private static final TextFieldWithBrowseButton dataOutputTextField = new TextFieldWithBrowseButton () ;
38+ private static TextFieldWithBrowseButton pythonInterpreterTextField ;
39+ private static TextFieldWithBrowseButton dataOutputTextField ;
4040
4141 private final JComboBox <Double > freqCombo = new ComboBox <>();
4242 private final JComboBox <String > deviceCombo = new ComboBox <>(new String []{"Mouse" });
@@ -54,6 +54,9 @@ public class ConfigDialog extends DialogWrapper {
5454 */
5555 public ConfigDialog (Project project ) throws IOException , InterruptedException {
5656 super (true );
57+ pythonInterpreterTextField = new TextFieldWithBrowseButton ();
58+ dataOutputTextField = new TextFieldWithBrowseButton ();
59+
5760 init ();
5861 setTitle ("CodeGRITS Configuration" );
5962 setSize (500 , 500 );
@@ -68,7 +71,7 @@ public ConfigDialog(Project project) throws IOException, InterruptedException {
6871 }
6972 pythonInterpreterTextField .setText (config .getPythonInterpreter ());
7073 }
71- if (getPythonInterpreter ().equals (selectPythonInterpreterPlaceHolder ) || getPythonInterpreter ().equals ("python" ) || getPythonInterpreter ().equals ("python3" ) || getPythonInterpreter ().equals ( "" ) || getPythonInterpreter ().endsWith ("python" ) || getPythonInterpreter ().endsWith ("python3" ) || getPythonInterpreter ().endsWith ("python.exe" ) || getPythonInterpreter ().endsWith ("python3.exe" )) {
74+ if (getPythonInterpreter ().equals (selectPythonInterpreterPlaceHolder ) || getPythonInterpreter ().equals ("python" ) || getPythonInterpreter ().equals ("python3" ) || getPythonInterpreter ().isEmpty ( ) || getPythonInterpreter ().endsWith ("python" ) || getPythonInterpreter ().endsWith ("python3" ) || getPythonInterpreter ().endsWith ("python.exe" ) || getPythonInterpreter ().endsWith ("python3.exe" )) {
7275
7376 pythonEnvironment = AvailabilityChecker .checkPythonEnvironment (getPythonInterpreter ());
7477 if (pythonEnvironment && checkBoxes .get (1 ).isSelected ()) {
@@ -259,7 +262,7 @@ protected JComponent createCenterPanel() {
259262 protected void textChanged (@ NotNull DocumentEvent e ) {
260263 try {
261264 //TODO: what if using mac/unix/anaconda
262- if (getPythonInterpreter ().equals ("python" ) || getPythonInterpreter ().equals ("python3" ) || getPythonInterpreter ().equals ( "" ) || getPythonInterpreter ().endsWith ("python" ) || getPythonInterpreter ().endsWith ("python3" ) || getPythonInterpreter ().endsWith ("python.exe" ) || getPythonInterpreter ().endsWith ("python3.exe" )) {
265+ if (getPythonInterpreter ().equals ("python" ) || getPythonInterpreter ().equals ("python3" ) || getPythonInterpreter ().isEmpty ( ) || getPythonInterpreter ().endsWith ("python" ) || getPythonInterpreter ().endsWith ("python3" ) || getPythonInterpreter ().endsWith ("python.exe" ) || getPythonInterpreter ().endsWith ("python3.exe" )) {
263266 pythonEnvironment = AvailabilityChecker .checkPythonEnvironment (getPythonInterpreter ());
264267 } else {
265268 pythonEnvironment = false ;
@@ -412,7 +415,7 @@ private void addLabelArea(boolean isEmpty) {
412415 Matcher lettersMatcher = lettersPattern .matcher (textField .getText ());
413416 Matcher punctuationMatcher = punctuationPattern .matcher (textField .getText ());
414417 Set <String > invalidChars = new HashSet <>();
415- if (spaceMatcher .matches () || text .equals ( "" )) {
418+ if (spaceMatcher .matches () || text .isEmpty ( )) {
416419 button .setEnabled (false );
417420 return new ValidationInfo ("Label cannot be empty" , textField );
418421 } else {
@@ -423,8 +426,8 @@ private void addLabelArea(boolean isEmpty) {
423426 button .setEnabled (false );
424427 }
425428 }
426- if (invalidChars .size () > 0 ) {
427- return new ValidationInfo ("Label cannot contain " + invalidChars . toString () , textField );
429+ if (! invalidChars .isEmpty () ) {
430+ return new ValidationInfo ("Label cannot contain " + invalidChars , textField );
428431 } else {
429432 button .setEnabled (true );
430433 return null ;
@@ -521,7 +524,7 @@ public static String getPythonInterpreter() {
521524 if (ProjectManager .getInstance ().getOpenProjects ().length == 0 ) {
522525 return "python" ;
523526 }
524- if (pythonInterpreterTextField .getText ().equals ( "" )
527+ if (pythonInterpreterTextField .getText ().isEmpty ( )
525528 || pythonInterpreterTextField .getText ().equals (selectPythonInterpreterPlaceHolder )) {
526529 return "python" ;
527530 }
0 commit comments