sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject [sis] branch geoapi-4.0 updated: Rename MetadataOverview as MetadataSummary and put those metadata in a "summary" tab. Move also the world map in the "metadata" package; it was forgotten in previous commit and is necessary for avoiding a NullPointerException.
Date Mon, 04 Nov 2019 09:22:07 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


The following commit(s) were added to refs/heads/geoapi-4.0 by this push:
     new 3637132  Rename MetadataOverview as MetadataSummary and put those metadata in a "summary"
tab. Move also the world map in the "metadata" package; it was forgotten in previous commit
and is necessary for avoiding a NullPointerException.
3637132 is described below

commit 363713270d46d44937d983b38d4a6e29acff5fe2
Author: Martin Desruisseaux <martin.desruisseaux@geomatys.com>
AuthorDate: Mon Nov 4 10:20:20 2019 +0100

    Rename MetadataOverview as MetadataSummary and put those metadata in a "summary" tab.
    Move also the world map in the "metadata" package; it was forgotten in previous commit
    and is necessary for avoiding a NullPointerException.
---
 .../apache/sis/gui/dataset/ResourceExplorer.java   |  17 +++++++++++----
 .../org/apache/sis/gui/dataset/ResourceTree.java   |   2 +-
 .../sis/gui/metadata/IdentificationInfo.java       |   9 +++++---
 ...{MetadataOverview.java => MetadataSummary.java} |  24 +++++++++++----------
 .../sis/gui/metadata/RepresentationInfo.java       |   2 +-
 .../java/org/apache/sis/gui/metadata/Section.java  |   4 ++--
 .../org/apache/sis/internal/gui/Resources.java     |   5 +++++
 .../apache/sis/internal/gui/Resources.properties   |   1 +
 .../sis/internal/gui/Resources_fr.properties       |   1 +
 .../gui/{dataset => metadata}/WorldMap360x180.png  | Bin
 10 files changed, 43 insertions(+), 22 deletions(-)

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 5fb9693..0aac24b 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
@@ -21,9 +21,12 @@ import java.util.Collection;
 import javafx.collections.ListChangeListener;
 import javafx.scene.layout.Region;
 import javafx.scene.control.SplitPane;
+import javafx.scene.control.Tab;
+import javafx.scene.control.TabPane;
 import javafx.scene.control.TreeItem;
 import org.apache.sis.storage.Resource;
-import org.apache.sis.gui.metadata.MetadataOverview;
+import org.apache.sis.gui.metadata.MetadataSummary;
+import org.apache.sis.internal.gui.Resources;
 
 
 /**
@@ -44,7 +47,7 @@ public class ResourceExplorer {
     /**
      * The widget showing metadata about a selected resource.
      */
-    private final MetadataOverview metadata;
+    private final MetadataSummary metadata;
 
     /**
      * The control that put everything together.
@@ -57,9 +60,15 @@ public class ResourceExplorer {
      */
     public ResourceExplorer() {
         resources = new ResourceTree();
-        metadata  = new MetadataOverview(resources.getLocale(), Locale.getDefault(Locale.Category.FORMAT));
+        metadata  = new MetadataSummary(resources.getLocale(), Locale.getDefault(Locale.Category.FORMAT));
         pane      = new SplitPane();
-        pane.getItems().setAll(resources, metadata.getView());
+
+        final Tab mdTab = new Tab(resources.localized.getString(Resources.Keys.Summary),
metadata.getView());
+        final TabPane tabs = new TabPane(mdTab);
+        tabs.setTabClosingPolicy(TabPane.TabClosingPolicy.UNAVAILABLE);
+        tabs.setTabDragPolicy(TabPane.TabDragPolicy.REORDER);
+
+        pane.getItems().setAll(resources, tabs);
         resources.getSelectionModel().getSelectedItems().addListener(this::selectResource);
         SplitPane.setResizableWithParent(resources, Boolean.FALSE);
         SplitPane.setResizableWithParent(metadata.getView(), Boolean.TRUE);
diff --git a/application/sis-javafx/src/main/java/org/apache/sis/gui/dataset/ResourceTree.java
b/application/sis-javafx/src/main/java/org/apache/sis/gui/dataset/ResourceTree.java
index b75dc1b..6fc59bb 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/gui/dataset/ResourceTree.java
+++ b/application/sis-javafx/src/main/java/org/apache/sis/gui/dataset/ResourceTree.java
@@ -85,7 +85,7 @@ public class ResourceTree extends TreeView<Resource> {
      * The resources for localized strings. Stored because needed often
      * (when loading data, when building a contextual menu, etc.).
      */
-    private final Resources localized;
+    final Resources localized;
 
     /**
      * Creates a new tree of resources with initially no resource to show.
diff --git a/application/sis-javafx/src/main/java/org/apache/sis/gui/metadata/IdentificationInfo.java
b/application/sis-javafx/src/main/java/org/apache/sis/gui/metadata/IdentificationInfo.java
index cab00ab..94ffee3 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/gui/metadata/IdentificationInfo.java
+++ b/application/sis-javafx/src/main/java/org/apache/sis/gui/metadata/IdentificationInfo.java
@@ -42,6 +42,7 @@ import org.apache.sis.internal.gui.Resources;
 import org.apache.sis.internal.referencing.Formulas;
 import org.apache.sis.measure.Latitude;
 import org.apache.sis.measure.Longitude;
+import org.apache.sis.util.CharSequences;
 import org.apache.sis.util.Workaround;
 import org.apache.sis.util.resources.Vocabulary;
 
@@ -85,10 +86,10 @@ final class IdentificationInfo extends Section<Identification> {
     /**
      * Creates an initially empty view for identification information.
      */
-    IdentificationInfo(final MetadataOverview owner) {
+    IdentificationInfo(final MetadataSummary owner) {
         super(owner);
         title = new Label();
-        title.setFont(Font.font(null, FontWeight.BOLD, 14));
+        title.setFont(Font.font(null, FontWeight.BOLD, 15));
         add(title, 0, 0, NUM_CHILD_PER_LINE, 1);
 
         extentOnMap = new Canvas();                     // Size of (0,0) by default.
@@ -152,6 +153,8 @@ final class IdentificationInfo extends Section<Identification> {
         }
         if (text == null) {
             text = vocabulary(Vocabulary.Keys.Untitled);
+        } else if (CharSequences.isUnicodeIdentifier(text)) {
+            text = CharSequences.camelCaseToSentence(text).toString();
         }
         title.setText(text);
         /*
@@ -302,7 +305,7 @@ final class IdentificationInfo extends Section<Identification> {
              * the rectangle in two parts because of anti-meridian crossing.
              */
             if (isWorldMapEmpty()) {
-                final Image image = owner.getWorldMap();
+                final Image image = MetadataSummary.getWorldMap();
                 if (image == null) {
                     return false;                   // Failed to load the image.
                 }
diff --git a/application/sis-javafx/src/main/java/org/apache/sis/gui/metadata/MetadataOverview.java
b/application/sis-javafx/src/main/java/org/apache/sis/gui/metadata/MetadataSummary.java
similarity index 92%
rename from application/sis-javafx/src/main/java/org/apache/sis/gui/metadata/MetadataOverview.java
rename to application/sis-javafx/src/main/java/org/apache/sis/gui/metadata/MetadataSummary.java
index b2db733..b0ac119 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/gui/metadata/MetadataOverview.java
+++ b/application/sis-javafx/src/main/java/org/apache/sis/gui/metadata/MetadataSummary.java
@@ -55,7 +55,7 @@ import org.apache.sis.util.logging.Logging;
  * @since   1.1
  * @module
  */
-public class MetadataOverview {
+public class MetadataSummary {
     /**
      * Titles panes for different metadata sections (identification info, spatial information,
<i>etc</i>).
      * This is similar to {@link javafx.scene.control.Accordion} except that we allow an
arbitrary amount
@@ -93,15 +93,15 @@ public class MetadataOverview {
      *
      * @see #getWorldMap()
      */
-    private Image worldMap;
+    private static Image worldMap;
 
     /**
      * Whether we already tried to load {@link #worldMap}.
      */
-    private boolean worldMapLoaded;
+    private static boolean worldMapLoaded;
 
     /**
-     * If this {@link MetadataOverview} is loading metadata, the worker doing this task.
+     * If this {@link MetadataSummary} is loading metadata, the worker doing this task.
      * Otherwise {@code null}. This is used for cancelling the currently running loading
      * process if {@link #setMetadata(Resource)} is invoked again before completion.
      */
@@ -128,7 +128,7 @@ public class MetadataOverview {
      * @param  dataLocale  the locale for formatting numbers and dates.
      *                     This is often the same than {@code textLocale}.
      */
-    public MetadataOverview(final Locale textLocale, final Locale dataLocale) {
+    public MetadataSummary(final Locale textLocale, final Locale dataLocale) {
         localized    = Resources.forLocale(textLocale);
         formatLocale = dataLocale;
         information  = new TitledPane[] {
@@ -140,7 +140,7 @@ public class MetadataOverview {
     }
 
     /**
-     * Returns the region containing the visual components managed by this {@code MetadataOverview}.
+     * Returns the region containing the visual components managed by this {@code MetadataSummary}.
      * The subclass is implementation dependent and may change in any future version.
      *
      * @return the region to show.
@@ -248,21 +248,23 @@ public class MetadataOverview {
     }
 
     /**
-     * Returns an image of size 360×180 pixels showing a map of the world,
-     * or {@code null} if we failed to load the image.
+     * Returns an image of size 360×180 pixels showing a map of the world, or {@code null}
+     * if we failed to load the image. This method shall be invoked in JavaFX thread;
+     * the map is small enough that loading it in that thread should not be an issue.
      */
-    final Image getWorldMap() {
+    static Image getWorldMap() {
+        assert Platform.isFxApplicationThread();
         if (!worldMapLoaded) {
             worldMapLoaded = true;                  // Set now for avoiding retries in case
of failure.
             Exception error;
-            try (InputStream in = MetadataOverview.class.getResourceAsStream("WorldMap360x180.png"))
{
+            try (InputStream in = MetadataSummary.class.getResourceAsStream("WorldMap360x180.png"))
{
                 worldMap = new Image(in);
                 error = worldMap.getException();
             } catch (IOException e) {
                 error = e;
             }
             if (error != null) {
-                Logging.unexpectedException(Logging.getLogger(Modules.APPLICATION), MetadataOverview.class,
"getWorldMap", error);
+                Logging.unexpectedException(Logging.getLogger(Modules.APPLICATION), MetadataSummary.class,
"getWorldMap", error);
             }
         }
         return worldMap;
diff --git a/application/sis-javafx/src/main/java/org/apache/sis/gui/metadata/RepresentationInfo.java
b/application/sis-javafx/src/main/java/org/apache/sis/gui/metadata/RepresentationInfo.java
index bcd892d..3bb134c 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/gui/metadata/RepresentationInfo.java
+++ b/application/sis-javafx/src/main/java/org/apache/sis/gui/metadata/RepresentationInfo.java
@@ -48,7 +48,7 @@ final class RepresentationInfo extends Section<SpatialRepresentation>
{
     /**
      * Creates an initially empty view for spatial representation information.
      */
-    RepresentationInfo(final MetadataOverview owner) {
+    RepresentationInfo(final MetadataSummary owner) {
         super(owner);
         finished();
     }
diff --git a/application/sis-javafx/src/main/java/org/apache/sis/gui/metadata/Section.java
b/application/sis-javafx/src/main/java/org/apache/sis/gui/metadata/Section.java
index dd80c9e..277b0c4 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/gui/metadata/Section.java
+++ b/application/sis-javafx/src/main/java/org/apache/sis/gui/metadata/Section.java
@@ -63,7 +63,7 @@ abstract class Section<T> extends GridPane implements EventHandler<ActionEvent>
      * The pane which contains this section. Used for fetching information like number format
      * or localization resources.
      */
-    final MetadataOverview owner;
+    final MetadataSummary owner;
 
     /**
      * Number of children per line. This is not necessarily the number of columns in the
grid pane
@@ -110,7 +110,7 @@ abstract class Section<T> extends GridPane implements EventHandler<ActionEvent>
     /**
      * Creates a new section.
      */
-    Section(final MetadataOverview owner) {
+    Section(final MetadataSummary owner) {
         this.owner = owner;
         pageGroup  = new ToggleGroup();
         pagination = new TilePane(Orientation.VERTICAL);
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 80c905c..59cbb10 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
@@ -186,6 +186,11 @@ public final class Resources extends IndexedResourceBundle {
         public static final short SpatialRepresentation = 24;
 
         /**
+         * Summary
+         */
+        public static final short Summary = 29;
+
+        /**
          * Topic category:
          */
         public static final short TopicCategory = 25;
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 4f21493..eeb6167 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
@@ -46,5 +46,6 @@ Purpose                = Purpose:
 ReferenceSystem        = Reference system:
 ResourceIdentification = Resource identification
 SpatialRepresentation  = Spatial representation
+Summary                = Summary
 TopicCategory          = Topic category:
 TypeOfResource         = Type of resource:
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 18aaea9..2b4225a 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
@@ -51,5 +51,6 @@ Purpose                = Objectif\u00a0:
 ReferenceSystem        = Syst\u00e8me de r\u00e9f\u00e9rence\u00a0:
 ResourceIdentification = Identification de la ressource
 SpatialRepresentation  = Repr\u00e9sentation spatiale
+Summary                = R\u00e9sum\u00e9
 TopicCategory          = Cat\u00e9gorie th\u00e9matique\u00a0:
 TypeOfResource         = Type de ressource\u00a0:
diff --git a/application/sis-javafx/src/main/resources/org/apache/sis/gui/dataset/WorldMap360x180.png
b/application/sis-javafx/src/main/resources/org/apache/sis/gui/metadata/WorldMap360x180.png
similarity index 100%
rename from application/sis-javafx/src/main/resources/org/apache/sis/gui/dataset/WorldMap360x180.png
rename to application/sis-javafx/src/main/resources/org/apache/sis/gui/metadata/WorldMap360x180.png


Mime
View raw message