You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2021/09/29 14:36:04 UTC
[sis] branch geoapi-4.0 updated (5a19844 -> c18ff54)
This is an automated email from the ASF dual-hosted git repository.
desruisseaux pushed a change to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git.
from 5a19844 Move into a new class (`OptionalInstallations`) part of the `ResourceDownloader` code asking if user agrees with EPSG terms of use. The intend is to allow to reuse this code in JavaFX application in addition of console application.
new 1e93fa3 Add the possibility to download automatically EPSG data if user agrees with EPSG terms of use.
new c18ff54 Update the EPSG data URL to the next version to be published.
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
application/sis-javafx/doc/readme.txt | 6 +-
application/sis-javafx/pom.xml | 12 +++-
application/sis-javafx/src/main/artifact/bin/sisfx | 2 +-
.../sis-javafx/src/main/artifact/bin/sisfx.bat | 2 +-
.../main/java/org/apache/sis/gui/DataViewer.java | 17 +++++
.../apache/sis/internal/gui/BackgroundThreads.java | 26 +++++++
.../sis/internal/gui/OptionalDataDownloader.java | 84 ++++++++++++++++++++++
.../org/apache/sis/internal/gui/Resources.java | 21 ++++++
.../apache/sis/internal/gui/Resources.properties | 4 ++
.../sis/internal/gui/Resources_fr.properties | 4 ++
.../org.apache.sis.setup.InstallationResources | 2 +-
.../apache/sis/setup/OptionalInstallations.java | 2 +-
12 files changed, 172 insertions(+), 10 deletions(-)
create mode 100644 application/sis-javafx/src/main/java/org/apache/sis/internal/gui/OptionalDataDownloader.java
copy application/{sis-console => sis-javafx}/src/main/resources/META-INF/services/org.apache.sis.setup.InstallationResources (75%)
[sis] 02/02: Update the EPSG data URL to the next version to be
published.
Posted by de...@apache.org.
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 c18ff54690d124306ee83b6f32ac2322fe1e7ae2
Author: Martin Desruisseaux <ma...@geomatys.com>
AuthorDate: Wed Sep 29 16:34:02 2021 +0200
Update the EPSG data URL to the next version to be published.
---
.../src/main/java/org/apache/sis/setup/OptionalInstallations.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/core/sis-utility/src/main/java/org/apache/sis/setup/OptionalInstallations.java b/core/sis-utility/src/main/java/org/apache/sis/setup/OptionalInstallations.java
index f2be4de..9a42c59 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/setup/OptionalInstallations.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/setup/OptionalInstallations.java
@@ -54,7 +54,7 @@ public abstract class OptionalInstallations extends InstallationResources implem
/**
* Where to download the EPSG scripts after user has approved the terms of use.
*/
- private static final String DOWNLOAD_URL = "http://repo1.maven.org/maven2/org/apache/sis/non-free/sis-epsg/1.0/sis-epsg-1.0.jar";
+ private static final String DOWNLOAD_URL = "http://repo1.maven.org/maven2/org/apache/sis/non-free/sis-epsg/1.1/sis-epsg-1.1.jar";
/**
* Estimation of the EPSG database size after installation, in megabytes.
[sis] 01/02: Add the possibility to download automatically EPSG
data if user agrees with EPSG terms of use.
Posted by de...@apache.org.
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 1e93fa3961a9ac36f3e7f0a267f1b88377c5556c
Author: Martin Desruisseaux <ma...@geomatys.com>
AuthorDate: Wed Sep 29 15:46:12 2021 +0200
Add the possibility to download automatically EPSG data if user agrees with EPSG terms of use.
---
application/sis-javafx/doc/readme.txt | 6 +-
application/sis-javafx/pom.xml | 12 +++-
application/sis-javafx/src/main/artifact/bin/sisfx | 2 +-
.../sis-javafx/src/main/artifact/bin/sisfx.bat | 2 +-
.../main/java/org/apache/sis/gui/DataViewer.java | 17 +++++
.../apache/sis/internal/gui/BackgroundThreads.java | 26 +++++++
.../sis/internal/gui/OptionalDataDownloader.java | 84 ++++++++++++++++++++++
.../org/apache/sis/internal/gui/Resources.java | 21 ++++++
.../apache/sis/internal/gui/Resources.properties | 4 ++
.../sis/internal/gui/Resources_fr.properties | 4 ++
.../org.apache.sis.setup.InstallationResources | 3 +
11 files changed, 173 insertions(+), 8 deletions(-)
diff --git a/application/sis-javafx/doc/readme.txt b/application/sis-javafx/doc/readme.txt
index 279505e..ba6acfb 100644
--- a/application/sis-javafx/doc/readme.txt
+++ b/application/sis-javafx/doc/readme.txt
@@ -12,8 +12,8 @@ NetBeans Ant project, open the following file:
And add the following lines:
- javac.source = 14
- javac.target = 14
+ javac.source = 17
+ javac.target = 17
javac.modulepath = /path/to/my/install/javafx-sdk/lib
- javafx.options = --add-modules javafx.graphics,javafx.controls,javafx.fxml
+ javafx.options = --add-modules javafx.graphics,javafx.controls,javafx.web
src.javafx.dir = ${project.root}/application/sis-javafx/src/main/java
diff --git a/application/sis-javafx/pom.xml b/application/sis-javafx/pom.xml
index 995a99f..44ad128 100644
--- a/application/sis-javafx/pom.xml
+++ b/application/sis-javafx/pom.xml
@@ -212,6 +212,12 @@
<version>${javafx.version}</version>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>org.openjfx</groupId>
+ <artifactId>javafx-web</artifactId>
+ <version>${javafx.version}</version>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
</profile>
@@ -230,7 +236,7 @@
<configuration>
<compilerArgs>
<arg>--module-path</arg> <arg>${env.PATH_TO_FX}</arg>
- <arg>--add-modules</arg> <arg>javafx.graphics,javafx.controls</arg>
+ <arg>--add-modules</arg> <arg>javafx.graphics,javafx.controls,javafx.web</arg>
</compilerArgs>
</configuration>
</plugin>
@@ -238,7 +244,7 @@
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>
- --module-path ${env.PATH_TO_FX} --add-modules javafx.graphics,javafx.controls
+ --module-path ${env.PATH_TO_FX} --add-modules javafx.graphics,javafx.controls,javafx.web
</argLine>
</configuration>
</plugin>
@@ -249,7 +255,7 @@
<additionalJOption>--module-path</additionalJOption>
<additionalJOption>${env.PATH_TO_FX}</additionalJOption>
<additionalJOption>--add-modules</additionalJOption>
- <additionalJOption>javafx.graphics,javafx.controls</additionalJOption>
+ <additionalJOption>javafx.graphics,javafx.controls,javafx.web</additionalJOption>
</additionalJOptions>
</configuration>
</plugin>
diff --git a/application/sis-javafx/src/main/artifact/bin/sisfx b/application/sis-javafx/src/main/artifact/bin/sisfx
index fe4dfbe..82df3c8 100755
--- a/application/sis-javafx/src/main/artifact/bin/sisfx
+++ b/application/sis-javafx/src/main/artifact/bin/sisfx
@@ -36,7 +36,7 @@ fi
# Execute SIS with any optional JAR that the user may put in the `lib` directory.
java -splash:"$BASE_DIR/lib/logo.jpg" \
- --add-modules javafx.graphics,javafx.controls \
+ --add-modules javafx.graphics,javafx.controls,javafx.web \
--module-path "$PATH_TO_FX" \
--class-path "$BASE_DIR/lib/*" \
-Djava.util.logging.config.class="org.apache.sis.internal.setup.LoggingConfiguration" \
diff --git a/application/sis-javafx/src/main/artifact/bin/sisfx.bat b/application/sis-javafx/src/main/artifact/bin/sisfx.bat
index eb1126e..2c12cb0 100644
--- a/application/sis-javafx/src/main/artifact/bin/sisfx.bat
+++ b/application/sis-javafx/src/main/artifact/bin/sisfx.bat
@@ -27,7 +27,7 @@ IF "%PATH_TO_FX%"=="" (
)
java -splash:"%BASE_DIR%\lib\logo.jpg"^
- --add-modules javafx.graphics,javafx.controls^
+ --add-modules javafx.graphics,javafx.controls,javafx.web^
--module-path "%PATH_TO_FX%"^
--class-path "%BASE_DIR%\lib\*"^
-Djava.util.logging.config.class=org.apache.sis.internal.setup.LoggingConfiguration^
diff --git a/application/sis-javafx/src/main/java/org/apache/sis/gui/DataViewer.java b/application/sis-javafx/src/main/java/org/apache/sis/gui/DataViewer.java
index 08d9bbc..bd0eee2 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/gui/DataViewer.java
+++ b/application/sis-javafx/src/main/java/org/apache/sis/gui/DataViewer.java
@@ -65,6 +65,11 @@ import org.apache.sis.util.resources.Vocabulary;
*/
public class DataViewer extends Application {
/**
+ * The application being executed, or {@code null} if none.
+ */
+ private static volatile DataViewer running;
+
+ /**
* Starts the Apache SIS application.
*
* @param args ignored.
@@ -195,6 +200,7 @@ public class DataViewer extends Application {
if (sp != null) {
sp.close();
}
+ running = this;
}
/**
@@ -300,9 +306,20 @@ public class DataViewer extends Application {
*/
@Override
public void stop() throws Exception {
+ running = null;
LogHandler.register(false);
BackgroundThreads.stop();
RecentChoices.saveReferenceSystems();
super.stop();
}
+
+ /**
+ * Returns the window in which the application is running, or {@code null} if the application is not running.
+ *
+ * @return the window in which the application is running, or {@code null}.
+ */
+ public static Stage getCurrentStage() {
+ final DataViewer r = running;
+ return (r != null) ? r.window : null;
+ }
}
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 bb5ea2e..312292f 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
@@ -16,14 +16,18 @@
*/
package org.apache.sis.internal.gui;
+import java.util.concurrent.Callable;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.concurrent.ExecutorService;
+import java.util.concurrent.ExecutionException;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
+import java.util.concurrent.FutureTask;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicInteger;
import javafx.application.Platform;
+import org.apache.sis.gui.DataViewer;
import org.apache.sis.internal.system.Modules;
import org.apache.sis.internal.system.Threads;
import org.apache.sis.util.logging.Logging;
@@ -115,6 +119,28 @@ public final class BackgroundThreads extends AtomicInteger implements ThreadFact
}
/**
+ * Runs the given task in JavaFX thread and wait for completion before to return.
+ * This method should <em>not</em> be invoked from JavaFX application thread.
+ * This method can be used for showing a dialog box during a background operation.
+ *
+ * @param <V> type of result that will be returned.
+ * @param task the task to execute in JavaFX thread.
+ * @return the task result, or {@code null} if an error occurred.
+ */
+ public static <V> V runAndWait(final Callable<V> task) {
+ final FutureTask<V> f = new FutureTask<>(task);
+ Platform.runLater(f);
+ try {
+ return f.get();
+ } catch (ExecutionException e) {
+ ExceptionReporter.show(DataViewer.getCurrentStage(), null, null, e.getCause());
+ } catch (InterruptedException e) {
+ interrupted("runAndWait", e);
+ }
+ return null;
+ }
+
+ /**
* Invoked at application shutdown time for stopping the executor threads after they completed their tasks.
* This method returns soon but the background threads may continue for some time if they did not finished
* their task yet.
diff --git a/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/OptionalDataDownloader.java b/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/OptionalDataDownloader.java
new file mode 100644
index 0000000..dff857a
--- /dev/null
+++ b/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/OptionalDataDownloader.java
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.internal.gui;
+
+import javafx.application.Platform;
+import javafx.scene.control.Alert;
+import javafx.scene.control.ButtonType;
+import javafx.scene.control.DialogPane;
+import javafx.scene.web.WebView;
+import org.apache.sis.gui.DataViewer;
+import org.apache.sis.internal.system.Fallback;
+import org.apache.sis.setup.OptionalInstallations;
+
+
+/**
+ * A provider for data licensed under different terms of use than the Apache license.
+ * This class is automatically instantiated and executed when EPSG data are missing.
+ * It popups a dialog box proposing to the user to download the data, if (s)he accepts
+ * the EPSG terms of use.
+ *
+ * @author Martin Desruisseaux (Geomatys)
+ * @version 1.1
+ * @since 1.1
+ * @module
+ */
+@Fallback
+public final class OptionalDataDownloader extends OptionalInstallations {
+ /**
+ * Creates a new installation scripts provider.
+ */
+ public OptionalDataDownloader() {
+ super("text/html");
+ }
+
+ /**
+ * Asks to the user if (s)he agree to download and install the resource for the given authority.
+ * This method may be invoked twice for the same {@code authority} argument:
+ * first with a null {@code license} argument for asking if the user agrees to download the data,
+ * then with a non-null {@code license} argument for asking if the user agrees with the license terms.
+ */
+ @Override
+ protected boolean askUserAgreement(final String authority, final String license) {
+ if (!Platform.isFxApplicationThread()) {
+ return BackgroundThreads.runAndWait(() -> {
+ return askUserAgreement(authority, license);
+ });
+ }
+ final Resources resources = Resources.forLocale(getLocale());
+ final Alert dialog;
+ dialog = new Alert(Alert.AlertType.CONFIRMATION, null, ButtonType.NO, ButtonType.YES);
+ dialog.initOwner(DataViewer.getCurrentStage());
+ dialog.setTitle(resources.getString(Resources.Keys.GeodeticDataset_1, authority));
+ dialog.setResizable(true);
+ if (license == null) {
+ dialog.getDialogPane().setPrefWidth(600);
+ dialog.setHeaderText(resources.getString(Resources.Keys.DownloadAndInstall_1, authority));
+ dialog.setContentText(resources.getString(Resources.Keys.DownloadDetails_3,
+ authority, getSpaceRequirement(authority), destinationDirectory));
+ } else {
+ final WebView content = new WebView();
+ content.getEngine().loadContent(license);
+ final DialogPane pane = dialog.getDialogPane();
+ pane.setContent(content);
+ pane.setPrefWidth(800);
+ pane.setPrefHeight(600);
+ dialog.setHeaderText(resources.getString(Resources.Keys.LicenseAgreement));
+ }
+ return dialog.showAndWait().orElse(ButtonType.NO) == ButtonType.YES;
+ }
+}
diff --git a/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/Resources.java b/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/Resources.java
index c983d43..dbee944 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/Resources.java
+++ b/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/Resources.java
@@ -166,6 +166,17 @@ public final class Resources extends IndexedResourceBundle {
public static final short DoesNotCoverAOI = 13;
/**
+ * Download and install {0} database?
+ */
+ public static final short DownloadAndInstall_1 = 58;
+
+ /**
+ * This geodetic dataset is required for the support of Coordinate Reference Systems defined by
+ * {0} codes. The database will use {1} Mb in directory {2}.
+ */
+ public static final short DownloadDetails_3 = 59;
+
+ /**
* An error occurred at the following location:
*/
public static final short ErrorAt = 53;
@@ -211,6 +222,11 @@ public final class Resources extends IndexedResourceBundle {
public static final short FullScreen = 22;
/**
+ * {0} geodetic dataset
+ */
+ public static final short GeodeticDataset_1 = 60;
+
+ /**
* Geospatial data files
*/
public static final short GeospatialFiles = 23;
@@ -237,6 +253,11 @@ public final class Resources extends IndexedResourceBundle {
public static final short IsolinesInRange = 57;
/**
+ * Do you accept the license shown below?
+ */
+ public static final short LicenseAgreement = 61;
+
+ /**
* Loading…
*/
public static final short Loading = 24;
diff --git a/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/Resources.properties b/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/Resources.properties
index 179baf0..1ece0b8 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/Resources.properties
+++ b/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/Resources.properties
@@ -42,6 +42,8 @@ CopyFilePath = Copy file path
DisplayedSize = Displayed size
DisplayStart = Display start
DoesNotCoverAOI = Does not cover the area of interest.
+DownloadAndInstall_1 = Download and install {0} database?
+DownloadDetails_3 = This geodetic dataset is required for the support of Coordinate Reference Systems defined by {0} codes. The database will use {1} Mb in directory {2}.
ErrorDetails = Details about error
ErrorExportingData = Error exporting data
ErrorOpeningFile = Error opening file
@@ -51,11 +53,13 @@ ErrorDataAccess = Error during data access
ErrorAt = An error occurred at the following location:
Exit = Exit
FullScreen = Full screen
+GeodeticDataset_1 = {0} geodetic dataset
GeospatialFiles = Geospatial data files
Help = Help
ImageStart = Image start
InconsistencyIn_2 = {0} \u2013 inconsistency in `{1}` property
IsolinesInRange = Generate isolines at constant interval\nstarting from given minimum.
+LicenseAgreement = Do you accept the license shown below?
Loading = Loading\u2026
Mercator = Mercator
MainWindow = Main window
diff --git a/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/Resources_fr.properties b/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/Resources_fr.properties
index f13048f..2998cd0 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/Resources_fr.properties
+++ b/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/Resources_fr.properties
@@ -47,6 +47,8 @@ CopyFilePath = Copier le chemin du fichier
DisplayedSize = Taille affich\u00e9e
DisplayStart = D\u00e9but de l\u2019affichage
DoesNotCoverAOI = Ne couvre pas la r\u00e9gion d\u2019int\u00e9r\u00eat.
+DownloadAndInstall_1 = T\u00e9l\u00e9charger et installer la base de donn\u00e9es {0}?
+DownloadDetails_3 = Cette base de donn\u00e9es est n\u00e9cessaire pour le support des syst\u00e8mes de r\u00e9f\u00e9rences d\u00e9finis par des codes {0}. La base occupera {1} Mo dans le r\u00e9pertoire {2}.
ErrorDetails = D\u00e9tails \u00e0 propos de l\u2019erreur
ErrorExportingData = Erreur \u00e0 l\u2019exportation de donn\u00e9es
ErrorOpeningFile = Erreur \u00e0 l\u2019ouverture du fichier
@@ -56,11 +58,13 @@ ErrorDataAccess = Erreur lors de l\u2019acc\u00e8s \u00e0 la donn\u00e9e
ErrorAt = Une erreur est survenue \u00e0 l\u2019endroit suivant\u00a0:
Exit = Quitter
FullScreen = Plein \u00e9cran
+GeodeticDataset_1 = Base de donn\u00e9es g\u00e9od\u00e9siques {0}
GeospatialFiles = Fichiers de donn\u00e9es g\u00e9ospatiales
Help = Aide
ImageStart = D\u00e9but de l\u2019image
InconsistencyIn_2 = {0} \u2013 incoh\u00e9rence dans la propri\u00e9t\u00e9 `{1}`
IsolinesInRange = G\u00e9n\u00e8re des isolignes \u00e0 intervalle constant en\ncommen\u00e7ant \u00e0 la valeur minimale sp\u00e9cifi\u00e9e.
+LicenseAgreement = Acceptez-vous la licence ci-dessous?
Loading = Chargement\u2026
Mercator = Mercator
MainWindow = Fen\u00eatre principale
diff --git a/application/sis-javafx/src/main/resources/META-INF/services/org.apache.sis.setup.InstallationResources b/application/sis-javafx/src/main/resources/META-INF/services/org.apache.sis.setup.InstallationResources
new file mode 100644
index 0000000..0cdb1b8
--- /dev/null
+++ b/application/sis-javafx/src/main/resources/META-INF/services/org.apache.sis.setup.InstallationResources
@@ -0,0 +1,3 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements;
+# and to You under the Apache License, Version 2.0.
+org.apache.sis.internal.gui.OptionalDataDownloader