diff --git a/sampler/src/main/java/atlantafx/sampler/page/general/SceneBuilderDialog.java b/sampler/src/main/java/atlantafx/sampler/page/general/SceneBuilderDialog.java index 0a9e122..74e2d8d 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/general/SceneBuilderDialog.java +++ b/sampler/src/main/java/atlantafx/sampler/page/general/SceneBuilderDialog.java @@ -181,6 +181,7 @@ class SceneBuilderDialog extends ModalDialog { browseBtn.setMinWidth(120); browseBtn.setOnAction(e -> { var dirChooser = new DirectoryChooser(); + dirChooser.setInitialDirectory(SceneBuilderInstaller.getDefaultConfigDir().toFile()); File dir = dirChooser.showDialog(getScene().getWindow()); if (dir != null) { model.setInstallDir(dir.toPath()); diff --git a/sampler/src/main/java/atlantafx/sampler/page/general/SceneBuilderInstaller.java b/sampler/src/main/java/atlantafx/sampler/page/general/SceneBuilderInstaller.java index 908caa9..6083219 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/general/SceneBuilderInstaller.java +++ b/sampler/src/main/java/atlantafx/sampler/page/general/SceneBuilderInstaller.java @@ -28,6 +28,7 @@ final class SceneBuilderInstaller { private static final String CONFIG_FILE_NAME = "SceneBuilder.cfg"; private static final String THEME_PACK_FILE_NAME = "atlantafx-scene-builder.zip"; + private static final char CLASSPATH_SEPARATOR = PlatformUtils.isWindows() ? ';' : ':'; private final Path sceneBuilderDir; private Path configDir; @@ -169,7 +170,7 @@ final class SceneBuilderInstaller { while (it.hasNext()) { var line = it.next(); if (line != null && line.startsWith("app.classpath")) { - it.set(line.replace("$APPDIR" + File.separator + THEME_PACK_FILE_NAME + ":", "")); + it.set(line.replace("$APPDIR" + File.separator + THEME_PACK_FILE_NAME + CLASSPATH_SEPARATOR, "")); } } @@ -221,6 +222,18 @@ final class SceneBuilderInstaller { } } + public static Path getDefaultConfigDir() { + if (PlatformUtils.isWindows()) { + return Path.of(System.getProperty("user.home"), "AppData", "Local", "SceneBuilder"); + } else if (PlatformUtils.isLinux()) { + return Path.of("/opt/scenebuilder/"); + } else if (PlatformUtils.isUnix()) { + return Path.of("/Applications/SceneBuilder.app/"); + } else { + return Path.of("."); + } + } + private Path getConfigDir() { if (configDir != null) { return configDir;