Skip to main content

[datafx~datafx2:64] use executor (if one available) in all writeback calls

  • From:
  • To:
  • Subject: [datafx~datafx2:64] use executor (if one available) in all writeback calls
  • Date: Tue, 2 Jul 2013 08:36:35 +0000

Project:    datafx
Repository: datafx2
Revision:   64
Author:     johanvos
Date:       2013-07-02 08:36:14 UTC
Link:       

Log Message:
------------
use executor (if one available)
use executor (if one available) in all writeback calls


Revisions:
----------
63
64


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


Diffs:
------
diff -r c0ad298ca0bc -r 139077362ebf 
datafx-core/src/main/java/org/datafx/provider/SingleObjectDataProvider.java
--- 
a/datafx-core/src/main/java/org/datafx/provider/SingleObjectDataProvider.java 
      Tue Jul 02 07:38:12 2013 +0200
+++ 
b/datafx-core/src/main/java/org/datafx/provider/SingleObjectDataProvider.java 
      Tue Jul 02 10:15:55 2013 +0200
@@ -55,6 +55,7 @@
         this.objectProperty = result;
     }
 
+    @Override
     public Worker<T> retrieve() {
         final Service<T> retriever = createService(objectProperty);
         retriever.setOnFailed(new EventHandler<WorkerStateEvent>() {
@@ -158,7 +159,6 @@
                             @Override
                             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() {
@@ -172,6 +172,9 @@
                                         return task;
                                     }
                                 };
+                                if (executor != null) {
+                                    service.setExecutor(executor);
+                                }
                                 service.start();
                             }
                         });


diff -r 139077362ebf -r 32f32537bf24 
datafx-core/src/main/java/org/datafx/provider/ListObjectDataProvider.java
--- 
a/datafx-core/src/main/java/org/datafx/provider/ListObjectDataProvider.java 
Tue Jul 02 10:15:55 2013 +0200
+++ 
b/datafx-core/src/main/java/org/datafx/provider/ListObjectDataProvider.java 
Tue Jul 02 10:36:14 2013 +0200
@@ -122,13 +122,42 @@
                         if (entryAddedHandler != null) {
                             value.addListener(new ListChangeListener<T>() {
                                 @Override
-                                public void 
onChanged(ListChangeListener.Change<? extends T> change) {
+                                public void onChanged(final 
ListChangeListener.Change<? extends T> change) {
                                     while (change.next()) {
+                                        Service service = new Service() {
+                                            @Override
+                                            protected Task createTask() {
+                                                Task task = new Task() {
+                                                    @Override
+                                                    protected Object call() 
throws Exception {
+
+
+                                                        List<? extends T> 
addedSubList = change.getAddedSubList();
+                                                        for (T entry : 
addedSubList) {
+                                                            
WritableDataReader dataReader = entryAddedHandler.createDataSource(entry);
+                                                            
dataReader.writeBack();
+                                                        }
+                                                        return addedSubList;
+
+
+                                                    }
+                                                };
+                                                return task;
+                                            }
+                                        };
+                                        if (executor != null) {
+                                            service.setExecutor(executor);
+                                        }
+                                        service.start();
+
+
                                         List<? extends T> addedSubList = 
change.getAddedSubList();
                                         for (T entry : addedSubList) {
                                             WritableDataReader dataReader = 
entryAddedHandler.createDataSource(entry);
                                             dataReader.writeBack();
                                         }
+
+
                                     }
 
                                 }
@@ -177,7 +206,7 @@
     public ListProperty<T> getData() {
         return new SimpleListProperty<T>(resultList);
     }
-    
+
     @Override
     public void setAddEntryHandler(WriteBackHandler<T> handler) {
         this.entryAddedHandler = handler;
@@ -214,9 +243,27 @@
                     if (observable != null) {
                         observable.addListener(new InvalidationListener() {
                             @Override
-                            public void invalidated(Observable o) {
-                                WritableDataReader reader = 
writeBackHandler.createDataSource(target);
-                                reader.writeBack();
+                            public void invalidated(final Observable o) {
+
+                                Service service = new Service() {
+                                    @Override
+                                    protected Task createTask() {
+                                        Task task = new Task() {
+                                            @Override
+                                            protected Object call() throws 
Exception {
+
+                                                WritableDataReader reader = 
writeBackHandler.createDataSource(target);
+                                                reader.writeBack();
+                                                return o;
+                                            }
+                                        };
+                                        return task;
+                                    }
+                                };
+                                if (executor != null) {
+                                    service.setExecutor(executor);
+                                }
+                                service.start();
                             }
                         });
                     }






[datafx~datafx2:64] use executor (if one available) in all writeback calls

johanvos 07/02/2013
 
 
Close
loading
Please Confirm
Close