diff --git a/app/pom.xml b/app/pom.xml
index 1a3eddc38..7bb5f83c8 100644
--- a/app/pom.xml
+++ b/app/pom.xml
@@ -16,8 +16,8 @@
${maven.build.timestamp}
${java.version}, ${java.runtime.name}
${javafx.version}
- 17
yyyy-MM-dd HH:mm:ss
+ 17
diff --git a/app/src/main/java/com/oracle/javafx/scenebuilder/app/library/user/UserLibraryImporter.java b/app/src/main/java/com/oracle/javafx/scenebuilder/app/library/user/UserLibraryImporter.java
index 5a60a0c52..347f6461b 100644
--- a/app/src/main/java/com/oracle/javafx/scenebuilder/app/library/user/UserLibraryImporter.java
+++ b/app/src/main/java/com/oracle/javafx/scenebuilder/app/library/user/UserLibraryImporter.java
@@ -91,17 +91,22 @@ AppPlatformDirectories getPlatformDirectories() {
* @return {@link ImportResult} describing how the activity was completed.
*/
ImportResult performImportWhenDesired() {
- String forceImport = System.getProperty("forceImport", "false");
- if ("true".equalsIgnoreCase(forceImport)) {
- preferences.remove(PREF_IMPORT_USER_LIBRARY);
- }
+ boolean forcedImport = importForced();
boolean requiresImport = preferences.getBoolean(PREF_IMPORT_USER_LIBRARY, true);
- if (requiresImport) {
+ if (requiresImport || forcedImport) {
+ if (forcedImport) {
+ logger.log(Level.FINE, "detected -DforceImport=true");
+ }
return importPreviousVersionUserLibrary();
}
logger.log(Level.INFO, "Previous version user library will not be imported.");
return ImportResult.SKIPPED;
}
+
+ private boolean importForced() {
+ String forceImport = System.getProperty("forceImport", "false");
+ return "true".equalsIgnoreCase(forceImport);
+ }
void clearImportDecision() {
preferences.remove(PREF_IMPORT_USER_LIBRARY);
diff --git a/app/src/main/java/com/oracle/javafx/scenebuilder/app/preferences/PreferencesController.java b/app/src/main/java/com/oracle/javafx/scenebuilder/app/preferences/PreferencesController.java
index 7b10dd09a..cbe5cad07 100644
--- a/app/src/main/java/com/oracle/javafx/scenebuilder/app/preferences/PreferencesController.java
+++ b/app/src/main/java/com/oracle/javafx/scenebuilder/app/preferences/PreferencesController.java
@@ -251,6 +251,6 @@ public PreferencesImporter getImporter() {
}
public UserLibraryImporter getUserLibraryImporter() {
- return new UserLibraryImporter(applicationPreferences);
+ return new UserLibraryImporter(applicationRootPreferences);
}
}
diff --git a/app/src/main/java/com/oracle/javafx/scenebuilder/app/preferences/PreferencesImporter.java b/app/src/main/java/com/oracle/javafx/scenebuilder/app/preferences/PreferencesImporter.java
index 857807c7f..cb3eb9046 100644
--- a/app/src/main/java/com/oracle/javafx/scenebuilder/app/preferences/PreferencesImporter.java
+++ b/app/src/main/java/com/oracle/javafx/scenebuilder/app/preferences/PreferencesImporter.java
@@ -130,10 +130,6 @@ private void copyChildren(Preferences source, Preferences targetNode) throws Bac
* @return true in case the key is not {@code PREF_PERFORM_IMPORT} set.
*/
boolean askForImport() {
- String forceImport = System.getProperty("forceImport", "false");
- if ("true".equalsIgnoreCase(forceImport)) {
- target.remove(PREF_PERFORM_IMPORT);
- }
boolean importRequired = target.getBoolean(PREF_PERFORM_IMPORT, true);
logger.log(Level.FINE, "preferences import required; {0}", importRequired);
return importRequired;
@@ -180,14 +176,24 @@ public void tryImportingPreviousVersionSettings() {
* @return true when previous version settings have been found and user has not yet decided
*/
public boolean askForImportIfOlderSettingsExist() {
- return this.optionalSourceNode.map(this::previousVersionPrefsFound).isPresent() && askForImport();
+ boolean previousVersionFound = this.optionalSourceNode.isPresent();
+ logger.log(Level.FINE, "older preferences detected: {0}", previousVersionFound);
+ if (previousVersionFound) {
+ VersionedPreferences prefs = this.optionalSourceNode.get();
+ logger.log(Level.FINE, "Version: {0}", prefs.version());
+ logger.log(Level.FINE, "Node : {0}", prefs.node());
+ }
+ boolean forcedImport = importForced();
+ if (forcedImport) {
+ logger.log(Level.FINE, "detected -DforceImport=true");
+ }
+ return previousVersionFound && (forcedImport || askForImport());
}
- private VersionedPreferences previousVersionPrefsFound(VersionedPreferences versionedpreferences) {
- logger.log(Level.FINE, "{0}", versionedpreferences);
- return versionedpreferences;
+ private boolean importForced() {
+ String forceImport = System.getProperty("forceImport", "false");
+ return "true".equalsIgnoreCase(forceImport);
}
-
/**
* Defines an activity which will be executed after import of settings.
*
diff --git a/app/src/main/java/com/oracle/javafx/scenebuilder/app/preferences/VersionedPreferencesFinder.java b/app/src/main/java/com/oracle/javafx/scenebuilder/app/preferences/VersionedPreferencesFinder.java
index 4d2cb8402..686a94ce7 100644
--- a/app/src/main/java/com/oracle/javafx/scenebuilder/app/preferences/VersionedPreferencesFinder.java
+++ b/app/src/main/java/com/oracle/javafx/scenebuilder/app/preferences/VersionedPreferencesFinder.java
@@ -119,6 +119,8 @@ public List getPreviousVersions() {
public Optional previousVersionPrefs() {
List previousVersions = getPreviousVersions();
if (previousVersions.isEmpty()) {
+ Logger.getLogger(VersionedPreferencesFinder.class.getName()).log(Level.FINE,
+ "No previous versions preferences found!");
return Optional.empty();
}
return Optional.of(previousVersions.get(0));
diff --git a/app/src/test/java/com/oracle/javafx/scenebuilder/app/preferences/PreferencesControllerTest.java b/app/src/test/java/com/oracle/javafx/scenebuilder/app/preferences/PreferencesControllerTest.java
index ed8779cdf..47cc90fea 100644
--- a/app/src/test/java/com/oracle/javafx/scenebuilder/app/preferences/PreferencesControllerTest.java
+++ b/app/src/test/java/com/oracle/javafx/scenebuilder/app/preferences/PreferencesControllerTest.java
@@ -54,11 +54,12 @@ public class PreferencesControllerTest {
@BeforeClass
public static void setup() {
- PrefsHelper.setToNull(PreferencesController.getSingleton(),"singleton");
testNode = Preferences.userRoot()
.node("PREFS_CONTROLLER_TEST")
.node("com/oracle/javafx/scenebuilder/app/preferences");
+
PrefsHelper.removeAllChildNodes(testNode);
+ PrefsHelper.setToNull(PreferencesController.getSingleton(),"singleton");
classUnderTest = PreferencesController.getSingleton(testNode);
}
diff --git a/app/src/test/java/com/oracle/javafx/scenebuilder/app/preferences/PrefsHelper.java b/app/src/test/java/com/oracle/javafx/scenebuilder/app/preferences/PrefsHelper.java
index c0d9d552c..eec87d9b4 100644
--- a/app/src/test/java/com/oracle/javafx/scenebuilder/app/preferences/PrefsHelper.java
+++ b/app/src/test/java/com/oracle/javafx/scenebuilder/app/preferences/PrefsHelper.java
@@ -41,10 +41,13 @@
* Utility Class to help preparing Preferences nodes for tests
*/
public class PrefsHelper {
+
private PrefsHelper() {
/* not intended for instantiation */
}
+
public static void removeAllNonReleaseNodes(Preferences prefs) {
+ System.out.println(prefs);
String appVersion = AppSettings.getSceneBuilderVersion();
String versionSpecificNode = PreferencesController.SB_RELEASE_NODE_PREFIX + appVersion;
try {
@@ -59,7 +62,7 @@ public static void removeAllNonReleaseNodes(Preferences prefs) {
throw new RuntimeException(e);
}
}
-
+
public static void removeAllChildNodes(Preferences prefs) {
try {
String[] childnodes = prefs.childrenNames();
@@ -71,7 +74,7 @@ public static void removeAllChildNodes(Preferences prefs) {
throw new RuntimeException(e);
}
}
-
+
public static synchronized void setToNull(Object source, String fieldName) {
try {
Class> sourceClass = source.getClass();
diff --git a/app/src/test/java/com/oracle/javafx/scenebuilder/app/preferences/VersionedPreferencesFinderTest.java b/app/src/test/java/com/oracle/javafx/scenebuilder/app/preferences/VersionedPreferencesFinderTest.java
index d10713b30..a4b86351f 100644
--- a/app/src/test/java/com/oracle/javafx/scenebuilder/app/preferences/VersionedPreferencesFinderTest.java
+++ b/app/src/test/java/com/oracle/javafx/scenebuilder/app/preferences/VersionedPreferencesFinderTest.java
@@ -50,8 +50,9 @@ public class VersionedPreferencesFinderTest {
@BeforeClass
public static void setup() {
testNode = Preferences.userRoot()
- .node("/SBTEST")
- .node("/com/oracle/javafx/scenebuilder/app/preferences");
+ .node("SBTEST")
+ .node("com/oracle/javafx/scenebuilder/app/preferences");
+
PrefsHelper.removeAllChildNodes(testNode);
classUnderTest = new VersionedPreferencesFinder("SB_", testNode);
}
diff --git a/pom.xml b/pom.xml
index 00532d14a..433393059 100644
--- a/pom.xml
+++ b/pom.xml
@@ -46,6 +46,7 @@
${main.class.name}
+