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 classan undoable insertion operation forGuiReprValueDocumentEditor.StringBuilderContentstatic classa position implementation with an offsetstatic classan undoable removing operation forGuiReprValueDocumentEditor.StringBuilderContentstatic classa styled-document impl.static interfacea functional interface used inGuiReprValueDocumentEditor.StringBuilderContentstatic classa content forStringBuilder: wraps a buffer and manages any changes to the buffer.static classa saved position forGuiReprValueDocumentEditor.ContentPosition.Nested classes/interfaces inherited from class org.autogui.base.mapping.GuiReprValue
GuiReprValue.NamedValue, GuiReprValue.ObjectSpecifier, GuiReprValue.ObjectSpecifierIndex, GuiReprValue.ObjectSpecifierNothingNested classes/interfaces inherited from interface org.autogui.base.mapping.GuiRepresentation
GuiRepresentation.GuiReprNone, GuiRepresentation.TreeString, GuiRepresentation.TreeStringComposite, GuiRepresentation.TreeStringValue -
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 TabSetgetValue(GuiMappingContext context, GuiMappingContext.GuiSourceValue parentSource, GuiReprValue.ObjectSpecifier specifier, GuiMappingContext.GuiSourceValue prev) obtain the property value from parentSource as an owner.booleanisHistoryValueStored(Object value) booleanisStyledDocument(GuiMappingContext context) booleanisTaskRunnerUsedFor(Supplier<?> task) booleanmatchValueType(Class<?> cls) voidsetSource(GuiMappingContext context, Object value) static booleansetupStyle(Style style) static voidsetupStyle(StyledDocument doc) toHumanReadableStringTree(GuiMappingContext context, Object source) toJson(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 propertyGuiReprPropertyPaneor 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, updateWithParentSourceMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.autogui.base.mapping.GuiRepresentation
continueCheckAndUpdateSourceForChildren, fromJsonWithNamed, isJsonSetter, matchAndSetNotifiersAsInit, setNotifiersTree, shutdown, toHumanReadableString, 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:
matchValueTypein classGuiReprValue
-
getValue
public GuiUpdatedValue getValue(GuiMappingContext context, GuiMappingContext.GuiSourceValue parentSource, GuiReprValue.ObjectSpecifier specifier, GuiMappingContext.GuiSourceValue prev) throws Throwable Description copied from class:GuiReprValueobtain the property value from parentSource as an owner.In this class, support following cases:
- the type is a
GuiTypeMemberProperty - other types: use methods of
GuiTypeValuewith prev and parentSource as the inherited value
- Overrides:
getValuein 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_UPDATEif 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:GuiReprValueset 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
GuiReprPropertyPaneor 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:
updatein 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:
isHistoryValueStoredin classGuiReprValue- Parameters:
value- the tested value, or null at loading- Returns:
- if true, actually the value is stored to the preferences store
-
setSource
- Overrides:
setSourcein classGuiReprValue
-
toUpdateValue
Description copied from class:GuiReprValuecalled 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:
toUpdateValuein classGuiReprValue- Parameters:
context- the context of the repr.value- the current value- Returns:
- the updated value
-
toUpdateValue
-
toSourceValue
-
isStyledDocument
-
toJson
Description copied from interface:GuiRepresentationconvert the source into JSON format- Specified by:
toJsonin interfaceGuiRepresentation- Overrides:
toJsonin classGuiReprValue- Parameters:
context- a context holds the representationsource- the converted object- Returns:
- document text String
-
toJsonInEvent
-
toHumanReadableStringTree
public GuiRepresentation.TreeString toHumanReadableStringTree(GuiMappingContext context, Object source) - Parameters:
context- the context of the reprsource- convert to string- Returns:
- tree string of source, can be encoded by
Object.toString()(used byGuiRepresentation.toHumanReadableString(GuiMappingContext, Object)
-
fromHumanReadableString
-
fromJson
Description copied from interface:GuiRepresentationcreate 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:
fromJsonin interfaceGuiRepresentation- Overrides:
fromJsonin classGuiReprValue- Parameters:
context- a context holds the representationtarget- the target object or nulljson- JSON objects representing the targetString,Number,Boolean,List,Mapor null- Returns:
- created object from the json, target if provided, or null.
-
fromJsonInEvent
-
getTabSet
-
setupStyle
-
setupStyle
-