Skip to content

Commit 219a63b

Browse files
committed
fixed many bugs in windows
1 parent dda784f commit 219a63b

File tree

8 files changed

+66
-61
lines changed

8 files changed

+66
-61
lines changed

.idea/workspace.xml

Lines changed: 30 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build.gradle.kts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ plugins {
44
id("org.jetbrains.intellij") version "1.13.3"
55
}
66

7-
group = "com.nd"
8-
version = "0.2.0"
7+
group = "io.github.codegrits"
8+
version = "0.3.0"
99

1010
repositories {
1111
mavenCentral()
@@ -23,11 +23,18 @@ dependencies {
2323
// Configure Gradle IntelliJ Plugin
2424
// Read more: https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html
2525
intellij {
26-
version.set("2023.1.4")
26+
localPath.set( // Example paths
27+
if (System.getProperty("os.name").lowercase().contains("windows")) {
28+
"D:/Program Files/JetBrains/IntelliJ IDEA 2024.3.4.1"
29+
} else {
30+
"/Applications/PyCharm.app/Contents"
31+
}
32+
)
33+
// version.set("2023.1.4")
2734

28-
type.set("IC") // IntelliJ Community Edition
35+
// type.set("IC") // IntelliJ Community Edition
2936
// type.set("IU") // IntelliJ Ultimate Edition
30-
plugins.set(listOf("com.intellij.java"))
37+
// plugins.set(listOf("com.intellij.java"))
3138

3239
// type.set("PC") // PyCharm Community Edition
3340
// type.set("PY") // PyCharm Professional Edition
@@ -36,10 +43,6 @@ intellij {
3643
// type.set("CL") // CLion
3744

3845
// type.set("PS") // PhpStorm
39-
40-
// Fixme: Android Studio
41-
// type.set("IC")
42-
// plugins.set(listOf("android"))
4346
}
4447

4548
tasks {
@@ -54,7 +57,7 @@ tasks {
5457

5558
patchPluginXml {
5659
sinceBuild.set("222") // 2022.2 NOTE Java 17 is now required
57-
untilBuild.set("233.*")
60+
untilBuild.set("252.*")
5861
}
5962

6063
signPlugin {

src/main/java/actions/AddLabelAction.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,4 @@ public static void setIsEnabled(boolean isEnabled) {
4040
AddLabelAction.isEnabled = isEnabled;
4141
}
4242

43-
@Override
44-
public @NotNull String getTemplateText() {
45-
return description;
46-
}
4743
}

src/main/java/components/ConfigDialog.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

src/main/java/entity/Config.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public Config() {
4949
}
5050

5151
public boolean configExists() {
52-
try (FileReader fileReader = new FileReader(PathManager.getPluginsPath() + "/config.json")) {
52+
try (FileReader ignored = new FileReader(PathManager.getPluginsPath() + "/config.json")) {
5353
return true;
5454
} catch (Exception e) {
5555
return false;
@@ -91,7 +91,7 @@ public void loadFromJson() {
9191
dataOutputPath = jsonObject.get("dataOutputPath").getAsString();
9292
eyeTrackerDevice = jsonObject.get("eyeTrackerDevice").getAsInt();
9393
String labelsString = jsonObject.get("labels").getAsString().substring(1, jsonObject.get("labels").getAsString().length() - 1);
94-
if (labelsString.equals("")) {
94+
if (labelsString.isEmpty()) {
9595
labels = List.of();
9696
} else labels = List.of(labelsString.split(", "));
9797
checkBoxes = gson.fromJson(jsonObject.get("checkBoxes").getAsString(), new TypeToken<List<Boolean>>() {

src/main/java/trackers/EyeTracker.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -430,8 +430,8 @@ public void setPythonScriptTobii() {
430430
import time
431431
import sys
432432
import math
433-
434-
433+
434+
435435
def gaze_data_callback(gaze_data):
436436
message = '{}; {}, {}, {}, {}, {}; {}, {}, {}, {}, {}'.format(
437437
round(time.time() * 1000),
@@ -448,7 +448,7 @@ def gaze_data_callback(gaze_data):
448448
)
449449
print(message)
450450
sys.stdout.flush()
451-
451+
452452
found_eyetrackers = tr.find_all_eyetrackers()
453453
my_eyetracker = found_eyetrackers[0]
454454
my_eyetracker.set_gaze_output_frequency(freq)
@@ -469,11 +469,11 @@ public void setPythonScriptMouse() {
469469
import time
470470
import sys
471471
import math
472-
472+
473473
width, height = get_monitors()[0].width, get_monitors()[0].height
474474
start_time = time.time()
475475
last_time = start_time
476-
476+
477477
while time.time() - start_time <= math.inf:
478478
current_time = time.time()
479479
if current_time - last_time > 1 / freq:

src/main/java/utils/AvailabilityChecker.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public static boolean checkPythonEnvironment(String pythonInterpreter) throws IO
2525
import time
2626
import sys
2727
import math
28-
28+
2929
print('OK')
3030
""";
3131

@@ -42,7 +42,7 @@ public static boolean checkPythonEnvironment(String pythonInterpreter) throws IO
4242
public static boolean checkEyeTracker(String pythonInterpreter) throws IOException, InterruptedException {
4343
String pythonScript = """
4444
import tobii_research as tr
45-
45+
4646
found_eyetrackers = tr.find_all_eyetrackers()
4747
if found_eyetrackers == ():
4848
print('Not Found')
@@ -63,7 +63,7 @@ public static boolean checkEyeTracker(String pythonInterpreter) throws IOExcepti
6363
public static String getEyeTrackerName(String pythonInterpreter) throws IOException, InterruptedException {
6464
String pythonScript = """
6565
import tobii_research as tr
66-
66+
6767
found_eyetrackers = tr.find_all_eyetrackers()
6868
if found_eyetrackers == ():
6969
print('Not Found')
@@ -83,7 +83,7 @@ public static String getEyeTrackerName(String pythonInterpreter) throws IOExcept
8383
public static List<String> getFrequencies(String pythonInterpreter) throws IOException, InterruptedException {
8484
String pythonScript = """
8585
import tobii_research as tr
86-
86+
8787
found_eyetrackers = tr.find_all_eyetrackers()
8888
if found_eyetrackers == ():
8989
print('Not Found')

src/main/resources/META-INF/plugin.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!-- Plugin Configuration File. Read more: https://plugins.jetbrains.com/docs/intellij/plugin-configuration-file.html -->
22
<idea-plugin>
33
<!-- Unique identifier of the plugin. It should be FQN. It cannot be changed between the plugin versions. -->
4-
<id>com.nd.codegrits</id>
4+
<id>io.github.codegrits</id>
55

66
<!-- Public plugin name should be written in Title Case.
77
Guidelines: https://plugins.jetbrains.com/docs/marketplace/plugin-overview-page.html#plugin-name -->

0 commit comments

Comments
 (0)