55import com .google .gson .JsonObject ;
66import com .google .gson .JsonParser ;
77import com .google .gson .reflect .TypeToken ;
8+ import com .intellij .openapi .application .PathManager ;
89
910import java .io .FileReader ;
1011import java .io .FileWriter ;
@@ -48,7 +49,7 @@ public Config() {
4849 }
4950
5051 public boolean configExists () {
51- try (FileReader fileReader = new FileReader (" config.json" )) {
52+ try (FileReader fileReader = new FileReader (PathManager . getPluginsPath () + "/ config.json" )) {
5253 return true ;
5354 } catch (Exception e ) {
5455 return false ;
@@ -68,8 +69,10 @@ public void saveAsJson() {
6869 jsonObject .addProperty ("dataOutputPath" , dataOutputPath );
6970 jsonObject .addProperty ("eyeTrackerDevice" , eyeTrackerDevice );
7071
71- try (FileWriter fileWriter = new FileWriter ("config.json" )) {
72- fileWriter .write (jsonObject .toString ());
72+ Gson gson = new Gson ();
73+ try (FileWriter fileWriter = new FileWriter (PathManager .getPluginsPath () + "/config.json" )) {
74+ System .out .println (PathManager .getPluginsPath () + "/config.json" );
75+ fileWriter .write (gson .toJson (jsonObject ));
7376 } catch (Exception e ) {
7477 throw new RuntimeException (e );
7578 }
@@ -79,7 +82,7 @@ public void saveAsJson() {
7982 * Load the configuration from the JSON file.
8083 */
8184 public void loadFromJson () {
82- try (FileReader fileReader = new FileReader (" config.json" )) {
85+ try (FileReader fileReader = new FileReader (PathManager . getPluginsPath () + "/ config.json" )) {
8386 Gson gson = new Gson ();
8487 JsonElement jsonElement = JsonParser .parseReader (fileReader );
8588 JsonObject jsonObject = jsonElement .getAsJsonObject ();
0 commit comments