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 2023/12/04 15:32:16 UTC

(sis) branch geoapi-4.0 updated (ca43fdb6a7 -> a3767ac21e)

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 ca43fdb6a7 Wrap the line of log messages in console application, for making easier to read the warnings.
     new c8e8207f1f Avoid broken rendering of non-ASCII characters when downloading EPSG data from JShell.
     new a3767ac21e Fix the OpenJFX detection, including the wizard which was not started anymore.

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:
 .../apache/sis/console/ResourcesDownloader.java    | 42 ++++++++++++++++++---
 optional/src/org.apache.sis.gui/bundle/bin/sisfx   | 43 +++++++++++++++++++++-
 .../src/org.apache.sis.gui/bundle/bin/sisfx.bat    |  2 +-
 .../main/org/apache/sis/gui/setup/Wizard.java      |  4 +-
 4 files changed, 81 insertions(+), 10 deletions(-)


(sis) 02/02: Fix the OpenJFX detection, including the wizard which was not started anymore.

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 a3767ac21efc20f6e35ed73b3046d57538c2e57c
Author: Martin Desruisseaux <ma...@geomatys.com>
AuthorDate: Mon Dec 4 16:23:32 2023 +0100

    Fix the OpenJFX detection, including the wizard which was not started anymore.
---
 optional/src/org.apache.sis.gui/bundle/bin/sisfx   | 43 +++++++++++++++++++++-
 .../src/org.apache.sis.gui/bundle/bin/sisfx.bat    |  2 +-
 .../main/org/apache/sis/gui/setup/Wizard.java      |  4 +-
 3 files changed, 45 insertions(+), 4 deletions(-)

diff --git a/optional/src/org.apache.sis.gui/bundle/bin/sisfx b/optional/src/org.apache.sis.gui/bundle/bin/sisfx
index 68a85b4ff9..3f5d9186cf 100755
--- a/optional/src/org.apache.sis.gui/bundle/bin/sisfx
+++ b/optional/src/org.apache.sis.gui/bundle/bin/sisfx
@@ -18,6 +18,10 @@
 
 set -o errexit
 
+
+#
+# Initialization.
+#
 BASE_DIR="`dirname "$( readlink -e "$0"; )";`/.."
 . "$BASE_DIR/conf/setenv.sh"
 
@@ -25,9 +29,43 @@ SIS_DATA="${SIS_DATA:-$BASE_DIR/data}"
 export SIS_DATA
 unset  SIS_HOME
 
+
+#
+# Check requirements. If no path to FX is specified,
+# try the location used by some package managers.
+#
+MIN_FX_VERSION=20
+if [ -z "$PATH_TO_FX" ]
+then
+    PATH_TO_FX=/usr/lib/jvm/openjfx
+fi
+
+
+#
+# Check for a sentinel OpenJFX file and its version number.
+# If too old, we will process as if no OpenJFX is installed.
+#
+if [ -r $PATH_TO_FX/javafx.controls.jar ]
+then
+    FX_VERSION=`java --module-path=$PATH_TO_FX --describe-module=javafx.controls | grep --only-matching --max-count=1 "[0-9]\+" | head --lines=1`
+    if [ $FX_VERSION -lt $MIN_FX_VERSION ]
+    then
+        echo "Found OpenJFX $FX_VERSION in $PATH_TO_FX but requires OpenJFX $MIN_FX_VERSION."
+        unset PATH_TO_FX
+    else
+        export PATH_TO_FX
+    fi
+else
+    unset PATH_TO_FX
+fi
+
+
+#
+# If no suitable OpenJFX version has been found, start the installation wizard.
+#
 if [ -z "$PATH_TO_FX" ]
 then
-    java --class-path "$BASE_DIR/lib/*" org.apache.sis.gui.setup.FXFinder $BASE_DIR/conf/setenv.sh
+    java --class-path "$BASE_DIR/lib/app/org.apache.sis.gui.jar" org.apache.sis.gui.setup.FXFinder $BASE_DIR/conf/setenv.sh
     if [ $? -ne 0 ]
     then
         exit
@@ -35,7 +73,10 @@ then
     . "$BASE_DIR/conf/setenv.sh"
 fi
 
+
+#
 # Execute SIS with any optional JAR that the user may put in the `lib` directory.
+#
 java -splash:"$BASE_DIR/lib/logo.jpg" \
      --module-path "$PATH_TO_FX:$BASE_DIR/lib:$BASE_DIR/lib/app/org.apache.sis.gui.jar" \
      -Djava.util.logging.config.class="org.apache.sis.util.logging.Initializer" \
diff --git a/optional/src/org.apache.sis.gui/bundle/bin/sisfx.bat b/optional/src/org.apache.sis.gui/bundle/bin/sisfx.bat
index 1517a2b985..eaeca53264 100644
--- a/optional/src/org.apache.sis.gui/bundle/bin/sisfx.bat
+++ b/optional/src/org.apache.sis.gui/bundle/bin/sisfx.bat
@@ -21,7 +21,7 @@ CALL "%BASE_DIR%\conf\setenv.bat"
 SET SIS_DATA=%BASE_DIR%\data
 
 IF "%PATH_TO_FX%"=="" (
-    java --class-path "%BASE_DIR%\lib\*" org.apache.sis.gui.setup.FXFinder "%BASE_DIR%\conf\setenv.bat"
+    java --class-path "%BASE_DIR%\lib\app\org.apache.sis.gui.jar" org.apache.sis.gui.setup.FXFinder "%BASE_DIR%\conf\setenv.bat"
     IF %ERRORLEVEL% GEQ 1 EXIT /B 1
     CALL "%BASE_DIR%\conf\setenv.bat"
 )
diff --git a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/setup/Wizard.java b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/setup/Wizard.java
index 77b8d40d94..bd7312d744 100644
--- a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/setup/Wizard.java
+++ b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/setup/Wizard.java
@@ -385,7 +385,7 @@ final class Wizard extends FileFilter implements ActionListener, PropertyChangeL
      * @return the added button.
      */
     private JButton createButton(final Box addTo, final String label) {
-        JButton button = new JButton(label);
+        var button = new JButton(label);
         button.setActionCommand(label);
         button.addActionListener(this);
         addTo.add(button);
@@ -533,7 +533,7 @@ final class Wizard extends FileFilter implements ActionListener, PropertyChangeL
      * file or cancels.
      */
     private void showDirectoryChooser() {
-        final JFileChooser fd = new JFileChooser(javafxFinder.getDirectory());
+        final var fd = new JFileChooser(javafxFinder.getDirectory());
         fd.addChoosableFileFilter(this);
         fd.setFileFilter(this);
         fd.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);


(sis) 01/02: Avoid broken rendering of non-ASCII characters when downloading EPSG data from JShell.

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 c8e8207f1fb00dc6fafa1415a13c9f1118d9e9b4
Author: Martin Desruisseaux <ma...@geomatys.com>
AuthorDate: Mon Dec 4 14:56:25 2023 +0100

    Avoid broken rendering of non-ASCII characters when downloading EPSG data from JShell.
---
 .../apache/sis/console/ResourcesDownloader.java    | 42 ++++++++++++++++++----
 1 file changed, 36 insertions(+), 6 deletions(-)

diff --git a/endorsed/src/org.apache.sis.console/main/org/apache/sis/console/ResourcesDownloader.java b/endorsed/src/org.apache.sis.console/main/org/apache/sis/console/ResourcesDownloader.java
index 9ccedb690f..f33658b8f1 100644
--- a/endorsed/src/org.apache.sis.console/main/org/apache/sis/console/ResourcesDownloader.java
+++ b/endorsed/src/org.apache.sis.console/main/org/apache/sis/console/ResourcesDownloader.java
@@ -22,6 +22,7 @@ import java.util.HashMap;
 import java.util.Locale;
 import java.util.ResourceBundle;
 import java.io.Console;
+import java.io.PrintWriter;
 import org.apache.sis.util.internal.X364;
 import org.apache.sis.system.Fallback;
 import org.apache.sis.setup.OptionalInstallations;
@@ -37,7 +38,7 @@ import org.apache.sis.setup.OptionalInstallations;
  * </ul>
  *
  * @author  Martin Desruisseaux (Geomatys)
- * @version 1.1
+ * @version 1.5
  * @since   0.7
  */
 @Fallback
@@ -47,6 +48,12 @@ public class ResourcesDownloader extends OptionalInstallations {
      */
     private final Console console;
 
+    /**
+     * Where to write. It should be {@code console.writer()},
+     * but the latter seems partially broken when used from JShell.
+     */
+    private final PrintWriter out;
+
     /**
      * The locale to use for text display.
      */
@@ -66,6 +73,7 @@ public class ResourcesDownloader extends OptionalInstallations {
     /**
      * Creates a new installation scripts provider.
      */
+    @SuppressWarnings("UseOfSystemOutOrSystemErr")
     public ResourcesDownloader() {
         super("text/plain");
         final CommandRunner command = CommandRunner.instance.get();
@@ -77,6 +85,7 @@ public class ResourcesDownloader extends OptionalInstallations {
             colors = false;
         }
         console = System.console();
+        out = CommandRunner.writer(console, System.out);
     }
 
     /**
@@ -107,6 +116,10 @@ public class ResourcesDownloader extends OptionalInstallations {
      * 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.
+     *
+     * @param  authority  "EPSG".
+     * @param  license    the license, or {@code null} for asking if the user wants to download the data.
+     * @return whether user accepted.
      */
     @Override
     protected boolean askUserAgreement(final String authority, final String license) {
@@ -131,18 +144,21 @@ public class ResourcesDownloader extends OptionalInstallations {
         /*
          * Show the question.
          */
+        final String lineSeparator = System.lineSeparator();
         final String prompt, action;
         if (license == null) {
             prompt = "download";
             action = "downloading";
-            console.format(resources.getString("install"), textColor, getSpaceRequirement(authority),
+            format(resources.getString("install"), textColor, getSpaceRequirement(authority),
                            linkColor, destinationDirectory, linkOff, resetColor);
         } else {
             prompt = "accept";
             action = "installing";
-            console.format("%n").writer().write(license);
-            console.format("%n");
+            out.write(lineSeparator);
+            out.write(license);
+            out.write(lineSeparator);
         }
+        out.flush();
         /*
          * Ask user agreement.
          */
@@ -151,10 +167,24 @@ public class ResourcesDownloader extends OptionalInstallations {
             answer = answers.get(console.readLine(resources.getString(prompt), textColor, resetColor).toLowerCase(getLocale()));
         } while (answer == null);
         if (answer) {
-            console.format(resources.getString(action), actionColor, resetColor);
+            format(resources.getString(action), actionColor, resetColor);
         } else {
-            console.format("%n");
+            out.write(lineSeparator);
         }
         return answer;
     }
+
+    /**
+     * Writes a formatted output to the console.
+     *
+     * @param pattern  pattern to write.
+     * @param args  arguments referenced by the pattern.
+     */
+    private void format(final String pattern, final Object... args) {
+        if (console.writer() == out) {
+            console.format(pattern, args);
+        } else {
+            out.format(pattern, args);
+        }
+    }
 }