Skip to content

Commit

Permalink
Added warning and informative logging for cases of removing files fro…
Browse files Browse the repository at this point in the history
…m recent items and for cases where errors occured during FXML loading.
  • Loading branch information
Oliver-Loeffler committed Nov 8, 2022
1 parent f1187fc commit 750c728
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -736,6 +738,7 @@ private FileOpenResult performOpenFiles(List<File> fxmlFiles) {
final Map<File, Exception> exceptions = new HashMap<>();
final List<File> 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());
Expand All @@ -748,8 +751,10 @@ private FileOpenResult performOpenFiles(List<File> 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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -67,6 +69,8 @@

public class WelcomeDialogWindowController extends TemplatesBaseWindowController {

private static final Logger LOGGER = Logger.getLogger(WelcomeDialogWindowController.class.getName());

@FXML
private BorderPane contentPane;

Expand Down Expand Up @@ -302,7 +306,7 @@ void handleOpen(List<String> filePaths,

List<String> missingFiles = candidates.getOrDefault(Boolean.FALSE, new ArrayList<>());
missingFilesHandler.accept(missingFiles);

List<String> paths = candidates.getOrDefault(Boolean.TRUE, new ArrayList<>())
.stream()
.toList();
Expand All @@ -314,6 +318,7 @@ void handleOpen(List<String> filePaths,
}

private void removeMissingFilesFromPrefs(List<String> missingFiles) {
missingFiles.forEach(fxmlFileName->LOGGER.log(Level.INFO, "Removing missing file from recent items: {0}", fxmlFileName));
PreferencesRecordGlobal preferencesRecordGlobal = PreferencesController.getSingleton().getRecordGlobal();
preferencesRecordGlobal.removeRecentItems(missingFiles);
}
Expand Down

0 comments on commit 750c728

Please sign in to comment.