Skip to content

Commit

Permalink
Fixed Windows classpath and added default directory (fixes mkpaz#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
ennerf committed Jun 9, 2023
1 parent e383e65 commit d9d9a7a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ private Pane createStartScreen() {
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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -169,7 +170,7 @@ public void uninstall() {
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, ""));
}
}

Expand Down Expand Up @@ -221,6 +222,18 @@ public static void deleteFile(Path path) {
}
}

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;
Expand Down

0 comments on commit d9d9a7a

Please sign in to comment.