-
Notifications
You must be signed in to change notification settings - Fork 68
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
Feature request: PreferencesFx.of(java.util.prefs.Preferences... #132
Comments
+1, in order to export preferences, I have to use java reflection to access model -> storage handler -> preferences, may be a public StorageHandler ref will suffice. |
+1 for this, I'd really prefer my settings to be saved in a settings file, not the registry. |
First, inject a custom storage handler that overrides the default behaviours: PreferencesFx.of( createStorageHandler(), createCategories() )
.instantPersistent( false )
// ... along with ...
private StorageHandler createStorageHandler() {
return new XmlStorageHandler();
} Next, implement that custom XmlStorageHandler to perform no actions. That is, PreferencesFX will no longer use its own storage handling routines. Then, define application Keys to help ensure type safety when referencing settings. This avoids hard-coding strings for key names everywhere and allows for defining structured relationships between keys, such as a hierarchy of settings. Following that, create a Workspace concept that handles persisting of settings data. This is where you'd populate default values for every setting (to be Up next, map the keys to PreferencesFX settings and widgets. Check out the PreferencesController class to see one way to accomplish this mapping. Finally, when persisting the data, you now have control over the settings file format, the file location and name, and the ability to maintain backwards compatibility with previous versions. |
While adding PreferencesFX to a NetBeans Platform application I noticed that my settings where scattered.
On Linux, a NetBeans Platform application store its settings in a directory like ~/.MYAPP while PreferencesFX defaults to ~/.java/.userPrefs/...
With NbPreferences.forModule(Class c)
https://bits.netbeans.org/dev/javadoc/org-openide-util/org/openide/util/NbPreferences.html#forModule-java.lang.Class-
I get a java.util.prefs.Preferences object I would like to use when calling PreferencesFx.of().
Is it possible to add that functionality to the framework?
While reading the code I got to PreferencesBasedStorageHandler and the row
PreferencesFX/preferencesfx/src/main/java/com/dlsc/preferencesfx/util/PreferencesBasedStorageHandler.java
Line 42 in d09c87b
So, I guess I could make my own StorageHandler, but I believe it makes more sence to have a simple PreferencesFx.of(java.util.prefs.Preferences... in the framework.
The text was updated successfully, but these errors were encountered: