Skip to content

Commit 1c5c2db

Browse files
committed
Merge branch 'develop' into stable
2 parents 8a71033 + 66e5c22 commit 1c5c2db

File tree

185 files changed

+5005
-1824
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

185 files changed

+5005
-1824
lines changed

README.md

+15-13
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
![image](http://www.buildpath.de/mvvm/mvvmfx.png)
22

3-
__mvvm(fx)__ is an application framework which provides you necessary components to implement the [MVVM](../../wiki/MVVM "MVVM") pattern with JavaFX.
3+
**mvvmFX** is an application framework which provides you necessary components to implement the [MVVM](../../wiki/MVVM "MVVM") pattern with JavaFX.
44

5-
__MVVM__ is the enhanced version of the [Presentation Model](http://martinfowler.com/eaaDev/PresentationModel.html "Presentation Model") pattern and was created by Microsoft engineers for [WPF](http://msdn.microsoft.com/en-us/library/ms754130.aspx "WPF") . JavaFX and WPF does have similarities like Databinding and descriptive UI declaration (FXML/XAML). Because of this fact we adopt best practices of the development with the Microsoft technology.
5+
**MVVM** is the enhanced version of the [Presentation Model](http://martinfowler.com/eaaDev/PresentationModel.html "Presentation Model") pattern and was created by Microsoft engineers for [WPF](http://msdn.microsoft.com/en-us/library/ms754130.aspx "WPF"). JavaFX and WPF does have similarities like data binding and descriptive UI declaration (FXML/XAML). Because of this fact we adopted best practices of the development with the Microsoft technology and introduced new helpers to support the development of applications with JavaFX and MVVM.
66

77
[![Commercial Support](https://img.shields.io/badge/Commercial%20Support%20-by%20Saxonia%20Systems-brightgreen.svg)](http://goo.gl/forms/WVBG3SWHuL)
88
[![Build Status](https://api.travis-ci.org/sialcasa/mvvmFX.svg?branch=develop)](https://travis-ci.org/sialcasa/mvvmFX)
99

1010

11-
###[Howto](../../wiki "Howto")###
11+
### [Howto](../../wiki "Howto")
1212

13-
### Maven dependency###
13+
### Maven dependency
1414

1515
#### Stable Release
1616

@@ -20,7 +20,7 @@ This is the stable release that can be used in production.
2020
<dependency>
2121
<groupId>de.saxsys</groupId>
2222
<artifactId>mvvmfx</artifactId>
23-
<version>1.6.0</version>
23+
<version>1.7.0</version>
2424
</dependency>
2525
```
2626

@@ -32,7 +32,7 @@ Here we make bug fixes for the current stable release.
3232
<dependency>
3333
<groupId>de.saxsys</groupId>
3434
<artifactId>mvvmfx</artifactId>
35-
<version>1.6.1-SNAPSHOT</version>
35+
<version>1.7.1-SNAPSHOT</version>
3636
</dependency>
3737
```
3838

@@ -44,21 +44,23 @@ Here we develop new features. This release is unstable and shouldn't be used in
4444
<dependency>
4545
<groupId>de.saxsys</groupId>
4646
<artifactId>mvvmfx</artifactId>
47-
<version>1.7.0-SNAPSHOT</version>
47+
<version>1.8.0-SNAPSHOT</version>
4848
</dependency>
4949
```
5050

5151

5252
### Get Help
5353

54-
If you need help you can use the forums on [Google Groups](https://groups.google.com/forum/#!forum/mvvmfx-dev) for asking questions and interacting with the mvvmFX developers. Additionally you can create issues, report bugs and add feature requests on the issue tracker at [github](https://github.com/sialcasa/mvvmFX/issues).
54+
The best way to get help with mvvmFX is to either ask questions on StackOverflow using the [tag "mvvmfx"](https://stackoverflow.com/questions/tagged/mvvmfx) or to use our [Google Groups](https://groups.google.com/forum/#!forum/mvvmfx-dev) mailing list. Additionally you can create issues, report bugs and add feature requests on the issue tracker at [github](https://github.com/sialcasa/mvvmFX/issues).
5555

5656
### Links
5757

5858
- [Project Page](http://sialcasa.github.io/mvvmFX/)
59-
- [javadoc mvvmfx core](http://sialcasa.github.io/mvvmFX/javadoc/1.5.0/mvvmfx/)
60-
- [javadoc mvvmfx-cdi](http://sialcasa.github.io/mvvmFX/javadoc/1.5.0/mvvmfx-cdi/)
61-
- [javadoc mvvmfx-guice](http://sialcasa.github.io/mvvmFX/javadoc/1.5.0/mvvmfx-guice/)
62-
- [javadoc mvvmfx-utils](http://sialcasa.github.io/mvvmFX/javadoc/1.5.0/mvvmfx-utils/)
63-
- [javadoc mvvmfx-testing-utils](http://sialcasa.github.io/mvvmFX/javadoc/1.5.0/mvvmfx-testing-utils/)
59+
- [javadoc mvvmfx core](http://sialcasa.github.io/mvvmFX/javadoc/1.7.0/mvvmfx/)
60+
- [javadoc mvvmfx-cdi](http://sialcasa.github.io/mvvmFX/javadoc/1.7.0/mvvmfx-cdi/)
61+
- [javadoc mvvmfx-guice](http://sialcasa.github.io/mvvmFX/javadoc/1.7.0/mvvmfx-guice/)
62+
- [javadoc mvvmfx-easydi](http://sialcasa.github.io/mvvmFX/javadoc/1.7.0/mvvmfx-easydi/)
63+
- [javadoc mvvmfx-validation](http://sialcasa.github.io/mvvmFX/javadoc/1.7.0/mvvmfx-validation/)
64+
- [javadoc mvvmfx-utils](http://sialcasa.github.io/mvvmFX/javadoc/1.7.0/mvvmfx-utils/)
65+
- [javadoc mvvmfx-testing-utils](http://sialcasa.github.io/mvvmFX/javadoc/1.7.0/mvvmfx-testing-utils/)
6466

examples/books-example/pom.xml

+6-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>de.saxsys.mvvmfx</groupId>
77
<artifactId>examples</artifactId>
8-
<version>1.6.0</version>
8+
<version>1.7.0</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

@@ -88,7 +88,11 @@
8888
<artifactId>junit</artifactId>
8989
<scope>test</scope>
9090
</dependency>
91-
91+
<dependency>
92+
<groupId>org.junit.jupiter</groupId>
93+
<artifactId>junit-jupiter-api</artifactId>
94+
<scope>test</scope>
95+
</dependency>
9296
<dependency>
9397
<groupId>org.assertj</groupId>
9498
<artifactId>assertj-core</artifactId>

examples/books-example/src/test/java/de/saxsys/mvvmfx/examples/books/MainViewModelTest.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import de.saxsys.mvvmfx.examples.books.backend.Error;
44
import de.saxsys.mvvmfx.examples.books.backend.Book;
55
import de.saxsys.mvvmfx.examples.books.backend.LibraryService;
6-
import org.junit.Before;
7-
import org.junit.Test;
6+
import org.junit.jupiter.api.BeforeEach;
7+
import org.junit.jupiter.api.Test;
88

99
import java.util.Arrays;
1010
import java.util.Collections;
@@ -19,7 +19,7 @@ public class MainViewModelTest {
1919
private MainViewModel viewModel;
2020
private LibraryService libraryService;
2121

22-
@Before
22+
@BeforeEach
2323
public void setup() {
2424
libraryService = mock(LibraryService.class);
2525

examples/books-example/src/test/java/de/saxsys/mvvmfx/examples/books/backend/LibraryServiceMockTest.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package de.saxsys.mvvmfx.examples.books.backend;
22

3-
import org.junit.Before;
4-
import org.junit.Test;
3+
import org.junit.jupiter.api.BeforeEach;
4+
import org.junit.jupiter.api.Test;
55

66
import java.util.List;
77

@@ -18,7 +18,7 @@ public class LibraryServiceMockTest {
1818

1919
private Book theMetamorphosis;
2020

21-
@Before
21+
@BeforeEach
2222
public void setup() {
2323
libraryService = new LibraryServiceMockImpl();
2424

examples/contacts-example/pom.xml

+9-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>de.saxsys.mvvmfx</groupId>
88
<artifactId>examples</artifactId>
9-
<version>1.6.0</version>
9+
<version>1.7.0</version>
1010
</parent>
1111
<artifactId>contacts-example</artifactId>
1212

@@ -48,12 +48,16 @@
4848
<groupId>de.saxsys</groupId>
4949
<artifactId>mvvmfx-cdi</artifactId>
5050
</dependency>
51-
51+
<dependency>
52+
<groupId>org.jboss.weld.se</groupId>
53+
<artifactId>weld-se-core</artifactId>
54+
</dependency>
5255
<dependency>
5356
<groupId>org.jboss</groupId>
5457
<artifactId>jandex</artifactId>
55-
<version>1.2.4.Final</version>
58+
<version>2.0.3.Final</version>
5659
</dependency>
60+
5761
<dependency>
5862
<groupId>ch.qos.logback</groupId>
5963
<artifactId>logback-classic</artifactId>
@@ -89,8 +93,8 @@
8993
</dependency>
9094

9195
<dependency>
92-
<groupId>junit</groupId>
93-
<artifactId>junit</artifactId>
96+
<groupId>org.junit.jupiter</groupId>
97+
<artifactId>junit-jupiter-api</artifactId>
9498
<scope>test</scope>
9599
</dependency>
96100
<dependency>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package de.saxsys.mvvmfx.examples.contacts.model;
2+
3+
import javax.xml.bind.annotation.XmlAccessType;
4+
import javax.xml.bind.annotation.XmlAccessorType;
5+
import javax.xml.bind.annotation.XmlElement;
6+
import javax.xml.bind.annotation.XmlRootElement;
7+
import java.util.ArrayList;
8+
9+
@XmlRootElement(name = "iso_3166_entries")
10+
@XmlAccessorType(XmlAccessType.FIELD)
11+
public class Countries {
12+
13+
@XmlElement(name = "iso_3166_entry")
14+
private ArrayList<Country> countries;
15+
16+
public ArrayList<Country> getCountries() {
17+
return countries;
18+
}
19+
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package de.saxsys.mvvmfx.examples.contacts.model.countries;
2+
3+
import de.saxsys.mvvmfx.examples.contacts.model.Country;
4+
import de.saxsys.mvvmfx.examples.contacts.model.Subdivision;
5+
import javafx.beans.property.ReadOnlyBooleanProperty;
6+
import javafx.beans.property.ReadOnlyStringProperty;
7+
import javafx.collections.ObservableList;
8+
9+
/**
10+
* Implementations of this interface are used to encapsulate the process of loading available countries
11+
* and their subdivisions (if available).
12+
*
13+
* Instances are meant to be a stateful wrapper around the existing countries.
14+
* You should create an instance of this class, call the {@link #init()} method
15+
* and then bind the UI to the provided observable lists (
16+
* {@link #availableCountries()} and {@link #subdivisions()}).
17+
*
18+
* To choose a country use the {@link #setCountry(Country)} method. This
19+
* will lead to a change of the {@link #subdivisions()} list.
20+
*/
21+
public interface CountrySelector {
22+
23+
void init();
24+
25+
void setCountry(Country country);
26+
27+
ObservableList<Country> availableCountries();
28+
29+
ReadOnlyStringProperty subdivisionLabel();
30+
31+
ObservableList<Subdivision> subdivisions();
32+
33+
ReadOnlyBooleanProperty inProgressProperty();
34+
}

examples/contacts-example/src/main/java/de/saxsys/mvvmfx/examples/contacts/model/CountrySelector.java examples/contacts-example/src/main/java/de/saxsys/mvvmfx/examples/contacts/model/countries/DataFxCountrySelector.java

+30-59
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
package de.saxsys.mvvmfx.examples.contacts.model;
1+
package de.saxsys.mvvmfx.examples.contacts.model.countries;
22

3+
import de.saxsys.mvvmfx.examples.contacts.model.Country;
4+
import de.saxsys.mvvmfx.examples.contacts.model.Subdivision;
35
import javafx.beans.property.ReadOnlyBooleanProperty;
46
import javafx.beans.property.ReadOnlyBooleanWrapper;
57
import javafx.beans.property.ReadOnlyStringProperty;
@@ -15,36 +17,41 @@
1517
import org.slf4j.Logger;
1618
import org.slf4j.LoggerFactory;
1719

18-
import javax.xml.bind.annotation.*;
20+
import javax.annotation.PostConstruct;
21+
import javax.enterprise.inject.Alternative;
22+
import javax.inject.Singleton;
1923
import java.io.IOException;
2024
import java.io.InputStream;
2125
import java.util.ArrayList;
2226
import java.util.HashMap;
2327
import java.util.List;
2428
import java.util.Map;
29+
import java.util.stream.Collectors;
2530

2631
/**
2732
* This class is used to encapsulate the process of loading available countries
28-
* and there subdivisions (if available).
33+
* and their subdivisions (if available).
2934
*
3035
* This class is meant to be a stateful wrapper around the existing countries.
3136
* You should create an instance of this class, call the {@link #init()} method
3237
* and then bind the UI to the provided observable lists (
3338
* {@link #availableCountries()} and {@link #subdivisions()}).
3439
*
35-
* To choose a country have to use the {@link #setCountry(Country)} method. This
40+
* To choose a country use the {@link #setCountry(Country)} method. This
3641
* will lead to a change of the {@link #subdivisions()} list.
3742
*
3843
*
39-
* At the moment this class used two XML files ({@link #ISO_3166_LOCATION} and
44+
* At the moment this class uses two XML files ({@link #ISO_3166_LOCATION} and
4045
* {@link #ISO_3166_2_LOCATION}) that contain information about countries,
4146
* country-codes and subdivisions according to ISO 3166 and ISO 3166-2.
4247
*
4348
* The loading process is implemented with the DataFX framework.
4449
*/
45-
public class CountrySelector {
50+
@Singleton
51+
@Alternative
52+
public class DataFxCountrySelector implements CountrySelector {
4653

47-
private static final Logger LOG = LoggerFactory.getLogger(CountrySelector.class);
54+
private static final Logger LOG = LoggerFactory.getLogger(DataFxCountrySelector.class);
4855

4956
public static final String ISO_3166_LOCATION = "/countries/iso_3166.xml";
5057
public static final String ISO_3166_2_LOCATION = "/countries/iso_3166_2.xml";
@@ -62,6 +69,8 @@ public class CountrySelector {
6269
* This method triggers the loading of the available countries and
6370
* subdivisions.
6471
*/
72+
@PostConstruct
73+
@Override
6574
public void init() {
6675
inProgress.set(true);
6776
loadCountries();
@@ -75,6 +84,7 @@ public void init() {
7584
* @param country the country that will be selected or <code>null</code> if
7685
* no country is selected.
7786
*/
87+
@Override
7888
public void setCountry(Country country) {
7989
if (country == null) {
8090
subdivisionLabel.set(null);
@@ -169,11 +179,17 @@ void loadSubdivisions() {
169179

170180
List<Subdivision> subdivisionList = countryCodeSubdivisionMap.get(country);
171181

172-
entity.subsets.get(0).entryList.forEach(entry -> {
173-
subdivisionList.add(new Subdivision(entry.name, entry.code, country));
182+
entity.subsets.forEach(subset -> {
183+
subset.entryList.forEach(entry -> {
184+
subdivisionList.add(new Subdivision(entry.name, entry.code, country));
185+
});
174186
});
175187

176-
countryCodeSubdivisionNameMap.put(country, entity.subsets.get(0).subdivisionType);
188+
String subdivisionName = entity.subsets.stream()
189+
.map(subset -> subset.subdivisionType)
190+
.collect(Collectors.joining("/"));
191+
192+
countryCodeSubdivisionNameMap.put(country, subdivisionName);
177193
}
178194
});
179195

@@ -190,67 +206,22 @@ private Country findCountryByCode(String code) {
190206
return countries.stream().filter(country -> country.getCountryCode().equals(code)).findFirst().orElse(null);
191207
}
192208

193-
/**
194-
* XML entity class. These classes represent the structure of the XML files
195-
* to be loaded.
196-
*/
197-
@XmlRootElement(name = "iso_3166_subset")
198-
@XmlAccessorType(XmlAccessType.FIELD)
199-
static class ISO3166_2_EntryEntity {
200-
201-
@XmlAttribute(name = "code")
202-
public String code;
203-
@XmlAttribute(name = "name")
204-
public String name;
205-
}
206-
207-
/**
208-
* XML entity class. These classes represent the structure of the XML files
209-
* to be loaded.
210-
*/
211-
@XmlRootElement(name = "iso_3166_subset")
212-
@XmlAccessorType(XmlAccessType.FIELD)
213-
static class ISO3166_2_SubsetEntity {
214-
215-
@XmlElement(name = "iso_3166_2_entry")
216-
public List<ISO3166_2_EntryEntity> entryList;
217-
218-
@XmlAttribute(name = "type")
219-
public String subdivisionType;
220-
}
221-
222-
/**
223-
* XML entity class. These classes represent the structure of the XML files
224-
* to be loaded.
225-
*/
226-
@XmlRootElement(name = "iso_3166_country")
227-
@XmlAccessorType(XmlAccessType.FIELD)
228-
static class ISO3166_2_CountryEntity {
229-
230-
@XmlAttribute(name = "code")
231-
public String code;
232-
233-
@XmlElement(name = "iso_3166_subset")
234-
public List<ISO3166_2_SubsetEntity> subsets;
235-
236-
@Override
237-
public String toString() {
238-
return "CountryEntity " + code;
239-
}
240-
}
241-
209+
@Override
242210
public ObservableList<Country> availableCountries() {
243211
return countries;
244212
}
245213

214+
@Override
246215
public ReadOnlyStringProperty subdivisionLabel() {
247216
return subdivisionLabel.getReadOnlyProperty();
248217
}
249218

219+
@Override
250220
public ObservableList<Subdivision> subdivisions() {
251221
return FXCollections.unmodifiableObservableList(subdivisions);
252222
}
253223

224+
@Override
254225
public ReadOnlyBooleanProperty inProgressProperty() {
255226
return inProgress.getReadOnlyProperty();
256227
}

0 commit comments

Comments
 (0)