Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/keenwrite.git
src/main/java/com/keenwrite/preferences/PreferencesController.java
import com.dlsc.preferencesfx.model.Group;
import com.dlsc.preferencesfx.model.Setting;
+import com.dlsc.preferencesfx.util.StorageHandler;
import com.dlsc.preferencesfx.view.NavigationView;
import javafx.beans.property.DoubleProperty;
import static com.dlsc.formsfx.model.structure.Field.ofStringType;
import static com.dlsc.preferencesfx.PreferencesFxEvent.EVENT_PREFERENCES_SAVED;
-import static com.keenwrite.constants.GraphicsConstants.ICON_DIALOG;
import static com.keenwrite.Messages.get;
+import static com.keenwrite.constants.GraphicsConstants.ICON_DIALOG;
import static com.keenwrite.preferences.LocaleProperty.localeListProperty;
import static com.keenwrite.preferences.SkinProperty.skinListProperty;
/**
- * Creates the preferences dialog.
- * <p>
- * TODO: Make this dynamic by iterating over all "Preferences.*" values
- * that follow a particular naming pattern.
- * </p>
+ * Creates the preferences dialog based using {@link XmlStorageHandler} and
+ * numerous {@link Category} objects.
*
- * @return A new instance of preferences for users to edit.
+ * @return A component for editing preferences.
*/
private PreferencesFx createPreferencesFx() {
- return PreferencesFx.of(
- new XmlStorageHandler(),
- Category.of(
- get( KEY_R ),
- Group.of(
- get( KEY_R_DIR ),
- Setting.of( label( KEY_R_DIR,
- stringProperty( KEY_DEF_DELIM_BEGAN ).get(),
- stringProperty( KEY_DEF_DELIM_ENDED ).get() ) ),
- Setting.of( title( KEY_R_DIR ),
- fileProperty( KEY_R_DIR ), true )
- ),
- Group.of(
- get( KEY_R_SCRIPT ),
- Setting.of( label( KEY_R_SCRIPT ) ),
- createScriptSetting()
- ),
- Group.of(
- get( KEY_R_DELIM_BEGAN ),
- Setting.of( label( KEY_R_DELIM_BEGAN ) ),
- Setting.of( title( KEY_R_DELIM_BEGAN ),
- stringProperty( KEY_R_DELIM_BEGAN ) )
- ),
- Group.of(
- get( KEY_R_DELIM_ENDED ),
- Setting.of( label( KEY_R_DELIM_ENDED ) ),
- Setting.of( title( KEY_R_DELIM_ENDED ),
- stringProperty( KEY_R_DELIM_ENDED ) )
- )
+ return PreferencesFx.of( createStorageHandler(), createCategories() )
+ .instantPersistent( false )
+ .dialogIcon( ICON_DIALOG );
+ }
+
+ private StorageHandler createStorageHandler() {
+ return new XmlStorageHandler();
+ }
+
+ private Category[] createCategories() {
+ return new Category[]{Category.of(
+ get( KEY_R ),
+ Group.of(
+ get( KEY_R_DIR ),
+ Setting.of( label( KEY_R_DIR,
+ stringProperty( KEY_DEF_DELIM_BEGAN ).get(),
+ stringProperty( KEY_DEF_DELIM_ENDED ).get() ) ),
+ Setting.of( title( KEY_R_DIR ),
+ fileProperty( KEY_R_DIR ), true )
+ ),
+ Group.of(
+ get( KEY_R_SCRIPT ),
+ Setting.of( label( KEY_R_SCRIPT ) ),
+ createScriptSetting()
+ ),
+ Group.of(
+ get( KEY_R_DELIM_BEGAN ),
+ Setting.of( label( KEY_R_DELIM_BEGAN ) ),
+ Setting.of( title( KEY_R_DELIM_BEGAN ),
+ stringProperty( KEY_R_DELIM_BEGAN ) )
),
+ Group.of(
+ get( KEY_R_DELIM_ENDED ),
+ Setting.of( label( KEY_R_DELIM_ENDED ) ),
+ Setting.of( title( KEY_R_DELIM_ENDED ),
+ stringProperty( KEY_R_DELIM_ENDED ) )
+ )
+ ),
Category.of(
get( KEY_IMAGES ),
stringProperty( KEY_TYPESET_CONTEXT_ENV ) )
)
- )
- ).instantPersistent( false ).dialogIcon( ICON_DIALOG );
+ )};
}

Minor clean-up of preferences

Author DaveJarvis <email>
Date 2021-04-10 13:33:20 GMT-0700
Commit 812332b0cf57de8b698277b5c3264f052cdd8cba
Parent a895d07
Delta 43 lines added, 38 lines removed, 5-line increase