Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge version 1.4.0 into stable #307

Merged
merged 49 commits into from
Oct 1, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
f79696d
#272 update javadoc links in README
manuel-mauky Jun 17, 2015
cabe42d
#272 change version number from 1.3.1 to 1.4.0-SNAPSHOT
manuel-mauky Jun 17, 2015
67e8ae8
#275 ViewListCell is now public to allow customization
manuel-mauky Jul 1, 2015
e86550e
#275 remove redundant access modifiers in ViewTupleMapper
manuel-mauky Jul 1, 2015
70a2b21
Merge pull request #276 from sialcasa/275_public_viewlistcell
manuel-mauky Jul 1, 2015
d0e3af3
#258 remove dependency to assertj from GCVerifier and mvvmfx-testing-…
manuel-mauky Jul 1, 2015
ee8953e
Merge pull request #277 from sialcasa/258_remove_assertj_dependency_g…
manuel-mauky Jul 1, 2015
7823f4c
#279 use stand-alone weld-se-core dependency instead of uber-jar weld-se
tomasz Jul 2, 2015
2e99e45
#217 changed groupid of examples to de.saxsys.mvvmfx
manuel-mauky Jul 2, 2015
ba92846
#217 renamed books-example
manuel-mauky Jul 2, 2015
d33762b
#217 renamed contacts-example module
manuel-mauky Jul 2, 2015
8b930b7
#217 renamed todomvc-example module
manuel-mauky Jul 2, 2015
6ddd78e
#217 moved mini example modules
manuel-mauky Jul 2, 2015
c8deace
#271 combined cdi,guice and complex example into one
manuel-mauky Jul 2, 2015
97f5e27
#217 fixed package names of welcome example
manuel-mauky Jul 2, 2015
5ef3c60
#217 fix package of other mini-examples
manuel-mauky Jul 2, 2015
7e21ae8
#217 fix package of todomvc app
manuel-mauky Jul 2, 2015
d8c9caa
Merge pull request #280 from sialcasa/217_cleanup_examples
manuel-mauky Jul 2, 2015
085b77f
Merge pull request #279 from tomasz/279_weld_se_core
manuel-mauky Jul 6, 2015
9c8faee
#281 fix bug in ListTransformation
manuel-mauky Jul 6, 2015
8054ed3
#260 set failing test to ignore as a temporal fix
manuel-mauky Jul 6, 2015
57ecce7
Merge pull request #282 from sialcasa/260_long_running_test
manuel-mauky Jul 6, 2015
5afe7e6
Merge pull request #283 from sialcasa/281_listtransformation_bug
manuel-mauky Jul 6, 2015
98e17ce
#217 fixed and improved readme files
manuel-mauky Jul 6, 2015
82a6d75
Merge pull request #284 from sialcasa/217_cleanup_examples
manuel-mauky Jul 6, 2015
c4e7ce3
#247 add modified version of JfxRunner
manuel-mauky Jul 21, 2015
4ed98eb
Merge pull request #285 from sialcasa/247_jfx_testrunner
manuel-mauky Jul 23, 2015
a61431c
#287: the view model's publish() method no longer needs an UI thread,…
Jul 30, 2015
e6d5f30
Merge remote-tracking branch 'upstream/develop' into 287_change_notif…
Jul 30, 2015
f46dafd
#287: changed to new JfxRunner package
Jul 30, 2015
c0af6b9
Merge pull request #288 from mthiele/287_change_notification_center
manuel-mauky Jul 30, 2015
782288b
#289 fix ConcurrentModificationException in NotificationCenter
manuel-mauky Jul 31, 2015
5bf3204
Merge pull request #290 from sialcasa/289_notificationCenter_concurre…
manuel-mauky Jul 31, 2015
779cdf5
#292 test case to reproduce the bug
manuel-mauky Aug 17, 2015
d667cfd
#292 fixed bug
manuel-mauky Aug 17, 2015
13897bd
Merge pull request #294 from sialcasa/292_bug_unexpected_vm_is_created
manuel-mauky Aug 17, 2015
8fed2c6
#293 simpler factory methods for CachedViewModelCellFactory
manuel-mauky Aug 18, 2015
a401638
Merge pull request #296 from sialcasa/293_shortcut_cellfactory
manuel-mauky Aug 18, 2015
099dab9
#286 weak references to observers
manuel-mauky Aug 19, 2015
62f73be
Revert "#286 weak references to observers"
manuel-mauky Aug 20, 2015
df9065f
221 add list support to ModelWrapper
lihop Sep 1, 2015
770952c
221 add tests for ModelWrapper list support
lihop Sep 1, 2015
0c0e733
Merge pull request #298 from ThirstyGoat/221_ModelWrapper_listSupport
manuel-mauky Sep 4, 2015
23eed47
#301 fix NPE in NotificationCenter
manuel-mauky Sep 7, 2015
491f58f
Merge pull request #302 from sialcasa/301_npe_notificationcenter
manuel-mauky Sep 7, 2015
3506996
#303 extended exception messages for wrong usage of InjectViewModel a…
manuel-mauky Sep 8, 2015
8cdfcdd
Merge pull request #304 from sialcasa/303_exception_wrong_vm_type
manuel-mauky Sep 8, 2015
19da09f
Add maven coordinates to README files
manuel-mauky Sep 9, 2015
8db526d
#305 update version numbers to 1.4.0
manuel-mauky Oct 1, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ __MVVM__ is the enhanced version of the [Presentation Model](http://martinfowler
<dependency>
<groupId>de.saxsys</groupId>
<artifactId>mvvmfx</artifactId>
<version>1.3.1</version>
<version>1.4.0</version>
</dependency>
```

Expand All @@ -24,7 +24,7 @@ __MVVM__ is the enhanced version of the [Presentation Model](http://martinfowler
<dependency>
<groupId>de.saxsys</groupId>
<artifactId>mvvmfx</artifactId>
<version>1.4.0-SNAPSHOT</version>
<version>1.5.0-SNAPSHOT</version>
</dependency>
```

Expand All @@ -36,9 +36,9 @@ If you need help you can use the forums on [Google Groups](https://groups.google
### Links

- [Project Page](http://sialcasa.github.io/mvvmFX/)
- [javadoc mvvmfx core](http://sialcasa.github.io/mvvmFX/javadoc/1.3.0/mvvmfx/)
- [javadoc mvvmfx-cdi](http://sialcasa.github.io/mvvmFX/javadoc/1.3.0/mvvmfx-cdi/)
- [javadoc mvvmfx-guice](http://sialcasa.github.io/mvvmFX/javadoc/1.3.0/mvvmfx-guice/)
- [javadoc mvvmfx-utils](http://sialcasa.github.io/mvvmFX/javadoc/1.3.0/mvvmfx-utils/)
- [javadoc mvvmfx-testing-utils](http://sialcasa.github.io/mvvmFX/javadoc/1.3.0/mvvmfx-testing-utils/)
- [javadoc mvvmfx core](http://sialcasa.github.io/mvvmFX/javadoc/1.4.0/mvvmfx/)
- [javadoc mvvmfx-cdi](http://sialcasa.github.io/mvvmFX/javadoc/1.4.0/mvvmfx-cdi/)
- [javadoc mvvmfx-guice](http://sialcasa.github.io/mvvmFX/javadoc/1.4.0/mvvmfx-guice/)
- [javadoc mvvmfx-utils](http://sialcasa.github.io/mvvmFX/javadoc/1.4.0/mvvmfx-utils/)
- [javadoc mvvmfx-testing-utils](http://sialcasa.github.io/mvvmFX/javadoc/1.4.0/mvvmfx-testing-utils/)

41 changes: 26 additions & 15 deletions examples/README.md
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).
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>mvvmfx-examples</artifactId>
<groupId>de.saxsys</groupId>
<version>1.3.1</version>
<groupId>de.saxsys.mvvmfx</groupId>
<artifactId>examples</artifactId>
<version>1.4.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>mvvmfx-library-example</artifactId>
<artifactId>books-example</artifactId>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package de.saxsys.mvvmfx.examples.books;

import de.saxsys.mvvmfx.utils.viewlist.CachedViewModelCellFactory;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.ListView;
import javafx.scene.control.TextField;
import de.saxsys.mvvmfx.FluentViewLoader;

import de.saxsys.mvvmfx.FxmlView;
import de.saxsys.mvvmfx.InjectViewModel;
import de.saxsys.mvvmfx.utils.viewlist.ViewListCellFactory;
import de.saxsys.mvvmfx.utils.viewlist.CachedViewModelCellFactory;

public class MainView implements FxmlView<MainViewModel> {

Expand Down Expand Up @@ -46,18 +45,13 @@ public void initialize() {

bookList.setItems(viewModel.booksProperty());


final ViewListCellFactory<BookListItemViewModel> cellFactory =
new CachedViewModelCellFactory<>(viewModel -> FluentViewLoader.fxmlView(BookListItemView.class)
.viewModel(viewModel).load());

bookList.setCellFactory(cellFactory);
bookList.setCellFactory(CachedViewModelCellFactory.createForFxmlView(BookListItemView.class));

viewModel.selectedBookProperty().bind(bookList.getSelectionModel().selectedItemProperty());
errorLabel.textProperty().bind(viewModel.errorProperty());

searchButton.disableProperty().bind(viewModel.getSearchCommand().executableProperty().not());

}

public void searchButtonPressed() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ public class MainViewModel implements ViewModel {
private ObjectProperty<BookListItemViewModel> selectedBook = new SimpleObjectProperty<>();

private StringProperty error = new SimpleStringProperty();

private Command searchCommand;

public MainViewModel(LibraryService libraryService) {
this.libraryService = libraryService;

searchCommand = new DelegateCommand(() -> new Action() {
@Override
protected void action() throws Exception {
Expand All @@ -53,7 +53,7 @@ protected void action() throws Exception {
public Command getSearchCommand() {
return searchCommand;
}

void search() {
Consumer<Error> errorHandler = err -> error.set(err.getMessage());

Expand Down
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;
}
100 changes: 100 additions & 0 deletions examples/contacts-example/README.md
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>mvvmfx-examples</artifactId>
<groupId>de.saxsys</groupId>
<version>1.3.1</version>
<groupId>de.saxsys.mvvmfx</groupId>
<artifactId>examples</artifactId>
<version>1.4.0</version>
</parent>
<artifactId>mvvmfx-contacts</artifactId>
<artifactId>contacts-example</artifactId>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand All @@ -23,7 +23,7 @@
<artifactId>javafx-maven-plugin</artifactId>
<version>8.1.2</version>
<configuration>
<mainClass>de.saxsys.mvvmfx.contacts.App</mainClass>
<mainClass>de.saxsys.mvvmfx.examples.contacts.App</mainClass>
</configuration>
</plugin>
</plugins>
Expand Down Expand Up @@ -88,12 +88,6 @@
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>de.saxsys</groupId>
<artifactId>jfx-testrunner</artifactId>
<version>1.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>eu.lestard</groupId>
<artifactId>assertj-javafx</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.saxsys.mvvmfx.contacts;
package de.saxsys.mvvmfx.examples.contacts;

import java.util.Locale;
import java.util.ResourceBundle;
Expand All @@ -17,18 +17,18 @@
import de.saxsys.mvvmfx.FluentViewLoader;
import de.saxsys.mvvmfx.ViewTuple;
import de.saxsys.mvvmfx.cdi.MvvmfxCdiApplication;
import de.saxsys.mvvmfx.contacts.events.TriggerShutdownEvent;
import de.saxsys.mvvmfx.contacts.model.ContactFactory;
import de.saxsys.mvvmfx.contacts.model.Repository;
import de.saxsys.mvvmfx.contacts.ui.main.MainView;
import de.saxsys.mvvmfx.contacts.ui.main.MainViewModel;
import de.saxsys.mvvmfx.examples.contacts.events.TriggerShutdownEvent;
import de.saxsys.mvvmfx.examples.contacts.model.ContactFactory;
import de.saxsys.mvvmfx.examples.contacts.model.Repository;
import de.saxsys.mvvmfx.examples.contacts.ui.main.MainView;
import de.saxsys.mvvmfx.examples.contacts.ui.main.MainViewModel;

public class App extends MvvmfxCdiApplication {

private static final Logger LOG = LoggerFactory.getLogger(App.class);

public static void main(String... args) {

Locale.setDefault(Locale.ENGLISH);

launch(args);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package de.saxsys.mvvmfx.contacts.config;
package de.saxsys.mvvmfx.examples.contacts.config;

import javax.enterprise.inject.Produces;
import javax.inject.Singleton;
import java.util.Locale;
import java.util.ResourceBundle;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.saxsys.mvvmfx.contacts.events;
package de.saxsys.mvvmfx.examples.contacts.events;

/**
* CDI event class that is used to indicate that a contact was updated/added/removed.
Expand Down
Loading