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 26643fc8215f4b5417b066a57a92614b99e65e18
Author: Martin Desruisseaux <martin.desruisse...@geomatys.com>
AuthorDate: Sun Mar 20 20:14:29 2022 +0100

    Slight simplification and more javadoc for windows management.
---
 .../main/java/org/apache/sis/gui/dataset/DataWindow.java    |  8 +++-----
 .../main/java/org/apache/sis/gui/dataset/SelectedData.java  | 11 +++++++----
 .../main/java/org/apache/sis/gui/dataset/WindowManager.java | 13 +++++++------
 3 files changed, 17 insertions(+), 15 deletions(-)

diff --git 
a/application/sis-javafx/src/main/java/org/apache/sis/gui/dataset/DataWindow.java
 
b/application/sis-javafx/src/main/java/org/apache/sis/gui/dataset/DataWindow.java
index d1ca566..4f4b120 100644
--- 
a/application/sis-javafx/src/main/java/org/apache/sis/gui/dataset/DataWindow.java
+++ 
b/application/sis-javafx/src/main/java/org/apache/sis/gui/dataset/DataWindow.java
@@ -16,7 +16,6 @@
  */
 package org.apache.sis.gui.dataset;
 
-import java.util.EventObject;
 import javafx.geometry.Rectangle2D;
 import javafx.stage.Screen;
 import javafx.stage.Stage;
@@ -39,7 +38,7 @@ import org.apache.sis.internal.gui.ToolbarButton;
  * but may be copied in a separated, usually bigger, windows.
  *
  * @author  Martin Desruisseaux (Geomatys)
- * @version 1.1
+ * @version 1.2
  * @since   1.1
  * @module
  */
@@ -56,12 +55,11 @@ final class DataWindow extends Stage {
      * Creates a new window for the given data selected in the explorer or 
determined by the active tab.
      * The new window will be positioned in the screen center but not yet 
shown.
      *
-     * @param  event  the event (e.g. mouse action) requesting a new window, 
or {@code null} if unknown.
      * @param  home   the window containing the main explorer, to be the 
target of "home" button.
      * @param  data   the data selected by user, to show in a new window.
      */
-    DataWindow(final EventObject event, final Stage home, final SelectedData 
data) {
-        final Region content = data.createView(event);
+    DataWindow(final Stage home, final SelectedData data) {
+        final Region content = data.createView();
         /*
          * Build the tools bar. This bar will be hidden in full screen mode. 
Note that above
          * method assumes that the "home" button created below is the first 
one in the toolbar.
diff --git 
a/application/sis-javafx/src/main/java/org/apache/sis/gui/dataset/SelectedData.java
 
b/application/sis-javafx/src/main/java/org/apache/sis/gui/dataset/SelectedData.java
index d69907e..184a89c 100644
--- 
a/application/sis-javafx/src/main/java/org/apache/sis/gui/dataset/SelectedData.java
+++ 
b/application/sis-javafx/src/main/java/org/apache/sis/gui/dataset/SelectedData.java
@@ -16,7 +16,6 @@
  */
 package org.apache.sis.gui.dataset;
 
-import java.util.EventObject;
 import javafx.scene.layout.Region;
 import org.apache.sis.gui.coverage.CoverageExplorer;
 import org.apache.sis.internal.gui.Resources;
@@ -65,6 +64,12 @@ final class SelectedData {
 
     /**
      * Creates a snapshot of selected data.
+     * Only one of {@code features} and {@code coverage} shall be non-null.
+     *
+     * @param  title      a title to use for windows and menu items.
+     * @param  features   control that contains the currently selected data if 
those data are features.
+     * @param  coverage   the request for coverage data.
+     * @param  localized  localized resources, for convenience only.
      */
     SelectedData(final String title, final FeatureTable features, final 
CoverageExplorer coverage, final Resources localized) {
         this.title     = title;
@@ -75,10 +80,8 @@ final class SelectedData {
 
     /**
      * Creates the view for selected data.
-     *
-     * @param  event  the event (e.g. mouse action) requesting a new window, 
or {@code null} if unknown.
      */
-    final Region createView(final EventObject event) {
+    final Region createView() {
         if (features != null) {
             return new FeatureTable(features);
         } else {
diff --git 
a/application/sis-javafx/src/main/java/org/apache/sis/gui/dataset/WindowManager.java
 
b/application/sis-javafx/src/main/java/org/apache/sis/gui/dataset/WindowManager.java
index 47fc08b..f00a78a 100644
--- 
a/application/sis-javafx/src/main/java/org/apache/sis/gui/dataset/WindowManager.java
+++ 
b/application/sis-javafx/src/main/java/org/apache/sis/gui/dataset/WindowManager.java
@@ -21,7 +21,6 @@ import java.util.ArrayList;
 import java.util.Locale;
 import javafx.collections.ObservableList;
 import javafx.stage.Stage;
-import javafx.event.ActionEvent;
 import javafx.scene.control.MenuItem;
 import javafx.scene.control.SeparatorMenuItem;
 import javafx.beans.property.ReadOnlyBooleanProperty;
@@ -91,6 +90,8 @@ abstract class WindowManager extends Widget {
     /**
      * Returns resources for current locale. We could fetch this information 
ourselves,
      * but we currently ask to subclass because it has this information anyway.
+     *
+     * @return the resources in current locale.
      */
     abstract Resources localized();
 
@@ -115,7 +116,7 @@ abstract class WindowManager extends Widget {
      * @see #hasWindowsProperty
      */
     public final MenuItem createNewWindowMenu() {
-        final MenuItem menu = localized().menu(Resources.Keys.NewWindow, 
this::newDataWindow);
+        final MenuItem menu = localized().menu(Resources.Keys.NewWindow, (e) 
-> newDataWindow());
         menu.setDisable(true);
         newWindowMenus.add(menu);
         return menu;
@@ -150,19 +151,19 @@ abstract class WindowManager extends Widget {
 
     /**
      * Returns the set of currently selected data, or {@code null} if none.
+     *
+     * @return the selected data, or {@code null} if none.
      */
     abstract SelectedData getSelectedData();
 
     /**
      * Invoked when user asked to show the data in a new window. This method 
may be invoked from various sources:
      * contextual menu on the tab, contextual menu in the explorer tree, or 
from the "new window" menu item.
-     *
-     * @param  event  ignored (can be {@code null}).
      */
-    private void newDataWindow(final ActionEvent event) {
+    private void newDataWindow() {
         final SelectedData selection = getSelectedData();
         if (selection != null) {
-            final DataWindow window = new DataWindow(event, (Stage) 
getView().getScene().getWindow(), selection);
+            final DataWindow window = new DataWindow((Stage) 
getView().getScene().getWindow(), selection);
             window.setTitle(selection.title + " — Apache SIS");
             window.show();
             if (showWindowMenus != null) {

Reply via email to