sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1832807 - in /sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui: Main.java metadata/ResourceView.java
Date Mon, 04 Jun 2018 10:27:20 GMT
Author: desruisseaux
Date: Mon Jun  4 10:27:20 2018
New Revision: 1832807

URL: http://svn.apache.org/viewvc?rev=1832807&view=rev
Log:
Remember the filter used last time the user opened a file.

Modified:
    sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/Main.java
    sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/metadata/ResourceView.java

Modified: sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/Main.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/Main.java?rev=1832807&r1=1832806&r2=1832807&view=diff
==============================================================================
--- sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/Main.java [UTF-8]
(original)
+++ sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/Main.java [UTF-8]
Mon Jun  4 10:27:20 2018
@@ -16,6 +16,7 @@
  */
 package org.apache.sis.gui;
 
+import java.io.File;
 import java.util.ArrayList;
 import java.util.LinkedHashSet;
 import java.util.List;
@@ -74,6 +75,11 @@ public class Main extends Application {
     private FileChooser.ExtensionFilter[] openFilters;
 
     /**
+     * The last filter used by the {@link #open()} action.
+     */
+    private FileChooser.ExtensionFilter lastFilter;
+
+    /**
      * Creates a new Apache SIS application.
      */
     public Main() {
@@ -174,12 +180,17 @@ public class Main extends Application {
     private void open() {
         if (openFilters == null) {
             createFileFilters();
+            lastFilter = openFilters[1];
         }
         final FileChooser chooser = new FileChooser();
         chooser.setTitle(Resources.format(Resources.Keys.OpenDataFile));
         chooser.getExtensionFilters().addAll(openFilters);
-        chooser.setSelectedExtensionFilter(openFilters[1]);         // TODO: remember last
filter used.
-        content.open(chooser.showOpenMultipleDialog(window));
+        chooser.setSelectedExtensionFilter(lastFilter);
+        final List<File> files = chooser.showOpenMultipleDialog(window);
+        if (files != null) {
+            lastFilter = chooser.getSelectedExtensionFilter();
+            content.open(files);
+        }
     }
 
     /**

Modified: sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/metadata/ResourceView.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/metadata/ResourceView.java?rev=1832807&r1=1832806&r2=1832807&view=diff
==============================================================================
--- sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/metadata/ResourceView.java
[UTF-8] (original)
+++ sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/metadata/ResourceView.java
[UTF-8] Mon Jun  4 10:27:20 2018
@@ -210,13 +210,11 @@ public class ResourceView {
     }
 
     public void open(final List<File> files) {
-        if (files != null) {
-            for (final File file : files) {
-                if (file.isDirectory()) {
-                    openDirectory(file);
-                } else {
-                    openFile(file);
-                }
+        for (final File file : files) {
+            if (file.isDirectory()) {
+                openDirectory(file);
+            } else {
+                openFile(file);
             }
         }
     }



Mime
View raw message