Skip to content
This repository was archived by the owner on Jan 3, 2020. It is now read-only.

krampenschiesser/standbein-sample

Repository files navigation

Standbein samples

This is a collection of samples for the Standbein library. In order to properly use them you have to install standbein to your local maven repository:

$ git clone https://github.com/krampenschiesser/standbein.git
$ cd standbein
$ ./gradlew publishToMavenLocal

You can find the different example in the following package:
de.ks.standbein.sample

Hello world

The hello world example can be found in src/main/java/de/ks/standbein/sample/hello/HellWorld.java
It contains:

  • A main class HelloWorld which creates a guice injector and launches the application

  • A guice module HelloWorldModule which configures

    • the applications applications appearance (title, icon, size)

    • the main window to use

    • and allows you to change the locale (during startup only) to see how localization works

  • The main window HelloWindow which contains a label with a localized and parameterized string

Customized localization

An example showing how to configure custom localization files.
It can be found in: src/main/java/de/ks/standbein/sample/customizedlocalization/CustomLocalizationExample.java

It is configured to look for controller local resource files with the name MyLocalization.* and for the main localization files in de.ks.customlocalization.MyLocalization.

Startup services

This example shows on how to create and integrate services. It can be found in: src/main/java/de/ks/standbein/sample/service/ServiceExample.java A service can be used for eg. initializing JPA, creating a connection to a remote service etc. Services are started in the order of their runlevels.

In this example we have 2 services.

  • The MyLongRunningStartupService which simulates a long running resource initialization before the actual application service is launched You will see its output in the logging and the application window takes some time to open

  • The MyPostApplicationService which has a higher run level than the ApplicationService(which launches FX). So this service will be started after the application window is shown. After some time it will calculated a value and propagate it to the FX window.

Using services you have a predefined application startup order which can manage dependencies(via runlevels).

Validation

This example shows how validation is used. It can be found in: src/main/java/de/ks/standbein/sample/validation/ValidationExample.java

In most cases where validation is used you would also use an activity. Therefore a simple ValidationActivity is created. Notice the change in the guice module(ValidationModule) where we do not define a mainwindow but an InitialActivity.

The binding is all defined in the ValidationController, which is defined via the ValidationView.fxml. In this example we have 3 validators:

  1. TextField name must not be empty

  2. Slider value has to be greater than 50%

  3. From the 3 radio buttons the second one has to be selected

Additionally we bind the disablement of the submit button to the invalid property of the validationregistry.

Fieldbinding

This example shows how you can bind model properties to ui elements. It can be found in: src/main/java/de/ks/standbein/sample/fieldbinding/FieldBindingExample.java

Again we have one activity FieldBindingActivity which defines Controller and a Datasource which loads a Model .

In the controller we bind several fields bidirectionally to the corresponding properties of JavaFX controls. So during load the properties are assigned to the FX controls and during save the values of the controls are applied back to the model.

Additionally each controller can implement the methods duringLoad and duringSave in order to read/save values from/to the model.

Menu extension

The menu extension can be added via:

    compile "de.ks:standbein-extensions-menu:$version"

It is mainly aimed at modular applications where each module registers its activities at menues which the main application can implement. Usually if you have just a small application you might want to create your menu directly (as you have far more control over it).

The example can be found in: src/main/java/de/ks/standbein/sample/menu/MenuExample.java. Most of the work is done in the Module which registeres the menu items to various callbacks. These MenuEntries are used by the MenuBarCreator to create a menu.

Notice the MenuWindow where we change the application root to contain a borderpane with the menubar.

About

Samples for standbein

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages