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 Feb 6, 2017
2 parents bd81823 + 2df9526 commit 8a71033
Show file tree
Hide file tree
Showing 142 changed files with 3,785 additions and 855 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.5.1</version>
<version>1.6.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.5.2-SNAPSHOT</version>
<version>1.6.1-SNAPSHOT</version>
</dependency>
```

Expand All @@ -44,7 +44,7 @@ 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.6.0-SNAPSHOT</version>
<version>1.7.0-SNAPSHOT</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion deploy_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@
# </servers>
# </settings>

mvn clean deploy -pl 'mvvmfx,mvvmfx-cdi,mvvmfx-guice,mvvmfx-archetype,mvvmfx-utils,mvvmfx-testing-utils' -am -DskipTests=true -Pdeploy-release --settings ~/.m2/settings-mvvmfx.xml
mvn clean deploy -pl 'mvvmfx,mvvmfx-cdi,mvvmfx-guice,mvvmfx-easydi,mvvmfx-archetype,mvvmfx-utils,mvvmfx-testing-utils,mvvmfx-validation' -am -DskipTests=true -Pdeploy-release --settings ~/.m2/settings-mvvmfx.xml
7 changes: 3 additions & 4 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.5.2</version>
<version>1.6.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down Expand Up @@ -35,9 +35,8 @@
<artifactId>mvvmfx</artifactId>
</dependency>
<dependency>
<groupId>eu.lestard</groupId>
<artifactId>easy-di</artifactId>
<version>0.2.0</version>
<groupId>de.saxsys</groupId>
<artifactId>mvvmfx-easydi</artifactId>
</dependency>
<dependency>
<groupId>de.jensd</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,44 +1,39 @@
package de.saxsys.mvvmfx.examples.books;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.stage.Stage;

import com.guigarage.flatterfx.FlatterFX;
import com.guigarage.flatterfx.FlatterInputType;

import de.saxsys.mvvmfx.FluentViewLoader;
import de.saxsys.mvvmfx.MvvmFX;
import de.saxsys.mvvmfx.easydi.MvvmfxEasyDIApplication;
import de.saxsys.mvvmfx.examples.books.backend.LibraryService;
import de.saxsys.mvvmfx.examples.books.backend.LibraryServiceImpl;
import de.saxsys.mvvmfx.examples.books.backend.LibraryServiceMockImpl;
import eu.lestard.easydi.EasyDI;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.stage.Stage;

public class App extends Application {
public class App extends MvvmfxEasyDIApplication {

private static final boolean ENABLE_MOCK_SERVICE = true;

private EasyDI context = new EasyDI();


public static void main(String[] args) {
launch(args);
}

@Override
public void start(Stage primaryStage) throws Exception {
protected void initEasyDi(EasyDI context) throws Exception {
if (ENABLE_MOCK_SERVICE) {
context.bindInterface(LibraryService.class, LibraryServiceMockImpl.class);
LibraryServiceMockImpl libraryServiceMock = context.getInstance(LibraryServiceMockImpl.class);
libraryServiceMock.addSomeBooks();
} else {
context.bindInterface(LibraryService.class, LibraryServiceImpl.class);
}


MvvmFX.setCustomDependencyInjector(type -> context.getInstance(type));

}

@Override
public void startMvvmfx(Stage primaryStage) throws Exception {

primaryStage.setTitle("Library JavaFX");
primaryStage.setMinWidth(1200);
primaryStage.setMaxWidth(1200);
Expand Down
8 changes: 6 additions & 2 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.5.2</version>
<version>1.6.0</version>
</parent>
<artifactId>contacts-example</artifactId>

Expand Down Expand Up @@ -62,7 +62,7 @@
<dependency>
<groupId>org.controlsfx</groupId>
<artifactId>controlsfx</artifactId>
<version>8.40.9</version>
<version>8.40.12</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -121,6 +121,10 @@
<artifactId>mvvmfx-testing-utils</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>de.saxsys</groupId>
<artifactId>mvvmfx-validation</artifactId>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -1,32 +1,28 @@
package de.saxsys.mvvmfx.examples.contacts.model;

import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javafx.beans.property.ReadOnlyBooleanProperty;
import javafx.beans.property.ReadOnlyBooleanWrapper;
import javafx.beans.property.ReadOnlyStringProperty;
import javafx.beans.property.ReadOnlyStringWrapper;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.concurrent.Worker;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

import org.datafx.provider.ListDataProvider;
import org.datafx.reader.FileSource;
import org.datafx.reader.DataReader;
import org.datafx.reader.InputStreamDataReader;
import org.datafx.reader.converter.InputStreamConverter;
import org.datafx.reader.converter.XmlConverter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.xml.bind.annotation.*;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* This class is used to encapsulate the process of loading available countries
* and there subdivisions (if available).
Expand Down Expand Up @@ -98,7 +94,7 @@ public void setCountry(Country country) {
* Load all countries from the XML file source with DataFX.
*/
void loadCountries() {
URL iso3166Resource = this.getClass().getResource(ISO_3166_LOCATION);
InputStream iso3166Resource = this.getClass().getResourceAsStream(ISO_3166_LOCATION);
if (iso3166Resource == null) {
throw new IllegalStateException("Can't find the list of countries! Expected location was:"
+ ISO_3166_LOCATION);
Expand All @@ -107,7 +103,8 @@ void loadCountries() {
XmlConverter<Country> countryConverter = new XmlConverter<>("iso_3166_entry", Country.class);

try {
FileSource<Country> dataSource = new FileSource<>(new File(iso3166Resource.getFile()), countryConverter);
DataReader<Country> dataSource = new InputStreamSource<>( iso3166Resource, countryConverter );

ListDataProvider<Country> listDataProvider = new ListDataProvider<>(dataSource);

listDataProvider.setResultObservableList(countries);
Expand All @@ -124,12 +121,19 @@ void loadCountries() {
}
}

static class InputStreamSource<T> extends InputStreamDataReader<T> {
public InputStreamSource(InputStream is, InputStreamConverter converter) throws IOException {
super(converter);
setInputStream(is);
}
}

/**
* Load all subdivisions from the XML file source with DataFX.
*/
void loadSubdivisions() {

URL iso3166_2Resource = this.getClass().getResource(ISO_3166_2_LOCATION);
InputStream iso3166_2Resource = this.getClass().getResourceAsStream(ISO_3166_2_LOCATION);

if (iso3166_2Resource == null) {
throw new IllegalStateException("Can't find the list of subdivisions! Expected location was:"
Expand All @@ -142,8 +146,10 @@ void loadSubdivisions() {
ObservableList<ISO3166_2_CountryEntity> subdivisionsEntities = FXCollections.observableArrayList();

try {
FileSource<ISO3166_2_CountryEntity> dataSource = new FileSource<>(new File(iso3166_2Resource.getFile()),
converter);

DataReader<ISO3166_2_CountryEntity> dataSource =
new InputStreamSource<>( iso3166_2Resource, converter );

ListDataProvider<ISO3166_2_CountryEntity> listDataProvider = new ListDataProvider<>(dataSource);

listDataProvider.setResultObservableList(subdivisionsEntities);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Objects;
import java.util.Optional;
import java.util.StringJoiner;

import javax.inject.Inject;

Expand All @@ -26,6 +29,7 @@
import javafx.beans.property.ReadOnlyObjectProperty;
import javafx.beans.property.ReadOnlyStringProperty;
import javafx.beans.property.ReadOnlyStringWrapper;
import javafx.beans.value.ObservableValue;

@ScopeProvider(scopes = ContactDialogScope.class)
public class DetailViewModel implements ViewModel {
Expand Down Expand Up @@ -101,19 +105,17 @@ protected void action() throws Exception {

private void createBindingsForLabels(ReadOnlyObjectProperty<Contact> contactProperty) {
name.bind(emptyStringOnNull(map(contactProperty, contact -> {
StringBuilder result = new StringBuilder();
StringJoiner joiner = new StringJoiner(" ");

String title = contact.getTitle();
if (title != null && !title.trim().isEmpty()) {
result.append(title);
result.append(" ");
}
Optional.ofNullable(contact.getTitle())
.filter(Objects::nonNull)
.filter(s -> !s.trim().isEmpty())
.ifPresent(joiner::add);

result.append(contact.getFirstname());
result.append(" ");
result.append(contact.getLastname());
joiner.add(contact.getFirstname());
joiner.add(contact.getLastname());

return result.toString();
return joiner.toString();
})));

email.bind(emptyStringOnNull(map(contactProperty, Contact::getEmailAddress)));
Expand Down Expand Up @@ -184,12 +186,12 @@ private void createBindingsForLabels(ReadOnlyObjectProperty<Contact> contactProp
* string is used for the returned binding. Otherwise the value of the
* source binding is used.
*/
private StringBinding emptyStringOnNull(ObjectBinding<String> source) {
private StringBinding emptyStringOnNull(ObservableValue<String> source) {
return Bindings.createStringBinding(() -> {
if (source.get() == null) {
if (source.getValue() == null) {
return "";
} else {
return source.get();
return source.getValue();
}
}, source);
}
Expand Down Expand Up @@ -242,20 +244,6 @@ public ReadOnlyStringProperty countrySubdivisionLabelTextProperty() {
return countrySubdivision.getReadOnlyProperty();
}

private String trimString(String string) {
if (string == null || string.trim().isEmpty()) {
return "";
}
return string;
}

private String trimStringWithPostfix(String string, String append) {
if (string == null || string.trim().isEmpty()) {
return "";
}
return string + append;
}

private Contact getSelectedContactFromScope() {
return getSelectedContactPropertyFromScope().get();
}
Expand Down
Loading

0 comments on commit 8a71033

Please sign in to comment.