You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by jt...@apache.org on 2019/10/28 11:12:11 UTC

[netbeans-html4j] branch master updated: Keep reference to InitializeWebView until it is notified for the first time

This is an automated email from the ASF dual-hosted git repository.

jtulach pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans-html4j.git


The following commit(s) were added to refs/heads/master by this push:
     new cd32292  Keep reference to InitializeWebView until it is notified for the first time
cd32292 is described below

commit cd3229252279ee02de13230909393f88cb5de18e
Author: Jaroslav Tulach <ja...@apidesign.org>
AuthorDate: Mon Oct 28 12:11:57 2019 +0100

    Keep reference to InitializeWebView until it is notified for the first time
---
 .../netbeans/html/boot/fx/InitializeWebView.java   |  5 +++--
 .../org/netbeans/html/ko4j/DoubleViewTest.java     | 23 ++++++++++++++++------
 .../java/org/netbeans/html/ko4j/DumpStack.java     |  4 ++--
 3 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/boot-fx/src/main/java/org/netbeans/html/boot/fx/InitializeWebView.java b/boot-fx/src/main/java/org/netbeans/html/boot/fx/InitializeWebView.java
index 4853ffe..2bbc3c2 100644
--- a/boot-fx/src/main/java/org/netbeans/html/boot/fx/InitializeWebView.java
+++ b/boot-fx/src/main/java/org/netbeans/html/boot/fx/InitializeWebView.java
@@ -25,7 +25,6 @@ import javafx.beans.value.ObservableValue;
 import javafx.concurrent.Worker;
 import javafx.scene.web.WebView;
 import net.java.html.BrwsrCtx;
-import org.netbeans.html.boot.fx.AbstractFXPresenter;
 
 public final class InitializeWebView extends AbstractFXPresenter implements Runnable {
 
@@ -65,12 +64,13 @@ public final class InitializeWebView extends AbstractFXPresenter implements Runn
 
     private static class FindViewListener extends WeakReference<InitializeWebView>
     implements ChangeListener<Worker.State> {
-
+        private InitializeWebView toNotify;
         private final URL resource;
         private final Worker<Void> w;
 
         public FindViewListener(InitializeWebView view, URL resource, Worker<Void> w) {
             super(view);
+            this.toNotify = view;
             this.resource = resource;
             this.w = w;
         }
@@ -86,6 +86,7 @@ public final class InitializeWebView extends AbstractFXPresenter implements Runn
             if (newState.equals(Worker.State.SUCCEEDED)) {
                 if (checkValid(view)) {
                     view.onPageLoad();
+                    toNotify = null;
                 }
             }
             if (newState.equals(Worker.State.FAILED)) {
diff --git a/ko4j/src/test/java/org/netbeans/html/ko4j/DoubleViewTest.java b/ko4j/src/test/java/org/netbeans/html/ko4j/DoubleViewTest.java
index 5cfcf5f..b32c039 100644
--- a/ko4j/src/test/java/org/netbeans/html/ko4j/DoubleViewTest.java
+++ b/ko4j/src/test/java/org/netbeans/html/ko4j/DoubleViewTest.java
@@ -48,9 +48,6 @@ import org.testng.annotations.Test;
 })
 public class DoubleViewTest {
     private static String set;
-    static {
-        DumpStack.initialize();
-    }
 
     @Function
     static void change(DoubleView model) {
@@ -66,6 +63,9 @@ public class DoubleViewTest {
     private WebView view2;
 
     private static final StringBuffer LOG = new StringBuffer();
+    static {
+        DumpStack.initialize();
+    }
     private JFrame frame;
     private Fn.Presenter presenter1;
     private Fn.Presenter presenter2;
@@ -77,6 +77,7 @@ public class DoubleViewTest {
         final JFXPanel panel = new JFXPanel();
         final JFXPanel p2 = new JFXPanel();
 
+        log("Panel #1 " + panel + " and #2 " + p2);
         final CountDownLatch initViews = new CountDownLatch(1);
         Platform.runLater(() -> {
             displayFrame(panel, p2);
@@ -87,29 +88,39 @@ public class DoubleViewTest {
         doubleView = new DoubleView();
         doubleView.setMessage("Initialized");
 
+        log("DoubleView: " + doubleView);
+
         final URL page = DoubleViewTest.class.getResource("double.html");
         assertNotNull(page, "double.html found");
 
 
-
         final CountDownLatch view1Init = new CountDownLatch(1);
         final CountDownLatch view2Init = new CountDownLatch(1);
+        log("Scheduling view1");
         Platform.runLater(() -> {
+            log("Platform.runLater");
             FXBrowsers.load(view1, page, () -> {
+                log("initializing view1");
                 presenter1 = Fn.activePresenter();
                 doubleView.applyBindings();
                 log("applyBindings view One");
                 view1Init.countDown();
             });
-
+        });
+        log("Waiting for view1");
+        view1Init.await();
+        log("Scheduling view1");
+        Platform.runLater(() -> {
             FXBrowsers.load(view2, page, () -> {
+                log("initializing view2");
                 presenter2 = Fn.activePresenter();
                 doubleView.applyBindings();
                 log("applyBindings view Two");
                 view2Init.countDown();
             });
+            log("view2 load scheduled");
         });
-        view1Init.await();
+        log("Waiting for view2");
         view2Init.await();
         log("initializeViews - done");
         assertNotNull(presenter1, "presenter for view1 found");
diff --git a/ko4j/src/test/java/org/netbeans/html/ko4j/DumpStack.java b/ko4j/src/test/java/org/netbeans/html/ko4j/DumpStack.java
index fae001f..9bc6dde 100644
--- a/ko4j/src/test/java/org/netbeans/html/ko4j/DumpStack.java
+++ b/ko4j/src/test/java/org/netbeans/html/ko4j/DumpStack.java
@@ -44,7 +44,7 @@ final class DumpStack extends TimerTask {
     }
 
     public static void initialize() {
-        final int thirtySeconds = 30000;
-        TIMER.schedule(new DumpStack(), thirtySeconds, thirtySeconds);
+        final int fiveSec = 5000;
+        TIMER.schedule(new DumpStack(), fiveSec, 2 * fiveSec);
     }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists