Skip to content
This repository has been archived by the owner on Jun 11, 2023. It is now read-only.
/ lib-fxml Public archive

The `Lib-FXML` library simplifies the loading of [JavaFX] relevant files (model, view, controller, .fxml, .css, .properties) and enables a standardized handling of the data flow to (in, from) the gui.

License

Notifications You must be signed in to change notification settings

Naoghuman/lib-fxml

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lib-FXML

Build Status license: GPL v3 GitHub release

Intention

The Lib-FXML library simplifies the loading of JavaFX relevant files (model, view, controller, .fxml, .css, .properties) and enables a standardized handling of the data flow to (in, from) the gui.

Inspired by Adam Bien's library afterburner.fx, which unfortunately hasn't been developed since 2015, the library Lib-FXML simplifies the daily developer tasks in context from the aboved mentioned two main points:

  • Simplifying the loading of JavaFX relevant files and
  • offering a standardized data flow to (in, from) the gui.

Image: Overview Lib-FXML
Overview-UML_Lib-FXML_v0.3.0-PRERELEASE_2019-04-14_23-39.png

Content

Demo 'All in Ones'

Image: Demo 'All in Ones'
Lib-FXML_Demo-All-in-Ones_v0.3.0-PRERELEASE_2019-04-15_21-40.png

Intention

This demo wants to show, explain how to integrate the various features from the library Lib-FXML into a demo application:

General features

  • How to use the abstract class FXMLController as a convention to managed the presentation from the FXMLModel data in a concrete implementation from FXMLController.
  • How to use the class FXMLModel as a lightweight version from an entity to manage the dataflow to (in, from) the controller.
  • How to use the class FXMLView to load the gui declaration (.fxml file) and map it (initialization from the gui) to a controller.

Extended features

  • How to use the singleton FXMLAction to register (handle) lambda methods such like Consumer, Function and Supplier.
  • (TODO) How to use the class FXMLModel to add additional methods which extend the original entity behavior. For example #isUpdatedProperty().
  • How to use the interface FXMLRegisterable as a convention which allowes developers to register for example action methods.
  • How to use the interface FXMLModelable as a convention to create a lightweight version from an entity.

Additional features

Demo files

In this section all files are listed which are involved into this demo. Also their main purpose are explained:

DemoAllInOnes.java

  • Shows how to start a JavaFX application :) .
  • Shows how to create an instance from the class FXMLView to show then the gui with 'view.getRoot().orElse(new AnchorPane)' in the demo application.
  • Shows how the interface FXMLRegisterable can be used as a convention to register the action method from this class.

DemoAllInOnesController.java

  • Shows how the developer can access the URL from the .fxml file.
  • Shows how the developer can access the optional ResourceBundle if defined.
  • Shows how to use the classes 'DemoInfoWriter', 'DemoAllInOnesInfoWriter' and 'DemoAllInOnesPreferencesWriter' to write the demo infos.
  • Shows how to use the overriden method FXMLController#configure(FXMLModel) to bind the data from the FXMLModel to the gui components.
  • Shows how the interface FXMLRegisterable can be used as a convention to register the various action methods from this controller.
  • Shows how to use the different FXMLAction#handle(...) methods to fit the necessities from this controller.

DemoAllInOnesEntity.java

  • Shows how to create a simple POJO with JavaFX properties (LongProperty and StringProperty).
  • Shows the usage from JavaFX properties to bind data which means we don't need to be aware that the data is up-to-date :).
  • Shows how to use the interface FXMLModelable which allowed to configure a FXMLModel with selected data properties from the entity.

DemoAllInOnesSqlEntityProvider.java

  • Shows how to define a simple sql entity provider which simulates the crud operations for an entity to (from) a database.
  • Shows how to use the interface FXMLRegisterable as a convention to register the action methods from this class.
  • Shows how to use the class FXMLAction to register the (crud) action methods via lambda injection.

demoallinones.css

  • Shows how to create a CSS (Cascading Style Sheets) file which styles will be then shown in the demo application.
  • Shows how to style with CSS different JavaFX components such like AnchorPane, Button, TextField, ScrollPane.

demoallinones.fxml

  • Shows how to define a declaration from the demo gui in form from a special JavaFX XML file so called FXML.
  • Shows how then the initialization will be done during the loading and mapping from the .fxml file with the corresponding controller.
    See FXMLView#initializeFXMLLoader(FXMLModel) for more informations.

demoallinones.properties

  • Shows how to create a .properties file which can contains different key/value String pairs. Over the key the value can retrieved then in the application.
  • An alternative is the useage from my Library Lib-I18N (https://github.com/Naoghuman/lib-i18n), which allowed multilingualism depending from an actual Locale.

The next files are used to create the demo informations:

DemoInfoWriter.java

  • The abstract class 'DemoInfoWriter' offers various functions for writing different styled informations into a VBox.
  • For example: Styled text (size, FontPosture), Buttons, Separators and TextFields.

DemoAllInOnesInfoWriter.java

  • A concrete implementation from the abstract class 'DemoInfoWriter' for this demo.
  • All informations about the features from the library Lib-FXML and the demo :) in the left side from the demo are written with this class.

DemoAllInOnesPreferencesWriter.java

  • Another concrete implementation from the abstract class 'DemoInfoWriter'.
  • With this class the interactive area on the right side in the demo application is written.

How it works

This section shows how to use the different classes and interfaces from the Lib-FXML api:

Usage from the singleton class 'FXMLAction'

  • Used in 'DemoAllInOnes', 'DemoAllInOnesController', 'DemoAllInOnesInfoWriter' and 'DemoAllInOnesSqlEntityProvider'.
  • Answers the question how to implement a singleton instance with Optional<T> in FXMLAction and access the class behaviours with the static method #getDefault().
  • Answers the question how to register (handle) action methods from type Consumer<FXMLModel>, EventHandler<ActionEvent> and Function<Long, FXMLModel>.
  • Answers also the question how to register (handle) action methods from type EventHandler<ActionEvent>.

Usage from the abstract class 'FXMLController'

  • Used in 'DemoAllInOnesController'.
  • Used in FXMLView.
  • Answers the question how to use the abstract class as a convention to managed the presentation from the FXMLModel data in a concrete controller.
  • Answers the question how the controller (it's attributs) is the initialization from the declaration in the .fxml file.

Usage from the class 'FXMLModel'

  • Used in 'DemoAllInOnes', 'DemoAllInOnesController', 'DemoAllInOnesEntity' and 'DemoAllInOnesSqlEntityProvider'.
  • Used in FXMLAction, FXMLController, FXMLModelable and FXMLView.
  • Answers the question how to use the model to managed the dataflow to (in, from) the gui.
  • Answers the question how the FXMLModel will be initialized in the entity 'DemoAllInOnesEntity' with the convention methods from the interface FXMLModelable.
  • Answers the question how to add some additional data methods to extend the behavior from the original entity.

Usage from the class 'FXMLView'

  • Used in 'DemoAllInOnes'.
  • Answers the question how to use the class FXMLView to load the gui declaration (.fxml file) and map it (initialization from the gui) to a controller.
  • Answers the question how to use the JavaFX standard class FXMLLoader in FXMLView to load .fxml, .css, .properties files and assoziate them with a controller.

Usage from the interface 'FXMLModelable'

  • Used in 'DemoAllInOnesEntity'.
  • Answers the question how to use the interface as a convention to initialize a FXMLModel with different entity properties.

Usage from the interface 'FXMLRegisterable'

  • Used in 'DemoAllInOnes', 'DemoAllInOnesController' and 'DemoAllInOnesSqlEntityProvider'.
  • Answers the question how to use the interface as a convention to register different action methods via lambda injection.

JavaDoc

The JavaDoc from the library Lib-FXML can be explored here: JavaDoc Lib-FXML (in work)

Image: JavaDoc Lib-FXML v0.3.0-PRERELEASE Lib-FXML_JavaDoc_v0.3.0-PRERELEASE_2019-04-23_20-35.png

Download

Current version is 0.3.0-PRERELEASE. Main points in this release are:

  • Extend the api with exciting features like FXMLAction, FXMLModel.
  • Create an extended demo application with all features from the library.

Download:

An overview about all existings releases can be found here:

  • Overview from all releases in Lib-FXML.

Requirements

In the library following dependencies are registered:

Installation

Contribution

  • If you find a Bug I will be glad if you could report an Issue.
  • If you want to contribute to the project plz fork the project and do a Pull Request.

License

The project Lib-FXML is licensed under General Public License 3.0.

Autor

The project Lib-FXML is maintained by me, Naoghuman (Peter Rogge). See Contact.

Contact

You can reach me under [email protected].

About

The `Lib-FXML` library simplifies the loading of [JavaFX] relevant files (model, view, controller, .fxml, .css, .properties) and enables a standardized handling of the data flow to (in, from) the gui.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published