sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject [sis] 02/02: Fix recent files ordering.
Date Fri, 23 Oct 2020 22:23:48 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

commit 1b47d2facf9f7bd72d3bdb5ad5f05001e7c0acff
Author: Martin Desruisseaux <martin.desruisseaux@geomatys.com>
AuthorDate: Fri Oct 23 23:42:02 2020 +0200

    Fix recent files ordering.
---
 .../main/java/org/apache/sis/gui/RecentFiles.java    | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/application/sis-javafx/src/main/java/org/apache/sis/gui/RecentFiles.java b/application/sis-javafx/src/main/java/org/apache/sis/gui/RecentFiles.java
index fb82de7..7a5a9fd 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/gui/RecentFiles.java
+++ b/application/sis-javafx/src/main/java/org/apache/sis/gui/RecentFiles.java
@@ -115,19 +115,21 @@ final class RecentFiles implements EventHandler<ActionEvent> {
          * Verifies if an item already exists for the given file.
          * If yes, we will just move it.
          */
+        MenuItem item = null;
         for (int i=0; i<size; i++) {
             if (file.equals(items.get(i).getUserData())) {
-                items.add(0, items.remove(i));
-                return;
+                item = items.remove(i);
+                break;
             }
         }
-        final MenuItem item;
-        if (size >= MAX_COUNT) {
-            item = items.remove(size-1);
-            item.setText(file.getName());
-            item.setUserData(file);
-        } else {
-            item = createItem(file);
+        if (item == null) {
+            if (size >= MAX_COUNT) {
+                item = items.remove(size-1);
+                item.setText(file.getName());
+                item.setUserData(file);
+            } else {
+                item = createItem(file);
+            }
         }
         items.add(0, item);
         /*


Mime
View raw message