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 8043e5e Define FeatureTable content as a property and add warning in
documentation about what can be modified.
8043e5e is described below
commit 8043e5ec704872caae69fe9bd569551f835735b0
Author: Martin Desruisseaux <[email protected]>
AuthorDate: Sat Nov 9 15:27:42 2019 +0100
Define FeatureTable content as a property and add warning in documentation
about what can be modified.
---
.../org/apache/sis/gui/dataset/FeatureTable.java | 52 ++++++++++++++++++++--
.../org/apache/sis/gui/dataset/ResourceTree.java | 10 +++--
.../org/apache/sis/gui/metadata/MetadataTree.java | 10 ++++-
3 files changed, 64 insertions(+), 8 deletions(-)
diff --git
a/application/sis-javafx/src/main/java/org/apache/sis/gui/dataset/FeatureTable.java
b/application/sis-javafx/src/main/java/org/apache/sis/gui/dataset/FeatureTable.java
index 309427c..4ddb483 100644
---
a/application/sis-javafx/src/main/java/org/apache/sis/gui/dataset/FeatureTable.java
+++
b/application/sis-javafx/src/main/java/org/apache/sis/gui/dataset/FeatureTable.java
@@ -26,7 +26,10 @@ import javafx.scene.control.TableView;
import javafx.scene.control.TableCell;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.Region;
+import javafx.beans.DefaultProperty;
import javafx.beans.property.ReadOnlyObjectWrapper;
+import javafx.beans.property.SimpleObjectProperty;
+import javafx.beans.property.ObjectProperty;
import javafx.beans.value.ObservableValue;
import javafx.collections.ObservableList;
import javafx.geometry.Pos;
@@ -54,6 +57,13 @@ import org.apache.sis.internal.gui.ExceptionReporter;
* <p>If this view is removed from scene graph, then {@link #interrupt()}
should be called
* for stopping any loading process that may be under progress.</p>
*
+ * <h2>Limitations</h2>
+ * <ul>
+ * <li>The {@link #itemsProperty() itemsProperty} should be considered
read-only.
+ * For changing content, use the {@link #featuresProperty} instead.</li>
+ * <li>The list returned by {@link #getItems()} should be considered
read-only.</li>
+ * </ul>
+ *
* @todo This class does not yet handle {@link FeatureAssociationRole}. We
could handle them with
* {@link javafx.scene.control.SplitPane} with the main feature table in
the upper part and
* the feature table of selected cell in the bottom part. Bottom part
could put tables in a
@@ -67,6 +77,7 @@ import org.apache.sis.internal.gui.ExceptionReporter;
* @since 1.1
* @module
*/
+@DefaultProperty("features")
public class FeatureTable extends TableView<Feature> {
/**
* The locale to use for texts.
@@ -88,11 +99,23 @@ public class FeatureTable extends TableView<Feature> {
private FeatureType featureType;
/**
+ * The data shown in this table. Note that setting this property to a
non-null value
+ * does not modify the table content immediately. Instead, a background
process will
+ * load the feature instances.
+ *
+ * @see #getFeatures()
+ * @see #setFeatures(FeatureSet)
+ */
+ public final ObjectProperty<FeatureSet> featuresProperty;
+
+ /**
* Creates an initially empty table.
*/
public FeatureTable() {
- textLocale = Locale.getDefault(Locale.Category.DISPLAY);
- dataLocale = Locale.getDefault(Locale.Category.FORMAT);
+ textLocale = Locale.getDefault(Locale.Category.DISPLAY);
+ dataLocale = Locale.getDefault(Locale.Category.FORMAT);
+ featuresProperty = new SimpleObjectProperty<>(this, "features");
+ featuresProperty.addListener(this::startFeaturesLoading);
setColumnResizePolicy(CONSTRAINED_RESIZE_POLICY);
setTableMenuButtonVisible(true);
setItems(new FeatureList());
@@ -125,6 +148,17 @@ public class FeatureTable extends TableView<Feature> {
}
/**
+ * Returns the source of features for this table.
+ *
+ * @return the features shown in this table, or {@code null} if none.
+ *
+ * @see #featuresProperty
+ */
+ public final FeatureSet getFeatures() {
+ return featuresProperty.get();
+ }
+
+ /**
* Sets the features to show in this table. This method loads an arbitrary
amount of
* features in a background thread. It does not load all features if the
feature set
* is large, unless the user scroll down.
@@ -136,8 +170,20 @@ public class FeatureTable extends TableView<Feature> {
* The modifications will appear at an undetermined amount of time
later.</p>
*
* @param features the features to show in this table, or {@code null}
if none.
+ *
+ * @see #featuresProperty
+ */
+ public final void setFeatures(final FeatureSet features) {
+ featuresProperty.set(features);
+ }
+
+ /**
+ * Invoked (indirectly) when the user sets a new {@link FeatureSet}.
+ * See {@link #setFeatures(FeatureSet)} for method description.
*/
- public void setFeatures(final FeatureSet features) {
+ private void startFeaturesLoading(final ObservableValue<? extends
FeatureSet> property,
+ final FeatureSet old, final FeatureSet
features)
+ {
final FeatureList items = getFeatureList();
if (!items.startFeaturesLoading(this, features)) {
featureType = null;
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 8a03e46..72aaeee 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
@@ -71,9 +71,13 @@ import org.apache.sis.internal.util.Strings;
* of "drag and drop" events. Users can drop files or URLs for opening data
files.</p>
*
* <h2>Limitations</h2>
- * If the user selects "close" in the contextual menu, the resource if closed
(if it is an instance
- * of {@link DataStore}). There is not yet a mechanism for keeping it open if
the resource is shared
- * by another {@link ResourceTree} instance.
+ * <ul>
+ * <li>The {@link #rootProperty() rootProperty} should be considered
read-only.
+ * For changing content, use the {@link #setResource(Resource)}
instead.</li>
+ * <li>If the user selects "close" in the contextual menu, the resource is
closed (if it is an instance
+ * of {@link DataStore}). There is not yet a mechanism for keeping it
open if the resource is shared
+ * by another {@link ResourceTree} instance.</li>
+ * </ul>
*
* @todo Listen to warnings and save log records in a separated collection for
each data store.
* Add to the contextual menu an option for viewing the log records of
selected data store.
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 e925dc3..e923015 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
@@ -54,8 +54,14 @@ import org.apache.sis.util.iso.Types;
* <li>{@link TableColumn#VALUE} — the property value typically as a string,
number or date.</li>
* </ul>
*
- * <p>While this view is designed mostly for metadata, it can actually be used
- * for other kinds of data provided by the {@link TreeTable} interface.</p>
+ * While this view is designed mostly for metadata, it can actually be used
+ * for other kinds of data provided by the {@link TreeTable} interface.
+ *
+ * <h2>Limitations</h2>
+ * <ul>
+ * <li>The {@link #rootProperty() rootProperty} should be considered
read-only.
+ * For changing content, use the {@link #contentProperty} instead.</li>
+ * </ul>
*
* @todo Add contextual menu for saving or copying in clipboard the XML
starting from the selected node.
* Add contextual menu for showing a node in the summary pane (we would
store in memory the path,