java.lang.Object
org.autogui.base.mapping.GuiReprValue
org.autogui.swing.mapping.GuiReprEmbeddedComponent
- All Implemented Interfaces:
GuiRepresentation
a GUI component for a property holding a
JComponent
private JComponent comp; @GuiIncluded public JComponent getComp() { if (comp == null) { comp = new JLabel("hello"); } return comp; }
the class executes obtaining and updating a target value under the event dispatching thread
via SwingDeferredRunner
.
For the case of updating from GUI,
a UI event (in the event thread) ->
executeContextTask
and it observes that isTaskRunnerUsedFor(Supplier)
returns false and directly invoke the given task
->
updateFromGui -> update ->
SwingDeferredRunner.run(SwingDeferredRunner.Task)
with super.update
(it directly invoke the task as in the event thread)
-> the method of the target object is invoked under the event thread.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
a dummy component class for representing no updating.Nested classes/interfaces inherited from class org.autogui.base.mapping.GuiReprValue
GuiReprValue.NamedValue, GuiReprValue.ObjectSpecifier, GuiReprValue.ObjectSpecifierIndex, GuiReprValue.ObjectSpecifierNothing
Nested classes/interfaces inherited from interface org.autogui.base.mapping.GuiRepresentation
GuiRepresentation.GuiReprNone
-
Field Summary
FieldsFields inherited from class org.autogui.base.mapping.GuiReprValue
NONE, NONE_WITH_CACHE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetValue
(GuiMappingContext context, GuiMappingContext.GuiSourceValue parentSource, GuiReprValue.ObjectSpecifier specifier, GuiMappingContext.GuiSourceValue prev) obtain the property value from parentSource as an owner.boolean
boolean
isTaskRunnerUsedFor
(Supplier<?> task) boolean
matchValueType
(Class<?> cls) toUpdateValue
(GuiMappingContext context, Object value) called from a GUI element in order to update its value.toUpdateValue
(GuiMappingContext context, Object value, Consumer<JComponent> delayed) update
(GuiMappingContext context, GuiMappingContext.GuiSourceValue parentSource, Object newValue, GuiReprValue.ObjectSpecifier specifier) set a new value to a property of an object, which specified by the context usingGuiMappingContext.execute(Callable)
if the type is aGuiTypeMemberProperty
, update the property byGuiTypeMemberProperty.executeSet(Object, Object)
if parent is a propertyGuiReprPropertyPane
or a collection elementGuiReprCollectionElement
, obtain the parent source of the parent, and update the parent with the source and newValue.Methods inherited from class org.autogui.base.mapping.GuiReprValue
addHistoryValue, castOrMake, checkAndUpdateSource, convertLog, createNewValue, errorWhileAddHistoryValue, fromJson, fromSource, fromSourceUpdated, getNoneSupplier, getParentSource, getUpdatedSource, getUpdatedValue, getUpdatedValueWithoutNoUpdate, getValueCollectionElement, getValueCollectionSize, getValueType, getValueWithoutNoUpdate, isEditable, isFromJsonTakingMapWithContextNameEntry, isHistoryValueStored, isHistoryValueStored, isHistoryValueSupported, isUpdateContextSourceByUpdateFromGui, match, notifyUpdateWithParentSourceNone, setSource, toJson, toParentSource, toSource, toString, unwrapNoUpdate, updateCollectionElement, updateFromGui, updateWithParentSource
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.autogui.base.mapping.GuiRepresentation
continueCheckAndUpdateSourceForChildren, fromHumanReadableString, fromJsonWithNamed, isJsonSetter, matchAndSetNotifiersAsInit, setNotifiersTree, shutdown, toHumanReadableString, toJsonWithNamed, toStringHeader
-
Field Details
-
COMPONENT_NONE
-
-
Constructor Details
-
GuiReprEmbeddedComponent
public GuiReprEmbeddedComponent()
-
-
Method Details
-
matchValueType
- Overrides:
matchValueType
in classGuiReprValue
-
isTaskRunnerUsedFor
- Parameters:
task
- the tested task- Returns:
- true if the task can be executed under the task-runner of a context. the method can be used for the cases that the task is dispatched to a custom task-runner mechanism
-
getValue
public GuiUpdatedValue getValue(GuiMappingContext context, GuiMappingContext.GuiSourceValue parentSource, GuiReprValue.ObjectSpecifier specifier, GuiMappingContext.GuiSourceValue prev) throws Throwable Description copied from class:GuiReprValue
obtain the property value from parentSource as an owner.In this class, support following cases:
- the type is a
GuiTypeMemberProperty
- other types: use methods of
GuiTypeValue
with prev and parentSource as the inherited value
- Overrides:
getValue
in classGuiReprValue
- Parameters:
context
- the context holding the repr.parentSource
- the property owner. if no value then nothing will happen for propertiesspecifier
- the specifier of the valueprev
- a previous value compared to the obtained value- Returns:
- an obtained property value (nullable) or
GuiUpdatedValue.NO_UPDATE
if the value is equivalent to the previous value. - Throws:
Throwable
- might be caused by executing method invocations.
- the type is a
-
update
public Object update(GuiMappingContext context, GuiMappingContext.GuiSourceValue parentSource, Object newValue, GuiReprValue.ObjectSpecifier specifier) Description copied from class:GuiReprValue
set a new value to a property of an object, which specified by the context- using
GuiMappingContext.execute(Callable)
- if the type is a
GuiTypeMemberProperty
, update the property byGuiTypeMemberProperty.executeSet(Object, Object)
- if parent is a property
GuiReprPropertyPane
or a collection elementGuiReprCollectionElement
, obtain the parent source of the parent, and update the parent with the source and newValue. This will be done by parent'sGuiReprValue.updateWithParentSource(GuiMappingContext, Object, ObjectSpecifier)
- otherwise call
GuiTypeValue.writeValue(Object, Object)
or a similar method
- Overrides:
update
in classGuiReprValue
- Parameters:
context
- the target contextparentSource
- the property ownernewValue
- a new value to be set to the propertyspecifier
- the specifier of the value- Returns:
- newValue which will need to be passed to
GuiMappingContext.updateSourceFromGui(Object)
, or null if error
- using
-
toUpdateValue
Description copied from class:GuiReprValue
called from a GUI element in order to update its value. subclass can change to returned type and convert the value to the type. a typical use case is just down-casting and converting null to an empty object.- Overrides:
toUpdateValue
in classGuiReprValue
- Parameters:
context
- the context of the repr.value
- the current value- Returns:
- obtains a
JComponent
value, or if the value is a deferred future, then get the done value or null if it is not completed. To support the delayed completion, usetoUpdateValue(GuiMappingContext, Object, Consumer)
instead.
-
toUpdateValue
public JComponent toUpdateValue(GuiMappingContext context, Object value, Consumer<JComponent> delayed) -
isHistoryValueSupported
public boolean isHistoryValueSupported()- Overrides:
isHistoryValueSupported
in classGuiReprValue
- Returns:
- if true,
GuiReprValue.updateFromGui(GuiMappingContext, Object, ObjectSpecifier, GuiTaskClock)
automatically add the value to the preferences. the default impl. returns true.
-