Fix Windows classpath and add default directory (fixes #42) (#59)

This commit is contained in:
Florian Enner 2023-06-17 11:00:57 +02:00 committed by GitHub
parent e383e6596f
commit 47bbf9d97e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 1 deletions

@ -181,6 +181,7 @@ class SceneBuilderDialog extends ModalDialog {
browseBtn.setMinWidth(120); browseBtn.setMinWidth(120);
browseBtn.setOnAction(e -> { browseBtn.setOnAction(e -> {
var dirChooser = new DirectoryChooser(); var dirChooser = new DirectoryChooser();
dirChooser.setInitialDirectory(SceneBuilderInstaller.getDefaultConfigDir().toFile());
File dir = dirChooser.showDialog(getScene().getWindow()); File dir = dirChooser.showDialog(getScene().getWindow());
if (dir != null) { if (dir != null) {
model.setInstallDir(dir.toPath()); model.setInstallDir(dir.toPath());

@ -28,6 +28,7 @@ final class SceneBuilderInstaller {
private static final String CONFIG_FILE_NAME = "SceneBuilder.cfg"; private static final String CONFIG_FILE_NAME = "SceneBuilder.cfg";
private static final String THEME_PACK_FILE_NAME = "atlantafx-scene-builder.zip"; 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 final Path sceneBuilderDir;
private Path configDir; private Path configDir;
@ -169,7 +170,7 @@ final class SceneBuilderInstaller {
while (it.hasNext()) { while (it.hasNext()) {
var line = it.next(); var line = it.next();
if (line != null && line.startsWith("app.classpath")) { 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() { private Path getConfigDir() {
if (configDir != null) { if (configDir != null) {
return configDir; return configDir;