Added the initial application files.

This commit is contained in:
Andrew Lalis 2023-12-14 17:23:43 -05:00
parent fc30c5b9bb
commit b81b27770e
10 changed files with 258 additions and 2 deletions

39
.gitignore vendored Normal file
View File

@ -0,0 +1,39 @@
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
.idea/
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store

View File

@ -1,2 +1,5 @@
# perfin
Personal accounting desktop app to track your finances.
# Perfin
> *Per*sonal *Fin*ance
Personal accounting desktop app to track your finances using common file formats.

49
pom.xml Normal file
View File

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.andrewlalis</groupId>
<artifactId>perfin</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<javafx.version>21.0.1</javafx.version>
</properties>
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>${javafx.version}</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>${javafx.version}</version>
</dependency>
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.44.1.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.8</version>
<configuration>
<mainClass>com.andrewlalis.perfin.PerfinApp</mainClass>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,49 @@
package com.andrewlalis.perfin;
import javafx.application.Application;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
public class PerfinApp extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage stage) {
initMainScreen(stage);
Stage splashStage = showStartupSplashScreen();
// Once the splash stage is hidden, show the main stage.
splashStage.showingProperty().not().addListener((v, old, hidden) -> {
if (hidden) {
showMainScreen(stage);
}
});
}
private void initMainScreen(Stage stage) {
stage.hide();
stage.setScene(SceneUtil.load("/main.fxml"));
stage.setTitle("Perfin");
}
private void showMainScreen(Stage stage) {
System.out.println("Showing the main application.");
// stage.setMaximized(true);
stage.show();
}
/**
* Shows a startup "splash" screen for a short time.
* @return The stage in which the splash screen is shown.
*/
private Stage showStartupSplashScreen() {
Stage stage = new Stage();
stage.initStyle(StageStyle.UNDECORATED);
stage.setScene(SceneUtil.load("/startup-splash-screen.fxml"));
stage.setTitle("Loading");
stage.setResizable(false);
stage.show();
return stage;
}
}

View File

@ -0,0 +1,37 @@
package com.andrewlalis.perfin;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.net.URL;
public class SceneUtil {
public static Scene load(String fxml, Object controller) {
FXMLLoader loader = new FXMLLoader(SceneUtil.class.getResource(fxml));
if (controller != null) {
if (loader.getController() != null) {
throw new IllegalStateException("Cannot set loader for resource " + fxml + " because it has declared one already.");
}
loader.setController(controller);
}
try {
return new Scene(loader.load());
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
public static Scene load(String fxml) {
return load(fxml, null);
}
public static void addStylesheets(Scene scene, String... resources) {
for (String resource : resources) {
URL url = SceneUtil.class.getResource(resource);
if (url == null) throw new RuntimeException("Could not load resource " + resource);
scene.getStylesheets().add(url.toExternalForm());
}
}
}

View File

@ -0,0 +1,10 @@
package com.andrewlalis.perfin.control;
import javafx.fxml.FXML;
public class MainController {
@FXML
public void initialize() {
}
}

View File

@ -0,0 +1,36 @@
package com.andrewlalis.perfin.control;
import javafx.application.Platform;
import javafx.fxml.FXML;
import javafx.scene.control.Label;
import javafx.stage.Stage;
public class StartupSplashScreenController {
@FXML
public Label content;
@FXML
public void initialize() {
content.setText("Loading Perfin...");
Thread.ofVirtual().start(() -> {
try {
Thread.sleep(1000);
Platform.runLater(() -> content.setText("Still loading..."));
Thread.sleep(1000);
Platform.runLater(() -> content.setText("Almost done..."));
Thread.sleep(1000);
Platform.runLater(() -> content.setText("Done!"));
Thread.sleep(500);
System.out.println("Closing splash screen...");
Stage stage = (Stage) content.getScene().getWindow();
Platform.runLater(stage::close);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
});
}
}

View File

@ -0,0 +1,11 @@
module com.andrewlalis.perfin {
requires javafx.base;
requires javafx.controls;
requires javafx.fxml;
requires javafx.graphics;
requires org.xerial.sqlitejdbc;
exports com.andrewlalis.perfin to javafx.graphics;
opens com.andrewlalis.perfin.control to javafx.fxml;
}

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.AnchorPane?>
<AnchorPane xmlns="http://javafx.com/javafx"
xmlns:fx="http://javafx.com/fxml"
fx:controller="com.andrewlalis.perfin.control.MainController"
minWidth="600.0" minHeight="400.0"
>
<Label>Main UI</Label>
</AnchorPane>

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.AnchorPane?>
<AnchorPane xmlns="http://javafx.com/javafx"
xmlns:fx="http://javafx.com/fxml"
fx:controller="com.andrewlalis.perfin.control.StartupSplashScreenController"
prefHeight="200" prefWidth="400">
<Label fx:id="content" wrapText="true"/>
</AnchorPane>