From 7e7113538ab7108ea8b935e569fe40f53d4df945 Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 28 Nov 2024 07:42:00 +0000 Subject: [PATCH] example improvements --- java/embedControlJavaFx/README.md | 6 +++--- java/embeddedJavaDeviceUI/README.md | 20 +++++++++++++++++++- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/java/embedControlJavaFx/README.md b/java/embedControlJavaFx/README.md index abd109b..e4b8901 100644 --- a/java/embedControlJavaFx/README.md +++ b/java/embedControlJavaFx/README.md @@ -14,8 +14,6 @@ It is likely before any public release that you'll want to customize the applica * `fximg/embedCONTROL.ico` is the start-up application icon, only used by the packager on Windows * `fximg/MyIcons.icns` is the start-up application icon, only used by the packager on macOS -## Layout of the application - ## Overriding how pages are drawn By default, every time you navigate to a menu structure you'll see an auto-generated page. You can also provide your own custom pages, each page must extend from `PanelPresentable` and can be added to the navigation manager, in this case the `JfxNavigationHeader` in `RemoteConnectionPanel` using `navigationManager.addCustomMenuPanel(subMenuCustom, myPanelPresentable)`. By the time the `RemoteConnectionPanel` is constructed you know which board/UUID you're connected with, and can then determine if you want to override drawing for any submenus. @@ -30,7 +28,9 @@ Once the project has fully loaded, you can run the application by opening `Embed ## Building a packaged version -The below will produce you a package that can be used on most platforms supported by Java. It will use the [Java SDK jpackage tool](https://docs.oracle.com/en/java/javase/21/docs/specs/man/jpackage.html) to build a native image that can be installed onto a user system. +The below will produce you a package that can be used on most platforms supported by Java. It will use the [Java SDK jpackage tool](https://docs.oracle.com/en/java/javase/21/docs/specs/man/jpackage.html) to build a native image that can be installed onto a user system. + +From the command line you can use Apache Maven to do the build. Simply `mvn clean install` in this directory will build the app into the `target` directory. ### Building the embedCONTROLFx desktop UI for Windows diff --git a/java/embeddedJavaDeviceUI/README.md b/java/embeddedJavaDeviceUI/README.md index 3c954b9..f9d5e63 100644 --- a/java/embeddedJavaDeviceUI/README.md +++ b/java/embeddedJavaDeviceUI/README.md @@ -4,6 +4,24 @@ This application is the starting point for building an embedded Java TcMenu appl This app framework is somewhat opinionated, but if it doesn't match with what you need, you can always look at the Java API examples. +## Creating a project based on this code + +In either case the create project process will output a starter project very similar to this working project, you can then decide which of the optional components you want to keep, these are the components that are in the `optional` package. By default it will have a Jetty webserver that serves up browser based EmbedControlJS and a JavaFX UI. + +### From the CLI simply + + tcmenu create-project -p RASPBERRY_PIJ -v -n "com.example.menu" "SimpleProject" + +Where `com.example.menu` is the Java package to put the source code in, and the project will be called "SimpleProject". + +### From TcMenu Designer UI + +Go to the `File -> New` option and select to create a Java/Raspberry PI project. Ensure the package name is filled in with the Java package name. + +### Loading into an IDE + +We use IntelliJ, but many IDEs support Java and you can consult their documentation for importing a maven (pom.xml) project. In IntelliJ simply create a new project from the POM file. + ## How the app is organised. The application is split up into several files: @@ -56,7 +74,7 @@ Consider the `MenuConfig` class somewhat like a storage object that can hold ins public class MenuConfig extends BaseMenuConfig { // other configuration... public Engine myEngine() { - in cylinders = + int cylinders = Integer.parseInt(mandatoryStringProp("engine.cylinders")); return new Engine(); } public Car myCar(Engine engine) {