Package com.hybris.cockpitng.common
Class EditorBuilder
- java.lang.Object
-
- com.hybris.cockpitng.common.EditorBuilder
-
public class EditorBuilder extends java.lang.ObjectBuilder class to help creating and configuringEditorcomponents
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classEditorBuilder.AbstractConditional<ELEMENT>static interfaceEditorBuilder.Conditional<ELEMENT>Defines builder configuration depending on conditionprotected classEditorBuilder.EditorBuilderConditionalprotected classEditorBuilder.EditorConditional
-
Constructor Summary
Constructors Constructor Description EditorBuilder(Editor editor, EditorConfigurator editorConfigurator)EditorBuilder(EditorContext<?> editorContext)Creates new builder basing on provided editor's context.EditorBuilder(WidgetInstanceManager widgetInstanceManager)Creates new builder forEditorthat will work with provided widget.EditorBuilder(WidgetInstanceManager widgetInstanceManager, DataAttribute genericAttribute, java.lang.String referencedModelProperty)Deprecated, for removal: This API element is subject to removal in a future version.since 6.7, use instead:configure(DataAttribute),setconfigure(String, DataAttribute)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description EditorBuilderaddParameter(java.lang.String parameter, java.lang.Object value)Adds a parameter to editor's context.<V> EditorBuilderaddParameters(java.util.Map<java.lang.String,V> parameters)Adds parameters to editor's context.<ELEMENT> EditorBuilderaddParameters(java.util.stream.Stream<ELEMENT> stream, java.util.function.Function<ELEMENT,java.lang.String> keySupplier, java.util.function.Function<ELEMENT,java.lang.Object> valueSupplier)Adds a parameter to editor's context.EditorBuilderappendSClass(java.lang.String sclass)Adds a CSS class to editor component.EditorBuilderapply(java.util.function.Consumer<Editor> configuration)Allows any modification of editor to be applied before it is initialized.EditorBuilderattach(java.lang.Object item, java.lang.String qualifier)Configures editor in the way that it may be used to manipulate with values of specified attribute.EditorBuilderattach(java.lang.String qualifier)Configures editor in the way that it may be used to manipulate with values of specified attribute.Editorbuild()Builds editor componentEditorbuildNotInitialized()Deprecated, for removal: This API element is subject to removal in a future version.since 6.7, please create an instance manually and useEditorConfiguratorinsteadEditorBuilderconfigure(DataAttribute attribute)Configures component to use default behavior for specified attributeEditorBuilderconfigure(DataType dataType)Configures component to use default behavior for specified type.EditorBuilderconfigure(java.lang.String itemKey, DataAttribute attribute)Configures component to use default behavior for specified attribute of itemEditorBuilderconfigure(java.lang.String itemKey, DataAttribute attribute, boolean editorValueDetached)EditorBuilderconfigure(java.lang.String itemKey, java.lang.String qualifier)Configures component to use default behavior for specified attribute of itemEditorBuilderenableValidation(ValidatableContainer container)Configures validation for editor.EditorBuilderenableValidation(java.lang.String modelKey, java.lang.String qualifier, ValidatableContainer container)Deprecated.useenableValidation(ValidatableContainer)insteadprotected ObjectFacadegetObjectFacade()protected PermissionFacadegetPermissionFacade()protected TypeFacadegetTypeFacade()WidgetInstanceManagergetWidgetInstanceManager()EditorBuilder.Conditional<Editor>ifTrue(boolean test)Allows conditional modification of editor before it is initialized using flow programming.EditorBuildersetDescription(java.lang.String description)Some editors are capable of decorating editor component with proper description (i.e.EditorBuildersetEditor(java.lang.String editorType)Deprecated, for removal: This API element is subject to removal in a future version.since 6.7, use #useEditor(String)insteadEditorBuildersetEditorRegistry(EditorRegistry editorRegistry)EditorBuildersetEditorType(java.lang.String editorType)Deprecated, for removal: This API element is subject to removal in a future version.since 6.7, useuseEditor(String)insteadEditorBuildersetGroup(java.lang.String groupName)Sets a name of editors group, that configured one belongs to.EditorBuildersetLabel(java.lang.String label)Some editors are capable of decorating editor component with proper label (i.e.EditorBuildersetLabelService(LabelService labelService)EditorBuildersetMultilingual(boolean multilingual)Configures editor in context of allowing providing localized values in regards to specified flag.EditorBuildersetMultilingual(boolean multilingual, java.lang.Object item)Configures editor in context of allowing providing localized values in regards to specified flag.EditorBuildersetObjectFacade(ObjectFacade objectFacade)EditorBuildersetOptional(boolean optional)Informs whether editor value should be mandatory.EditorBuildersetPermissionFacade(PermissionFacade permissionFacade)EditorBuildersetReadOnly(boolean readOnly)Informs whether editor value should work in read-only mode.EditorBuildersetReferenceModelProperties(ReferenceModelProperties referenceModelProperties)EditorBuildersetSingleValued()Changes all multivalued editors into single-valued - i.e.EditorBuildersetTypeFacade(TypeFacade typeFacade)EditorBuildersetValue(java.lang.Object value)Initializes editor component with provided value.EditorBuildersetValueCreationEnabled(boolean enabled)Some editors allows creation new values (i.e.EditorBuildersetValueType(java.lang.String valueType)Sets an encoded type of value that editor is supposed to provide (i.e.EditorBuilderuseDefaultEditor()Updates editor definition to be used basing on value typeEditorBuilderuseEditor(java.lang.String editorType)Explicitly defines which editor definition should be used by componentEditorBuilder.Conditional<EditorBuilder>when(boolean test)Allows conditional builder configuration using flow programming.
-
-
-
Constructor Detail
-
EditorBuilder
public EditorBuilder(WidgetInstanceManager widgetInstanceManager)
Creates new builder forEditorthat will work with provided widget.Specific implementations of facades may be provided.
- Parameters:
widgetInstanceManager- editor manager of widget with which editor is supposed to work
-
EditorBuilder
public EditorBuilder(Editor editor, EditorConfigurator editorConfigurator)
-
EditorBuilder
public EditorBuilder(EditorContext<?> editorContext)
Creates new builder basing on provided editor's context.- Parameters:
editorContext- base editor context
-
EditorBuilder
@Deprecated(since="6.7", forRemoval=true) public EditorBuilder(WidgetInstanceManager widgetInstanceManager, DataAttribute genericAttribute, java.lang.String referencedModelProperty)Deprecated, for removal: This API element is subject to removal in a future version.since 6.7, use instead:configure(DataAttribute),setconfigure(String, DataAttribute)
-
-
Method Detail
-
getTypeFacade
protected TypeFacade getTypeFacade()
-
setTypeFacade
public EditorBuilder setTypeFacade(TypeFacade typeFacade)
-
getPermissionFacade
protected PermissionFacade getPermissionFacade()
-
setPermissionFacade
public EditorBuilder setPermissionFacade(PermissionFacade permissionFacade)
-
getObjectFacade
protected ObjectFacade getObjectFacade()
-
setObjectFacade
public EditorBuilder setObjectFacade(ObjectFacade objectFacade)
-
setReferenceModelProperties
public EditorBuilder setReferenceModelProperties(ReferenceModelProperties referenceModelProperties)
-
setEditorRegistry
public EditorBuilder setEditorRegistry(EditorRegistry editorRegistry)
-
setLabelService
public EditorBuilder setLabelService(LabelService labelService)
-
getWidgetInstanceManager
public WidgetInstanceManager getWidgetInstanceManager()
- Returns:
- editor manager of widget with which editor is supposed to work
-
buildNotInitialized
@Deprecated(since="6.7", forRemoval=true) public Editor buildNotInitialized()Deprecated, for removal: This API element is subject to removal in a future version.since 6.7, please create an instance manually and useEditorConfiguratorinsteadBuilds editor component without initializing it. Initialization (Editor.initialize()should be performed before using Editor.- Returns:
- configured but not initialized
Editor - See Also:
EditorConfigurator
-
apply
public EditorBuilder apply(java.util.function.Consumer<Editor> configuration)
Allows any modification of editor to be applied before it is initialized.- Parameters:
configuration- a function configuring editor- Returns:
- builder for further settings
-
ifTrue
public EditorBuilder.Conditional<Editor> ifTrue(boolean test)
Allows conditional modification of editor before it is initialized using flow programming.- Parameters:
test- condition to be met for modification to be applied- Returns:
- an object that defines modification depending on condition
-
when
public EditorBuilder.Conditional<EditorBuilder> when(boolean test)
Allows conditional builder configuration using flow programming.- Parameters:
test- condition to be met for configuration to be applied- Returns:
- an object that defines configuration depending on condition
-
configure
public EditorBuilder configure(DataAttribute attribute)
Configures component to use default behavior for specified attribute- Parameters:
attribute- attribute to be manipulated by editor- Returns:
- builder for further settings
- See Also:
configure(String, String),configure(String, DataAttribute)
-
configure
public EditorBuilder configure(java.lang.String itemKey, DataAttribute attribute)
Configures component to use default behavior for specified attribute of item- Parameters:
itemKey- model value key under which a manipulated item may be foundattribute- attribute to be manipulated by editor- Returns:
- builder for further settings
- See Also:
configure(String, String)
-
configure
public EditorBuilder configure(java.lang.String itemKey, DataAttribute attribute, boolean editorValueDetached)
-
configure
public EditorBuilder configure(java.lang.String itemKey, java.lang.String qualifier)
Configures component to use default behavior for specified attribute of item- Parameters:
itemKey- model value key under which a manipulated item may be foundqualifier- qualifier of attribute to be manipulated by editor- Returns:
- builder for further settings
- See Also:
configure(String, DataAttribute)
-
configure
public EditorBuilder configure(DataType dataType)
Configures component to use default behavior for specified type.Method should be used, if editor is not supposed to manipulate with any item, rather to provide a value of specified type.
- Parameters:
dataType- type of value to be provided by editor- Returns:
- builder for further settings
- See Also:
configure(String, DataAttribute),configure(String, String)
-
attach
public EditorBuilder attach(java.lang.String qualifier)
Configures editor in the way that it may be used to manipulate with values of specified attribute.- Parameters:
qualifier- qualifier of attribute which values will be changed by editor- Returns:
- builder for further settings
-
attach
public EditorBuilder attach(java.lang.Object item, java.lang.String qualifier)
Configures editor in the way that it may be used to manipulate with values of specified attribute.- Parameters:
item- item which attribute is to be manipulatedqualifier- qualifier of attribute which values will be changed by editor- Returns:
- builder for further settings
-
addParameter
public EditorBuilder addParameter(java.lang.String parameter, java.lang.Object value)
Adds a parameter to editor's context.- Parameters:
parameter- parameter's namevalue- parameters's value- Returns:
- builder for further settings
-
addParameters
public <V> EditorBuilder addParameters(java.util.Map<java.lang.String,V> parameters)
Adds parameters to editor's context.- Parameters:
parameters- parameters to be added- Returns:
- builder for further settings
-
addParameters
public <ELEMENT> EditorBuilder addParameters(java.util.stream.Stream<ELEMENT> stream, java.util.function.Function<ELEMENT,java.lang.String> keySupplier, java.util.function.Function<ELEMENT,java.lang.Object> valueSupplier)
Adds a parameter to editor's context.- Parameters:
stream- stream of parameters definitionskeySupplier- a supplier to provide parameter name out of definitionvalueSupplier- a supplier to provide parameter value out of definition- Returns:
- builder for further settings
-
setSingleValued
public EditorBuilder setSingleValued()
Changes all multivalued editors into single-valued - i.e. localized editors should allow providing values only for a single language, multi-reference editors should allow providing only single reference, etc.- Returns:
- builder to continue configuration of editor
-
setReadOnly
public EditorBuilder setReadOnly(boolean readOnly)
Informs whether editor value should work in read-only mode.- Parameters:
readOnly-trueif value should work in read-only mode.- Returns:
- builder to continue configuration of editor
-
setMultilingual
public EditorBuilder setMultilingual(boolean multilingual)
Configures editor in context of allowing providing localized values in regards to specified flag.- Parameters:
multilingual-trueif editor should allow localized values,falseotherwise- Returns:
- builder to continue configuration of editor
- See Also:
setMultilingual(boolean, Object)
-
setMultilingual
public EditorBuilder setMultilingual(boolean multilingual, java.lang.Object item)
Configures editor in context of allowing providing localized values in regards to specified flag.- Parameters:
item- item which attribute will be manipulated with editormultilingual-trueif editor should allow localized values,falseotherwise- Returns:
- builder to continue configuration of editor
-
setOptional
public EditorBuilder setOptional(boolean optional)
Informs whether editor value should be mandatory.- Parameters:
optional-trueif value should not be mandatory- Returns:
- builder to continue configuration of editor
-
setValue
public EditorBuilder setValue(java.lang.Object value)
Initializes editor component with provided value.- Parameters:
value- value to be displayed initially- Returns:
- builder to continue configuration of editor
-
setValueType
public EditorBuilder setValueType(java.lang.String valueType)
Sets an encoded type of value that editor is supposed to provide (i.e. LIST(Product))Editor type is not updated in this method!
- Parameters:
valueType- encoded value type- Returns:
- builder to continue configuration of editor
- See Also:
useEditor(String)
-
setEditorType
@Deprecated(since="6.7", forRemoval=true) public EditorBuilder setEditorType(java.lang.String editorType)Deprecated, for removal: This API element is subject to removal in a future version.since 6.7, useuseEditor(String)instead
-
useEditor
public EditorBuilder useEditor(java.lang.String editorType)
Explicitly defines which editor definition should be used by component- Parameters:
editorType- editor definition id- Returns:
- builder to continue configuration of editor
- See Also:
setValueType(String)
-
useDefaultEditor
public EditorBuilder useDefaultEditor()
Updates editor definition to be used basing on value type- Returns:
- builder to continue configuration of editor
- See Also:
setValueType(String)
-
setEditor
@Deprecated(since="6.7", forRemoval=true) public EditorBuilder setEditor(java.lang.String editorType)Deprecated, for removal: This API element is subject to removal in a future version.since 6.7, use #useEditor(String)insteadConfigures which editor should be used - either specified or default one.- Parameters:
editorType- editor to be used ornullfor default- Returns:
- builder to continue configuration of editor
-
setValueCreationEnabled
public EditorBuilder setValueCreationEnabled(boolean enabled)
Some editors allows creation new values (i.e. new items to be referenced). This method allows setting whether such possibility should be available.- Parameters:
enabled-trueif value creation should be possible- Returns:
- builder to continue configuration of editor
-
appendSClass
public EditorBuilder appendSClass(java.lang.String sclass)
Adds a CSS class to editor component.- Parameters:
sclass- name of CSS class to be added- Returns:
- builder to continue configuration of editor
-
setLabel
public EditorBuilder setLabel(java.lang.String label)
Some editors are capable of decorating editor component with proper label (i.e. localized editors). Please provide proper label to make it possible.- Parameters:
label- label to be used- Returns:
- builder to continue configuration of editor
-
setGroup
public EditorBuilder setGroup(java.lang.String groupName)
Sets a name of editors group, that configured one belongs to. A name of group is then passed directly to editor.- Parameters:
groupName- name of group that contains configured editor
-
setDescription
public EditorBuilder setDescription(java.lang.String description)
Some editors are capable of decorating editor component with proper description (i.e. localized editors). Please provide proper text to make it possible.- Parameters:
description- description to be used- Returns:
- builder to continue configuration of editor
-
enableValidation
@Deprecated(since="20.05") public EditorBuilder enableValidation(java.lang.String modelKey, java.lang.String qualifier, ValidatableContainer container)
Deprecated.useenableValidation(ValidatableContainer)insteadConfigures validation for editor.- Parameters:
modelKey- name of widget model value under which an item may be found, which attribute will be changed by editorqualifier- qualifier of attribute which values will be changed by editorcontainer- validatable container- Returns:
- builder to continue configuration of editor
-
enableValidation
public EditorBuilder enableValidation(ValidatableContainer container)
Configures validation for editor.- Parameters:
container- validatable container- Returns:
- builder to continue configuration of editor
-
-