-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #307 from sialcasa/develop
merge version 1.4.0 into stable
- Loading branch information
Showing
254 changed files
with
1,950 additions
and
1,122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,29 @@ | ||
### Contains the examples for mvvmfx | ||
|
||
Content: | ||
At the moment we have 3 example applications: | ||
- **books-example**: An app to search for books in a library. | ||
- Shows how to integrate a REST backend (Optional) | ||
- Uses EasyDI as dependency injection library | ||
- **contacts-example**: A contact management application | ||
- Master-Detail | ||
- Dialogs | ||
- CDI as dependency injection library, including CDI-Events | ||
- Validation | ||
- Model-Wrapper | ||
- I18N and ResourceBundle handling | ||
- [DataFX](http://www.javafxdata.org/) | ||
- **todomvc-example**: A Todo-App influenced by the popular [TodoMVC.com](http://todomvc.com/). | ||
- NotificationCenter | ||
- MvvmFX views as items of a ListView | ||
- [EasyBind](https://github.com/TomasMikula/EasyBind) for filtering Lists | ||
|
||
- **mvvmfx-books-example**: An app to search for books in a library. Connects to a REST backend. | ||
- **mvvmfx-complex-example**: contains the user interface and logic code for an example application. | ||
To run this example you need either mvvmfx-cdi-starter or mvvmfx-guice-starter. | ||
- **mvvmfx-cdi-starter**: contains the startup code to run the mvvmfx-complex-example with CDI/Weld | ||
as dependency injection framework. | ||
- **mvvmfx-guice-starter**: contains the startup code to run the mvvmfx-complex-example with Guice | ||
as dependency injection framework. | ||
- **mvvmfx-fx-root-example**: contains a small custom control that uses the fx:root element together with mvvmfx. | ||
- **mvvmfx-helloworld-example**: A simple hello world view. This example is used in the [Getting Started/Step-by-Step tutorial](/../../wiki/Getting-Started-HelloWorld-%28deutsch%29). | ||
- **mvvmfx-helloworld-without-fxml**: A hello world example that shows hot to use MvvmFX with a view implemented in pure Java and not with FXML. | ||
- **mvvmfx-contacts**: A contact management application. This example shows a master-detail view, dialogs and the usage of CDI including CDI-Events. | ||
This example also integrates some other JavaFX community libraries. | ||
- **mvvmfx-synchronizefx**: This example uses the library [SynchronizeFX](https://github.com/saxsys/SynchronizeFX) to create a distributed ViewModel. | ||
This way the state of the UI of different instances of the App (on different JVM's, on different computers) is always synchronized between the apps. | ||
|
||
In addition to these apps we have some smaller examples. Each examples shows a specific aspect of the framework but isn't very useful by itself. | ||
|
||
- **fx-root-example**: Shows how to use `fx:root` with mvvmFX. This way you can create your own custom components. | ||
- **helloworld**: A minimal mvvmFX application using *FXML*. | ||
- **helloworld-without-fxml**: A minimal mvvmFX application using pure Java code instead of *FXML*. | ||
- **synchronizefx-example**: Shows how to integrade the library [SynchronizeFX](https://github.com/saxsys/SynchronizeFX) to implement a distributed ViewModel. This way the state of the UI of different instances of the App (on different JVM's, on different computers) is always synchronized between the apps. | ||
- **welcome-example**: A simple app that shows a welcome message for people. | ||
- It demonstrates the usage of [mvvmfx-cdi](https://github.com/sialcasa/mvvmFX/tree/develop/mvvmfx-cdi) and [mvvmfx-guice](https://github.com/sialcasa/mvvmFX/tree/develop/mvvmfx-guice). The complete code base is shared, only a specific starter class for each dependency injection framework is needed. | ||
- Shows the usage of [Commands](https://github.com/sialcasa/mvvmFX/wiki/Commands). |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
52 changes: 26 additions & 26 deletions
52
...de/saxsys/mvvmfx/examples/books/style.css → ...de/saxsys/mvvmfx/examples/books/style.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,26 @@ | ||
.container { | ||
|
||
} | ||
|
||
.label | ||
{ | ||
-fx-text-fill: black; | ||
} | ||
|
||
.title1{ | ||
-fx-font-size:50; | ||
} | ||
|
||
.title2{ | ||
-fx-font-size:40; | ||
-fx-text-fill: gray; | ||
} | ||
|
||
.errorLabel{ | ||
-fx-font-size:20; | ||
-fx-text-fill: red; | ||
} | ||
|
||
.split-pane *.split-pane-divider { | ||
-fx-padding: 0 1 0 1; | ||
} | ||
.container { | ||
|
||
} | ||
|
||
.label | ||
{ | ||
-fx-text-fill: black; | ||
} | ||
|
||
.title1{ | ||
-fx-font-size:50; | ||
} | ||
|
||
.title2{ | ||
-fx-font-size:40; | ||
-fx-text-fill: gray; | ||
} | ||
|
||
.errorLabel{ | ||
-fx-font-size:20; | ||
-fx-text-fill: red; | ||
} | ||
|
||
.split-pane *.split-pane-divider { | ||
-fx-padding: 0 1 0 1; | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
# MvvmFX Contacts Example | ||
|
||
This is a more complex example application in which you can manage contacts. | ||
|
||
It uses **mvvmFX** and **mvvmFX-CDI**. Additionally the following third-party libraries are used: | ||
|
||
- [FontAwesomeFX](https://bitbucket.org/Jerady/fontawesomefx) for the icons | ||
- [ControlsFX](http://fxexperience.com/controlsfx/) for the validation decorators | ||
- [AssertJ-JavaFX](https://github.com/lestard/assertj-javafx) for easier testing of observable values in unit tests | ||
- [DataFX](http://www.javafxdata.org/) for loading XML files | ||
- [Advanced-Bindings](https://github.com/lestard/advanced-bindings) to simplify some bindings | ||
- [JFX-Testrunner](https://github.com/sialcasa/jfx-testrunner) to run Tests in the JavaFX Application thread | ||
|
||
### The Use-Case | ||
|
||
The application has a **master-detail** view. In the master pane there is a table of all contacts. | ||
When one contact is selected, the detail view will show the properties of the selected contact. | ||
|
||
With a dialog you can add new contacts or edit existing ones. | ||
|
||
|
||
|
||
### Highlights and interesting parts | ||
|
||
#### Dialogs opened with CDI-Events | ||
|
||
- The application uses CDI-Events to decouple the *add*/*edit* dialogs from the places where they are opened. Instead, when a | ||
button is clicked to open a dialog, an CDI-Event is fired. The dialog reacts to this event and will open up itself. | ||
|
||
[ToolbarViewModel.java:](src/main/java/de/saxsys/mvvmfx/examples/contacts/ui/toolbar/ToolbarViewModel.java) | ||
|
||
```java | ||
@Inject | ||
private Event<OpenAddContactDialogEvent> openPopupEvent; | ||
|
||
public void addNewContactAction(){ | ||
openPopupEvent.fire(new OpenAddContactDialogEvent()); | ||
} | ||
``` | ||
|
||
[AddContactDialog.java:](src/main/java/de/saxsys/mvvmfx/examples/contacts/ui/addcontact/AddContactDialog.java) | ||
|
||
```java | ||
public class AddContactDialog implements FxmlView<AddContactDialogViewModel> { | ||
... | ||
|
||
public void open(@Observes OpenAddContactDialogEvent event) { | ||
viewModel.openDialog(); | ||
} | ||
} | ||
``` | ||
|
||
#### ResourceBundles and I18N | ||
|
||
There are resourceBundles available for german and english language. In [App.java](src/main/java/de/saxsys/mvvmfx/examples/contacts/App.java) | ||
a global resourceBundle is defined for the whole application: | ||
|
||
```java | ||
... | ||
|
||
@Inject | ||
private ResourceBundle resourceBundle; | ||
|
||
|
||
@Override | ||
public void startMvvmfx(Stage stage) throws Exception { | ||
LOG.info("Starting the Application"); | ||
MvvmFX.setGlobalResourceBundle(resourceBundle); | ||
|
||
... | ||
} | ||
``` | ||
|
||
In addition for the menu a specific resourceBundle is defined in the [MainView.fxml](src/main/resources/de/saxsys/mvvmfx/examples/contacts/ui/main/MainView.fxml) via `fx:include`: | ||
|
||
```xml | ||
... | ||
<fx:include source="../menu/MenuView.fxml" resources="menu"/> | ||
... | ||
``` | ||
|
||
This resourceBundle is merged internally with the global resourceBundle so that the menu can access both resources. | ||
|
||
|
||
#### Validation | ||
|
||
In the dialog for adding/editing contacts the mvvmFX validation feature is used. | ||
In [ContactFormViewModel.java](src/main/java/de/saxsys/mvvmfx/examples/contacts/ui/contactform/ContactFormViewModel.java) you can see | ||
how to define validation logic. | ||
In the [ContactFormView.java](src/main/java/de/saxsys/mvvmfx/examples/contacts/ui/contactform/ContactFormView.java) the connection to the UI is done. | ||
This way the aspects of validation logic and validation visualization are separated. | ||
|
||
|
||
#### Model-Wrapper | ||
|
||
In the [ContactFormViewModel.java](src/main/java/de/saxsys/mvvmfx/examples/contacts/ui/contactform/ContactFormViewModel.java) | ||
the mvvmFX ModelWrapper is used to connect the Model and the ViewModel layers with reduced code size and coupling. | ||
|
||
|
||
|
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
...mfx/contacts/config/ResourceProvider.java → ...les/contacts/config/ResourceProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...contacts/events/ContactsUpdatedEvent.java → ...contacts/events/ContactsUpdatedEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.