1212import com .intellij .openapi .actionSystem .AnActionEvent ;
1313import com .intellij .openapi .actionSystem .CommonDataKeys ;
1414import com .intellij .openapi .project .Project ;
15- import com .intellij .openapi .ui .DialogWrapper ;
1615import com .intellij .util .messages .MessageBus ;
1716import de .fraunhofer .iem .swan .assist .comm .SuggestNotifier ;
1817import de .fraunhofer .iem .swan .assist .data .JSONFileLoader ;
19- import de .fraunhofer .iem .swan .assist .ui . dialog . SwanLauncherDialog ;
18+ import de .fraunhofer .iem .swan .assist .data . PropertiesManager ;
2019import de .fraunhofer .iem .swan .assist .util .Constants ;
2120
22- import java .io .File ;
23- import java .util .HashMap ;
24-
2521public class SuggestAction extends AnAction {
2622
2723 /**
2824 * Obtains suggested methods from SWAN and loads them in a dialog for user classification.
29- *
3025 * @param e source event
3126 */
3227 @ Override
@@ -36,50 +31,17 @@ public void actionPerformed(AnActionEvent e) {
3631 MessageBus messageBus = project .getMessageBus ();
3732
3833 //Set output directory for plugin, if not set
39- if (!PropertiesComponent .getInstance (project ).isValueSet (Constants .SWAN_OUTPUT_DIR )) {
40-
41- setProjectPath (project );
42- } else {
43- File trainFile = new File (PropertiesComponent .getInstance (project ).getValue (Constants .SWAN_OUTPUT_DIR ));
44-
45- if (!trainFile .exists ())
46- setProjectPath (project );
47- }
34+ PropertiesManager .setProjectOutputPath (project );
4835
4936 SuggestThread suggestThread = new SuggestThread (project ,
50- "/Users/oshando/Projects/IdeaProjects/mois-evaluation/mois-rq3/resources/gxa-methods-r.json" ,
51- "/Users/oshando/Projects/IdeaProjects/mois-evaluation/mois-executor/project-jars/gxa"
52- );
37+ PropertiesComponent .getInstance (project ).getValue (Constants .SWAN_CONFIG_FILE ),
38+ PropertiesComponent .getInstance (project ).getValue (Constants .SWAN_SOURCE_DIR ));
5339 suggestThread .start ();
5440
5541 SuggestNotifier suggestNotifier = messageBus .syncPublisher (SuggestNotifier .SUGGEST_METHOD_TOPIC );
5642 suggestNotifier .startSuggestMethod ();
5743 }
5844
59- private void setProjectPath (Project project ) {
60-
61- //Launch SWAN Properties Dialog
62- SwanLauncherDialog dialog = new SwanLauncherDialog (project , true );
63- dialog .show ();
64-
65- if (dialog .getExitCode () == DialogWrapper .OK_EXIT_CODE ) {
66-
67- HashMap <String , String > swanParameters = dialog .getParameters ();
68-
69- File outputFolder = new File (swanParameters .get (Constants .SWAN_OUTPUT_DIR ));
70-
71- if (!outputFolder .exists ())
72- outputFolder .mkdir ();
73-
74- PropertiesComponent .getInstance (project ).setValue (Constants .SWAN_OUTPUT_DIR , swanParameters .get (Constants .SWAN_OUTPUT_DIR ));
75-
76-
77-
78-
79- System .out .println ("Set project path: : " + swanParameters .get (Constants .SWAN_OUTPUT_DIR ));
80- }
81- }
82-
8345 /**
8446 * Controls whether the action is enabled or disabled
8547 *
0 commit comments