@@ -52,21 +52,27 @@ public ConfigDialog(Project project) throws IOException, InterruptedException {
5252 setSize (500 , 500 );
5353 setAutoAdjustable (true );
5454 setResizable (false );
55- if (new File ("config.json" ).exists ()) {
56- loadConfig ();
55+ Config config = new Config ();
56+ if (config .configExists ()) {
57+ config .loadFromJson ();
58+ List <Boolean > selected = config .getCheckBoxes ();
59+ for (int i = 0 ; i < selected .size (); i ++) {
60+ checkBoxes .get (i ).setSelected (selected .get (i ));
61+ }
62+ pythonInterpreterTextField .setText (config .getPythonInterpreter ());
5763 }
58- addLabelArea (true );
5964 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" )) {
65+
6066 pythonEnvironment = AvailabilityChecker .checkPythonEnvironment (getPythonInterpreter ());
6167 if (pythonEnvironment && checkBoxes .get (1 ).isSelected ()) {
6268 eyeTracker = AvailabilityChecker .checkEyeTracker (getPythonInterpreter ());
6369 if (eyeTracker ) { //eye tracker found, add mouse and eye tracker name, add eye tracker freq
6470 String trackerName = AvailabilityChecker .getEyeTrackerName (getPythonInterpreter ());
6571 if (trackerName != null && !trackerName .equals ("Not Found" )) {
6672 deviceCombo .removeAllItems ();
67- deviceCombo .addItem (trackerName );
6873 deviceCombo .addItem ("Mouse" );
69- deviceCombo .setSelectedIndex (0 );
74+ deviceCombo .addItem (trackerName );
75+ deviceCombo .setSelectedIndex (1 );
7076 }
7177 List <String > freqList = AvailabilityChecker .getFrequencies (getPythonInterpreter ());
7278 freqCombo .removeAllItems ();
@@ -81,8 +87,7 @@ public ConfigDialog(Project project) throws IOException, InterruptedException {
8187 freqCombo .addItem (60.0 );
8288 freqCombo .addItem (120.0 );
8389 }
84- }
85- if (!checkBoxes .get (1 ).isSelected () || !pythonEnvironment ) {
90+ } else {
8691 freqCombo .setEnabled (false );
8792 deviceCombo .setEnabled (false );
8893 freqCombo .removeAllItems ();
@@ -93,11 +98,8 @@ public ConfigDialog(Project project) throws IOException, InterruptedException {
9398 freqCombo .addItem (120.0 );
9499 }
95100 }
96- Config config = new Config ();
97- if (config .configExists ()) {
98- config .loadFromJson ();
99- // load freq
100- freqCombo .setSelectedItem (config .getSampleFreq ());
101+ if (new File ("config.json" ).exists ()) {
102+ loadConfig ();
101103 }
102104 }
103105
@@ -114,16 +116,21 @@ private void loadConfig() {
114116 for (int i = 0 ; i < selected .size (); i ++) {
115117 checkBoxes .get (i ).setSelected (selected .get (i ));
116118 }
117-
118119 labelAreas = new ArrayList <>();
119120 for (int i = 0 ; i < labels .size (); i ++) {
120121 addLabelArea (false );
121122 labelAreas .get (i ).setText (labels .get (i ));
122123 }
124+ addLabelArea (true );
123125 freqCombo .setSelectedItem (freq );
124126 pythonInterpreterTextField .setText (config .getPythonInterpreter ());
125127 dataOutputTextField .setText (config .getDataOutputPath ());
126- deviceCombo .setSelectedIndex (config .getEyeTrackerDevice ());
128+
129+ if (deviceCombo .getItemCount () > 1 ){
130+ deviceCombo .setSelectedIndex (config .getEyeTrackerDevice ());
131+ } else {
132+ deviceCombo .setSelectedIndex (0 );
133+ }
127134 if (!checkBoxes .get (1 ).isSelected ()) {
128135 freqCombo .setEnabled (false );
129136 deviceCombo .setEnabled (false );
@@ -202,14 +209,9 @@ protected JComponent createCenterPanel() {
202209 checkBoxes .add (screenRecording );
203210 checkBoxPanel .add (screenRecording );
204211
205- JCheckBox transmitData = new JCheckBox ("Transmit Data" );
206- // checkBoxes.add(transmitData);
207- // checkBoxPanel.add(transmitData);
208-
209212 iDETracking .setBorder (new EmptyBorder (contentMargin ));
210213 eyeTracking .setBorder (new EmptyBorder (contentMargin ));
211214 screenRecording .setBorder (new EmptyBorder (contentMargin ));
212- transmitData .setBorder (new EmptyBorder (contentMargin ));
213215
214216 panel .add (checkBoxPanel );
215217
@@ -223,7 +225,6 @@ protected JComponent createCenterPanel() {
223225 pythonInterpreterLabel .setHorizontalTextPosition (JLabel .LEFT );
224226 panel .add (pythonInterpreterLabel );
225227
226- // pythonInterpreterTextField = new TextFieldWithBrowseButton();
227228 pythonInterpreterTextField .setEditable (false );
228229 pythonInterpreterTextField .setMaximumSize (new Dimension (500 , 40 ));
229230 pythonInterpreterTextField .setBorder (new EmptyBorder (contentMargin ));
@@ -265,7 +266,6 @@ protected void textChanged(@NotNull DocumentEvent e) {
265266
266267 panel .add (pythonInterpreterTextField );
267268
268-
269269 JLabel dataOutputLabel = new JLabel ("Data Output Path" );
270270 dataOutputLabel .setHorizontalTextPosition (JLabel .LEFT );
271271 dataOutputLabel .setBorder (new EmptyBorder (JBUI .insetsLeft (20 )));
@@ -277,15 +277,6 @@ protected void textChanged(@NotNull DocumentEvent e) {
277277 dataOutputTextField .setText (selectDataOutputPlaceHolder );
278278 dataOutputTextField .setAlignmentX (Component .LEFT_ALIGNMENT );
279279 dataOutputTextField .addBrowseFolderListener (new TextBrowseFolderListener (new FileChooserDescriptor (false , true , false , false , false , false )));
280- //
281- // new ComponentValidator(getDisposable()).withValidator(() -> {
282- // String text = dataOutputTextField.getText();
283- // if (text.equals("Select Data Output Folder")) {
284- // return new ValidationInfo("Please select a data output folder", dataOutputTextField.getTextField());
285- // }
286- // return null;
287- // }).installOn(dataOutputTextField.getTextField());
288-
289280
290281 panel .add (dataOutputTextField );
291282
@@ -321,6 +312,7 @@ protected void textChanged(@NotNull DocumentEvent e) {
321312
322313 eyeTracking .addChangeListener (e -> {
323314 freqCombo .setEnabled (eyeTracking .isSelected ());
315+ deviceCombo .setEnabled (eyeTracking .isSelected ());
324316 });
325317
326318 JPanel labelAreaPanel = new JPanel ();
@@ -333,7 +325,6 @@ protected void textChanged(@NotNull DocumentEvent e) {
333325 labelAreaPanel .add (labels );
334326 panel .add (labelAreaPanel );
335327
336-
337328 eyeTracking .addActionListener (actionEvent -> {
338329 if (!pythonEnvironment ) {
339330 eyeTracking .setSelected (false );
@@ -355,26 +346,23 @@ protected void textChanged(@NotNull DocumentEvent e) {
355346 String trackerName = AvailabilityChecker .getEyeTrackerName (getPythonInterpreter ());
356347 if (trackerName != null && !trackerName .equals ("Not Found" )) {
357348 deviceCombo .removeAllItems ();
358- deviceCombo .addItem (trackerName );
359349 deviceCombo .addItem ("Mouse" );
350+ deviceCombo .addItem (trackerName );
351+ deviceCombo .setSelectedIndex (1 );
360352 }
361- deviceCombo .setSelectedIndex (0 );
362353 List <String > freqList = AvailabilityChecker .getFrequencies (getPythonInterpreter ());
363354 freqCombo .removeAllItems ();
364355 for (String freq : freqList ) {
365356 freqCombo .addItem (Double .parseDouble (freq ));
366357 }
367358 new AlertDialog ("Eye tracker found." , AllIcons .General .InspectionsOK ).show ();
368-
369-
370359 }
371360 } catch (IOException | InterruptedException e ) {
372361 throw new RuntimeException (e );
373362 }
374363 }
375364 });
376365
377-
378366 return panel ;
379367 }
380368
0 commit comments