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 ofGuiReprObjectPane
(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 class
a subclass of prefs for custom usage with supplying specific sub-paths.static class
the abstract definition of key-value store.static class
the concrete implementation of the store byPreferences
static class
static class
an on-memory impl.static class
an entry of the value history, consisting of a value, an index and a time-stamp, associated with a key-index.static class
JSON entry for JSON support objectstatic class
an on-memory impl.static interface
the interface for supporting user-defined prefs: a context-object that implements the interface always saves/loads prefs via the interface.static class
the entire lock object for the preferencesstatic interface
static enum
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Map
<GuiMappingContext, GuiPreferences> protected GuiMappingContext
protected int
protected List
<GuiPreferences.HistoryValueEntry> protected List
<GuiPreferences.HistoryValueEntry> static final String
the key forgetCurrentValue()
static final String
the key for the defaultGuiPreferences
node under the rootstatic final String
the key for the history node containingGuiPreferences.HistoryValueEntry
underGuiPreferences
static final String
the key for the int index ofGuiPreferences.HistoryValueEntry
static final String
the key for the stringInstant
value ofGuiPreferences.HistoryValueEntry
static final String
the key for the JSON string value ofGuiPreferences.HistoryValueEntry
static final String
the key for the string uuid refering a savedGuiPreferences
under the rootstatic final String
the key for the string name ofGuiPreferences
static final String
the key for saved node containing sub-nodes ofGuiPreferences
under the rootstatic final String
the key for the string UUID ofGuiPreferences
protected GuiPreferences.PreferencesLock
protected GuiPreferences
protected GuiPreferences.GuiValueStore
-
Constructor Summary
ConstructorsConstructorDescriptionGuiPreferences
(GuiMappingContext context) GuiPreferences
(GuiPreferences.GuiValueStore valueStore, GuiMappingContext context) GuiPreferences
(GuiPreferences parent, GuiMappingContext context) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addHistoryValue
(Object value) add a value to the history.void
addHistoryValue
(Object value, Instant optionalTime) void
void
clearAll()
after calling the method, the preferences will be invalidatedvoid
void
void
clearHistoriesTree
(boolean clearPrefs) copyOnMemory
(GuiPreferences parent) static GuiPreferences.GuiValueStore
copyOnMemoryStore
(GuiPreferences src, GuiPreferences prefs, GuiPreferences.GuiValueStore store, boolean putToParent) createHistoryValueEntry
(Object value) protected List
<GuiPreferences.HistoryValueEntry> void
protected void
fromJsonChildNodes
(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.HistoryValueEntry
int
loaded history values the size of the list is up tohistoryValueLimit
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 nodeint
getName()
"$default/" ...static int
boolean
void
load()
void
load or create historyValues: it's size becomes up to historyValueLimit and sorted by index.protected void
loadNodes
(GuiPreferences.GuiValueStore store, Collection<String> keys) lock()
void
notifyStoreChange
(String key, Object value) void
notifyStoreChange
(GuiPreferences preferences, String key, Object value) void
void
void
removeHistories
(Collection<GuiPreferences.HistoryValueEntry> loadedValuesRemoved) void
void
protected void
setChild
(GuiMappingContext context, GuiPreferences child) void
setCurrentValue
(Object value) void
saves the given JSON as a prefs entryvoid
sort es by index,void
setLaunchPrefsAsRoot
(String uuid) void
void
syncHistoryValues
(boolean resetIndex) toJson()
static String
toStoreKey
(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 defaultGuiPreferences
node under the root- See Also:
-
KEY_CURRENT_VALUE
the key forgetCurrentValue()
- See Also:
-
KEY_LAUNCH_PREFS
the key for the string uuid refering a savedGuiPreferences
under the root- See Also:
-
KEY_SAVED
the key for saved node containing sub-nodes ofGuiPreferences
under 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.HistoryValueEntry
underGuiPreferences
- 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 stringInstant
value 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
-