From 750c7288feb0600730597e0ca5b71bcc62661741 Mon Sep 17 00:00:00 2001 From: Oliver-Loeffler Date: Tue, 8 Nov 2022 18:17:35 +0100 Subject: [PATCH] Added warning and informative logging for cases of removing files from recent items and for cases where errors occured during FXML loading. --- .../oracle/javafx/scenebuilder/app/SceneBuilderApp.java | 5 +++++ .../app/welcomedialog/WelcomeDialogWindowController.java | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/oracle/javafx/scenebuilder/app/SceneBuilderApp.java b/app/src/main/java/com/oracle/javafx/scenebuilder/app/SceneBuilderApp.java index d657a1146..d10b0e7d0 100644 --- a/app/src/main/java/com/oracle/javafx/scenebuilder/app/SceneBuilderApp.java +++ b/app/src/main/java/com/oracle/javafx/scenebuilder/app/SceneBuilderApp.java @@ -99,6 +99,8 @@ */ public class SceneBuilderApp extends Application implements AppPlatform.AppNotificationHandler { + private static final Logger LOGGER = Logger.getLogger(SceneBuilderApp.class.getName()); + public enum ApplicationControlAction { ABOUT, CHECK_UPDATES, @@ -736,6 +738,7 @@ private FileOpenResult performOpenFiles(List fxmlFiles) { final Map exceptions = new HashMap<>(); final List openedFiles = new ArrayList<>(); for (File fxmlFile : fxmlFiles) { + LOGGER.log(Level.FINE, "Attempting to open file {0}", fxmlFile); try { final DocumentWindowController dwc = lookupDocumentWindowControllers(fxmlFile.toURI().toURL()); @@ -748,8 +751,10 @@ private FileOpenResult performOpenFiles(List fxmlFiles) { hostWindow.loadFromFile(fxmlFile); hostWindow.openWindow(); openedFiles.add(fxmlFile); + LOGGER.log(Level.INFO, "Successfully opened file {0}", fxmlFile); } } catch (Exception xx) { + LOGGER.log(Level.WARNING, "Failed to open file: %s".formatted(fxmlFile), xx); exceptions.put(fxmlFile, xx); } } diff --git a/app/src/main/java/com/oracle/javafx/scenebuilder/app/welcomedialog/WelcomeDialogWindowController.java b/app/src/main/java/com/oracle/javafx/scenebuilder/app/welcomedialog/WelcomeDialogWindowController.java index 8995a26b7..f7e66839e 100644 --- a/app/src/main/java/com/oracle/javafx/scenebuilder/app/welcomedialog/WelcomeDialogWindowController.java +++ b/app/src/main/java/com/oracle/javafx/scenebuilder/app/welcomedialog/WelcomeDialogWindowController.java @@ -38,6 +38,8 @@ import java.util.ArrayList; import java.util.List; import java.util.function.Consumer; +import java.util.logging.Level; +import java.util.logging.Logger; import java.util.stream.Collectors; import com.oracle.javafx.scenebuilder.app.SceneBuilderApp; @@ -67,6 +69,8 @@ public class WelcomeDialogWindowController extends TemplatesBaseWindowController { + private static final Logger LOGGER = Logger.getLogger(WelcomeDialogWindowController.class.getName()); + @FXML private BorderPane contentPane; @@ -302,7 +306,7 @@ void handleOpen(List filePaths, List missingFiles = candidates.getOrDefault(Boolean.FALSE, new ArrayList<>()); missingFilesHandler.accept(missingFiles); - + List paths = candidates.getOrDefault(Boolean.TRUE, new ArrayList<>()) .stream() .toList(); @@ -314,6 +318,7 @@ void handleOpen(List filePaths, } private void removeMissingFilesFromPrefs(List missingFiles) { + missingFiles.forEach(fxmlFileName->LOGGER.log(Level.INFO, "Removing missing file from recent items: {0}", fxmlFileName)); PreferencesRecordGlobal preferencesRecordGlobal = PreferencesController.getSingleton().getRecordGlobal(); preferencesRecordGlobal.removeRecentItems(missingFiles); }