Skip to content

Commit

Permalink
example improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
davetcc committed Nov 28, 2024
1 parent 673e6d1 commit 7e71135
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
6 changes: 3 additions & 3 deletions java/embedControlJavaFx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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

Expand Down
20 changes: 19 additions & 1 deletion java/embeddedJavaDeviceUI/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 7e71135

Please sign in to comment.