Class CompareViewController
- java.lang.Object
-
- org.zkoss.zk.ui.event.GenericEventListener
-
- org.zkoss.zk.ui.util.GenericComposer<T>
-
- org.zkoss.zk.ui.util.GenericAutowireComposer<T>
-
- org.zkoss.zk.ui.util.GenericForwardComposer<org.zkoss.zk.ui.Component>
-
- com.hybris.cockpitng.util.ViewAnnotationAwareComposer
-
- com.hybris.cockpitng.util.DefaultWidgetController
-
- com.hybris.cockpitng.widgets.compare.CompareViewController
-
- All Implemented Interfaces:
WidgetController,WidgetDragAndDropAware,WidgetInstanceManagerAware,java.io.Serializable,org.zkoss.zk.ui.event.EventListener,org.zkoss.zk.ui.event.SerializableEventListener,org.zkoss.zk.ui.util.ComponentActivationListener,org.zkoss.zk.ui.util.ComponentCloneListener,org.zkoss.zk.ui.util.Composer<org.zkoss.zk.ui.Component>,org.zkoss.zk.ui.util.ComposerExt<org.zkoss.zk.ui.Component>
public class CompareViewController extends DefaultWidgetController
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classCompareViewController.PartialComparisonOperation
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.StringLABEL_LOADINGstatic java.lang.StringMARK_NAME_ADD_ITEMSstatic java.lang.StringMARK_NAME_DIFF_ONLYstatic java.lang.StringMARK_NAME_HYPERLINKstatic java.lang.StringMARK_NAME_PINstatic java.lang.StringMARK_NAME_REMOVE_ITEMstatic java.lang.StringMODEL_COMPARISON_REQUEST_IDprotected static java.lang.StringSETTING_CONFIGURATION_CONTEXTprotected static java.lang.StringSETTING_DEFAULT_TYPE_CODEprotected static java.lang.StringSETTING_LAYOUTprotected static java.lang.StringSOCKET_INPUT_OBJECTSprotected static java.lang.StringSOCKET_INPUT_OBJECTS_ADDprotected static java.lang.StringSOCKET_INPUT_OBJECTS_REMOVEprotected static java.lang.StringSOCKET_INPUT_REFERENCEprotected static java.lang.StringSOCKET_OUTPUT_ADD_ITEMS_REQUESTprotected static java.lang.StringSOCKET_OUTPUT_OBJECTS_LIST_UPDATEDprotected static java.lang.StringSOCKET_OUTPUT_SELECTED_ITEM
-
Constructor Summary
Constructors Constructor Description CompareViewController()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected voidaddInProgressMarker()Marks UI component as in progressprotected voidaddObjectIdsImmediately(java.util.Collection<java.lang.Object> objects)protected voidaddObjectsImmediately(java.util.Collection<java.lang.Object> objects)voidaddObjectsToCompare(java.util.Collection<java.lang.Object> objects)protected voidassureComparisonFinished(CompareViewData<?> data)Deprecated, for removal: This API element is subject to removal in a future version.since 1811.protected voidassureComparisonNotFinished(CompareViewData<?> data)Checks if any other comparisons are required to meet all data marked for comparison.protected voidassureReferenceInObjectsList()voidchangeReference(java.lang.Object object)protected voidclearComparisonStatus()protected voidclearObjectsAndIds()protected voidclearViewData()protected java.util.stream.Stream<CompareAttributeDescriptor>compareAttributeDescriptorFromQualifier(java.lang.String qualifier)protected TypeAwareSelectionContext<java.lang.Object>createAddSelectionContext(java.lang.Object selectedItem)protected OperationcreateBuildDataOperation()Creates an operation responsible for performing a partial comparison in background.protected OperationcreateBuildDataOperation(DefaultComparisonState status)Deprecated, for removal: This API element is subject to removal in a future version.since 1811.protected ComparisonResultcreateComparisonResult(java.util.Set<GroupDescriptor> groupDescriptors)protected TypeAwareSelectionContext<java.lang.Object>createSelectionContext(java.lang.Object selectedItem)protected CockpitConfigurationServicegetCockpitConfigurationService()protected CockpitLocaleServicegetCockpitLocaleService()protected CockpitUserServicegetCockpitUserService()protected DefaultComparisonStategetComparisonState()protected DefaultComparisonStategetComparisonStatus()Deprecated, for removal: This API element is subject to removal in a future version.since 1811.protected CompareViewDatagetCurrentViewData()protected CompareViewLayoutgetDefaultLayout()protected java.lang.StringgetFallbackItemType()protected ItemComparisonFacadegetItemComparisonFacade()protected java.lang.StringgetItemType()protected CompareViewLayoutgetLayout()protected NotificationServicegetNotificationService()protected java.util.Optional<java.lang.Object>getObjectById(java.lang.Object id)ObjectFacadegetObjectFacade()protected java.util.List<java.lang.Object>getObjectIds()protected java.util.List<java.lang.Object>getObjectIdsMutable()protected java.util.List<java.lang.Object>getObjects()protected java.lang.ObjectgetReferenceObject()protected java.lang.ObjectgetReferenceObjectId()protected java.lang.StringgetSelectionItemType()protected TypeFacadegetTypeFacade()protected java.util.Set<java.lang.String>getTypeWithSuperTypes(java.lang.Object object)protected org.zkoss.zul.DivgetView()protected WidgetRenderingUtilsgetWidgetRenderingUtils()protected GroupDescriptorgroupDescriptorFromSection(Section section)protected voidhandleAddItemsClicked()protected voidhandleDiffOnlyChecked(org.zkoss.zk.ui.HtmlBasedComponent component, org.zkoss.zk.ui.event.CheckEvent checkEvent)protected voidhandleHyperLinkClicked(java.lang.Object item)protected voidhandleNotValidObject(java.lang.Object objectId)protected voidhandlePartialComparisonResult(DefaultComparisonState state, PartialComparisonOperationResult partialComparisonResult)protected voidhandlePartialComparisonResult(DefaultComparisonState state, org.apache.commons.lang3.tuple.Pair<java.lang.Object,ComparisonResult> compareObjectIdAndResult)protected voidhandlePinClicked(java.lang.Object object)protected voidhandleRemoveItemClicked(java.lang.Object item)voidinitialize(org.zkoss.zk.ui.Component comp)Override this method to do initialization stuff for your widget, like initialize widget settings, restore view state from viewmodel, etc.protected voidinvalidateView()Marks current view as invalid - future calls tovalidateView()will trigger full comparison from scratchprotected booleanisDiffOnlyEnabled()protected booleanisValidComparison(ComparisonState<?> status)protected booleanisValidViewData(CompareViewData<?> data)protected CompareViewloadConfiguration()protected java.util.Set<GroupDescriptor>loadGroupDescriptors()voidobjectsDeleted(CockpitEvent event)voidobjectsUpdated(CockpitEvent event)protected ComparisonResultperformPartialComparison(java.lang.Object reference, java.lang.Object itemToCompare)protected voidregisterAddItemsListeners()protected voidregisterDiffOnlyListeners()protected voidregisterHyperlinkEventListeners()protected voidregisterListeners()protected voidregisterPinEventListeners()protected voidregisterRemoveItemListeners()protected voidremoveInProgressMarker()Removes in progress marker from UI componentprotected voidremoveObjectIdsImmediately(java.util.Collection<java.lang.Object> objects)protected voidremoveObjectsImmediately(java.util.Collection<java.lang.Object> objects)protected voidremoveObjectsNotMatchingDefaultTypeFromComparison()protected voidremoveObjectsNotMatchingDefaultTypeFromComparison(java.util.Collection<java.lang.Object> objects)voidremoveObjectsToCompare(java.util.Collection<java.lang.Object> objects)protected voidresetView()Clears whole view built up till now, invalidates current comparison result and triggers view build from scratch.protected voidrevalidateView()Forces view to validate - new comparison is being performed and whole view is being validated from scratch.voidsetCockpitLocaleService(CockpitLocaleService cockpitLocaleService)voidsetCockpitUserService(CockpitUserService cockpitUserService)protected voidsetComparisonRequestId()Sets unique comparison request ID in the modelvoidsetDefaultLayout(CompareViewLayout compareViewLayout)voidsetNotificationService(NotificationService notificationService)voidsetObjects(java.util.Collection<java.lang.Object> objects)protected voidsetObjectsImmediately(java.util.Collection<java.lang.Object> objects)protected voidsetReferenceObjectImmediately(java.lang.Object reference)voidsetTypeFacade(TypeFacade typeFacade)voidsetWidgetRenderingUtils(WidgetRenderingUtils widgetRenderingUtils)protected voidupdateComparisonState(DefaultComparisonState<? super java.lang.Object> comparisonState, java.lang.Object objectId)protected voidupdateComparisonStatus(DefaultComparisonState<? super java.lang.Object> comparisonStatus, java.lang.Object comparedObject)Deprecated, for removal: This API element is subject to removal in a future version.since 1811.protected voidupdateDiffOnlyState(CompareViewData currentData, boolean diffOnly)protected voidupdateDiffOnlyTrigger()protected voidupdateItemType()protected voidupdateObjectsImmediately(java.util.List<java.lang.Object> changedObjects)protected voidupdateView(CompareViewData data)Checks if current view reflects provided comparison data.protected voidupdateViewInternal(CompareViewData data)protected voidvalidateView()Checks if current view reflects data marked for comparison and comparison result.-
Methods inherited from class com.hybris.cockpitng.util.DefaultWidgetController
doAfterCompose, doBeforeCompose, doBeforeComposeChildren, executeOperation, getDragAndDropStrategy, getLabel, getLabel, getModel, getValue, getWidgetDragAndDropStrategyRepository, getWidgetInstanceManager, getWidgetRoot, getWidgetSettings, getWidgetslot, getWidgetTitle, getWidgetUtils, initDragAndDropAwareness, initWidgetSetting, initWidgetSetting, initWidgetSetting, initWidgetSetting, initWidgetSetting, invokeListenerMethod, onSocketInput, preInitialize, sendOutput, sendOutputAfterOperation, sendOutputAfterOperation, sendOutputAfterOperation, setValue, setWidgetInstanceManager, setWidgetTitle
-
Methods inherited from class com.hybris.cockpitng.util.ViewAnnotationAwareComposer
scanEventListeners
-
Methods inherited from class org.zkoss.zk.ui.util.GenericAutowireComposer
alert, didActivate, getPage, willClone, willPassivate
-
-
-
-
Field Detail
-
MARK_NAME_DIFF_ONLY
public static final java.lang.String MARK_NAME_DIFF_ONLY
- See Also:
- Constant Field Values
-
MARK_NAME_PIN
public static final java.lang.String MARK_NAME_PIN
- See Also:
- Constant Field Values
-
MARK_NAME_HYPERLINK
public static final java.lang.String MARK_NAME_HYPERLINK
- See Also:
- Constant Field Values
-
MARK_NAME_ADD_ITEMS
public static final java.lang.String MARK_NAME_ADD_ITEMS
- See Also:
- Constant Field Values
-
MARK_NAME_REMOVE_ITEM
public static final java.lang.String MARK_NAME_REMOVE_ITEM
- See Also:
- Constant Field Values
-
MODEL_COMPARISON_REQUEST_ID
public static final java.lang.String MODEL_COMPARISON_REQUEST_ID
- See Also:
- Constant Field Values
-
SOCKET_INPUT_REFERENCE
protected static final java.lang.String SOCKET_INPUT_REFERENCE
- See Also:
- Constant Field Values
-
SOCKET_INPUT_OBJECTS
protected static final java.lang.String SOCKET_INPUT_OBJECTS
- See Also:
- Constant Field Values
-
SOCKET_INPUT_OBJECTS_REMOVE
protected static final java.lang.String SOCKET_INPUT_OBJECTS_REMOVE
- See Also:
- Constant Field Values
-
SOCKET_INPUT_OBJECTS_ADD
protected static final java.lang.String SOCKET_INPUT_OBJECTS_ADD
- See Also:
- Constant Field Values
-
SOCKET_OUTPUT_SELECTED_ITEM
protected static final java.lang.String SOCKET_OUTPUT_SELECTED_ITEM
- See Also:
- Constant Field Values
-
SOCKET_OUTPUT_ADD_ITEMS_REQUEST
protected static final java.lang.String SOCKET_OUTPUT_ADD_ITEMS_REQUEST
- See Also:
- Constant Field Values
-
SOCKET_OUTPUT_OBJECTS_LIST_UPDATED
protected static final java.lang.String SOCKET_OUTPUT_OBJECTS_LIST_UPDATED
- See Also:
- Constant Field Values
-
SETTING_LAYOUT
protected static final java.lang.String SETTING_LAYOUT
- See Also:
- Constant Field Values
-
SETTING_CONFIGURATION_CONTEXT
protected static final java.lang.String SETTING_CONFIGURATION_CONTEXT
- See Also:
- Constant Field Values
-
SETTING_DEFAULT_TYPE_CODE
protected static final java.lang.String SETTING_DEFAULT_TYPE_CODE
- See Also:
- Constant Field Values
-
LABEL_LOADING
protected static final java.lang.String LABEL_LOADING
- See Also:
- Constant Field Values
-
-
Method Detail
-
initialize
public void initialize(org.zkoss.zk.ui.Component comp)
Description copied from class:DefaultWidgetControllerOverride this method to do initialization stuff for your widget, like initialize widget settings, restore view state from viewmodel, etc. This method will be invoked byDefaultWidgetController.doAfterCompose(Component)everytime your widget view is created. SeeGenericForwardComposer.doAfterCompose(Component)for more details.- Overrides:
initializein classDefaultWidgetController
-
setComparisonRequestId
protected void setComparisonRequestId()
Sets unique comparison request ID in the model
-
resetView
protected void resetView()
Clears whole view built up till now, invalidates current comparison result and triggers view build from scratch.
-
revalidateView
protected void revalidateView()
Forces view to validate - new comparison is being performed and whole view is being validated from scratch.
-
invalidateView
protected void invalidateView()
Marks current view as invalid - future calls tovalidateView()will trigger full comparison from scratch
-
validateView
protected void validateView()
Checks if current view reflects data marked for comparison and comparison result. If any comparison is required, then it is triggered in background (non-blocking operation).
-
addInProgressMarker
protected void addInProgressMarker()
Marks UI component as in progress
-
createBuildDataOperation
@Deprecated(since="1811", forRemoval=true) protected Operation createBuildDataOperation(DefaultComparisonState status)Deprecated, for removal: This API element is subject to removal in a future version.since 1811. Please usecreateBuildDataOperation()
-
createBuildDataOperation
protected Operation createBuildDataOperation()
Creates an operation responsible for performing a partial comparison in background. As a result of this operation a pair <Object,ComparisonResult> is expected with compared object as key and result of comparison as value.- Returns:
- operation to be performed in background
-
handlePartialComparisonResult
protected void handlePartialComparisonResult(DefaultComparisonState state, PartialComparisonOperationResult partialComparisonResult)
-
handleNotValidObject
protected void handleNotValidObject(java.lang.Object objectId)
-
handlePartialComparisonResult
protected void handlePartialComparisonResult(DefaultComparisonState state, org.apache.commons.lang3.tuple.Pair<java.lang.Object,ComparisonResult> compareObjectIdAndResult)
-
updateView
protected void updateView(CompareViewData data)
Checks if current view reflects provided comparison data. If any comparison is still required, then it is triggered in background (non-blocking operation).- Parameters:
data- comparison data to validate view against- See Also:
assureComparisonNotFinished(CompareViewData)
-
updateViewInternal
protected void updateViewInternal(CompareViewData data) throws TypeNotFoundException, CockpitConfigurationException
-
removeObjectsNotMatchingDefaultTypeFromComparison
protected void removeObjectsNotMatchingDefaultTypeFromComparison()
-
registerListeners
protected void registerListeners()
-
registerDiffOnlyListeners
protected void registerDiffOnlyListeners()
-
handleDiffOnlyChecked
protected void handleDiffOnlyChecked(org.zkoss.zk.ui.HtmlBasedComponent component, org.zkoss.zk.ui.event.CheckEvent checkEvent)
-
updateDiffOnlyTrigger
protected void updateDiffOnlyTrigger()
-
assureComparisonFinished
@Deprecated(since="1811", forRemoval=true) protected void assureComparisonFinished(CompareViewData<?> data)Deprecated, for removal: This API element is subject to removal in a future version.since 1811. Please useassureComparisonNotFinished(CompareViewData)
-
assureComparisonNotFinished
protected void assureComparisonNotFinished(CompareViewData<?> data)
Checks if any other comparisons are required to meet all data marked for comparison. If so view validation is triggered.- Parameters:
data- comparison data to validate view against- See Also:
validateView()
-
registerPinEventListeners
protected void registerPinEventListeners()
-
handlePinClicked
protected void handlePinClicked(java.lang.Object object)
-
changeReference
public void changeReference(java.lang.Object object)
-
registerHyperlinkEventListeners
protected void registerHyperlinkEventListeners()
-
handleHyperLinkClicked
protected void handleHyperLinkClicked(java.lang.Object item)
-
registerAddItemsListeners
protected void registerAddItemsListeners()
-
handleAddItemsClicked
protected void handleAddItemsClicked()
-
registerRemoveItemListeners
protected void registerRemoveItemListeners()
-
handleRemoveItemClicked
protected void handleRemoveItemClicked(java.lang.Object item)
-
createSelectionContext
protected TypeAwareSelectionContext<java.lang.Object> createSelectionContext(java.lang.Object selectedItem)
-
createAddSelectionContext
protected TypeAwareSelectionContext<java.lang.Object> createAddSelectionContext(java.lang.Object selectedItem)
-
assureReferenceInObjectsList
protected void assureReferenceInObjectsList()
-
setReferenceObjectImmediately
protected void setReferenceObjectImmediately(java.lang.Object reference)
-
getReferenceObject
protected java.lang.Object getReferenceObject()
-
getReferenceObjectId
protected java.lang.Object getReferenceObjectId()
-
updateItemType
protected void updateItemType()
-
getItemType
protected java.lang.String getItemType()
-
getSelectionItemType
protected java.lang.String getSelectionItemType()
-
getFallbackItemType
protected java.lang.String getFallbackItemType()
-
addObjectsToCompare
public void addObjectsToCompare(java.util.Collection<java.lang.Object> objects)
-
removeObjectsToCompare
public void removeObjectsToCompare(java.util.Collection<java.lang.Object> objects)
-
objectsUpdated
public void objectsUpdated(CockpitEvent event)
-
objectsDeleted
public void objectsDeleted(CockpitEvent event)
-
getView
protected org.zkoss.zul.Div getView()
-
isValidComparison
protected boolean isValidComparison(ComparisonState<?> status)
-
isValidViewData
protected boolean isValidViewData(CompareViewData<?> data)
-
getCurrentViewData
protected CompareViewData getCurrentViewData()
-
createComparisonResult
protected ComparisonResult createComparisonResult(java.util.Set<GroupDescriptor> groupDescriptors)
-
isDiffOnlyEnabled
protected boolean isDiffOnlyEnabled()
-
updateDiffOnlyState
protected void updateDiffOnlyState(CompareViewData currentData, boolean diffOnly)
-
performPartialComparison
protected ComparisonResult performPartialComparison(java.lang.Object reference, java.lang.Object itemToCompare) throws CockpitConfigurationException
- Throws:
CockpitConfigurationException
-
loadGroupDescriptors
protected java.util.Set<GroupDescriptor> loadGroupDescriptors() throws CockpitConfigurationException
- Throws:
CockpitConfigurationException
-
groupDescriptorFromSection
protected GroupDescriptor groupDescriptorFromSection(Section section)
-
getComparisonStatus
@Deprecated(since="1811", forRemoval=true) protected DefaultComparisonState getComparisonStatus()Deprecated, for removal: This API element is subject to removal in a future version.since 1811. Please usegetComparisonState()instead.
-
getComparisonState
protected DefaultComparisonState getComparisonState()
-
clearViewData
protected void clearViewData()
-
clearComparisonStatus
protected void clearComparisonStatus()
-
updateComparisonStatus
@Deprecated(since="1811", forRemoval=true) protected void updateComparisonStatus(DefaultComparisonState<? super java.lang.Object> comparisonStatus, java.lang.Object comparedObject)Deprecated, for removal: This API element is subject to removal in a future version.since 1811. Please useupdateComparisonState(DefaultComparisonState, Object)
-
updateComparisonState
protected void updateComparisonState(DefaultComparisonState<? super java.lang.Object> comparisonState, java.lang.Object objectId)
-
removeInProgressMarker
protected void removeInProgressMarker()
Removes in progress marker from UI component
-
compareAttributeDescriptorFromQualifier
protected java.util.stream.Stream<CompareAttributeDescriptor> compareAttributeDescriptorFromQualifier(java.lang.String qualifier)
-
loadConfiguration
protected CompareView loadConfiguration() throws CockpitConfigurationException
- Throws:
CockpitConfigurationException
-
getObjects
protected java.util.List<java.lang.Object> getObjects()
-
setObjects
public void setObjects(java.util.Collection<java.lang.Object> objects)
-
removeObjectsNotMatchingDefaultTypeFromComparison
protected void removeObjectsNotMatchingDefaultTypeFromComparison(java.util.Collection<java.lang.Object> objects)
-
getTypeWithSuperTypes
protected java.util.Set<java.lang.String> getTypeWithSuperTypes(java.lang.Object object)
-
getObjectIds
protected java.util.List<java.lang.Object> getObjectIds()
-
getObjectIdsMutable
protected java.util.List<java.lang.Object> getObjectIdsMutable()
-
removeObjectsImmediately
protected void removeObjectsImmediately(java.util.Collection<java.lang.Object> objects)
-
removeObjectIdsImmediately
protected void removeObjectIdsImmediately(java.util.Collection<java.lang.Object> objects)
-
setObjectsImmediately
protected void setObjectsImmediately(java.util.Collection<java.lang.Object> objects)
-
clearObjectsAndIds
protected void clearObjectsAndIds()
-
addObjectsImmediately
protected void addObjectsImmediately(java.util.Collection<java.lang.Object> objects)
-
addObjectIdsImmediately
protected void addObjectIdsImmediately(java.util.Collection<java.lang.Object> objects)
-
updateObjectsImmediately
protected void updateObjectsImmediately(java.util.List<java.lang.Object> changedObjects)
-
getLayout
protected CompareViewLayout getLayout()
-
getDefaultLayout
protected CompareViewLayout getDefaultLayout()
-
setDefaultLayout
public void setDefaultLayout(CompareViewLayout compareViewLayout)
-
getTypeFacade
protected TypeFacade getTypeFacade()
-
setTypeFacade
public void setTypeFacade(TypeFacade typeFacade)
-
getObjectFacade
public ObjectFacade getObjectFacade()
-
getCockpitConfigurationService
protected CockpitConfigurationService getCockpitConfigurationService()
-
getItemComparisonFacade
protected ItemComparisonFacade getItemComparisonFacade()
-
getCockpitLocaleService
protected CockpitLocaleService getCockpitLocaleService()
-
setCockpitLocaleService
public void setCockpitLocaleService(CockpitLocaleService cockpitLocaleService)
-
getCockpitUserService
protected CockpitUserService getCockpitUserService()
-
setCockpitUserService
public void setCockpitUserService(CockpitUserService cockpitUserService)
-
getWidgetRenderingUtils
protected WidgetRenderingUtils getWidgetRenderingUtils()
-
setWidgetRenderingUtils
public void setWidgetRenderingUtils(WidgetRenderingUtils widgetRenderingUtils)
-
getNotificationService
protected NotificationService getNotificationService()
-
setNotificationService
public void setNotificationService(NotificationService notificationService)
-
getObjectById
protected java.util.Optional<java.lang.Object> getObjectById(java.lang.Object id)
-
-