Class CollectionPreviewController
- 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.backoffice.widgets.collectionpreview.CollectionPreviewController
-
- 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 CollectionPreviewController extends DefaultWidgetController
Controller of the collection preview widget - responsible for rendering a preview for each item from a passedPageablepageable. In order to setPage a comprehensive item representation controller relies on
Baseconfiguration where one can specified its name, description and a graphical representation.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.StringCOMP_ID_ITEMLISTprotected static java.lang.StringENTRY_DESCRprotected static java.lang.StringENTRY_IMG_FALLBACKprotected static java.lang.StringENTRY_IMG_URLprotected static java.lang.StringENTRY_NAMEprotected static java.lang.StringMODEL_ITEM_SELECTED_INDEXprotected static java.lang.StringMODEL_PAGEABLEprotected static java.lang.StringMODEL_PAGEABLE_LISTstatic java.lang.StringSOCKET_IN_PAGEABLEstatic java.lang.StringSOCKET_SELECTED_ITEMstatic java.lang.StringWIDGET_SETTING_ASYNCstatic java.lang.StringWIDGET_SETTING_CONFIG_CONTEXTprotected static java.lang.StringYW_COLLECTION_PREVIEW_EMPTY_LIST
-
Constructor Summary
Constructors Constructor Description CollectionPreviewController()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected <T> java.util.List<T>convertAllPagesIntoSingleList(Pageable<T> pageable)protected org.zkoss.zk.ui.ComponentcreateEntry(java.lang.Object entry, Base config)protected <T> Pageable<T>createPageableInstance(java.util.List<T> allResults, int pageSize, java.lang.String typeCode)Creates new instance ofPageableCockpitComponentDefinitionServicegetComponentDefinitionService()protected intgetIndexToSelectAfterRemoval(int currentIndex, int removedIndex)Returns new index of item to select based on currently selected and removed items or -1 if currently selected item has been removedorg.zkoss.zul.ListboxgetItemList()LabelServicegetLabelService()ObjectPreviewServicegetObjectPreviewService()protected <T> Pageable<T>getPageableCopyWithResultList(java.util.List<T> allResults)protected java.util.Map<java.lang.String,java.lang.Object>getRendererProps(java.lang.Object entry, Base baseConfig)Returns a map with all the key/value pairs which should be passed to the zul template used for rendering.TypeFacadegetTypeFacade()protected WidgetgetWidget(Widgetslot widgetslot)protected java.lang.StringgetWidgetResourcePath()voidhandleObjectDeletedEvent(CockpitEvent event)voidhandleObjectUpdatedEvent(CockpitEvent event)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 BaseloadConfiguration(java.lang.String typeCode)Loads the UI configuration for component with code "configContext" and for the specified type, typeCode.protected voidrender(Pageable<?> pageable, java.util.List<?> genericObjectList)Renders the provided entries as a list - each item is represented by base configuration where one can configure name, description and an image representation.voidselectEntry(org.zkoss.zk.ui.event.SelectEvent<org.zkoss.zk.ui.Component,?> event)Call back method for select events.protected voidselectItem(java.lang.Integer position)voidsetPageable(Pageable<?> pageable)Called whenever a socket event is sent to the "pageable" socket.protected voidsetPageable(Pageable<?> pageable, boolean synch)Renders the entries in the pageable object (if any)
Thread-safety is providedprotected voidsetResultList(java.util.List<?> allResults, java.lang.Integer indexToSelect)Changes currentMODEL_PAGEABLEto its copy with passed as an argument collection of available elements and selects an element with provided indexprotected voidsetResultList(java.util.List<?> allResults, java.lang.Integer indexToSelect, boolean synch)Changes currentMODEL_PAGEABLEto its copy with passed as an argument collection of available elements and selects an element with provided indexvoidsetSelectedItem(java.lang.Object itemToSelect)protected voidupdatePreviewCollection(CockpitEvent event)protected voidupdatePreviewCollection(Pageable pageable, CockpitEvent event, java.lang.Object updatedObject)-
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
-
SOCKET_IN_PAGEABLE
public static final java.lang.String SOCKET_IN_PAGEABLE
- See Also:
- Constant Field Values
-
SOCKET_SELECTED_ITEM
public static final java.lang.String SOCKET_SELECTED_ITEM
- See Also:
- Constant Field Values
-
WIDGET_SETTING_CONFIG_CONTEXT
public static final java.lang.String WIDGET_SETTING_CONFIG_CONTEXT
- See Also:
- Constant Field Values
-
WIDGET_SETTING_ASYNC
public static final java.lang.String WIDGET_SETTING_ASYNC
- See Also:
- Constant Field Values
-
ENTRY_NAME
protected static final java.lang.String ENTRY_NAME
- See Also:
- Constant Field Values
-
ENTRY_DESCR
protected static final java.lang.String ENTRY_DESCR
- See Also:
- Constant Field Values
-
ENTRY_IMG_URL
protected static final java.lang.String ENTRY_IMG_URL
- See Also:
- Constant Field Values
-
ENTRY_IMG_FALLBACK
protected static final java.lang.String ENTRY_IMG_FALLBACK
- See Also:
- Constant Field Values
-
YW_COLLECTION_PREVIEW_EMPTY_LIST
protected static final java.lang.String YW_COLLECTION_PREVIEW_EMPTY_LIST
- See Also:
- Constant Field Values
-
COMP_ID_ITEMLIST
protected static final java.lang.String COMP_ID_ITEMLIST
- See Also:
- Constant Field Values
-
MODEL_PAGEABLE
protected static final java.lang.String MODEL_PAGEABLE
- See Also:
- Constant Field Values
-
MODEL_PAGEABLE_LIST
protected static final java.lang.String MODEL_PAGEABLE_LIST
- See Also:
- Constant Field Values
-
MODEL_ITEM_SELECTED_INDEX
protected static final java.lang.String MODEL_ITEM_SELECTED_INDEX
- 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
-
setPageable
public void setPageable(Pageable<?> pageable)
Called whenever a socket event is sent to the "pageable" socket. Renders the entries in the pageable object (if any)
Thread-safety is provided- Parameters:
pageable- the pageable object to setPage
-
setPageable
protected void setPageable(Pageable<?> pageable, boolean synch)
Renders the entries in the pageable object (if any)
Thread-safety is provided- Parameters:
pageable- the pageable object to setPagesynch- when true renders entries synchronously
-
selectEntry
public void selectEntry(org.zkoss.zk.ui.event.SelectEvent<org.zkoss.zk.ui.Component,?> event)
Call back method for select events. Resolves the selected object and sends it out on the outgoing socket called "selectedItem".- Parameters:
event- the select event
-
setSelectedItem
public void setSelectedItem(java.lang.Object itemToSelect)
-
render
protected void render(Pageable<?> pageable, java.util.List<?> genericObjectList)
Renders the provided entries as a list - each item is represented by base configuration where one can configure name, description and an image representation.- Parameters:
pageable- used to resolve the relevant type code (if any) and other paging informationgenericObjectList- the objects to be rendered
-
handleObjectUpdatedEvent
public void handleObjectUpdatedEvent(CockpitEvent event)
-
handleObjectDeletedEvent
public void handleObjectDeletedEvent(CockpitEvent event)
-
updatePreviewCollection
protected void updatePreviewCollection(CockpitEvent event)
-
updatePreviewCollection
protected void updatePreviewCollection(Pageable pageable, CockpitEvent event, java.lang.Object updatedObject)
-
getIndexToSelectAfterRemoval
protected int getIndexToSelectAfterRemoval(int currentIndex, int removedIndex)Returns new index of item to select based on currently selected and removed items or -1 if currently selected item has been removed- Parameters:
currentIndex- index of currently selected itemremovedIndex- index of removed item- Returns:
- new index of item to select
-
setResultList
protected void setResultList(java.util.List<?> allResults, java.lang.Integer indexToSelect)Changes currentMODEL_PAGEABLEto its copy with passed as an argument collection of available elements and selects an element with provided index- Parameters:
allResults- collection of available elements to be set on theMODEL_PAGEABLE.indexToSelect- index of an element to be selected
-
setResultList
protected void setResultList(java.util.List<?> allResults, java.lang.Integer indexToSelect, boolean synch)Changes currentMODEL_PAGEABLEto its copy with passed as an argument collection of available elements and selects an element with provided index- Parameters:
allResults- collection of available elements to be set on theMODEL_PAGEABLE.indexToSelect- index of an element to be selectedsynch- when true renders entries synchronously
-
getPageableCopyWithResultList
protected <T> Pageable<T> getPageableCopyWithResultList(java.util.List<T> allResults)
-
createPageableInstance
protected <T> Pageable<T> createPageableInstance(java.util.List<T> allResults, int pageSize, java.lang.String typeCode)
Creates new instance ofPageable- Parameters:
allResults- collection of all elements available in the preview. The collection is exposed throughPageable.getAllResults()pageSize-typeCode-- Returns:
- new instance of
Pageablewith provided parameters
-
getWidgetResourcePath
protected java.lang.String getWidgetResourcePath()
-
getWidget
protected Widget getWidget(Widgetslot widgetslot)
-
createEntry
protected org.zkoss.zk.ui.Component createEntry(java.lang.Object entry, Base config)
-
loadConfiguration
protected Base loadConfiguration(java.lang.String typeCode)
Loads the UI configuration for component with code "configContext" and for the specified type, typeCode.- Parameters:
typeCode- the type code for which the configuration should be loaded- Returns:
- the configuration object if found, null otherwise
-
getRendererProps
protected java.util.Map<java.lang.String,java.lang.Object> getRendererProps(java.lang.Object entry, Base baseConfig)Returns a map with all the key/value pairs which should be passed to the zul template used for rendering.- Parameters:
entry- the object to be renderedbaseConfig- the UI configuration to be used when rendering- Returns:
- map with renderer properties, which are accessible in the zul template (using ${args.<KEY_NAME>} )
-
selectItem
protected void selectItem(java.lang.Integer position)
-
convertAllPagesIntoSingleList
protected <T> java.util.List<T> convertAllPagesIntoSingleList(Pageable<T> pageable)
-
getLabelService
public LabelService getLabelService()
-
getTypeFacade
public TypeFacade getTypeFacade()
-
getComponentDefinitionService
public CockpitComponentDefinitionService getComponentDefinitionService()
-
getItemList
public org.zkoss.zul.Listbox getItemList()
-
getObjectPreviewService
public ObjectPreviewService getObjectPreviewService()
-
-