From 7e810b7cda6e7d8db2032fdb936f9260aaf906f2 Mon Sep 17 00:00:00 2001 From: Mark Raynsford Date: Sun, 29 Sep 2024 18:44:01 +0000 Subject: [PATCH] Reconnect recent file preferences Fix: https://github.com/io7m-com/laurel/issues/75 --- .../java/com/io7m/laurel/gui/internal/LFileChoosers.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/com.io7m.laurel.gui/src/main/java/com/io7m/laurel/gui/internal/LFileChoosers.java b/com.io7m.laurel.gui/src/main/java/com/io7m/laurel/gui/internal/LFileChoosers.java index 0b570c2..8f29afa 100644 --- a/com.io7m.laurel.gui/src/main/java/com/io7m/laurel/gui/internal/LFileChoosers.java +++ b/com.io7m.laurel.gui/src/main/java/com/io7m/laurel/gui/internal/LFileChoosers.java @@ -42,6 +42,7 @@ public final class LFileChoosers implements LFileChoosersType new JWOxygenIconSet(); private final JWFileChoosersType choosers; + private final LPreferencesType preferences; private Path mostRecentDirectory; /** @@ -58,6 +59,8 @@ public LFileChoosers( Executors.newVirtualThreadPerTaskExecutor(), Locale.getDefault() ); + this.preferences = + services.requireService(LPreferencesType.class); } @Override @@ -67,6 +70,11 @@ public JWFileChooserType create( final var builder = JWFileChooserConfiguration.builder() .from(configuration) + .addAllRecentFiles( + this.preferences.recentFiles() + .stream() + .sorted() + .toList()) .setFileImageSet(OXYGEN_ICON_SET); if (this.mostRecentDirectory != null) {