sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject [sis] 03/04: Provide information about system configuration.
Date Tue, 07 Jul 2020 17:47:48 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 2b2a1f2039eb8c5adf91249266b1929d3cf0dab4
Author: Martin Desruisseaux <martin.desruisseaux@geomatys.com>
AuthorDate: Tue Jul 7 17:49:26 2020 +0200

    Provide information about system configuration.
---
 .../main/java/org/apache/sis/gui/AboutDialog.java  | 71 ++++++++++++++++++++++
 .../main/java/org/apache/sis/gui/DataViewer.java   | 10 ++-
 .../org/apache/sis/gui/metadata/MetadataTree.java  | 48 +++++++++++----
 .../sis/gui/metadata/StandardMetadataTree.java     |  4 +-
 .../org/apache/sis/internal/gui/Resources.java     | 15 +++++
 .../apache/sis/internal/gui/Resources.properties   |  3 +
 .../sis/internal/gui/Resources_fr.properties       |  3 +
 ide-project/NetBeans/nbproject/project.properties  |  2 +-
 8 files changed, 138 insertions(+), 18 deletions(-)

diff --git a/application/sis-javafx/src/main/java/org/apache/sis/gui/AboutDialog.java b/application/sis-javafx/src/main/java/org/apache/sis/gui/AboutDialog.java
new file mode 100644
index 0000000..3fc003a
--- /dev/null
+++ b/application/sis-javafx/src/main/java/org/apache/sis/gui/AboutDialog.java
@@ -0,0 +1,71 @@
+/*
+ * 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.gui;
+
+import javafx.geometry.Insets;
+import javafx.scene.control.Alert;
+import javafx.scene.control.DialogPane;
+import javafx.scene.control.Label;
+import org.apache.sis.gui.metadata.MetadataTree;
+import org.apache.sis.internal.gui.Resources;
+import org.apache.sis.util.resources.Vocabulary;
+import org.apache.sis.util.Version;
+import org.apache.sis.setup.About;
+
+
+/**
+ * Shows the "About" dialog.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @version 1.1
+ * @since   1.1
+ * @module
+ */
+final class AboutDialog {
+    /**
+     * Do not allow instantiation of this class.
+     */
+    private AboutDialog() {
+    }
+
+    /**
+     * Invoked when the user selects "Help" â–¶ "About" menu.
+     * It provides information about the system configuration.
+     *
+     * Apache SIS is a project of the Apache Software Foundation.
+     */
+    static void show() {
+        final Resources  localized  = Resources.getInstance();
+        final Vocabulary vocabulary = Vocabulary.getResources(localized.getLocale());
+        final Alert alert = new Alert(Alert.AlertType.INFORMATION);
+        alert.setTitle(localized.getString(Resources.Keys.About));
+        alert.setHeaderText(vocabulary.getString(Vocabulary.Keys.Version_2,
+                "Apache Spatial Information System", Version.SIS.toString()));
+
+        final DialogPane pane = alert.getDialogPane();
+        final Label content = new Label("Apache SIS is a project of the Apache Software Foundation.");
+        content.setPadding(new Insets(18));
+        pane.setContent(content);
+
+        final MetadataTree tree = new MetadataTree();
+        tree.contentProperty.set(About.configuration());
+        tree.setPadding(Insets.EMPTY);
+        pane.setExpandableContent(tree);
+        pane.setPrefWidth(650);
+        alert.show();
+    }
+}
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 78e685f..ba5aca1 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
@@ -129,14 +129,20 @@ public class DataViewer extends Application {
             file.getItems().addAll(
                     open = localized.menu(Resources.Keys.Open, (e) -> showOpenFileDialog()),
                     new SeparatorMenuItem(),
-                    localized.menu(Resources.Keys.Exit, (event) -> Platform.exit()));
+                    localized.menu(Resources.Keys.Exit, (e) -> Platform.exit()));
 
             open.setAccelerator(KeyCombination.keyCombination("Shortcut+O"));
         }
+        final Menu help = new Menu(localized.getString(Resources.Keys.Help));
+        {   // For keeping variables locale.
+            help.getItems().addAll(
+                    localized.menu(Resources.Keys.WebSite, (e) -> getHostServices().showDocument("https://sis.apache.org/")),
+                    localized.menu(Resources.Keys.About, (e) -> AboutDialog.show()));
+        }
         final Menu windows = new Menu(localized.getString(Resources.Keys.Windows));
         windows.getItems().add(content.createNewWindowMenu());
         content.setWindowsItems(windows.getItems());
-        menus.getMenus().addAll(file, windows);
+        menus.getMenus().addAll(file, windows, help);
         /*
          * Set the main content and show.
          */
diff --git a/application/sis-javafx/src/main/java/org/apache/sis/gui/metadata/MetadataTree.java
b/application/sis-javafx/src/main/java/org/apache/sis/gui/metadata/MetadataTree.java
index 6bdd23f..2704d01 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/gui/metadata/MetadataTree.java
+++ b/application/sis-javafx/src/main/java/org/apache/sis/gui/metadata/MetadataTree.java
@@ -40,6 +40,7 @@ import org.apache.sis.internal.util.PropertyFormat;
 import org.apache.sis.internal.system.Modules;
 import org.apache.sis.util.collection.TreeTable;
 import org.apache.sis.util.collection.TableColumn;
+import org.apache.sis.util.resources.Vocabulary;
 import org.apache.sis.util.logging.Logging;
 
 
@@ -74,17 +75,23 @@ import org.apache.sis.util.logging.Logging;
 @DefaultProperty("content")
 public class MetadataTree extends TreeTableView<TreeTable.Node> {
     /**
-     * The column for metadata property name.
+     * The column for metadata property name in the view.
      */
     private final TreeTableColumn<TreeTable.Node, String> nameColumn;
 
     /**
-     * The column for metadata property value.
+     * The column for metadata property value in the view.
      * Values are typically {@link InternationalString}, {@link Number} or dates.
      */
     private final TreeTableColumn<TreeTable.Node, Object> valueColumn;
 
     /**
+     * The column for metadata property value in the model.
+     * This is usually {@link TableColumn#VALUE} or {@link TableColumn#VALUE_AS_TEXT}.
+     */
+    TableColumn<?> valueSourceColumn;
+
+    /**
      * The data shown in this tree table. The {@link ObjectProperty#set(Object)} method requires
      * that the given value obey to the constraints documented in {@link #setContent(TreeTable)}.
      *
@@ -98,6 +105,15 @@ public class MetadataTree extends TreeTableView<TreeTable.Node>
{
      * This class verifies the constraints documented in {@link MetadataTree#setContent(TreeTable)}.
      */
     private static final class ContentProperty extends SimpleObjectProperty<TreeTable>
{
+        /**
+         * The columns where to search for values, in preference order.
+         */
+        private static final TableColumn<?>[] VALUES_COLUMNS = {
+            TableColumn.VALUE,
+            TableColumn.VALUE_AS_NUMBER,
+            TableColumn.VALUE_AS_TEXT
+        };
+
         /** Creates a new property. */
         ContentProperty(final MetadataTree bean) {
             super(bean, "content");
@@ -105,11 +121,17 @@ public class MetadataTree extends TreeTableView<TreeTable.Node>
{
 
         /** Invoked when the user wants to set new data. */
         @Override public void set(final TreeTable data) {
-            if (data != null) {
+check:      if (data != null) {
                 final List<TableColumn<?>> columns = data.getColumns();
-                if (!(columns.contains(TableColumn.NAME) && columns.contains(TableColumn.VALUE)))
{
-                    throw new IllegalArgumentException();
+                if (columns.contains(TableColumn.NAME)) {
+                    for (final TableColumn<?> value : VALUES_COLUMNS) {
+                        if (columns.contains(value)) {
+                            ((MetadataTree) getBean()).valueSourceColumn = value;
+                            break check;
+                        }
+                    }
                 }
+                throw new IllegalArgumentException();
             }
             super.set(data);
         }
@@ -145,16 +167,16 @@ public class MetadataTree extends TreeTableView<TreeTable.Node>
{
      */
     @SuppressWarnings("ThisEscapedInObjectConstruction")
     MetadataTree(final MetadataSummary controller, final boolean standard) {
-        final Locale locale;
+        final Vocabulary vocabulary;
         if (controller != null) {
-            locale = controller.vocabulary.getLocale();
+            vocabulary = controller.vocabulary;
         } else {
-            locale = Locale.getDefault(Locale.Category.DISPLAY);
+            vocabulary = Vocabulary.getResources((Locale) null);
         }
-        formatter       = new Formatter(locale);
+        formatter       = new Formatter(vocabulary.getLocale());
         contentProperty = new ContentProperty(this);
-        nameColumn      = new TreeTableColumn<>(TableColumn.NAME .getHeader().toString(locale));
-        valueColumn     = new TreeTableColumn<>(TableColumn.VALUE.getHeader().toString(locale));
+        nameColumn      = new TreeTableColumn<>(vocabulary.getString(Vocabulary.Keys.Property));
+        valueColumn     = new TreeTableColumn<>(vocabulary.getString(Vocabulary.Keys.Value));
         nameColumn .setCellValueFactory(MetadataTree::getPropertyName);
         valueColumn.setCellValueFactory(formatter);
 
@@ -279,7 +301,7 @@ public class MetadataTree extends TreeTableView<TreeTable.Node>
{
      * @param  column   column of the desired value.
      * @return value in the specified column. May be {@code null}.
      */
-    private static <T> T getValue(final CellDataFeatures<TreeTable.Node, ? extends
T> cell, final TableColumn<T> column) {
+    private static <T> T getValue(final CellDataFeatures<TreeTable.Node, ?> cell,
final TableColumn<T> column) {
         final TreeTable.Node node = cell.getValue().getValue();
         return node.getValue(column);
     }
@@ -336,7 +358,7 @@ public class MetadataTree extends TreeTableView<TreeTable.Node>
{
         @Override
         public ObservableValue<Object> call(final CellDataFeatures<TreeTable.Node,
Object> cell) {
             final MetadataTree view = (MetadataTree) cell.getTreeTableView();
-            Object value = getValue(cell, TableColumn.VALUE);
+            Object value = getValue(cell, view.valueSourceColumn);
             if (value instanceof IdentifiedObject) {
                 value = IdentifiedObjects.getDisplayName((IdentifiedObject) value, locale);
             }
diff --git a/application/sis-javafx/src/main/java/org/apache/sis/gui/metadata/StandardMetadataTree.java
b/application/sis-javafx/src/main/java/org/apache/sis/gui/metadata/StandardMetadataTree.java
index 10c90f4..0558e6a 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/gui/metadata/StandardMetadataTree.java
+++ b/application/sis-javafx/src/main/java/org/apache/sis/gui/metadata/StandardMetadataTree.java
@@ -222,12 +222,12 @@ public class StandardMetadataTree extends MetadataTree {
                         } else if (MetadataStandard.ISO_19115.isMetadata(obj.getClass()))
{
                             text = toTree(obj).toString();
                         } else {
-                            final Object value = node.getValue(TableColumn.VALUE);
+                            final Object value = node.getValue(((MetadataTree) getTreeTableView()).valueSourceColumn);
                             if (value == null) return;
                             text = value.toString();
                         }
                     } catch (Exception e) {
-                        final Resources localized = Resources.forLocale(((StandardMetadataTree)
getTreeTableView()).getLocale());
+                        final Resources localized = Resources.forLocale(((MetadataTree) getTreeTableView()).getLocale());
                         ExceptionReporter.show(localized.getString(Resources.Keys.ErrorExportingData),
                                                localized.getString(Resources.Keys.CanNotCreateXML),
e);
                         return;
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 1d1da13..733ef3b 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
@@ -56,6 +56,11 @@ public final class Resources extends IndexedResourceBundle {
         }
 
         /**
+         * About…
+         */
+        public static final short About = 46;
+
+        /**
          * All files
          */
         public static final short AllFiles = 1;
@@ -191,6 +196,11 @@ public final class Resources extends IndexedResourceBundle {
         public static final short GeospatialFiles = 23;
 
         /**
+         * Help
+         */
+        public static final short Help = 47;
+
+        /**
          * Image start
          */
         public static final short ImageStart = 36;
@@ -276,6 +286,11 @@ public final class Resources extends IndexedResourceBundle {
         public static final short Visualize = 34;
 
         /**
+         * Web site
+         */
+        public static final short WebSite = 48;
+
+        /**
          * Windows
          */
         public static final short Windows = 21;
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 5a54e7c..df019ba 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
@@ -20,6 +20,7 @@
 # For resources shared by all modules in the Apache SIS project, see "org.apache.sis.util.resources"
package.
 #
 
+About                  = About\u2026
 AllFiles               = All files
 Along_1                = Along {0}
 AzimuthalEquidistant   = Azimuthal equidistant
@@ -47,6 +48,7 @@ ErrorDataAccess        = Error during data access
 Exit                   = Exit
 FullScreen             = Full screen
 GeospatialFiles        = Geospatial data files
+Help                   = Help
 ImageStart             = Image start
 InconsistencyIn_2      = {0} \u2013 inconsistency in {1}
 Loading                = Loading\u2026
@@ -64,4 +66,5 @@ TabularData            = Tabular data
 TileIndexStart         = Tile index start
 UTM                    = Universal Transverse Mercator
 Visualize              = Visualize
+WebSite                = Web site
 Windows                = Windows
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 4a6add6..b2e0ddf 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
@@ -25,6 +25,7 @@
 #   U+00A0 NO-BREAK SPACE         before  :
 #
 
+About                  = \u00c0 propos de\u2026
 AllFiles               = Tous les fichiers
 Along_1                = Selon {0}
 AzimuthalEquidistant   = Azimutal \u00e9quidistant
@@ -52,6 +53,7 @@ ErrorDataAccess        = Erreur lors de l\u2019acc\u00e8s \u00e0 la donn\u00e9e
 Exit                   = Quitter
 FullScreen             = Plein \u00e9cran
 GeospatialFiles        = Fichiers de donn\u00e9es g\u00e9ospatiales
+Help                   = Aide
 ImageStart             = D\u00e9but de l\u2019image
 InconsistencyIn_2      = {0} \u2013 incoh\u00e9rence dans {1}
 Loading                = Chargement\u2026
@@ -69,4 +71,5 @@ TabularData            = Tableau de valeurs
 TileIndexStart         = D\u00e9but des indices de tuiles
 UTM                    = Transverse universelle de Mercator
 Visualize              = Visualiser
+WebSite                = Site web
 Windows                = Fen\u00eatres
diff --git a/ide-project/NetBeans/nbproject/project.properties b/ide-project/NetBeans/nbproject/project.properties
index 82c5377..e002d4d 100644
--- a/ide-project/NetBeans/nbproject/project.properties
+++ b/ide-project/NetBeans/nbproject/project.properties
@@ -21,7 +21,7 @@
 #
 application.title    = Spatial Information System (SIS)
 application.vendor   = Apache
-application.homepage = http://sis.apache.org/
+application.homepage = https://sis.apache.org/
 application.desc     = Apache SIS is a free software, Java language library for developing
geospatial applications.
 work.dir             = ../workspace
 work.dir.to.root     = ../..


Mime
View raw message