Skip to main content

[datafx~datafx2:62] writeback should be asynchronous, use a Task for this

  • From:
  • To:
  • Subject: [datafx~datafx2:62] writeback should be asynchronous, use a Task for this
  • Date: Tue, 2 Jul 2013 05:38:31 +0000

Project:    datafx
Repository: datafx2
Revision:   62
Author:     johanvos
Date:       2013-07-02 05:38:12 UTC
Link:       

Log Message:
------------
writeback should be asynchronous, use a Task for this


Revisions:
----------
62


Modified Paths:
---------------
datafx-core/src/main/java/org/datafx/provider/ListObjectDataProvider.java
datafx-core/src/main/java/org/datafx/provider/SingleObjectDataProvider.java


Diffs:
------
diff -r 3a29957e1d1d -r c0ad298ca0bc 
datafx-core/src/main/java/org/datafx/provider/ListObjectDataProvider.java
--- 
a/datafx-core/src/main/java/org/datafx/provider/ListObjectDataProvider.java 
Wed Jun 19 11:19:01 2013 +0200
+++ 
b/datafx-core/src/main/java/org/datafx/provider/ListObjectDataProvider.java 
Tue Jul 02 07:38:12 2013 +0200
@@ -128,7 +128,6 @@
                                         for (T entry : addedSubList) {
                                             WritableDataReader dataReader = 
entryAddedHandler.createDataSource(entry);
                                             dataReader.writeBack();
-
                                         }
                                     }
 

diff -r 3a29957e1d1d -r c0ad298ca0bc 
datafx-core/src/main/java/org/datafx/provider/SingleObjectDataProvider.java
--- 
a/datafx-core/src/main/java/org/datafx/provider/SingleObjectDataProvider.java 
      Wed Jun 19 11:19:01 2013 +0200
+++ 
b/datafx-core/src/main/java/org/datafx/provider/SingleObjectDataProvider.java 
      Tue Jul 02 07:38:12 2013 +0200
@@ -18,6 +18,7 @@
 import javafx.event.EventHandler;
 import org.datafx.concurrent.ObservableExecutor;
 import org.datafx.reader.DataReader;
+import org.datafx.reader.WritableDataReader;
 import org.datafx.writer.WriteBackHandler;
 import org.datafx.writer.WriteBackProvider;
 
@@ -155,25 +156,25 @@
                     if (observable != null) {
                         observable.addListener(new InvalidationListener() {
                             @Override
-                            public void invalidated(Observable o) {
-                                DataReader reader = 
writeBackHandler.createDataSource(objectProperty.get());
-                                Object response = reader.get();
+                            public void invalidated(final Observable o) {
+                                final WritableDataReader reader = 
writeBackHandler.createDataSource(objectProperty.get());
+                                // TODO use executors, and return a Worker
+                                Service service = new Service() {
+                                    @Override
+                                    protected Task createTask() {
+                                        Task task = new Task() {
+                                            @Override
+                                            protected Object call() throws 
Exception {
+                                                reader.writeBack();
+                                                return o;
+                                            }
+                                        };
+                                        return task;
+                                    }
+                                };
+                                service.start();
                             }
                         });
-//                        if 
(ObservableList.class.isAssignableFrom(observable.getClass())) {
-//                            ObservableList observableList = 
(ObservableList)observable;
-//                            observableList.addListener(new 
ListChangeListener(){
-//
-//                                @Override
-//                                public void 
onChanged(ListChangeListener.Change change) {
-//                                    System.out.println("LIST changed");
-//                                    DataReader reader = 
writeBackHandler.createDataSource(objectProperty.get());
-//                                    Object response = reader.get();
-//                                    System.out.println("done getting 
response from listchange" + response);
-//                                }
-//                            });
-//                        }
-              //          System.out.println("added a listener to 
"+observable+", class = "+observable.getClass());
                     }
 
                 } catch (IllegalArgumentException ex) {






[datafx~datafx2:62] writeback should be asynchronous, use a Task for this

johanvos 07/02/2013
 
 
Close
loading
Please Confirm
Close