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 2024/09/30 16:21:04 UTC
(sis) 03/04: Better reporting of the exception when metadata are shown in the JavaFX application.
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 732e232d70c2b41af16a35d8721860ef2c3c7871
Author: Martin Desruisseaux <ma...@geomatys.com>
AuthorDate: Mon Sep 30 17:16:29 2024 +0200
Better reporting of the exception when metadata are shown in the JavaFX application.
---
.../main/org/apache/sis/gui/map/MapCanvas.java | 2 +-
.../sis/gui/metadata/IdentificationInfo.java | 26 +++++++++++++---------
.../org/apache/sis/gui/metadata/MetadataTree.java | 12 +++-------
3 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/map/MapCanvas.java b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/map/MapCanvas.java
index d5f6e20e5c..4174e8036b 100644
--- a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/map/MapCanvas.java
+++ b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/map/MapCanvas.java
@@ -1236,7 +1236,7 @@ public abstract class MapCanvas extends PlanarCanvas {
}
}
if (objectiveCRS == null) {
- if (init.isDefined(GridGeometry.CRS)) {
+ if (init != null && init.isDefined(GridGeometry.CRS)) {
objectiveCRS = init.getCoordinateReferenceSystem();
} else {
objectiveCRS = extent.toEnvelope(crsToDisplay.inverse()).getCoordinateReferenceSystem();
diff --git a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/metadata/IdentificationInfo.java b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/metadata/IdentificationInfo.java
index ddced309c6..e19547f7da 100644
--- a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/metadata/IdentificationInfo.java
+++ b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/metadata/IdentificationInfo.java
@@ -56,6 +56,7 @@ import org.apache.sis.storage.Resource;
import org.apache.sis.storage.DataStoreException;
import org.apache.sis.util.CharSequences;
import org.apache.sis.util.Workaround;
+import org.apache.sis.util.collection.BackingStoreException;
import org.apache.sis.util.resources.Vocabulary;
import static org.apache.sis.util.privy.CollectionsExt.nonNull;
@@ -200,20 +201,25 @@ final class IdentificationInfo extends Section<Identification> {
BackgroundThreads.execute(aggregateWalker = new Task<Set<GeographicBoundingBox>>() {
/** Invoked in a background thread for fetching bounding boxes. */
@Override protected Set<GeographicBoundingBox> call() throws DataStoreException {
- final Set<GeographicBoundingBox> boxes = new LinkedHashSet<>();
- for (final Resource child : resource.components()) {
- final Metadata metadata = child.getMetadata();
- if (isCancelled()) break;
- if (metadata != null) {
- for (final Identification id : nonNull(metadata.getIdentificationInfo())) {
- if (id != null) {
- for (final Extent extent : id.getExtents()) {
- final GeographicBoundingBox b = Extents.getGeographicBoundingBox(extent);
- if (b != null) boxes.add(b);
+ final var boxes = new LinkedHashSet<GeographicBoundingBox>();
+ try {
+ for (final Resource child : resource.components()) {
+ final Metadata metadata = child.getMetadata();
+ if (isCancelled()) break;
+ if (metadata != null) {
+ for (final Identification id : nonNull(metadata.getIdentificationInfo())) {
+ if (id != null) {
+ for (final Extent extent : id.getExtents()) {
+ final GeographicBoundingBox b = Extents.getGeographicBoundingBox(extent);
+ if (b != null) boxes.add(b);
+ }
}
}
}
}
+ } catch (BackingStoreException e) {
+ // This exception can be thrown by the iterator.
+ throw e.unwrapOrRethrow(DataStoreException.class);
}
return boxes;
}
diff --git a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/metadata/MetadataTree.java b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/metadata/MetadataTree.java
index 8da1947388..badcf6e190 100644
--- a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/metadata/MetadataTree.java
+++ b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/metadata/MetadataTree.java
@@ -18,8 +18,6 @@ package org.apache.sis.gui.metadata;
import java.util.Locale;
import java.util.List;
-import java.util.ArrayList;
-import java.util.Collection;
import java.io.IOException;
import javafx.util.Callback;
import javafx.beans.DefaultProperty;
@@ -306,14 +304,10 @@ check: if (data != null) {
*/
@Override
public ObservableList<TreeItem<TreeTable.Node>> getChildren() {
- final ObservableList<TreeItem<TreeTable.Node>> children = super.getChildren();
+ final var children = super.getChildren();
if (children.isEmpty()) {
- final Collection<TreeTable.Node> data = getValue().getChildren();
- final List<Item> wrappers = new ArrayList<>(data.size());
- for (final TreeTable.Node child : data) {
- wrappers.add(new Item(child));
- }
- children.setAll(wrappers); // Fire a single event instead of multiple `add`.
+ // Fire a single event instead of multiple `add`.
+ children.setAll(getValue().getChildren().stream().map(Item::new).toList());
}
return children;
}