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 2020/10/23 22:23:48 UTC
[sis] 02/02: Fix recent files ordering.
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 <ma...@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);
/*