java.lang.Object
org.autogui.base.mapping.GuiPreferences
- Direct Known Subclasses:
GuiPreferences.GuiPreferencesWithPaths
the Preferences holder associated to a
GuiMappingContext.
Each child is also held by GuiMappingContext.
The class has a GuiPreferences.GuiValueStore.
It also has a list of history values.
pack/Type/ //root-context, in a case of GuiReprObjectPane(pack.Type)
//otherwise, "org/autogui/base/mapping/pack_Type"
"$default"/
propName = value... //regular preferences entries
...
"$value" = ... //current value, which will precede to history values
"$history"/
"0"/ //key-index
"index" = ...
"value" = ...
"time" = ... //Instant.toString()
...
propertyName/ //the name of a sub-context
...
"$launchPrefs" = "..." //value of "$uuid", "" or "empty"
"$saved"/
"$0"/
"$name" = ...
"$uuid" = "..." //a value from UUID.randomUUID()
... //same structure as "$default"
...
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classa subclass of prefs for custom usage with supplying specific sub-paths.static classthe abstract definition of key-value store.static classthe concrete implementation of the store byPreferencesstatic classstatic classan on-memory impl.static classan entry of the value history, consisting of a value, an index and a time-stamp, associated with a key-index.static classJSON entry for JSON support objectstatic classan on-memory impl.static interfacethe interface for supporting user-defined prefs: a context-object that implements the interface always saves/loads prefs via the interface.static classthe entire lock object for the preferencesstatic interfacestatic enum -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Map<GuiMappingContext, GuiPreferences> protected GuiMappingContextprotected intprotected List<GuiPreferences.HistoryValueEntry> protected List<GuiPreferences.HistoryValueEntry> static final Stringthe key forgetCurrentValue()static final Stringthe key for the defaultGuiPreferencesnode under the rootstatic final Stringthe key for the history node containingGuiPreferences.HistoryValueEntryunderGuiPreferencesstatic final Stringthe key for the int index ofGuiPreferences.HistoryValueEntrystatic final Stringthe key for the stringInstantvalue ofGuiPreferences.HistoryValueEntrystatic final Stringthe key for the JSON string value ofGuiPreferences.HistoryValueEntrystatic final Stringthe key for the string uuid refering a savedGuiPreferencesunder the rootstatic final Stringthe key for the string name ofGuiPreferencesstatic final Stringthe key for saved node containing sub-nodes ofGuiPreferencesunder the rootstatic final Stringthe key for the string UUID ofGuiPreferencesprotected GuiPreferences.PreferencesLockprotected GuiPreferencesprotected GuiPreferences.GuiValueStore -
Constructor Summary
ConstructorsConstructorDescriptionGuiPreferences(GuiMappingContext context) GuiPreferences(GuiPreferences.GuiValueStore valueStore, GuiMappingContext context) GuiPreferences(GuiPreferences parent, GuiMappingContext context) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddHistoryValue(Object value) add a value to the history.voidaddHistoryValue(Object value, Instant optionalTime) voidvoidclearAll()after calling the method, the preferences will be invalidatedvoidvoidvoidclearHistoriesTree(boolean clearPrefs) copyOnMemory(GuiPreferences parent) static GuiPreferences.GuiValueStorecopyOnMemoryStore(GuiPreferences src, GuiPreferences prefs, GuiPreferences.GuiValueStore store, boolean putToParent) createHistoryValueEntry(Object value) protected List<GuiPreferences.HistoryValueEntry> voidprotected voidfromJsonChildNodes(GuiPreferences.GuiValueStore store, Map<String, Object> json) getChild(GuiMappingContext context) loads prefs JSON object forGuiPreferences.PreferencesJsonSupport.setPrefsJson(Map)getDescendant(GuiMappingContext descendantContext) getHistoryValue(Object value) protected GuiPreferences.HistoryValueEntryintloaded history values the size of the list is up tohistoryValueLimitall entries have valid indices, !=-1, ordered, but might not start from 0 can be sorted by indices; the larger indices are recent entries their keyIndex are meaningless, just unique key for nodeintgetName()"$default/" ...static intbooleanvoidload()voidload or create historyValues: it's size becomes up to historyValueLimit and sorted by index.protected voidloadNodes(GuiPreferences.GuiValueStore store, Collection<String> keys) lock()voidnotifyStoreChange(String key, Object value) voidnotifyStoreChange(GuiPreferences preferences, String key, Object value) voidvoidvoidremoveHistories(Collection<GuiPreferences.HistoryValueEntry> loadedValuesRemoved) voidvoidprotected voidsetChild(GuiMappingContext context, GuiPreferences child) voidsetCurrentValue(Object value) voidsaves the given JSON as a prefs entryvoidsort es by index,voidsetLaunchPrefsAsRoot(String uuid) voidvoidsyncHistoryValues(boolean resetIndex) toJson()static StringtoStoreKey(String key)
-
Field Details
-
context
-
parent
-
children
-
valueStore
-
historyValues
-
historyValuesFree
-
historyValueLimit
protected int historyValueLimit -
storeChangeListeners
-
lock
- Since:
- 1.6
-
KEY_DEFAULT
the key for the defaultGuiPreferencesnode under the root- See Also:
-
KEY_CURRENT_VALUE
the key forgetCurrentValue()- See Also:
-
KEY_LAUNCH_PREFS
the key for the string uuid refering a savedGuiPreferencesunder the root- See Also:
-
KEY_SAVED
the key for saved node containing sub-nodes ofGuiPreferencesunder the root- See Also:
-
KEY_NAME
the key for the string name ofGuiPreferences- See Also:
-
KEY_UUID
the key for the string UUID ofGuiPreferences- See Also:
-
KEY_HISTORY
the key for the history node containingGuiPreferences.HistoryValueEntryunderGuiPreferences- See Also:
-
KEY_HISTORY_ENTRY_INDEX
the key for the int index ofGuiPreferences.HistoryValueEntry- See Also:
-
KEY_HISTORY_ENTRY_VALUE
the key for the JSON string value ofGuiPreferences.HistoryValueEntry- See Also:
-
KEY_HISTORY_ENTRY_TIME
the key for the stringInstantvalue ofGuiPreferences.HistoryValueEntry- See Also:
-
-
Constructor Details
-
GuiPreferences
-
GuiPreferences
-
GuiPreferences
-
-
Method Details
-
isContextTypeIsJsonSupport
public boolean isContextTypeIsJsonSupport()- Returns:
- the type of the context of the prefs is
GuiPreferences.PreferencesJsonSupport - Since:
- 1.5
-
copyInitAsRoot
-
getStoreValueMaxLength
public static int getStoreValueMaxLength() -
toStoreKey
-
getChild
- Parameters:
context- the parent- Returns:
- a child preference for context
-
setChild
-
getName
-
getContext
-
getParent
-
getDescendant
- Parameters:
descendantContext- a descendant context of the context returned bygetContext(), can begetContext()itself- Returns:
- a descendant preference associated with the descendantContext
-
getValueStore
- Returns:
- Preferences based value-store. if it has parent, node for context's name of the parent, otherwise, node for context's object-type (user-node "/pack/ObjType") or node for (pack of this type)+"/"+(context's name).
-
getValueStoreRootFromRepresentation
-
getPreferencesNodeAsRoot
-
resetAsRoot
public void resetAsRoot() -
lock
- Returns:
- lock object with holding the lock
- Since:
- 1.6
-
getSavedStoreListAsRoot
"$default/" ... "$launchPrefs" = "..." "$saved/" "$0/" "$name" = "prefs yyyy/mm/dd hh:mm" "$uuid" = "..." //checked ... "$1/" ...- Returns:
- saved preferences
-
getLaunchPrefsAsRoot
- Returns:
- "": value of "$uuid", "" (default) or "empty" (empty)
-
setLaunchPrefsAsRoot
-
addNewSavedStoreAsRoot
-
setCurrentValue
-
setCurrentValueAsJsonSupported
saves the given JSON as a prefs entry- Parameters:
json- the saved object- Since:
- 1.5
-
getCurrentValue
-
getCurrentValueAsJsonSupported
loads prefs JSON object forGuiPreferences.PreferencesJsonSupport.setPrefsJson(Map)- Returns:
- loaded JSON object
- Since:
- 1.5
-
addHistoryValue
add a value to the history.- it first loads the existing history if not yet loaded, by
loadHistoryValues(). -
it finds an existing entry or a create new entry by
getHistoryValue(Object). the entire number of entries always keeps underhistoryValueLimit. - The entry moves to the end of the history as the latest value, by setting the max index + 1 as it's index.
- set keyIndex if -1; those are new entries and no exsting nodes
- if the max index overs 100 x
historyValueLimit, reset all indices from 0
- Parameters:
value- the new entry value
- it first loads the existing history if not yet loaded, by
-
addHistoryValue
-
getHistoryValueLimit
public int getHistoryValueLimit() -
syncHistoryValues
public void syncHistoryValues() -
syncHistoryValues
public void syncHistoryValues(boolean resetIndex) -
setHistoryValues
sort es by index,- Parameters:
es- entries from another prefs
-
getHistoryValueUnusedKeyIndex
public int getHistoryValueUnusedKeyIndex() -
overwriteByAnotherPrefs
-
overwriteToEmpty
public void overwriteToEmpty() -
load
public void load() -
loadNodes
-
getHistoryValues
loaded history values- the size of the list is up to
historyValueLimit - all entries have valid indices, !=-1, ordered, but might not start from 0
- can be sorted by indices; the larger indices are recent entries
- their keyIndex are meaningless, just unique key for node
- Returns:
- loaded history-values
- the size of the list is up to
-
getHistoryValue
- Parameters:
value- the entry value (raw-object)- Returns:
- a new entry (keyIndex == -1),
an existing entry (index!=-1; removed from
historyValues), or an existing free entry (index==-1; removed fromhistoryValuesFree); the value is set to JSON of the given value; the obtained entry is temporarly not parted in both historyValues and historyValuesFree.
-
getHistoryValueForStoredValue
-
getHistoryValueFree
- Returns:
- a new entry (keyIndex == -1),
an existing entry (index!=-1; removed from
historyValues), or an existing free entry (index==-1; removed fromhistoryValuesFree); the obtained entry is temporarly not parted in both historyValues and historyValuesFree.
-
getHistoryValuesFree
-
loadHistoryValues
public void loadHistoryValues()load or create historyValues: it's size becomes up to historyValueLimit and sorted by index. The new entries have -1 indices. -
createHistoryValuesByLoad
-
createHistoryValueEntry
-
clearAll
public void clearAll()after calling the method, the preferences will be invalidated -
clearHistoriesTree
public void clearHistoriesTree() -
clearHistoriesTree
public void clearHistoriesTree(boolean clearPrefs) -
clearHistories
public void clearHistories() -
removeHistories
-
notifyStoreChange
-
notifyStoreChange
-
getStoreChangeListeners
-
addStoreChangeListener
-
removeStoreChangeListener
-
toJson
-
copyOnMemoryAsRoot
-
copyOnMemory
- Parameters:
parent- the parent which is already an on-memory instance or null- Returns:
- the copied preferences whose value-store is a
GuiPreferences.GuiValueStoreOnMemory
-
copyOnMemoryStore
public static GuiPreferences.GuiValueStore copyOnMemoryStore(GuiPreferences src, GuiPreferences prefs, GuiPreferences.GuiValueStore store, boolean putToParent) -
fromJson
-
fromJsonChildNodes
-