java.lang.Object
org.autogui.base.mapping.GuiReprValue
org.autogui.swing.mapping.GuiReprValueDocumentEditor
- All Implemented Interfaces:
GuiRepresentation
a GUI representation for a property holding
a
Document
, AbstractDocument.Content
, or a StringBuilder
.
the representation depends on some Swing classes(java.desktop module)
StyledDocument doc; @GuiIncluded public StyledDocument getDoc() { if (doc == null) { doc = new DefaultStyledDocument(); } return doc; } @GuiIncluded public StringContent content = new StringContent(); @GuiIncluded public StringBuilder builder = new StringBuilder();
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
an undoable insertion operation forGuiReprValueDocumentEditor.StringBuilderContent
static class
a position implementation with an offsetstatic class
an undoable removing operation forGuiReprValueDocumentEditor.StringBuilderContent
static class
a styled-document impl.static interface
a functional interface used inGuiReprValueDocumentEditor.StringBuilderContent
static class
a content forStringBuilder
: wraps a buffer and manages any changes to the buffer.static class
a saved position forGuiReprValueDocumentEditor.ContentPosition
.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 TypeMethodDescriptionfromHumanReadableString
(GuiMappingContext context, String str) fromJson
(GuiMappingContext context, Object target, Object json) create a new value object from the JSON with treating the target as an old value, or update the target with the JSON contents.fromJsonInEvent
(GuiMappingContext context, Object target, Object json) static TabSet
getValue
(GuiMappingContext context, GuiMappingContext.GuiSourceValue parentSource, GuiReprValue.ObjectSpecifier specifier, GuiMappingContext.GuiSourceValue prev) obtain the property value from parentSource as an owner.boolean
isHistoryValueStored
(Object value) boolean
isStyledDocument
(GuiMappingContext context) boolean
isTaskRunnerUsedFor
(Supplier<?> task) boolean
matchValueType
(Class<?> cls) void
setSource
(GuiMappingContext context, Object value) static boolean
setupStyle
(Style style) static void
setupStyle
(StyledDocument doc) toHumanReadableString
(GuiMappingContext context, Object source) method for constructing "toString" copy operations: the returned string will be separated by tabs and new-linestoJson
(GuiMappingContext context, Object source) convert the source into JSON formattoJsonInEvent
(Object source) toSourceValue
(GuiMappingContext context, Document document) toUpdateValue
(GuiMappingContext context, Object value) called from a GUI element in order to update its value.toUpdateValue
(GuiMappingContext context, Object value, Consumer<Document> 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, fromSource, fromSourceUpdated, getNoneSupplier, getParentSource, getUpdatedSource, getUpdatedValue, getUpdatedValueWithoutNoUpdate, getValueCollectionElement, getValueCollectionSize, getValueType, getValueWithoutNoUpdate, isEditable, isFromJsonTakingMapWithContextNameEntry, isHistoryValueStored, isHistoryValueSupported, isHistoryValueSupported, isUpdateContextSourceByUpdateFromGui, match, notifyUpdateWithParentSourceNone, 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, fromJsonWithNamed, isJsonSetter, matchAndSetNotifiersAsInit, setNotifiersTree, shutdown, toJsonWithNamed, toStringHeader
-
Field Details
-
tabSet
-
-
Constructor Details
-
GuiReprValueDocumentEditor
public GuiReprValueDocumentEditor()
-
-
Method Details
-
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
-
matchValueType
- Overrides:
matchValueType
in classGuiReprValue
-
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
-
isHistoryValueStored
- Overrides:
isHistoryValueStored
in classGuiReprValue
- Parameters:
value
- the tested value, or null at loading- Returns:
- if true, actually the value is stored to the preferences store
-
setSource
- Overrides:
setSource
in classGuiReprValue
-
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:
- the updated value
-
toUpdateValue
-
toSourceValue
-
isStyledDocument
-
toJson
Description copied from interface:GuiRepresentation
convert the source into JSON format- Specified by:
toJson
in interfaceGuiRepresentation
- Overrides:
toJson
in classGuiReprValue
- Parameters:
context
- a context holds the representationsource
- the converted object- Returns:
- document text String
-
toJsonInEvent
-
toHumanReadableString
Description copied from interface:GuiRepresentation
method for constructing "toString" copy operations: the returned string will be separated by tabs and new-lines- Parameters:
context
- the context of the repr.source
- converted to string- Returns:
- a string representation of the source
-
fromHumanReadableString
-
fromJson
Description copied from interface:GuiRepresentation
create a new value object from the JSON with treating the target as an old value, or update the target with the JSON contents. the behavior can be varied by each representation, confirmed byGuiRepresentation.isJsonSetter()
.- Specified by:
fromJson
in interfaceGuiRepresentation
- Overrides:
fromJson
in classGuiReprValue
- Parameters:
context
- a context holds the representationtarget
- the target object or nulljson
- JSON objects representing the targetString
,Number
,Boolean
,List
,Map
or null- Returns:
- created object from the json, target if provided, or null.
-
fromJsonInEvent
-
getTabSet
-
setupStyle
-
setupStyle
-