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

Possible to edit preferences by using the Preferences class or any other way? #297

Open
sreese4u opened this issue Dec 20, 2020 · 1 comment

Comments

@sreese4u
Copy link

sreese4u commented Dec 20, 2020

I have the requirement to delete a category. Is this somehow possible? How would I additionally check whether a category exists, without creating new PreferencesFX object?

@ghost
Copy link

ghost commented Apr 10, 2021

It doesn't look like there's any easy way to remove a category dynamically. The PreferencesFx class uses a PreferencesFxModel instance that's populated with the Category objects. The model has getCategories, which could be used to check whether a category exists. However, the model is inaccessible through any public API.

Keeping a handle to the list of categories used at construction-time is the only practical option to checking whether a category exists. Recreating the PreferencesFx object also looks like the only choice to adding or removing categories.

If it helps, here's how I organize the preferences in my app:

https://github.com/DaveJarvis/keenwrite/blob/812332b0cf57de8b698277b5c3264f052cdd8cba/src/main/java/com/keenwrite/preferences/PreferencesController.java#L106

Keeping a reference to Category instances would allow the application to add and remove items. Using an ObservableList instead of an array would allow triggering recreation of the PreferencesFx based on an event mechanism.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant