Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: app data, prefs and library are stored in version specific location (#346, #369) #579

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
4fd9107
fix: Application data, application preferences, messagebox and user l…
Oliver-Loeffler Oct 4, 2022
2b93977
Added Javadoc and reduced visibility of overloaded methods which were
Oliver-Loeffler Oct 4, 2022
47839cd
Imports cleaned.
Oliver-Loeffler Oct 4, 2022
1b7e1d0
Added more detailed error message in AppSettingsTest for case when re…
Oliver-Loeffler Oct 4, 2022
2a87ddf
Merge branch 'gluonhq:master' into issue-369
Oliver-Loeffler Nov 1, 2022
f0b1ec7
Merge branch 'gluonhq:master' into issue-369
Oliver-Loeffler Nov 2, 2022
051e665
Merge branch 'gluonhq:master' into issue-369
Oliver-Loeffler Mar 18, 2024
60bd738
Merge branch 'gluonhq:master' into issue-369
Oliver-Loeffler Aug 26, 2024
1aee392
OS is now passed consequently as param. Now also the path separators …
Oliver-Loeffler Aug 26, 2024
8250d42
Merge branch 'master' into issue-369
Oliver-Loeffler Sep 30, 2024
647ac20
Update PreferencesController.java
Oliver-Loeffler Sep 30, 2024
e5e46c0
Update PreferencesControllerTest.java
Oliver-Loeffler Sep 30, 2024
fe34536
Update AppSettingsTest.java
Oliver-Loeffler Sep 30, 2024
f0e54e2
Updated surefire version in reactor POM to make tests work with modul…
Oliver-Loeffler Sep 30, 2024
dd34480
Merge branch 'gluonhq:master' into issue-369
Oliver-Loeffler Oct 1, 2024
a5a490a
Merge branch 'gluonhq:master' into issue-369
Oliver-Loeffler Oct 2, 2024
3fe6c86
Merge branch 'gluonhq:master' into issue-369
Oliver-Loeffler Oct 2, 2024
91da6b8
Merge branch 'gluonhq:master' into issue-369
Oliver-Loeffler Oct 3, 2024
abe85a2
Merge branch 'gluonhq:master' into issue-369
Oliver-Loeffler Dec 22, 2024
bda6925
Merge branch 'gluonhq:master' into issue-369
Oliver-Loeffler Dec 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
OS is now passed consequently as param. Now also the path separators …
…are properly created regardless of the test exec OS.
Oliver-Loeffler committed Aug 26, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 1aee39255de45a99d1d9f93fe0878b1e00cde7a7
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2022 Gluon and/or its affiliates.
* Copyright (c) 2017, 2024 Gluon and/or its affiliates.
* Copyright (c) 2012, 2014, Oracle and/or its affiliates.
* All rights reserved. Use is subject to license terms.
*
@@ -37,6 +37,7 @@
import java.io.IOException;
import java.nio.file.FileAlreadyExistsException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
@@ -62,8 +63,14 @@ public class AppPlatform {
private static MessageBox<MessageBoxMessage> messageBox;

public static synchronized String getApplicationDataFolder() {
return getApplicationDataFolder(System.getenv(), System.getProperties(), OS.get(),
AppSettings.getSceneBuilderVersion());
return getApplicationDataFolder(OS.get());
}

static synchronized String getApplicationDataFolder(OS operatingSystem) {
return getApplicationDataFolder(System.getenv(),
System.getProperties(),
operatingSystem,
AppSettings.getSceneBuilderVersion());
}

static synchronized String getApplicationDataFolder(Map<String, String> sysenv, Properties system,
@@ -107,9 +114,9 @@ public static synchronized String getUserLibraryFolder() {
static synchronized String getUserLibraryFolder(OS operatingSystem) {
if (userLibraryFolder == null) {
if (OS.WINDOWS.equals(operatingSystem)) {
userLibraryFolder = getApplicationDataFolder() + "\\" + "Library"; // NOI18N
userLibraryFolder = getApplicationDataFolder(operatingSystem) + "\\" + "Library"; // NOI18N
} else {
userLibraryFolder = getApplicationDataFolder() + "/" + "Library"; // NOI18N
userLibraryFolder = getApplicationDataFolder(operatingSystem) + "/" + "Library"; // NOI18N
}
}
return userLibraryFolder;
@@ -122,12 +129,16 @@ static synchronized String getUserLibraryFolder(OS operatingSystem) {
* @return Directory path for Scene Builder logs
*/
public static synchronized String getLogFolder() {
return getLogFolder(System.getProperties());
return getLogFolder(System.getProperties(), OS.get());
}

static synchronized String getLogFolder(Properties system) {
static synchronized String getLogFolder(Properties system, OS operatingSystem) {
if (logsFolder == null) {
logsFolder = Paths.get(system.getProperty("user.home"), ".scenebuilder", "logs").toString(); //NOI18N
if (OS.WINDOWS.equals(operatingSystem)) {
logsFolder = system.getProperty("user.home") + "\\.scenebuilder\\logs"; //NOI18N
} else {
logsFolder = system.getProperty("user.home") + "/.scenebuilder/logs"; //NOI18N
}
}
return logsFolder;
}
@@ -196,10 +207,17 @@ private static synchronized boolean requestStartGeneric(
}

protected static String getMessageBoxFolder() {
return getMessageBoxFolder(OS.get());
}

protected static String getMessageBoxFolder(OS operatingSystem) {
if (messageBoxFolder == null) {
messageBoxFolder = getApplicationDataFolder() + "/MB"; //NOI18N
if (OS.WINDOWS.equals(operatingSystem)) {
messageBoxFolder = getApplicationDataFolder() + "\\MB"; //NOI18N
} else {
messageBoxFolder = getApplicationDataFolder() + "/MB"; //NOI18N
}
}

return messageBoxFolder;
}

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2022 Gluon and/or its affiliates.
* Copyright (c) 2016, 2024 Gluon and/or its affiliates.
* Copyright (c) 2012, 2014, Oracle and/or its affiliates.
* All rights reserved. Use is subject to license terms.
*
@@ -85,26 +85,23 @@ void that_library_path_is_subdir_of_appdata() {
}

@Test
@EnabledOnOs(value = org.junit.jupiter.api.condition.OS.WINDOWS)
void that_application_settings_directory_is_created_properly_on_windows() {
Path appDir = Path.of(AppPlatform.getApplicationDataFolder());
Path appDir = Path.of(AppPlatform.getApplicationDataFolder(OS.WINDOWS));
Path expected = Path.of(System.getenv("APPDATA") + "\\Scene Builder\\" + AppSettings.getSceneBuilderVersion());
assertEquals(expected, appDir);
}

@Test
@EnabledOnOs(value = org.junit.jupiter.api.condition.OS.LINUX)
void that_application_settings_directory_is_created_properly_on_linux() {
Path appDir = Path.of(AppPlatform.getApplicationDataFolder());
Path appDir = Path.of(AppPlatform.getApplicationDataFolder(OS.LINUX));
Path expected = Path
.of(System.getProperty("user.home") + "/.scenebuilder/" + AppSettings.getSceneBuilderVersion());
assertEquals(expected, appDir);
}

@Test
@EnabledOnOs(value = org.junit.jupiter.api.condition.OS.MAC)
void that_application_settings_directory_is_created_properly_on_mac() {
Path appDir = Path.of(AppPlatform.getApplicationDataFolder());
Path appDir = Path.of(AppPlatform.getApplicationDataFolder(OS.MAC));
Path expected = Path.of(System.getProperty("user.home") + "/Library/Application Support/Scene Builder/"
+ AppSettings.getSceneBuilderVersion());
assertEquals(expected, appDir);
@@ -122,7 +119,7 @@ void that_user_library_folder_resides_in_applications_data_folder() {
void that_messagebox_folder_resides_in_applications_data_folder() {
// init app data folder first as this is the basis
AppPlatform.getApplicationDataFolder(testEnvironment, testProperties, OS.WINDOWS, "19.0.0-SNAPSHOT");
Path messageBoxDir = Path.of(AppPlatform.getMessageBoxFolder());
Path messageBoxDir = Path.of(AppPlatform.getMessageBoxFolder(OS.WINDOWS));
Path expectedDir = Path.of("C:\\Users\\UserName\\AppData\\Roaming\\Scene Builder\\19.0.0-SNAPSHOT\\MB");
assertEquals(expectedDir, messageBoxDir);
}