Skip to content

Commit f346c4c

Browse files
authored
Merge pull request #186 from pwgit-create/imBranch
Im branch
2 parents c69165c + 1072885 commit f346c4c

13 files changed

Lines changed: 130 additions & 19 deletions

File tree

AppWish/AppWish/dependency-reduced-pom.xml

Lines changed: 1 addition & 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>

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

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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);
@@ -114,9 +115,8 @@ private void loadSplashScreen(Stage primaryStage) throws IOException {
114115

115116
@Override
116117
public void start(Stage primaryStage) throws IOException {
117-
System.setProperty(SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "DEBUG");
118-
// App Screen
119-
//loadDefaultScreen(primaryStage);
118+
System.setProperty(SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "INFO");
119+
120120

121121
// Splash Screen
122122
loadSplashScreen(primaryStage);
@@ -129,6 +129,7 @@ public void start(Stage primaryStage) throws IOException {
129129
*/
130130
private void onAppWish(CodeEvent codeEvent) {
131131
isCodeGenerationOnGoing = true;
132+
output_label.setStyle("-fx-background-color: #00277c; -fx-text-fill: white;");
132133
// The File Object will be null if it's a new app request or have
133134
// a value if it is a continuous build from an existing app
134135
File file;
@@ -151,6 +152,7 @@ private void onAppWish(CodeEvent codeEvent) {
151152
file = null;
152153
}
153154

155+
isSuperAppGeneration = false;
154156

155157
ThreadPoolMaster.getInstance().getExecutor().execute(() -> {
156158
startGuiThread(codeEvent);
@@ -176,10 +178,11 @@ private void onAppWish(CodeEvent codeEvent) {
176178
private void onRunJavaApp(ActionEvent ae) {
177179
btn_run_application.setVisible(false);
178180
btn_StopGeneratedApp.setVisible(true);
181+
output_label.setVisible(false);
179182

180183
if (javaExecutablePath != null) {
181184

182-
if (!output_label.isVisible()) {
185+
if (!isCodeGenerationOnGoing) {
183186
log.info("Executing java app on path -> {}", javaExecutablePath);
184187
}
185188
try {
@@ -196,8 +199,7 @@ private final ProcessBuilder GetProcessBuilderForRunningGeneratedJavaApplication
196199

197200
final String classPath = javaExecutablePath.replace(MAIN_DOT_JAVA, NOTHING_STRING);
198201

199-
if (output_label.isVisible()) {
200-
// Super App Creation
202+
if (isSuperAppGeneration) {
201203

202204
// Security
203205
if (classPath.concat(MAIN_DOT_JAVA).equals(javaExecutablePath)) {
@@ -342,17 +344,22 @@ private void handleCompilationResult(boolean isSuperGeneration) {
342344
Platform.runLater(() -> {
343345
if (DataStorage.getInstance().getJavaExecutionPath() != null || isSuperGeneration) {
344346
if (!isSuperGeneration) {
345-
output_label.setVisible(false);
347+
346348
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;");
347351
}
348352
btn_run_application.setVisible(true);
349353
setButtonGroupVisibilityForCodeGenerationButtons(true);
350354
isCodeGenerationOnGoing = false;
351355
if (isSuperGeneration) {
352356
output_label.setText(SUCCESS_ON_SUPER_APP_CREATION_TEXT);
357+
output_label.setStyle("-fx-background-color: green; -fx-text-fill: white;");
358+
353359
}
354360
} else {
355-
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;");
356363
}
357364
});
358365

@@ -408,6 +415,8 @@ private List<String> readTextByLinesFromFile(File file) {
408415
public void OnSuperAppCreationButton(ActionEvent ae) {
409416

410417
isCodeGenerationOnGoing = true;
418+
isSuperAppGeneration = true;
419+
output_label.setStyle("-fx-background-color: #00277c; -fx-text-fill: white;");
411420
DataStorage.getInstance().setCompilationJob(new CompilationJob(GUIConstants.DEFAULT_STAGE_TITLE));
412421
ThreadPoolMaster.getInstance().getExecutor().execute(() -> {
413422
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(() -> {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public void initialize(URL url, ResourceBundle rb) {
4040
try {
4141
Parent root = FXMLLoader.load(Objects.requireNonNull(getClass().getClassLoader().getResource("start.fxml")));
4242
Stage mainStage = new Stage();
43-
mainStage.setResizable(false);
43+
//mainStage.setResizable(false);
4444
mainStage.setScene(new Scene(root));
4545

4646
AppWish.mainStage = mainStage;

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.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
import java.lang.Thread;
3+
4+
public class Countdown {
5+
public static void main(String[] args) {
6+
for (int i = 10; i >= 0; i--) {
7+
System.out.println(i);
8+
try {
9+
Thread.sleep(1000); // Wait for 1 second
10+
} catch (InterruptedException e) {
11+
e.printStackTrace();
12+
}
13+
}
14+
}
15+
}

AppWish/AppWish/src/main/resources/splashscreen.fxml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22

33
<?import javafx.scene.control.*?>
4+
<?import javafx.scene.effect.*?>
45
<?import javafx.scene.image.*?>
56
<?import javafx.scene.layout.*?>
67
<?import javafx.scene.text.*?>
@@ -14,8 +15,11 @@
1415
</ImageView>
1516
<Label layoutX="168.0" layoutY="242.0" text="AppWish Enterprise" textFill="WHITE">
1617
<font>
17-
<Font size="36.0" />
18+
<Font name="Arif" size="36.0" />
1819
</font>
20+
<effect>
21+
<DropShadow />
22+
</effect>
1923
</Label>
2024

2125
</AnchorPane>

0 commit comments

Comments
 (0)