GuiTypeElement and GuiRepresentation.
The tree constructs an abstract GUI representation of an object tree (like HTML DOM tree).
First, an instance of this class is created with a GuiTypeElement tree of a target object:
GuiMappingContext(GuiTypeElement).
The type-element tree can be obtained by GuiTypeBuilder.
Second, GuiReprSet receives the unmapped context object, and constructs subtrees.
The subtrees are created by using createChildCandidates() and
matched with GuiReprSet.match(GuiMappingContext).
The only matched sub-context becomes an actual child of a context by addToParent().
Also, if matched, the context becomes to have a GuiRepresentation.
The entry point of construction can be the match method of GuiRepresentation.getDefaultSet().
Third, concrete entities of GuiRepresentations, like GuiSwingView, can create concrete GUI components.
Then the components can compute updating of their displays by using retained mapped objects and listeners,
which can be obtained by getSource() and getListeners().
- a GUI component can call
updateSourceFromRoot(GuiMappingContext)with passing an associated context. Note,updateSourceFromRoot()) is the no-source version and can be used for obtaining initial values. -
The method obtains the root context by
getRoot(), -
and traverses the tree and collects updated contexts, by
collectUpdatedSource(GuiMappingContext, List). -
GuiRepresentation.checkAndUpdateSource(GuiMappingContext)do the actual computation of checking the update. -
After that,
GuiMappingContext.SourceUpdateListener.update(GuiMappingContext, Object, GuiTaskClock)of each updated context will be called.
getType...(), isType...() check and obtain typeElement as a specified type.
isParent...() check the type of the parent.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classa task wrapper forGuiMappingContext.ContextExecutorServiceForkJoin, which enables to interrupt tasks byGuiMappingContext.ContextExecutorForkJoinTask.cancel(boolean)static interfacea sub-set ofExecutorServiceas the returned type ofgetTaskRunner()static classaForkJoinPoolbased executor: the fork-join pool have ability of work-stealing: i.e.static classexecutor-service without creating threads for tasksstatic classDeprecated.static classa runnable callback passed to the target object.static classa task for update propagation.static classthe task future without threadstatic classsource value held by a context.static final classnothing of source value, can be obtained byNO_SOURCEstatic final classconcrete source valuestatic interfacecalled fromupdateSourceFromRoot(GuiMappingContext)andupdateSourceSubTree(). -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected List<GuiMappingContext> protected GuiTaskClockprotected ScheduledTaskRunner<GuiMappingContext.DelayedTask> protected Stringprotected Stringprotected List<GuiMappingContext.SourceUpdateListener> static final GuiMappingContext.GuiSourceValueNoneprotected GuiMappingContextprotected GuiPreferencesprotected GuiRepresentationprotected GuiMappingContext.GuiSourceValueprotected GuiMappingContext.ContextExecutorServicestatic booleanflag for changing the type oftaskRunner: the default is false and thenGuiMappingContext.ContextExecutorServiceForkJoinis used.protected GuiTypeElement -
Constructor Summary
ConstructorsConstructorDescriptionGuiMappingContext(GuiTypeElement typeElement) GuiMappingContext(GuiTypeElement typeElement, Object source) GuiMappingContext(GuiTypeElement typeElement, GuiMappingContext parent) GuiMappingContext(GuiTypeElement typeElement, GuiRepresentation representation) GuiMappingContext(GuiTypeElement typeElement, GuiRepresentation representation, Object source) GuiMappingContext(GuiTypeElement typeElement, GuiRepresentation representation, GuiMappingContext parent, GuiMappingContext.GuiSourceValue source) -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidvoidvoidvoidcollectUpdatedSource(GuiMappingContext cause, List<GuiMappingContext> updated) recursively callGuiRepresentation.checkAndUpdateSource(GuiMappingContext): the checkAndUpdateSource invokes the getter of the target source object in order to update the value.createChildCandidate(GuiTypeElement typeElement) voiderrorWhileJson(Throwable error) voiderrorWhileUpdateSource(Throwable error) notify toGuiLogManager<T> Trun the task.voidexecuteAction(GuiReprValue.ObjectSpecifier targetSpecifier) execute the associated action throughGuiReprAction(can be checked byisReprAction()) otherwise throw an exception.getChildByName(String name) task runner for deferring frequent events and dispatching with accumulated eventsgetName()getNotifierForTarget(boolean fromRoot) getRoot()Class<?> Class<?> getValue(GuiReprValue.ObjectSpecifier specifier) booleanbooleanbooleanisHistoryValueStored(Object value) booleanstatic booleanisNameCharUpper(char c, int i, int len, String name, boolean forDisplay) static booleanisNameSeparator(char c) booleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanbooleannameJoinForDisplay(List<String> words) split a name to a list of words by camel case.voidvoidvoidsetNotifier(Object target, GuiTypeMemberPropertyNotifier notifier) set notifier to the target member of the target object, determined from the parameter of the annotationvoidsetNotifiers(Object target) set appropriate notifiers to the target if definedvoidsetPreferences(GuiPreferences preferences) voidsetRepresentation(GuiRepresentation representation) voidonly set the source valuevoidshutdown()callshutdownTaskRunner()and also close the target if the target is anAutoCloseablevoidprotected voidvoidprotected voidtoString()voidupdateSourceFromGui(Object newValue) set the source to newValue, callupdateSourceFromRoot(GuiMappingContext)starting with this.voidvoidupdateSourceFromRoot(GuiMappingContext)with the null causevoidobtains the root context, recursively collect updated sub-contexts from the root, and call listeners with each updated context.voidrecursively collect updated sub-contexts from this and call listeners
-
Field Details
-
typeElement
-
representation
-
parent
-
children
-
source
-
listeners
-
taskRunner
-
preferences
-
delayedTaskRunner
-
displayName
-
iconName
-
contextClock
-
NO_SOURCE
-
taskRunnerSingleThread
public static boolean taskRunnerSingleThreadflag for changing the type oftaskRunner: the default is false and thenGuiMappingContext.ContextExecutorServiceForkJoinis used. If the flag is set to true before the first call ofgetTaskRunner(), thenGuiMappingContext.ContextExecutorServiceNoThreadis used.- Since:
- 1.2
-
-
Constructor Details
-
GuiMappingContext
-
GuiMappingContext
-
GuiMappingContext
-
GuiMappingContext
public GuiMappingContext(GuiTypeElement typeElement, GuiRepresentation representation, Object source) -
GuiMappingContext
-
GuiMappingContext
public GuiMappingContext(GuiTypeElement typeElement, GuiRepresentation representation, GuiMappingContext parent, GuiMappingContext.GuiSourceValue source)
-
-
Method Details
-
getContextClock
-
setRepresentation
-
getTypeElement
-
getRepresentation
-
getChildren
-
getParent
-
createChildCandidates
-
getChildrenForAdding
-
createChildCandidate
-
addToParent
public void addToParent() -
isRecursive
public boolean isRecursive() -
getRoot
-
hasParent
public boolean hasParent() -
getName
- Returns:
- the name of
typeElement
-
getDescription
-
getAcceleratorKeyStroke
-
isAcceleratorKeyStrokeSpecified
public boolean isAcceleratorKeyStrokeSpecified() -
isTypeElementProperty
public boolean isTypeElementProperty() -
getTypeElementPropertyTypeAsClass
-
isTypeElementAction
public boolean isTypeElementAction() -
isTypeElementActionList
public boolean isTypeElementActionList() -
isTypeElementObject
public boolean isTypeElementObject() -
isTypeElementValue
public boolean isTypeElementValue()- Returns:
- includes
GuiTypeObjectandGuiTypeCollectionwhich are subtypes ofGuiTypeValue
-
isTypeElementCollection
public boolean isTypeElementCollection() -
getTypeElementValueAsClass
-
getTypeElementAsProperty
-
getTypeElementAsAction
-
getTypeElementAsActionList
-
getTypeElementCollection
-
getTypeElementValue
-
getTypeElementObject
- Returns:
- typeElement as type-object
- Since:
- 1.2
-
setSource
only set the source value- Parameters:
source- the source
-
getSource
- Returns:
- actual value of the context
-
addSourceUpdateListener
-
removeSourceUpdateListener
-
getListeners
-
updateSourceFromGui
set the source to newValue, callupdateSourceFromRoot(GuiMappingContext)starting with this. Note: the method does not update any properties of parent or other source objects The clock is already set.- Parameters:
newValue- the new source value to be set
-
updateSourceFromGuiByThisDelayed
public void updateSourceFromGuiByThisDelayed() -
updateSourceFromRoot
public void updateSourceFromRoot()updateSourceFromRoot(GuiMappingContext)with the null cause -
updateSourceFromRoot
obtains the root context, recursively collect updated sub-contexts from the root, and call listeners with each updated context.- Parameters:
cause- the cause of the updating process, and the process avoids to update the context.
-
sendUpdateToListeners
-
clearSourceSubTree
public void clearSourceSubTree() -
updateSourceSubTree
public void updateSourceSubTree()recursively collect updated sub-contexts from this and call listeners -
collectUpdatedSource
recursively callGuiRepresentation.checkAndUpdateSource(GuiMappingContext): the checkAndUpdateSource invokes the getter of the target source object in order to update the value.the recursion can be controlled by
GuiRepresentation.continueCheckAndUpdateSourceForChildren(GuiMappingContext, boolean): this is used for avoiding recursion of list elements.the method alone does not cause GUI updates because of no listener calls
- Parameters:
cause- the cause contextupdated- the list which the updated contexts will be added
-
getDisplayName
- Returns:
- space separated words from the camel-case context name e.g. "myPropName" -> "My Prop Name"
-
getIconName
- Returns:
- the top word of the split name, which is an action verb in most cases: e.g. "getProp" -> "get"
-
nameJoinForDisplay
-
nameSplit
split a name to a list of words by camel case.- Parameters:
name- the split nameforDisplay- if true,"helloWorld" => ["hello", "World"] "HelloWorld" => ["Hello", "World"] "helloWORLD" => ["hello", "WORLD"] "HELLOWorld" => ["HELLO", "World"] "" => [""]
- Returns:
- the split list, never null
If
forDisplay=false, "MYName" => ["M", "Y", "Name"]
-
isNameCharUpper
-
isNameSeparator
public static boolean isNameSeparator(char c) -
errorWhileUpdateSource
notify toGuiLogManager- Parameters:
error- the reported error
-
errorWhileJson
-
isParentPropertyPane
public boolean isParentPropertyPane() -
getParentRepresentation
-
getParentPropertyPane
-
isParentValuePane
public boolean isParentValuePane() -
isReprValue
public boolean isReprValue() -
getReprValue
-
getParentValuePane
-
getParentCollectionTable
-
getParentCollectionElement
-
getParentSource
-
isReprAction
public boolean isReprAction() -
isReprActionList
public boolean isReprActionList() -
getReprAction
-
getReprActionList
-
isParentCollectionTable
public boolean isParentCollectionTable() -
isReprCollectionTable
public boolean isReprCollectionTable() -
getReprCollectionTable
-
isParentCollectionElement
public boolean isParentCollectionElement() -
isReprCollectionElement
public boolean isReprCollectionElement() -
getReprCollectionElement
-
isHistoryValueSupported
public boolean isHistoryValueSupported() -
isHistoryValueStored
-
getTaskRunner
- Returns:
- taskRunner taken from parent context or single thread executor in the root.
- See Also:
-
shutdown
public void shutdown()callshutdownTaskRunner()and also close the target if the target is anAutoCloseable -
shutdownAutoCloseable
public void shutdownAutoCloseable() -
shutdownAutoCloseableSubTree
protected void shutdownAutoCloseableSubTree() -
shutdownTaskRunner
public void shutdownTaskRunner() -
shutdownTaskRunnerSubTree
protected void shutdownTaskRunnerSubTree() -
execute
run the task. used for wrapping tasks that execute type-element's actions- Type Parameters:
T- the returned type- Parameters:
task- the task to be executed- Returns:
- the returned value of the task
- Throws:
Throwable- an exception from the task
-
getDelayedTaskRunner
task runner for deferring frequent events and dispatching with accumulated events- Returns:
- the runner created as a root or obtained from the parent
-
executeAccumulated
-
getPreferences
- Returns:
- obtains from the parent. a preference object occasionally cleared from the parent context. so it does not recommend to hold the returned instance.
-
clearPreferences
public void clearPreferences() -
setPreferences
-
toString
-
getChildByName
- Parameters:
name- the name- Returns:
- a child whose name is the name
-
getValue
- Parameters:
specifier- the specifier for the value- Returns:
- get current value of the associated property
obtaining through
GuiReprValue(can be checked byisReprValue()) from current value of the parent.
-
executeAction
execute the associated action throughGuiReprAction(can be checked byisReprAction()) otherwise throw an exception. the method causes same effects by GUI operation, i.e. updating other components.- Parameters:
targetSpecifier- the specifier for the target object- Returns:
- result of execution
-
setNotifiers
set appropriate notifiers to the target if defined- Parameters:
target- the target object obtained from the source of the context. nullable- Since:
- 1.2
-
setNotifier
set notifier to the target member of the target object, determined from the parameter of the annotation- Parameters:
target- the target object obtained from the source of the contextnotifier- the notifier property- Since:
- 1.2
-
getNotifierForTarget
- Parameters:
fromRoot- true if the entire pane of the context- Returns:
- a
GuiMappingContext.ContextNotifier - Since:
- 1.2
-