diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..3d91c0a --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,17 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "java", + "name": "ApplicationView", + "request": "launch", + "mainClass": "edu.inventorym.ApplicationView", + "projectName": "UiView", + "vmArgs": " --module-path /home/sherwinp/workspace/javafx-sdk/lib --add-modules ALL-MODULE-PATH --enable-native-access=javafx.web,javafx.controls,javafx.graphics -Dcom.sun.management.jmxremote=false -Djava.awt.headless=true -XX:+DisableAttachMechanism" + }, + + ] +} \ No newline at end of file diff --git a/UiView/build.gradle b/UiView/build.gradle index 53bd8f7..de5360f 100644 --- a/UiView/build.gradle +++ b/UiView/build.gradle @@ -32,7 +32,7 @@ sourceSets { srcDirs = ['src/main/java'] } resources { - srcDirs = ['src/resources/media'] + srcDirs = ['src/resources'] } } test { @@ -64,6 +64,10 @@ dependencies { implementation 'org.openjfx:javafx-web:25.0.1' implementation group: 'org.slf4j', name: 'slf4j-api', version: '2.0.17' implementation group: 'org.slf4j', name: 'slf4j-simple', version: '2.0.17' + + implementation project(':Model') + implementation project(':Api') + } jar { @@ -71,7 +75,6 @@ jar { attributes 'Main-Class': application.mainClass } duplicatesStrategy = DuplicatesStrategy.EXCLUDE - from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } } } tasks.named('jar') { @@ -79,6 +82,6 @@ tasks.named('jar') { attributes('Implementation-Title': 'edu.inventorym.UiView', 'Implementation-Version': 1.0, 'Main-Class': application.mainClass, - 'Class-Path': 'lodge.reservationsystem javafx.base javafx.fxml javafx.controls javafx.graphics javafx.web com.google.gson .' ) + 'Class-Path': 'edu.inventorym.ApplicationView javafx.base javafx.controls javafx.graphics javafx.web .' ) } } diff --git a/UiView/src/main/java/edu/inventorym/ApplicationView.java b/UiView/src/main/java/edu/inventorym/ApplicationView.java index c4870f5..0d9625f 100644 --- a/UiView/src/main/java/edu/inventorym/ApplicationView.java +++ b/UiView/src/main/java/edu/inventorym/ApplicationView.java @@ -1,26 +1,47 @@ package edu.inventorym; import javafx.application.Application; -import javafx.fxml.FXMLLoader; -import javafx.scene.Parent; +import javafx.event.EventHandler; import javafx.scene.Scene; +import javafx.scene.web.WebEvent; +import javafx.scene.web.WebView; import javafx.stage.Stage; public class ApplicationView extends Application { - @Override - public void start(Stage primaryStage) { + + private void createWebView(Stage primaryStage, final String page) { + // create the JavaFX webview + final WebView webView = new WebView(); + + // show "alert" Javascript messages in stdout (useful to debug) + webView.getEngine().setOnAlert(new EventHandler>() { + @Override + public void handle(WebEvent arg0) { + System.err.println("alertwb1: " + arg0.getData()); + } + }); + try { - primaryStage.setTitle("Lodge ReservationSystem"); - Parent root = FXMLLoader.load(getClass().getClassLoader().getResource("mainViewModel.fxml")); - Scene scene = new Scene(root, 800, 600); + + webView.getEngine().load( + getClass().getResource(page).toExternalForm()); + + primaryStage.setTitle("Inventory Manager"); + Scene scene = new Scene(webView, 800, 600); primaryStage.setScene(scene); primaryStage.show(); - + } catch (Exception e) { e.printStackTrace(); } } + @Override + public void start(Stage primaryStage) { + final String PAGE = "/index.html"; + createWebView(primaryStage, PAGE); + } + public static void main(String[] args) { launch(args); } diff --git a/UiView/src/resources/css/style.css b/UiView/src/resources/css/style.css new file mode 100644 index 0000000..e0ba1a2 --- /dev/null +++ b/UiView/src/resources/css/style.css @@ -0,0 +1,3 @@ +body { + margin: 10px; +} \ No newline at end of file diff --git a/UiView/src/resources/index.html b/UiView/src/resources/index.html new file mode 100644 index 0000000..788e17e --- /dev/null +++ b/UiView/src/resources/index.html @@ -0,0 +1,12 @@ + + + + + Inventory HTML File + + + + +

Java desktop app with Web-based UI

+ + \ No newline at end of file