Skip to content

Commit

Permalink
Merge branch 'release' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
manuel-mauky committed Jun 30, 2016
2 parents 40e603e + a9a0a24 commit a1fe740
Show file tree
Hide file tree
Showing 22 changed files with 121 additions and 87 deletions.
2 changes: 1 addition & 1 deletion 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.1</version>
<version>1.5.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion 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.1</version>
<version>1.5.2-SNAPSHOT</version>
</parent>
<artifactId>contacts-example</artifactId>

Expand Down
2 changes: 1 addition & 1 deletion examples/mini-examples/fx-root-example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>mini-examples</artifactId>
<groupId>de.saxsys.mvvmfx</groupId>
<version>1.5.1</version>
<version>1.5.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion examples/mini-examples/helloworld-without-fxml/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>mini-examples</artifactId>
<groupId>de.saxsys.mvvmfx</groupId>
<version>1.5.1</version>
<version>1.5.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion examples/mini-examples/helloworld/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>mini-examples</artifactId>
<groupId>de.saxsys.mvvmfx</groupId>
<version>1.5.1</version>
<version>1.5.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion examples/mini-examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>examples</artifactId>
<groupId>de.saxsys.mvvmfx</groupId>
<version>1.5.1</version>
<version>1.5.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>pom</packaging>
Expand Down
2 changes: 1 addition & 1 deletion examples/mini-examples/scopes-example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>mini-examples</artifactId>
<groupId>de.saxsys.mvvmfx</groupId>
<version>1.5.1</version>
<version>1.5.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion examples/mini-examples/synchronizefx-example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>mini-examples</artifactId>
<groupId>de.saxsys.mvvmfx</groupId>
<version>1.5.1</version>
<version>1.5.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion examples/mini-examples/welcome-example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>mini-examples</artifactId>
<groupId>de.saxsys.mvvmfx</groupId>
<version>1.5.1</version>
<version>1.5.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>de.saxsys</groupId>
<artifactId>mvvmfx-parent</artifactId>
<version>1.5.1</version>
<version>1.5.2-SNAPSHOT</version>
</parent>

<groupId>de.saxsys.mvvmfx</groupId>
Expand Down
2 changes: 1 addition & 1 deletion examples/todomvc-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.1</version>
<version>1.5.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion mvvmfx-archetype/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>de.saxsys</groupId>
<artifactId>mvvmfx-parent</artifactId>
<version>1.5.1</version>
<version>1.5.2-SNAPSHOT</version>
</parent>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<dependency>
<groupId>de.saxsys</groupId>
<artifactId>mvvmfx-parent</artifactId>
<version>1.5.1</version>
<version>1.5.2-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down
2 changes: 1 addition & 1 deletion mvvmfx-cdi/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<groupId>de.saxsys</groupId>
<artifactId>mvvmfx-parent</artifactId>
<version>1.5.1</version>
<version>1.5.2-SNAPSHOT</version>
</parent>

<artifactId>mvvmfx-cdi</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion mvvmfx-guice/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<groupId>de.saxsys</groupId>
<artifactId>mvvmfx-parent</artifactId>
<version>1.5.1</version>
<version>1.5.2-SNAPSHOT</version>
</parent>

<artifactId>mvvmfx-guice</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion mvvmfx-testing-utils/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>mvvmfx-parent</artifactId>
<groupId>de.saxsys</groupId>
<version>1.5.1</version>
<version>1.5.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion mvvmfx-utils/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>mvvmfx-parent</artifactId>
<groupId>de.saxsys</groupId>
<version>1.5.1</version>
<version>1.5.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion mvvmfx/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<groupId>de.saxsys</groupId>
<artifactId>mvvmfx-parent</artifactId>
<version>1.5.1</version>
<version>1.5.2-SNAPSHOT</version>
</parent>

<artifactId>mvvmfx</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*******************************************************************************
* Copyright 2015 Alexander Casall, Manuel Mauky
*
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -15,14 +15,8 @@
******************************************************************************/
package de.saxsys.mvvmfx.utils.validation;

import javafx.beans.property.ListProperty;
import javafx.beans.property.SimpleListProperty;
import javafx.collections.FXCollections;
import javafx.collections.ListChangeListener;

import java.util.*;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
* This class is used as {@link ValidationStatus} for {@link CompositeValidator}.
Expand Down Expand Up @@ -66,32 +60,41 @@ void addMessage(Validator validator, List<? extends ValidationMessage> messages)
getMessagesInternal().addAll(
messages.stream()
// ... we wrap them to keep track of the used validator.
.map(message -> new CompositeValidationMessageWrapper(message, validator))
.collect(Collectors.toList()));
.map(message -> new CompositeValidationMessageWrapper(message, validator))
.collect(Collectors.toList()));
}

/*
Remove all given messages for the given validator.
*/
void removeMessage(Validator validator, List<? extends ValidationMessage> messages) {
List<CompositeValidationMessageWrapper> messagesToRemove =
void removeMessage(final Validator validator, final List<? extends ValidationMessage> messages) {
final List<CompositeValidationMessageWrapper> messagesToRemove =
getMessagesInternal().stream()
.filter(messages::contains) // only the given messages
.filter(message -> (message instanceof CompositeValidationMessageWrapper))
.map(message -> (CompositeValidationMessageWrapper) message)
.filter(message -> message.getValidatorCode().equals(System.identityHashCode(validator)))
.collect(Collectors.toList());
.filter(messages::contains) // only the given messages
.filter(message -> (message instanceof CompositeValidationMessageWrapper))
.map(message -> (CompositeValidationMessageWrapper) message)
.filter(message -> message.getValidatorCode().equals(System.identityHashCode(validator)))
.collect(Collectors.toList());

getMessagesInternal().removeAll(messagesToRemove);
getMessagesInternal().removeIf(validationMessage -> {
if (validationMessage instanceof CompositeValidationMessageWrapper) {
final CompositeValidationMessageWrapper wrapper = (CompositeValidationMessageWrapper) validationMessage;
return messagesToRemove.stream()
.filter(m -> m.getValidatorCode().equals(wrapper.getValidatorCode()))
.anyMatch(wrapper::equals);
}

return false;
});
}

/*
* Remove all messages for this particular validator.
*/
void removeMessage(Validator validator) {
void removeMessage(final Validator validator) {
getMessagesInternal().removeIf(validationMessage -> {
if(validationMessage instanceof CompositeValidationMessageWrapper) {
CompositeValidationMessageWrapper wrapper = (CompositeValidationMessageWrapper) validationMessage;
if (validationMessage instanceof CompositeValidationMessageWrapper) {
final CompositeValidationMessageWrapper wrapper = (CompositeValidationMessageWrapper) validationMessage;

return wrapper.getValidatorCode().equals(System.identityHashCode(validator));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*******************************************************************************
* Copyright 2015 Alexander Casall, Manuel Mauky
*
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -15,21 +15,20 @@
******************************************************************************/
package de.saxsys.mvvmfx.utils.validation;

import java.util.HashMap;
import java.util.Map;

import javafx.beans.property.ListProperty;
import javafx.beans.property.SimpleListProperty;
import javafx.collections.FXCollections;
import javafx.collections.ListChangeListener;
import javafx.collections.ObservableList;

import java.util.HashMap;
import java.util.Map;

/**
* This {@link Validator} implementation is used to compose multiple other validators.
* <p>
* The {@link ValidationStatus} of this validator will contain all messages of all registered validators.
*
*
* @author manuel.mauky
*/
public class CompositeValidator implements Validator {
Expand All @@ -45,7 +44,7 @@ public CompositeValidator() {
validators.addListener(new ListChangeListener<Validator>() {
@Override
public void onChanged(Change<? extends Validator> c) {
while(c.next()) {
while (c.next()) {

// When validators are added...
c.getAddedSubList().forEach(validator -> {
Expand All @@ -55,7 +54,7 @@ public void onChanged(Change<? extends Validator> c) {
status.addMessage(validator, messages);

final ListChangeListener<ValidationMessage> changeListener = change -> {
while(change.next()) {
while (change.next()) {
// add/remove messages for this particular validator
status.addMessage(validator, change.getAddedSubList());
status.removeMessage(validator, change.getRemoved());
Expand All @@ -73,7 +72,7 @@ public void onChanged(Change<? extends Validator> c) {
c.getRemoved().forEach(validator -> {
status.removeMessage(validator);

if(listenerMap.containsKey(validator)){
if (listenerMap.containsKey(validator)) {
ListChangeListener<ValidationMessage> changeListener = listenerMap.get(validator);

validator.getValidationStatus().getMessages().removeListener(changeListener);
Expand All @@ -85,21 +84,21 @@ public void onChanged(Change<? extends Validator> c) {
});

}

public CompositeValidator(Validator... validators) {
this(); // before adding the validators we need to setup the listeners in the default constructor
addValidators(validators);
}


public void addValidators(Validator... validators) {
this.validators.addAll(validators);
}

public void removeValidators(Validator... validators) {
this.validators.removeAll(validators);
}

@Override
public ValidationStatus getValidationStatus() {
return status;
Expand Down
Loading

0 comments on commit a1fe740

Please sign in to comment.