Skip to content

Commit 4cdbfb2

Browse files
authored
Merge pull request #187 from pwgit-create/develop
Appwish Enterprise 2.0.5. PR to Master Branch
2 parents bb607be + 09e7afb commit 4cdbfb2

File tree

16 files changed

+307
-88
lines changed

16 files changed

+307
-88
lines changed

AppWish/AppWish/dependency-reduced-pom.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<groupId>pn.dev</groupId>
55
<artifactId>code-generator-gui-ollama</artifactId>
66
<name>CodeGenerator-GUI</name>
7-
<version>2.0.4</version>
7+
<version>2.0.5</version>
88
<description>The GUI interface for the pn.dev.code-generator-ollama library</description>
99
<inceptionYear>2024</inceptionYear>
1010
<developers>
@@ -20,6 +20,12 @@
2020
<timezone>Central European Time</timezone>
2121
</developer>
2222
</developers>
23+
<licenses>
24+
<license>
25+
<name>MIT License</name>
26+
<url>https://raw.githubusercontent.com/pwgit-create/APPWISH_OLLAMA/master/LICENSE</url>
27+
</license>
28+
</licenses>
2329
<build>
2430
<plugins>
2531
<plugin>

AppWish/AppWish/pom.xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<modelVersion>4.0.0</modelVersion>
66
<groupId>pn.dev</groupId>
77
<artifactId>code-generator-gui-ollama</artifactId>
8-
<version>2.0.4</version>
8+
<version>2.0.5</version>
99
<name>CodeGenerator-GUI</name>
1010

1111

@@ -53,7 +53,7 @@
5353
<dependency>
5454
<groupId>pn.dev</groupId>
5555
<artifactId>code-generator-ollama</artifactId>
56-
<version>2.0.4</version>
56+
<version>2.0.5</version>
5757
</dependency>
5858
<dependency>
5959
<groupId>org.openjfx</groupId>
@@ -65,7 +65,6 @@
6565
<artifactId>javafx-fxml</artifactId>
6666
<version>${javafx.version}</version>
6767
</dependency>
68-
6968
<dependency>
7069
<groupId>org.junit.jupiter</groupId>
7170
<artifactId>junit-jupiter-api</artifactId>

AppWish/AppWish/src/main/java/pn/app_wish/AppWish.java

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import java.io.File;
2121

22+
import javafx.stage.StageStyle;
2223
import org.slf4j.Logger;
2324
import org.slf4j.LoggerFactory;
2425
import org.slf4j.simple.SimpleLogger;
@@ -51,7 +52,7 @@
5152

5253
public 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();
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package pn.app_wish.constant;
2+
3+
4+
public record AboutConstants() {
5+
6+
private static final String APP_WISH_VERSION = "Appwish Enterprise 2.0.5";
7+
private static final String ABOUT_APP_WISH = "AppWish (2) is a open source project that creates Java applications from text input with the help of AI models";
8+
private static final String DEVELOPED_BY = "Pwgit-Create / Peter Westin";
9+
private static final String CONTACT = "\nEmail: snow_900@outlook.com";
10+
private static final String LINK_TO_DISCUSSION = "https://github.com/pwgit-create/APPWISH_OLLAMA/discussions";
11+
private static final String LINK_TO_ISSUE_PORTAL="https://github.com/pwgit-create/APPWISH_OLLAMA/issues";
12+
private static final String IF_YOU_LIKE_THE_PROJECT = "\n\nIf you like AppWish and wants to show your support, please let me know by leaving a post";
13+
private static final String THANKS_FOR_USING_APP_WISH_ENTERPRISE = "\n\nThanks for taking the time to read the about section, you rock! :)";
14+
15+
16+
/**
17+
* Builds an About String that can be used in the About section
18+
* @return String
19+
*/
20+
public static String BuildAboutString() {
21+
22+
return "Version: " +
23+
APP_WISH_VERSION +
24+
"\n\nWhat is AppWish used for? " +
25+
ABOUT_APP_WISH +
26+
"\n\nDeveloper: " +
27+
DEVELOPED_BY +
28+
"\n\nQuestions or in need of support? " +
29+
CONTACT +
30+
"\nIssue Portal: " +
31+
LINK_TO_ISSUE_PORTAL +
32+
"\n\nJoin the discussion and see updates: " +
33+
LINK_TO_DISCUSSION +
34+
IF_YOU_LIKE_THE_PROJECT +
35+
THANKS_FOR_USING_APP_WISH_ENTERPRISE;
36+
37+
}
38+
39+
/*
40+
Get the header text for the about section
41+
*/
42+
public static String GetHeaderText(){
43+
44+
return "AppWish Enterprise";
45+
}
46+
47+
/*
48+
Get the header text for the about section
49+
*/
50+
public static String GetTitleTest(){
51+
52+
return "About AppWish";
53+
}
54+
55+
}

AppWish/AppWish/src/main/java/pn/app_wish/constant/GUIConstants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package pn.app_wish.constant;
22

3-
public class GUIConstants {
3+
public record GUIConstants() {
44

55
public static final String DEFAULT_STAGE_TITLE ="App Wish";
66
public static final String DEFAULT_FXML_FILE="start.fxml";

AppWish/AppWish/src/main/java/pn/app_wish/controller/AppHistoryController.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@
88
import javafx.scene.Scene;
99
import javafx.scene.control.*;
1010
import javafx.scene.layout.AnchorPane;
11+
import javafx.scene.layout.GridPane;
1112
import javafx.scene.layout.Pane;
1213
import javafx.stage.Stage;
1314
import javafx.util.Callback;
1415
import org.slf4j.Logger;
1516
import org.slf4j.LoggerFactory;
1617
import pn.app_wish.AppWish;
18+
import pn.app_wish.constant.AboutConstants;
1719
import pn.app_wish.constant.GUIConstants;
1820
import pn.app_wish.constant.StaticAppWishConstants;
1921
import pn.app_wish.util.AppWishUtil;
@@ -51,12 +53,16 @@ public class AppHistoryController implements Initializable {
5153
@FXML
5254
private Button btnDeleteApp;
5355

56+
@FXML
57+
private Button btnAbout;
58+
5459
private Process executingJavaAppProcess;
5560

5661

5762
@Override
5863
public void initialize(URL url, ResourceBundle resourceBundle) {
5964
AnchorPane.setRightAnchor(btnMainScene, 0d);
65+
AnchorPane.setRightAnchor(btnDeleteApp, 0d);
6066
AnchorPane.setRightAnchor(btnStopApp, 80d);
6167
btnStopApp.setVisible(false);
6268
try {
@@ -163,6 +169,25 @@ private void showConfirmDialogForDeletionOfAnJavaApplication(ActionEvent ae) {
163169
}
164170
}
165171

172+
@FXML
173+
private void showAboutMessage(ActionEvent ae) {
174+
if (fileListView != null) {
175+
Alert alert = new Alert(Alert.AlertType.INFORMATION);
176+
alert.setTitle(AboutConstants.GetTitleTest());
177+
alert.setHeaderText(AboutConstants.GetHeaderText());
178+
179+
// Make text copyable
180+
final TextArea textArea = new TextArea(AboutConstants.BuildAboutString());
181+
textArea.setEditable(false);
182+
textArea.setWrapText(true);
183+
GridPane gridPane = new GridPane();
184+
gridPane.setMaxWidth(Double.MAX_VALUE);
185+
gridPane.add(textArea, 0, 0);
186+
alert.getDialogPane().setContent(gridPane);
187+
alert.showAndWait();
188+
}
189+
}
190+
166191
private void deleteJavaApp(File classFileOfApplication) {
167192

168193
Platform.runLater(() -> {
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package pn.app_wish.controller;
2+
import javafx.animation.PauseTransition;
3+
import javafx.fxml.FXML;
4+
import javafx.fxml.FXMLLoader;
5+
import javafx.fxml.Initializable;
6+
import javafx.scene.Parent;
7+
import javafx.scene.Scene;
8+
import javafx.scene.control.Label;
9+
import javafx.scene.image.Image;
10+
import javafx.scene.image.ImageView;
11+
import javafx.stage.Stage;
12+
import javafx.util.Duration;
13+
import pn.app_wish.AppWish;
14+
15+
import java.io.IOException;
16+
import java.net.URL;
17+
import java.util.Objects;
18+
import java.util.ResourceBundle;
19+
20+
21+
22+
23+
public class SplashScreenController implements Initializable {
24+
@FXML
25+
private ImageView splashImage;
26+
27+
@FXML
28+
private Label label;
29+
30+
@Override
31+
public void initialize(URL url, ResourceBundle rb) {
32+
33+
splashImage.setImage(new Image("shooting_star.png"));
34+
PauseTransition delay = new PauseTransition(Duration.seconds(3));
35+
delay.setOnFinished(event -> {
36+
// Close the SplashScreen and show the main application stage
37+
Stage splashStage = (Stage) splashImage.getScene().getWindow();
38+
splashStage.close();
39+
40+
try {
41+
Parent root = FXMLLoader.load(Objects.requireNonNull(getClass().getClassLoader().getResource("start.fxml")));
42+
Stage mainStage = new Stage();
43+
//mainStage.setResizable(false);
44+
mainStage.setScene(new Scene(root));
45+
46+
AppWish.mainStage = mainStage;
47+
mainStage.show();
48+
} catch (IOException ex) {
49+
// Handle exception
50+
}
51+
});
52+
delay.play();
53+
}
54+
}

AppWish/AppWish/src/main/resources/app_history.fxml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@
33
<?import javafx.scene.control.*?>
44
<?import javafx.scene.layout.*?>
55

6-
<AnchorPane prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/17.0.2-ea" xmlns:fx="http://javafx.com/fxml/1" fx:controller="pn.app_wish.controller.AppHistoryController">
6+
<AnchorPane maxHeight="400" maxWidth="592" minHeight="400.0" minWidth="592.0" style="-fx-background-color: #00277c; " xmlns="http://javafx.com/javafx/17.0.2-ea" xmlns:fx="http://javafx.com/fxml/1" fx:controller="pn.app_wish.controller.AppHistoryController">
77

8-
<ListView fx:id="fileListView" prefHeight="400.0" prefWidth="200.0" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="0.0" />
9-
<Button fx:id="selectButton" layoutX="210.0" layoutY="10.0" mnemonicParsing="false" onAction="#handleSelectButtonAction" style="-fx-background-color: green;" text="Run" textFill="#f8f8f8" />
8+
<ListView fx:id="fileListView" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="0.0" />
9+
10+
11+
<Button fx:id="selectButton" layoutX="248.0" layoutY="2.0" mnemonicParsing="false" onAction="#handleSelectButtonAction" style="-fx-background-color: #00328c" text="Run" textFill="#f8f8f8" />
1012
<Button fx:id="btnMainScene" mnemonicParsing="false" onAction="#goToMainScene" style="-fx-background-color: #00328c" text="Back" textFill="WHITE" />
1113
<Button fx:id="btnStopApp" mnemonicParsing="false" onAction="#stopExecutedJavaApp" style="-fx-background-color: red" text="Stop your app" textFill="WHITE" />
12-
<Button fx:id="btnDeleteApp" layoutX="531.0" layoutY="368.0" mnemonicParsing="false" onAction="#showConfirmDialogForDeletionOfAnJavaApplication" style="-fx-background-color:red;" text="Delete" textFill="#f5eef5" />
14+
<Button fx:id="btnDeleteApp" layoutX="531.0" layoutY="374.0" onAction="#showConfirmDialogForDeletionOfAnJavaApplication" style="-fx-background-color: #00328c" text="Delete" textFill="#f5eef5" />
15+
<Button fx:id="btnAbout" layoutX="248.0" layoutY="374.0" mnemonicParsing="false" onAction="#showAboutMessage" style="-fx-background-color: #00328c" text="About" textFill="#f5eef5" />
1316

1417
</AnchorPane>
Binary file not shown.

0 commit comments

Comments
 (0)