Class AbstractComponentsVisitor<C extends org.zkoss.zk.ui.Component,E extends AbstractDynamicElement>
- java.lang.Object
-
- com.hybris.cockpitng.widgets.common.dynamicforms.impl.visitors.AbstractComponentsVisitor<C,E>
-
- All Implemented Interfaces:
ComponentsVisitor
- Direct Known Subclasses:
EditorsVisitor,SectionsVisitor,TabsVisitor
public abstract class AbstractComponentsVisitor<C extends org.zkoss.zk.ui.Component,E extends AbstractDynamicElement> extends java.lang.Object implements ComponentsVisitor
Abstract Visitor ofin UI elements. Gets configuration from specific field of DynamicForms. It should be extended for specific type of component and dynamic element.
-
-
Field Summary
-
Fields inherited from interface com.hybris.cockpitng.widgets.common.dynamicforms.ComponentsVisitor
COMPONENT_CTX, MODEL_ROOT, NULL
-
-
Constructor Summary
Constructors Constructor Description AbstractComponentsVisitor()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected booleancanChangeProperty(java.lang.Object target, java.lang.String property)Check whether user has permission to change property on targetObject.protected abstract booleancanHandle(org.zkoss.zk.ui.Component component)Decides if component can be handled by the visitor.protected booleancanReadProperty(java.lang.Object target, java.lang.String property)Check whether user has permission to read property on targetObject.voidcleanUp()Removes all registered components and observers.protected voidcleanUpInternal(WidgetModel model)Removes all components references and model observers.protected abstract java.lang.StringgetComponentKey(C component)Gets component's name key which is used to map components with dynamic forms throughAbstractDynamicElement.getQualifier().protected java.util.Map<java.lang.String,java.util.Collection<C>>getComponentKeyComponentsMap()protected DataTypegetDataType()protected ScriptingConfiggetDefaultScriptingConfig()protected abstract java.util.List<E>getDynamicElements()Extracts elements of typefrom DynamicForms.protected DynamicFormsgetDynamicForms()protected java.lang.StringgetElementQualifierKey(E dynamicElement)Gets qualifier of. protected ExpressionEvaluatorgetExpressionEvaluator()protected java.lang.StringgetPathToAttributeInModel(E dynamicElement)protected java.lang.StringgetPathToAttributeInModel(E dynamicElement, java.lang.String qualifier)Adds prefix with value of modelProperty.protected PermissionFacadegetPermissionFacade()protected java.lang.ObjectgetTargetObject(E dynamicElement)Returns object on which operations should be done for passed dynamic element.java.lang.StringgetTypeCode()protected TypeFacadegetTypeFacade()protected WidgetInstanceManagergetWidgetInstanceManager()voidinitialize(java.lang.String typeCode, WidgetInstanceManager wim, DynamicForms dynamicForms)Initializes a visitor.protected booleanisDisabled(E element, java.lang.Object target)Checks configuration fromAbstractDynamicElement.disabledIfagainst target object.protected booleanisVisible(E element, java.lang.Object target)Checks configuration fromAbstractDynamicElement.visibleIfagainst target object.voidregister(org.zkoss.zk.ui.Component component)Registers a component and it's child components recursively usingComponent.getChildren()voidsetExpressionEvaluator(ExpressionEvaluator expressionEvaluator)voidsetPermissionFacade(PermissionFacade permissionFacade)voidsetTypeFacade(TypeFacade typeFacade)voidunRegister(org.zkoss.zk.ui.Component component)Unregisters a component and it's child components recursively usingComponent.getChildren()protected abstract voidvisitComponents(E dynamicElement, java.lang.Object target, boolean initial)Visits components for dynamic element.
-
-
-
Method Detail
-
initialize
public void initialize(java.lang.String typeCode, WidgetInstanceManager wim, DynamicForms dynamicForms)Description copied from interface:ComponentsVisitorInitializes a visitor. The method should be called before the first usage of the visitor (calling methodComponentsVisitor.register(Component)).- Specified by:
initializein interfaceComponentsVisitor
-
register
public void register(org.zkoss.zk.ui.Component component)
Description copied from interface:ComponentsVisitorRegisters a component and it's child components recursively usingComponent.getChildren()- Specified by:
registerin interfaceComponentsVisitor- Parameters:
component- component to register
-
unRegister
public void unRegister(org.zkoss.zk.ui.Component component)
Description copied from interface:ComponentsVisitorUnregisters a component and it's child components recursively usingComponent.getChildren()- Specified by:
unRegisterin interfaceComponentsVisitor- Parameters:
component- component to unregister
-
cleanUp
public void cleanUp()
Description copied from interface:ComponentsVisitorRemoves all registered components and observers.- Specified by:
cleanUpin interfaceComponentsVisitor
-
cleanUpInternal
protected void cleanUpInternal(WidgetModel model)
Removes all components references and model observers.- Parameters:
model-
-
canHandle
protected abstract boolean canHandle(org.zkoss.zk.ui.Component component)
Decides if component can be handled by the visitor.- Parameters:
component- component to accept.- Returns:
- true if components should be accepted by visitor.
-
getComponentKey
protected abstract java.lang.String getComponentKey(C component)
Gets component's name key which is used to map components with dynamic forms throughAbstractDynamicElement.getQualifier().- Parameters:
component- component which id should be returned.- Returns:
- extracted key of a component.
-
getDynamicElements
protected abstract java.util.List<E> getDynamicElements()
Extracts elements of typefrom DynamicForms.- Returns:
- list of
to use in configuration.
-
visitComponents
protected abstract void visitComponents(E dynamicElement, java.lang.Object target, boolean initial)
Visits components for dynamic element.- Parameters:
dynamicElement- dynamic forms element configuration.target- currently displayed object.initial- flag which says if this is initial visit before any interaction with user.
-
getElementQualifierKey
protected java.lang.String getElementQualifierKey(E dynamicElement)
Gets qualifier of. For components which getComponentKey(Component)cannot be directly mapped to aAbstractDynamicElement.getQualifier()the method should be overridden so for matching components andvalues from these two methods should be equal. - Parameters:
dynamicElement- element of which qualifier should be returned.- Returns:
- qualifier of a element.
-
isVisible
protected boolean isVisible(E element, java.lang.Object target)
Checks configuration fromAbstractDynamicElement.visibleIfagainst target object.- Parameters:
element- element of configurationtarget- target object- Returns:
- true is component should be visible
-
isDisabled
protected boolean isDisabled(E element, java.lang.Object target)
Checks configuration fromAbstractDynamicElement.disabledIfagainst target object.- Parameters:
element- element of configurationtarget- target object- Returns:
- true if component should be disabled
-
getPathToAttributeInModel
protected java.lang.String getPathToAttributeInModel(E dynamicElement)
- See Also:
where as qualifier is passed
-
getPathToAttributeInModel
protected java.lang.String getPathToAttributeInModel(E dynamicElement, java.lang.String qualifier)
Adds prefix with value of modelProperty. IfAbstractDynamicElement.getModelProperty()is not null then it is used as the prefix otherwise the prefix will beDynamicForms.getModelProperty()- Parameters:
dynamicElement- element which modelProperty is taken as a prefix: e.g. currentObject.qualifier- qualifier of an object to check in model e.g code.- Returns:
- qualifier with prefix e.g. currentObject.code .
-
getTargetObject
protected java.lang.Object getTargetObject(E dynamicElement)
Returns object on which operations should be done for passed dynamic element.- Parameters:
dynamicElement- dynamic element- Returns:
- target object if
AbstractDynamicElement.getModelProperty()orDynamicForms.getModelProperty()equalComponentsVisitor.MODEL_ROOTthen entire model is returned.
-
canChangeProperty
protected boolean canChangeProperty(java.lang.Object target, java.lang.String property)Check whether user has permission to change property on targetObject. If property equalsComponentsVisitor.MODEL_ROOTthen it is checked whether user can change targetObject
-
canReadProperty
protected boolean canReadProperty(java.lang.Object target, java.lang.String property)Check whether user has permission to read property on targetObject. If property equalsComponentsVisitor.MODEL_ROOTthen it is checked whether user can read targetObject
-
getDataType
protected final DataType getDataType()
-
getTypeCode
public java.lang.String getTypeCode()
-
getDynamicForms
protected final DynamicForms getDynamicForms()
-
getWidgetInstanceManager
protected final WidgetInstanceManager getWidgetInstanceManager()
-
getComponentKeyComponentsMap
protected final java.util.Map<java.lang.String,java.util.Collection<C>> getComponentKeyComponentsMap()
-
getExpressionEvaluator
protected final ExpressionEvaluator getExpressionEvaluator()
-
getPermissionFacade
protected final PermissionFacade getPermissionFacade()
-
getTypeFacade
protected final TypeFacade getTypeFacade()
-
getDefaultScriptingConfig
protected final ScriptingConfig getDefaultScriptingConfig()
-
setExpressionEvaluator
public void setExpressionEvaluator(ExpressionEvaluator expressionEvaluator)
-
setPermissionFacade
public void setPermissionFacade(PermissionFacade permissionFacade)
-
setTypeFacade
public void setTypeFacade(TypeFacade typeFacade)
-
-