Class ItemCommentsController
- 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.itemcomments.ItemCommentsController
-
- All Implemented Interfaces:
com.hybris.cockpitng.core.WidgetController,com.hybris.cockpitng.dnd.WidgetDragAndDropAware,com.hybris.cockpitng.engine.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 ItemCommentsController extends com.hybris.cockpitng.util.DefaultWidgetController- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.StringCOMPONENT_ADD_COMMENT_BUTTONprotected static java.lang.StringCOMPONENT_COMMENTS_COUNT_LABELDeprecated.since 1811, the field is unusedprotected static java.lang.StringCOMPONENT_SHOW_POPUP_BUTTONDeprecated.since 1811, the field is unusedprotected static java.lang.StringLABEL_NO_COMMENTSprotected static java.lang.StringMODEL_COMMENTSprotected static java.lang.StringMODEL_DATA_TYPEstatic java.lang.StringMODEL_DATE_FORMATTERprotected static java.lang.StringMODEL_INPUT_ITEMprotected static java.lang.StringSCLASS_ADD_COMMENT_SECTIONprotected static java.lang.StringSCLASS_ADD_COMMENT_SECTION_BUTTON_CANCELprotected static java.lang.StringSCLASS_ADD_COMMENT_SECTION_BUTTON_OKprotected static java.lang.StringSCLASS_ADD_COMMENT_SECTION_TEXTBOXprotected static java.lang.StringSCLASS_COMMENTS_LIST_EMPTYprotected static java.lang.StringSETTING_COMMENTS_LIST_RENDERERprotected static java.lang.StringSETTING_DATE_FORMATprotected static java.lang.StringSETTING_DEFAULT_COMMENTS_COMMENT_TYPEprotected static java.lang.StringSETTING_DEFAULT_COMMENTS_COMPONENTprotected static java.lang.StringSETTING_DEFAULT_COMMENTS_DOMAINprotected static java.lang.StringSETTING_DEFAULT_COMMENTS_LIST_RENDERERprotected static java.lang.StringSETTING_POPUP_POSITIONprotected static java.lang.StringSOCKET_IN_INPUT_ITEM
-
Constructor Summary
Constructors Constructor Description ItemCommentsController()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddCommentToItem(CommentModel newComment)protected booleancanCreateComment()protected booleancanReadThisComment(CommentModel comment)protected voidclosePopup()protected org.zkoss.zul.DivcreateAddCommentContainer(org.zkoss.zul.Textbox textbox, org.zkoss.zul.Button okButton, org.zkoss.zul.Button cancelButton)protected org.zkoss.zk.ui.event.EventListener<org.zkoss.zk.ui.event.Event>createCancelButtonListener()protected java.util.Optional<CommentModel>createNewComment(java.lang.String text, ComponentModel component, CommentTypeModel commentType)protected java.util.Optional<CommentModel>createNewComment(org.zkoss.zul.Textbox textbox)protected org.zkoss.zk.ui.event.EventListener<org.zkoss.zk.ui.event.Event>createOkButtonEventListener(org.zkoss.zul.Textbox textbox)protected java.util.List<CommentModel>filterNotPermitted(java.util.List<CommentModel> comments)org.zkoss.zul.ButtongetAddCommentButton()org.zkoss.zul.DivgetAddCommentContainer()com.hybris.cockpitng.widgets.common.WidgetComponentRenderer<org.zkoss.zul.Div,java.lang.Void,CommentModel>getCommentRenderer()org.zkoss.zul.LabelgetCommentsCountLabel()CommentServicegetCommentService()java.util.List<CommentModel>getCommentsFromModel()org.zkoss.zul.DivgetCommentsListContainer()org.zkoss.zul.PopupgetCommentsPopup()protected java.lang.StringgetDefaultDateFormat()ItemModelgetInputItemModel()protected com.hybris.backoffice.widgets.notificationarea.NotificationServicegetNotificationService()com.hybris.cockpitng.dataaccess.facades.object.ObjectFacadegetObjectFacade()protected java.util.Collection<org.zkoss.zk.ui.Component>getOpenPopupAwareComponents()com.hybris.cockpitng.dataaccess.facades.permissions.PermissionFacadegetPermissionFacade()PopupPositiongetPopupPosition()org.zkoss.zul.ButtongetShowCommentsButton()com.hybris.cockpitng.dataaccess.facades.type.TypeFacadegetTypeFacade()UserServicegetUserService()protected voidhandleCommentSavingException(com.hybris.cockpitng.dataaccess.facades.object.exceptions.ObjectSavingException exception)protected voidinitDataType(ItemModel inputItem)protected voidinitDateFormatter()voidinitialize(org.zkoss.zk.ui.Component component)protected voidinitPopupPosition()protected voidinitRenderer()protected booleanisCommentsChanged(ItemModel freshInputItemModel)protected voidloadNewCommentsIfPossible()protected voidnotifyUserOfWrongSettings(java.lang.String wrongSettingsMessage)voidonHeartbeat(com.hybris.cockpitng.core.events.CockpitEvent cockpitEvent)voidonInputItemReceive(ItemModel inputItem)voidopenPopup()protected voidrender()protected voidrenderComments()protected voidrenderCommentsList()protected voidrenderContent()protected voidrenderEmptyMessage()protected voidrunWithReopeningPopup(com.hybris.cockpitng.core.Executable executable)Performs passed operation and closes and reopens comments popup so any modified elements in it will be recalculated correctly.protected voidscrollToLastComment()voidsetAddCommentButton(org.zkoss.zul.Button addCommentButton)voidsetAddCommentContainer(org.zkoss.zul.Div addCommentContainer)voidsetCommentRenderer(com.hybris.cockpitng.widgets.common.WidgetComponentRenderer<org.zkoss.zul.Div,java.lang.Void,CommentModel> commentRenderer)voidsetCommentsCountLabel(org.zkoss.zul.Label commentsCountLabel)voidsetCommentService(CommentService commentService)voidsetCommentsListContainer(org.zkoss.zul.Div commentsListContainer)voidsetCommentsPopup(org.zkoss.zul.Popup commentsPopup)voidsetNotificationService(com.hybris.backoffice.widgets.notificationarea.NotificationService notificationService)voidsetObjectFacade(com.hybris.cockpitng.dataaccess.facades.object.ObjectFacade objectFacade)protected voidsetOnClickEventListenersForOpenPopupAwareComponent(org.zkoss.zk.ui.Component component, boolean clickable)protected voidsetOpenPopupAwareComponentsClickability()voidsetPermissionFacade(com.hybris.cockpitng.dataaccess.facades.permissions.PermissionFacade permissionFacade)voidsetPopupPosition(PopupPosition popupPosition)voidsetShowCommentsButton(org.zkoss.zul.Button showCommentsButton)voidsetTypeFacade(com.hybris.cockpitng.dataaccess.facades.type.TypeFacade typeFacade)protected voidsetUIStateForOpenPopupAwareComponent(org.zkoss.zk.ui.Component component, boolean clickable)voidsetUserService(UserService userService)voidshowNewCommentSection()protected voidsortAndSetComments(java.util.List<CommentModel> comments)protected voidtryToSaveItemComment(CommentModel comment)-
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
-
MODEL_DATE_FORMATTER
public static final java.lang.String MODEL_DATE_FORMATTER
- See Also:
- Constant Field Values
-
SOCKET_IN_INPUT_ITEM
protected static final java.lang.String SOCKET_IN_INPUT_ITEM
- See Also:
- Constant Field Values
-
SETTING_COMMENTS_LIST_RENDERER
protected static final java.lang.String SETTING_COMMENTS_LIST_RENDERER
- See Also:
- Constant Field Values
-
SETTING_POPUP_POSITION
protected static final java.lang.String SETTING_POPUP_POSITION
- See Also:
- Constant Field Values
-
SETTING_DATE_FORMAT
protected static final java.lang.String SETTING_DATE_FORMAT
- See Also:
- Constant Field Values
-
SETTING_DEFAULT_COMMENTS_LIST_RENDERER
protected static final java.lang.String SETTING_DEFAULT_COMMENTS_LIST_RENDERER
- See Also:
- Constant Field Values
-
SETTING_DEFAULT_COMMENTS_DOMAIN
protected static final java.lang.String SETTING_DEFAULT_COMMENTS_DOMAIN
- See Also:
- Constant Field Values
-
SETTING_DEFAULT_COMMENTS_COMPONENT
protected static final java.lang.String SETTING_DEFAULT_COMMENTS_COMPONENT
- See Also:
- Constant Field Values
-
SETTING_DEFAULT_COMMENTS_COMMENT_TYPE
protected static final java.lang.String SETTING_DEFAULT_COMMENTS_COMMENT_TYPE
- See Also:
- Constant Field Values
-
COMPONENT_SHOW_POPUP_BUTTON
@Deprecated protected static final java.lang.String COMPONENT_SHOW_POPUP_BUTTON
Deprecated.since 1811, the field is unused- See Also:
- Constant Field Values
-
COMPONENT_COMMENTS_COUNT_LABEL
@Deprecated protected static final java.lang.String COMPONENT_COMMENTS_COUNT_LABEL
Deprecated.since 1811, the field is unused- See Also:
- Constant Field Values
-
COMPONENT_ADD_COMMENT_BUTTON
protected static final java.lang.String COMPONENT_ADD_COMMENT_BUTTON
- See Also:
- Constant Field Values
-
SCLASS_ADD_COMMENT_SECTION
protected static final java.lang.String SCLASS_ADD_COMMENT_SECTION
- See Also:
- Constant Field Values
-
SCLASS_ADD_COMMENT_SECTION_TEXTBOX
protected static final java.lang.String SCLASS_ADD_COMMENT_SECTION_TEXTBOX
- See Also:
- Constant Field Values
-
SCLASS_ADD_COMMENT_SECTION_BUTTON_OK
protected static final java.lang.String SCLASS_ADD_COMMENT_SECTION_BUTTON_OK
- See Also:
- Constant Field Values
-
SCLASS_ADD_COMMENT_SECTION_BUTTON_CANCEL
protected static final java.lang.String SCLASS_ADD_COMMENT_SECTION_BUTTON_CANCEL
- See Also:
- Constant Field Values
-
SCLASS_COMMENTS_LIST_EMPTY
protected static final java.lang.String SCLASS_COMMENTS_LIST_EMPTY
- See Also:
- Constant Field Values
-
LABEL_NO_COMMENTS
protected static final java.lang.String LABEL_NO_COMMENTS
- See Also:
- Constant Field Values
-
MODEL_DATA_TYPE
protected static final java.lang.String MODEL_DATA_TYPE
- See Also:
- Constant Field Values
-
MODEL_COMMENTS
protected static final java.lang.String MODEL_COMMENTS
- See Also:
- Constant Field Values
-
MODEL_INPUT_ITEM
protected static final java.lang.String MODEL_INPUT_ITEM
- See Also:
- Constant Field Values
-
-
Method Detail
-
initialize
public void initialize(org.zkoss.zk.ui.Component component)
- Overrides:
initializein classcom.hybris.cockpitng.util.DefaultWidgetController
-
onInputItemReceive
public void onInputItemReceive(ItemModel inputItem)
-
scrollToLastComment
protected void scrollToLastComment()
-
showNewCommentSection
public void showNewCommentSection()
-
onHeartbeat
public void onHeartbeat(com.hybris.cockpitng.core.events.CockpitEvent cockpitEvent)
-
openPopup
public void openPopup()
-
loadNewCommentsIfPossible
protected void loadNewCommentsIfPossible() throws com.hybris.cockpitng.dataaccess.facades.object.exceptions.ObjectNotFoundException- Throws:
com.hybris.cockpitng.dataaccess.facades.object.exceptions.ObjectNotFoundException
-
setOpenPopupAwareComponentsClickability
protected void setOpenPopupAwareComponentsClickability()
-
getOpenPopupAwareComponents
protected java.util.Collection<org.zkoss.zk.ui.Component> getOpenPopupAwareComponents()
-
setUIStateForOpenPopupAwareComponent
protected void setUIStateForOpenPopupAwareComponent(org.zkoss.zk.ui.Component component, boolean clickable)
-
setOnClickEventListenersForOpenPopupAwareComponent
protected void setOnClickEventListenersForOpenPopupAwareComponent(org.zkoss.zk.ui.Component component, boolean clickable)
-
isCommentsChanged
protected boolean isCommentsChanged(ItemModel freshInputItemModel)
-
runWithReopeningPopup
protected void runWithReopeningPopup(com.hybris.cockpitng.core.Executable executable)
Performs passed operation and closes and reopens comments popup so any modified elements in it will be recalculated correctly. If popup was closed is not opened again (in case to call this method fromonHeartbeat(CockpitEvent))- Parameters:
executable- passed operation which will be executed before popup will be reopened.
-
closePopup
protected void closePopup()
-
createAddCommentContainer
protected org.zkoss.zul.Div createAddCommentContainer(org.zkoss.zul.Textbox textbox, org.zkoss.zul.Button okButton, org.zkoss.zul.Button cancelButton)
-
createOkButtonEventListener
protected org.zkoss.zk.ui.event.EventListener<org.zkoss.zk.ui.event.Event> createOkButtonEventListener(org.zkoss.zul.Textbox textbox)
-
createCancelButtonListener
protected org.zkoss.zk.ui.event.EventListener<org.zkoss.zk.ui.event.Event> createCancelButtonListener()
-
tryToSaveItemComment
protected void tryToSaveItemComment(CommentModel comment)
-
handleCommentSavingException
protected void handleCommentSavingException(com.hybris.cockpitng.dataaccess.facades.object.exceptions.ObjectSavingException exception)
-
addCommentToItem
protected void addCommentToItem(CommentModel newComment) throws com.hybris.cockpitng.dataaccess.facades.object.exceptions.ObjectSavingException
- Throws:
com.hybris.cockpitng.dataaccess.facades.object.exceptions.ObjectSavingException
-
createNewComment
protected java.util.Optional<CommentModel> createNewComment(org.zkoss.zul.Textbox textbox) throws com.hybris.cockpitng.dataaccess.facades.object.exceptions.ObjectCreationException
- Throws:
com.hybris.cockpitng.dataaccess.facades.object.exceptions.ObjectCreationException
-
notifyUserOfWrongSettings
protected void notifyUserOfWrongSettings(java.lang.String wrongSettingsMessage)
-
createNewComment
protected java.util.Optional<CommentModel> createNewComment(java.lang.String text, ComponentModel component, CommentTypeModel commentType) throws com.hybris.cockpitng.dataaccess.facades.object.exceptions.ObjectCreationException
- Throws:
com.hybris.cockpitng.dataaccess.facades.object.exceptions.ObjectCreationException
-
getInputItemModel
public ItemModel getInputItemModel()
-
getCommentsFromModel
public java.util.List<CommentModel> getCommentsFromModel()
-
render
protected void render()
-
renderCommentsList
protected void renderCommentsList()
-
renderContent
protected void renderContent()
-
renderEmptyMessage
protected void renderEmptyMessage()
-
renderComments
protected void renderComments()
-
getDefaultDateFormat
protected java.lang.String getDefaultDateFormat()
-
initDataType
protected void initDataType(ItemModel inputItem)
-
initDateFormatter
protected void initDateFormatter()
-
initRenderer
protected void initRenderer()
-
initPopupPosition
protected void initPopupPosition()
-
sortAndSetComments
protected void sortAndSetComments(java.util.List<CommentModel> comments)
-
filterNotPermitted
protected java.util.List<CommentModel> filterNotPermitted(java.util.List<CommentModel> comments)
-
canReadThisComment
protected boolean canReadThisComment(CommentModel comment)
-
canCreateComment
protected boolean canCreateComment()
-
getCommentsListContainer
public org.zkoss.zul.Div getCommentsListContainer()
-
setCommentsListContainer
public void setCommentsListContainer(org.zkoss.zul.Div commentsListContainer)
-
getShowCommentsButton
public org.zkoss.zul.Button getShowCommentsButton()
-
setShowCommentsButton
public void setShowCommentsButton(org.zkoss.zul.Button showCommentsButton)
-
getCommentsCountLabel
public org.zkoss.zul.Label getCommentsCountLabel()
-
setCommentsCountLabel
public void setCommentsCountLabel(org.zkoss.zul.Label commentsCountLabel)
-
getPopupPosition
public PopupPosition getPopupPosition()
-
setPopupPosition
public void setPopupPosition(PopupPosition popupPosition)
-
getCommentsPopup
public org.zkoss.zul.Popup getCommentsPopup()
-
setCommentsPopup
public void setCommentsPopup(org.zkoss.zul.Popup commentsPopup)
-
getAddCommentButton
public org.zkoss.zul.Button getAddCommentButton()
-
setAddCommentButton
public void setAddCommentButton(org.zkoss.zul.Button addCommentButton)
-
getAddCommentContainer
public org.zkoss.zul.Div getAddCommentContainer()
-
setAddCommentContainer
public void setAddCommentContainer(org.zkoss.zul.Div addCommentContainer)
-
getObjectFacade
public com.hybris.cockpitng.dataaccess.facades.object.ObjectFacade getObjectFacade()
-
setObjectFacade
public void setObjectFacade(com.hybris.cockpitng.dataaccess.facades.object.ObjectFacade objectFacade)
-
getTypeFacade
public com.hybris.cockpitng.dataaccess.facades.type.TypeFacade getTypeFacade()
-
setTypeFacade
public void setTypeFacade(com.hybris.cockpitng.dataaccess.facades.type.TypeFacade typeFacade)
-
getUserService
public UserService getUserService()
-
setUserService
public void setUserService(UserService userService)
-
getCommentService
public CommentService getCommentService()
-
setCommentService
public void setCommentService(CommentService commentService)
-
getCommentRenderer
public com.hybris.cockpitng.widgets.common.WidgetComponentRenderer<org.zkoss.zul.Div,java.lang.Void,CommentModel> getCommentRenderer()
-
setCommentRenderer
public void setCommentRenderer(com.hybris.cockpitng.widgets.common.WidgetComponentRenderer<org.zkoss.zul.Div,java.lang.Void,CommentModel> commentRenderer)
-
getPermissionFacade
public com.hybris.cockpitng.dataaccess.facades.permissions.PermissionFacade getPermissionFacade()
-
setPermissionFacade
public void setPermissionFacade(com.hybris.cockpitng.dataaccess.facades.permissions.PermissionFacade permissionFacade)
-
getNotificationService
protected com.hybris.backoffice.widgets.notificationarea.NotificationService getNotificationService()
-
setNotificationService
public void setNotificationService(com.hybris.backoffice.widgets.notificationarea.NotificationService notificationService)
-
-