package org.genericsystem.todomvc;

import java.util.Objects;

import javafx.beans.binding.Bindings;
import javafx.beans.property.Property;
import javafx.beans.property.ReadOnlyObjectWrapper;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.value.ObservableValue;

import org.genericsystem.common.Generic;
import org.genericsystem.reactor.Model;
import org.genericsystem.todomvc.Todos.Completed;

/**
 * @author Nicolas Feybesse
 *
 */
public class Todo extends Model {

	private final Generic generic;
	private Property<String> todoString;
	private Property<Boolean> completed = new SimpleBooleanProperty();

	Todo(TodoList parentModel, Generic generic) {
		this.generic = generic;
		todoString = new ReadOnlyObjectWrapper<>(Objects.toString(generic));
		ObservableValue<Generic> observableHolder = generic.getObservableHolder(generic.getRoot().find(Completed.class));
		completed.bind(Bindings.createBooleanBinding(() -> observableHolder.getValue() != null ? (Boolean) observableHolder.getValue().getValue() : false, observableHolder));
	}

	/*********************************************************************************************************************************/

	public Property<String> getTodoString() {
		return todoString;
	}

	public ObservableValue<Boolean> getCompleted() {
		return completed;
	}

	public void setCompletion(boolean completion) {
		generic.setHolder(generic.getRoot().find(Completed.class), completion);
	}

	public void remove() {
		generic.remove();
	}
}

@@ -67,355 +67,344 @@
 ort 
-javafx.beans.binding.Bindings;%0Aimport javafx.beans.property.Property;%0Aimport javafx.beans.property.ReadOnlyObjectWrapper;%0Aimport javafx.beans.property.SimpleBooleanProperty;%0Aimport javafx.beans.value.ObservableValue;%0A%0Aimport org.genericsystem.common.Generic;%0Aimport org.genericsystem.reactor.Model;%0Aimport org.genericsystem.todomvc.Todos.Completed
+org.genericsystem.common.Generic;%0Aimport org.genericsystem.reactor.Model;%0Aimport org.genericsystem.todomvc.Todos.Completed;%0A%0Aimport com.esotericsoftware.minlog.Log;%0A%0Aimport javafx.beans.binding.Bindings;%0Aimport javafx.beans.property.Property;%0Aimport javafx.beans.property.ReadOnlyObjectWrapper;%0Aimport javafx.beans.value.ObservableValue
 ;%0A%0A/
@@ -555,24 +555,31 @@
 private 
-Property
+ObservableValue
 %3CBoolean
@@ -589,16 +589,19 @@
 ompleted
+;//
  = new S
@@ -900,14 +900,11 @@
 eted
-.bind(
+ = 
 Bind
@@ -1048,17 +1048,16 @@
 eHolder)
-)
 ;%0A%09%7D%0A%0A%09/
@@ -1375,24 +1375,52 @@
 mpletion) %7B%0A
+%09%09Log.info(%22update model%22);%0A
 %09%09generic.se

fix Todo.java