JFXtras Core Logo

Storage

XStore and XStoreItem are provided to allow for very easy application persistence in JavaFX without having to format and retrieve data, in addition to management of the stores

Features

As many stores as required may be defined as in the two below, store1 in file TestStore1 and store2 in file TestStore2. Each store may contain any mix of Integer, Float/Number, Boolean, String or Duration variables or sequences. It is anticipated that these will then be bound with inverse to the required script variable, as in the example code. Defaults for reset may be specified for initialisation when first creating and for any store reset that may be carried out. Various functions are provided to allow:
  • Reset any individual item
  • Reset all items in a store
  • Reload a store
  • Force a store save
  • Delete a store
  • List Stores and StoreItems (diagnostic)
Currently XStore will not autosave on exit, to save on exit you should add an onClose action to the Stage or similar.
Note - Durations will be stored and retireved in milliSeconds.

(see JavaFXDoc for details)

Sample Code


var store1 = XStore { name: "TestStore1" content: [ XStoreInteger { name: "mfSet" default: 1 value: bind mfSet with inverse }, XStoreFloat { name: "stageX" default: 300.0 value: bind stageX with inverse }, XStoreBoolean { name: "boolTest" default: true value: bind boolTest with inverse }, XStoreString { name: "stringTest" default: "Hello" value: bind stringTest with inverse }, XStoreDuration { name: "durTest" default: 30s value: bind durTest with inverse }, ] }; var store2 = XStore { name: "TestStore2" content: [ XStoreIntegerSeq { name: "integerSeq" default: [1, 3, 5] value: bind integerSeq with inverse }, XStoreFloatSeq { name: "floatSeq" default: [1.0, 3.0, 5.0] value: bind floatSeq with inverse }, XStoreBooleanSeq { name: "boolSeq" default: [true, false, true, false] value: bind boolSeq with inverse }, XStoreStringSeq { name: "stringSeq" default: [ "Monday","Tuesday","Wednesday","Thursday","Friday" ] value: bind stringSeq with inverse }, XStoreDurationSeq { name: "durSeq" default: [ 1s, 5s, 10s, 30s, 1m, 10m, 30m, 1h, 6h, 12h ] value: bind durSeq with inverse }, ] };


<< Back to JFXtras FrontPage

0 Attachments 0 Attachments
458 Views