Skip to content

Commit

Permalink
Merge branch 'develop' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
manuel-mauky committed Sep 26, 2017
2 parents 8a71033 + 66e5c22 commit 1c5c2db
Show file tree
Hide file tree
Showing 185 changed files with 5,005 additions and 1,824 deletions.
28 changes: 15 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
![image](http://www.buildpath.de/mvvm/mvvmfx.png)

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

__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.
**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.

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


###[Howto](../../wiki "Howto")###
### [Howto](../../wiki "Howto")

### Maven dependency###
### Maven dependency

#### Stable Release

Expand All @@ -20,7 +20,7 @@ This is the stable release that can be used in production.
<dependency>
<groupId>de.saxsys</groupId>
<artifactId>mvvmfx</artifactId>
<version>1.6.0</version>
<version>1.7.0</version>
</dependency>
```

Expand All @@ -32,7 +32,7 @@ Here we make bug fixes for the current stable release.
<dependency>
<groupId>de.saxsys</groupId>
<artifactId>mvvmfx</artifactId>
<version>1.6.1-SNAPSHOT</version>
<version>1.7.1-SNAPSHOT</version>
</dependency>
```

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


### Get Help

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).
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).

### Links

- [Project Page](http://sialcasa.github.io/mvvmFX/)
- [javadoc mvvmfx core](http://sialcasa.github.io/mvvmFX/javadoc/1.5.0/mvvmfx/)
- [javadoc mvvmfx-cdi](http://sialcasa.github.io/mvvmFX/javadoc/1.5.0/mvvmfx-cdi/)
- [javadoc mvvmfx-guice](http://sialcasa.github.io/mvvmFX/javadoc/1.5.0/mvvmfx-guice/)
- [javadoc mvvmfx-utils](http://sialcasa.github.io/mvvmFX/javadoc/1.5.0/mvvmfx-utils/)
- [javadoc mvvmfx-testing-utils](http://sialcasa.github.io/mvvmFX/javadoc/1.5.0/mvvmfx-testing-utils/)
- [javadoc mvvmfx core](http://sialcasa.github.io/mvvmFX/javadoc/1.7.0/mvvmfx/)
- [javadoc mvvmfx-cdi](http://sialcasa.github.io/mvvmFX/javadoc/1.7.0/mvvmfx-cdi/)
- [javadoc mvvmfx-guice](http://sialcasa.github.io/mvvmFX/javadoc/1.7.0/mvvmfx-guice/)
- [javadoc mvvmfx-easydi](http://sialcasa.github.io/mvvmFX/javadoc/1.7.0/mvvmfx-easydi/)
- [javadoc mvvmfx-validation](http://sialcasa.github.io/mvvmFX/javadoc/1.7.0/mvvmfx-validation/)
- [javadoc mvvmfx-utils](http://sialcasa.github.io/mvvmFX/javadoc/1.7.0/mvvmfx-utils/)
- [javadoc mvvmfx-testing-utils](http://sialcasa.github.io/mvvmFX/javadoc/1.7.0/mvvmfx-testing-utils/)

8 changes: 6 additions & 2 deletions examples/books-example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>de.saxsys.mvvmfx</groupId>
<artifactId>examples</artifactId>
<version>1.6.0</version>
<version>1.7.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down Expand Up @@ -88,7 +88,11 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import de.saxsys.mvvmfx.examples.books.backend.Error;
import de.saxsys.mvvmfx.examples.books.backend.Book;
import de.saxsys.mvvmfx.examples.books.backend.LibraryService;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.util.Arrays;
import java.util.Collections;
Expand All @@ -19,7 +19,7 @@ public class MainViewModelTest {
private MainViewModel viewModel;
private LibraryService libraryService;

@Before
@BeforeEach
public void setup() {
libraryService = mock(LibraryService.class);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package de.saxsys.mvvmfx.examples.books.backend;

import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.util.List;

Expand All @@ -18,7 +18,7 @@ public class LibraryServiceMockTest {

private Book theMetamorphosis;

@Before
@BeforeEach
public void setup() {
libraryService = new LibraryServiceMockImpl();

Expand Down
14 changes: 9 additions & 5 deletions examples/contacts-example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>de.saxsys.mvvmfx</groupId>
<artifactId>examples</artifactId>
<version>1.6.0</version>
<version>1.7.0</version>
</parent>
<artifactId>contacts-example</artifactId>

Expand Down Expand Up @@ -48,12 +48,16 @@
<groupId>de.saxsys</groupId>
<artifactId>mvvmfx-cdi</artifactId>
</dependency>

<dependency>
<groupId>org.jboss.weld.se</groupId>
<artifactId>weld-se-core</artifactId>
</dependency>
<dependency>
<groupId>org.jboss</groupId>
<artifactId>jandex</artifactId>
<version>1.2.4.Final</version>
<version>2.0.3.Final</version>
</dependency>

<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
Expand Down Expand Up @@ -89,8 +93,8 @@
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package de.saxsys.mvvmfx.examples.contacts.model;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.ArrayList;

@XmlRootElement(name = "iso_3166_entries")
@XmlAccessorType(XmlAccessType.FIELD)
public class Countries {

@XmlElement(name = "iso_3166_entry")
private ArrayList<Country> countries;

public ArrayList<Country> getCountries() {
return countries;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package de.saxsys.mvvmfx.examples.contacts.model.countries;

import de.saxsys.mvvmfx.examples.contacts.model.Country;
import de.saxsys.mvvmfx.examples.contacts.model.Subdivision;
import javafx.beans.property.ReadOnlyBooleanProperty;
import javafx.beans.property.ReadOnlyStringProperty;
import javafx.collections.ObservableList;

/**
* Implementations of this interface are used to encapsulate the process of loading available countries
* and their subdivisions (if available).
*
* Instances are meant to be a stateful wrapper around the existing countries.
* You should create an instance of this class, call the {@link #init()} method
* and then bind the UI to the provided observable lists (
* {@link #availableCountries()} and {@link #subdivisions()}).
*
* To choose a country use the {@link #setCountry(Country)} method. This
* will lead to a change of the {@link #subdivisions()} list.
*/
public interface CountrySelector {

void init();

void setCountry(Country country);

ObservableList<Country> availableCountries();

ReadOnlyStringProperty subdivisionLabel();

ObservableList<Subdivision> subdivisions();

ReadOnlyBooleanProperty inProgressProperty();
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package de.saxsys.mvvmfx.examples.contacts.model;
package de.saxsys.mvvmfx.examples.contacts.model.countries;

import de.saxsys.mvvmfx.examples.contacts.model.Country;
import de.saxsys.mvvmfx.examples.contacts.model.Subdivision;
import javafx.beans.property.ReadOnlyBooleanProperty;
import javafx.beans.property.ReadOnlyBooleanWrapper;
import javafx.beans.property.ReadOnlyStringProperty;
Expand All @@ -15,36 +17,41 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.xml.bind.annotation.*;
import javax.annotation.PostConstruct;
import javax.enterprise.inject.Alternative;
import javax.inject.Singleton;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
* This class is used to encapsulate the process of loading available countries
* and there subdivisions (if available).
* and their subdivisions (if available).
*
* This class is meant to be a stateful wrapper around the existing countries.
* You should create an instance of this class, call the {@link #init()} method
* and then bind the UI to the provided observable lists (
* {@link #availableCountries()} and {@link #subdivisions()}).
*
* To choose a country have to use the {@link #setCountry(Country)} method. This
* To choose a country use the {@link #setCountry(Country)} method. This
* will lead to a change of the {@link #subdivisions()} list.
*
*
* At the moment this class used two XML files ({@link #ISO_3166_LOCATION} and
* At the moment this class uses two XML files ({@link #ISO_3166_LOCATION} and
* {@link #ISO_3166_2_LOCATION}) that contain information about countries,
* country-codes and subdivisions according to ISO 3166 and ISO 3166-2.
*
* The loading process is implemented with the DataFX framework.
*/
public class CountrySelector {
@Singleton
@Alternative
public class DataFxCountrySelector implements CountrySelector {

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

public static final String ISO_3166_LOCATION = "/countries/iso_3166.xml";
public static final String ISO_3166_2_LOCATION = "/countries/iso_3166_2.xml";
Expand All @@ -62,6 +69,8 @@ public class CountrySelector {
* This method triggers the loading of the available countries and
* subdivisions.
*/
@PostConstruct
@Override
public void init() {
inProgress.set(true);
loadCountries();
Expand All @@ -75,6 +84,7 @@ public void init() {
* @param country the country that will be selected or <code>null</code> if
* no country is selected.
*/
@Override
public void setCountry(Country country) {
if (country == null) {
subdivisionLabel.set(null);
Expand Down Expand Up @@ -169,11 +179,17 @@ void loadSubdivisions() {

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

entity.subsets.get(0).entryList.forEach(entry -> {
subdivisionList.add(new Subdivision(entry.name, entry.code, country));
entity.subsets.forEach(subset -> {
subset.entryList.forEach(entry -> {
subdivisionList.add(new Subdivision(entry.name, entry.code, country));
});
});

countryCodeSubdivisionNameMap.put(country, entity.subsets.get(0).subdivisionType);
String subdivisionName = entity.subsets.stream()
.map(subset -> subset.subdivisionType)
.collect(Collectors.joining("/"));

countryCodeSubdivisionNameMap.put(country, subdivisionName);
}
});

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

/**
* XML entity class. These classes represent the structure of the XML files
* to be loaded.
*/
@XmlRootElement(name = "iso_3166_subset")
@XmlAccessorType(XmlAccessType.FIELD)
static class ISO3166_2_EntryEntity {

@XmlAttribute(name = "code")
public String code;
@XmlAttribute(name = "name")
public String name;
}

/**
* XML entity class. These classes represent the structure of the XML files
* to be loaded.
*/
@XmlRootElement(name = "iso_3166_subset")
@XmlAccessorType(XmlAccessType.FIELD)
static class ISO3166_2_SubsetEntity {

@XmlElement(name = "iso_3166_2_entry")
public List<ISO3166_2_EntryEntity> entryList;

@XmlAttribute(name = "type")
public String subdivisionType;
}

/**
* XML entity class. These classes represent the structure of the XML files
* to be loaded.
*/
@XmlRootElement(name = "iso_3166_country")
@XmlAccessorType(XmlAccessType.FIELD)
static class ISO3166_2_CountryEntity {

@XmlAttribute(name = "code")
public String code;

@XmlElement(name = "iso_3166_subset")
public List<ISO3166_2_SubsetEntity> subsets;

@Override
public String toString() {
return "CountryEntity " + code;
}
}

@Override
public ObservableList<Country> availableCountries() {
return countries;
}

@Override
public ReadOnlyStringProperty subdivisionLabel() {
return subdivisionLabel.getReadOnlyProperty();
}

@Override
public ObservableList<Subdivision> subdivisions() {
return FXCollections.unmodifiableObservableList(subdivisions);
}

@Override
public ReadOnlyBooleanProperty inProgressProperty() {
return inProgress.getReadOnlyProperty();
}
Expand Down
Loading

0 comments on commit 1c5c2db

Please sign in to comment.