1919
2020import java .io .File ;
2121
22+ import javafx .stage .StageStyle ;
2223import org .slf4j .Logger ;
2324import org .slf4j .LoggerFactory ;
2425import org .slf4j .simple .SimpleLogger ;
5152
5253public class AppWish extends Application {
5354 private static final Logger log = LoggerFactory .getLogger (AppWish .class );
54- private static Stage mainStage ;
55+ public static Stage mainStage ;
5556 @ FXML
5657 public TextField tf_input ;
5758 @ FXML
@@ -64,8 +65,7 @@ public class AppWish extends Application {
6465 public Button btn_app_history ;
6566 @ FXML
6667 public Button btn_continue_on_application ;
67- @ FXML
68- public BorderPane bp_main ;
68+
6969 @ FXML
7070 public Button btn_StopGeneratedApp ;
7171 @ FXML
@@ -76,6 +76,7 @@ public class AppWish extends Application {
7676 private String javaExecutablePath ;
7777 private Process executingJavaAppProcess ;
7878 private boolean isCodeGenerationOnGoing = false ;
79+ private boolean isSuperAppGeneration = false ;
7980
8081 public static void main (String [] args ) {
8182 launch (args );
@@ -101,18 +102,25 @@ public void stop() throws Exception {
101102 super .stop ();
102103 }
103104
105+ private void loadSplashScreen (Stage primaryStage ) throws IOException {
106+
107+ // Load splashscreen.fxml and show it
108+ Parent root = FXMLLoader .load (requireNonNull (getClass ().getClassLoader ().getResource ("splashscreen.fxml" )));
109+ Stage splashStage = new Stage ();
110+ splashStage .setScene (new Scene (root ));
111+ splashStage .initStyle (StageStyle .UNDECORATED );
112+ splashStage .show ();
113+ }
114+
115+
104116 @ Override
105117 public void start (Stage primaryStage ) throws IOException {
106- System .setProperty (SimpleLogger .DEFAULT_LOG_LEVEL_KEY , "DEBUG" );
107- Parent root = FXMLLoader .load (requireNonNull (getClass ().getClassLoader ().getResource (DEFAULT_FXML_FILE )));
108- mainStage = primaryStage ;
109- mainStage .setResizable (false );
110- primaryStage .setResizable (false );
111- primaryStage .setTitle (GUIConstants .DEFAULT_STAGE_TITLE );
112- Scene scene = new Scene (root );
113- primaryStage .setScene (scene );
114- primaryStage .show ();
115- System .out .println ("\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n " );
118+ System .setProperty (SimpleLogger .DEFAULT_LOG_LEVEL_KEY , "INFO" );
119+
120+
121+ // Splash Screen
122+ loadSplashScreen (primaryStage );
123+
116124
117125 }
118126
@@ -121,6 +129,7 @@ public void start(Stage primaryStage) throws IOException {
121129 */
122130 private void onAppWish (CodeEvent codeEvent ) {
123131 isCodeGenerationOnGoing = true ;
132+ output_label .setStyle ("-fx-background-color: #00277c; -fx-text-fill: white;" );
124133 // The File Object will be null if it's a new app request or have
125134 // a value if it is a continuous build from an existing app
126135 File file ;
@@ -143,6 +152,7 @@ private void onAppWish(CodeEvent codeEvent) {
143152 file = null ;
144153 }
145154
155+ isSuperAppGeneration = false ;
146156
147157 ThreadPoolMaster .getInstance ().getExecutor ().execute (() -> {
148158 startGuiThread (codeEvent );
@@ -168,10 +178,11 @@ private void onAppWish(CodeEvent codeEvent) {
168178 private void onRunJavaApp (ActionEvent ae ) {
169179 btn_run_application .setVisible (false );
170180 btn_StopGeneratedApp .setVisible (true );
181+ output_label .setVisible (false );
171182
172183 if (javaExecutablePath != null ) {
173184
174- if (!output_label . isVisible () ) {
185+ if (!isCodeGenerationOnGoing ) {
175186 log .info ("Executing java app on path -> {}" , javaExecutablePath );
176187 }
177188 try {
@@ -188,8 +199,7 @@ private final ProcessBuilder GetProcessBuilderForRunningGeneratedJavaApplication
188199
189200 final String classPath = javaExecutablePath .replace (MAIN_DOT_JAVA , NOTHING_STRING );
190201
191- if (output_label .isVisible ()) {
192- // Super App Creation
202+ if (isSuperAppGeneration ) {
193203
194204 // Security
195205 if (classPath .concat (MAIN_DOT_JAVA ).equals (javaExecutablePath )) {
@@ -334,17 +344,22 @@ private void handleCompilationResult(boolean isSuperGeneration) {
334344 Platform .runLater (() -> {
335345 if (DataStorage .getInstance ().getJavaExecutionPath () != null || isSuperGeneration ) {
336346 if (!isSuperGeneration ) {
337- output_label . setVisible ( false );
347+
338348 btn_run_application .setVisible (true );
349+ output_label .setText (SUCCESS_ON_SUPER_APP_CREATION_TEXT );
350+ output_label .setStyle ("-fx-background-color: green; -fx-text-fill: white;" );
339351 }
340352 btn_run_application .setVisible (true );
341353 setButtonGroupVisibilityForCodeGenerationButtons (true );
342354 isCodeGenerationOnGoing = false ;
343355 if (isSuperGeneration ) {
344356 output_label .setText (SUCCESS_ON_SUPER_APP_CREATION_TEXT );
357+ output_label .setStyle ("-fx-background-color: green; -fx-text-fill: white;" );
358+
345359 }
346360 } else {
347- output_label .setText ("Something went wrong :(" );
361+ output_label .setText ("Failed! Try again or write an issue report." );
362+ output_label .setStyle ("-fx-background-color: red; -fx-text-fill: white;" );
348363 }
349364 });
350365
@@ -358,6 +373,7 @@ private void setButtonGroupVisibilityForCodeGenerationButtons(boolean isVisible)
358373 btn_create_application .setVisible (isVisible );
359374 btn_continue_on_application .setVisible (isVisible );
360375 btn_super_app_creation .setVisible (isVisible );
376+ btn_app_history .setVisible (isVisible );
361377 }
362378
363379 /**
@@ -399,6 +415,8 @@ private List<String> readTextByLinesFromFile(File file) {
399415 public void OnSuperAppCreationButton (ActionEvent ae ) {
400416
401417 isCodeGenerationOnGoing = true ;
418+ isSuperAppGeneration = true ;
419+ output_label .setStyle ("-fx-background-color: #00277c; -fx-text-fill: white;" );
402420 DataStorage .getInstance ().setCompilationJob (new CompilationJob (GUIConstants .DEFAULT_STAGE_TITLE ));
403421 ThreadPoolMaster .getInstance ().getExecutor ().execute (() -> {
404422 StartGuiThreadForSuperAppCreation ();
0 commit comments