sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject [sis] 02/04: Preload `CoverageExplorer` on application startup.
Date Tue, 07 Jul 2020 17:47:47 GMT
This is an automated email from the ASF dual-hosted git repository.

desruisseaux pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git

commit 9d85a5a1c55b22b359bfacdf1a3c17f0adf83c47
Author: Martin Desruisseaux <martin.desruisseaux@geomatys.com>
AuthorDate: Tue Jul 7 16:36:41 2020 +0200

    Preload `CoverageExplorer` on application startup.
---
 .../main/java/org/apache/sis/gui/dataset/ResourceExplorer.java   | 9 +++++++++
 .../main/java/org/apache/sis/internal/gui/BackgroundThreads.java | 7 +++++++
 2 files changed, 16 insertions(+)

diff --git a/application/sis-javafx/src/main/java/org/apache/sis/gui/dataset/ResourceExplorer.java
b/application/sis-javafx/src/main/java/org/apache/sis/gui/dataset/ResourceExplorer.java
index 7f23dca..ec7eb4a 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/gui/dataset/ResourceExplorer.java
+++ b/application/sis-javafx/src/main/java/org/apache/sis/gui/dataset/ResourceExplorer.java
@@ -185,6 +185,15 @@ public class ResourceExplorer extends WindowManager {
          */
         viewTab .selectedProperty().addListener((p,o,n) -> dataTabShown(n, true));
         tableTab.selectedProperty().addListener((p,o,n) -> dataTabShown(n, false));
+        /*
+         * Optional execution in advance of a potentially slow operation. If `PRELOAD` is
`false`,
+         * then the data tabs will be initialized only the first time that one of those tabs
is
+         * visible in same time that a resource is selected in the resources explorer.
+         */
+        if (BackgroundThreads.PRELOAD) {
+            builder = new DataTabBuilder(null);
+            BackgroundThreads.execute(builder);
+        }
     }
 
     /**
diff --git a/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/BackgroundThreads.java
b/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/BackgroundThreads.java
index 3023c36..bb5ea2e 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/BackgroundThreads.java
+++ b/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/BackgroundThreads.java
@@ -49,6 +49,13 @@ import org.apache.sis.util.logging.Logging;
 @SuppressWarnings("serial")                         // Not intended to be serialized.
 public final class BackgroundThreads extends AtomicInteger implements ThreadFactory {
     /**
+     * Whether to allow the application to prepare in a background thread some GUI component
+     * before they are actually needed. It allows faster user experience, at the cost of
CPU
+     * and memory consumption that may not be needed.
+     */
+    public static final boolean PRELOAD = true;
+
+    /**
      * The executor for background tasks. This is actually an {@link ExecutorService} instance,
      * but only the {@link Executor} method should be used according JavaFX documentation.
      */


Mime
View raw message