Class DefaultCommentLayerComponentController
- java.lang.Object
-
- de.hybris.platform.cockpit.components.mvc.commentlayer.controller.impl.DefaultCommentLayerComponentController
-
- All Implemented Interfaces:
CommentLayerComponentController<CommentLayerComponent>
public class DefaultCommentLayerComponentController extends java.lang.Object implements CommentLayerComponentController<CommentLayerComponent>
Default implementation ofCommentLayerComponentController.
-
-
Field Summary
Fields Modifier and Type Field Description protected ModelHelpercockpitModelHelperprotected TypeServicecockpitTypeServiceprotected static java.lang.StringCOMMENT_LAYER_ARG_NAMEprotected static java.lang.StringCOMMENTLAYER_INDEXprotected CommentLayerServicecommentLayerServiceprotected CommentServicecommentServiceprotected TooltipRenderercommentTooltipRendererprotected CommentTypeModelcommentTypeprotected ComponentModelcomponentprotected DomainModeldomainprotected static org.apache.log4j.LoggerLOGprotected ModelServicemodelServiceprotected static java.lang.StringNORMAL_BORDERprotected UIAccessRightServiceuiAccessRightService
-
Constructor Summary
Constructors Constructor Description DefaultCommentLayerComponentController()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddCommentIcon(CommentLayerComponent commentLayerComponent, int x_Position, int y_Position)Appends new comment icon on thecommentLayercomponentat the x,y position.protected voidaddExistingComments(CommentLayerComponent commentLayerComponent)booleancanCreateComment()Checks if current user can create new comment instances.protected booleancanCreateComment(TypedObject commentTarget)booleancanDeleteComment(CommentModel comment)Evaluates if current user is eligible to delete the target comment instance.booleancanEditComment(CommentModel comment)Evaluates if current user can edit a comment behind the comment icon on the comment layer component.booleancanMoveCommentIcon(CommentIcon icon)Evaluates if current user can move given comment on the comment layer.booleancanReplyToComment(CommentModel comment)Evaluates if current user can reply to a comment behind the comment icon on the comment layer component.voidchangeCommentLayerMode(CommentLayerComponent component, java.lang.String mode)Changes the mode of the comment layer component.voidchangeCommentLayerMode(CommentLayerContext context, java.lang.String mode)Changes the mode of all comment layer components in the context.voidchangeCommentLayerToDefaultMode(CommentLayerComponent component)Changes the mode of the target comment layer component to default mode.voidchangeCommentLayerToDefaultMode(CommentLayerContext context)Changes the mode of all comment layer components in the context to default mode.protected CockpitBasicFCKEditorcreateCockpitFCKEditor(java.util.Map<java.lang.String,? extends java.lang.Object> editorParameters)protected CommentMetadataModelcreateCommentMetadata(CommentLayerComponentModel model, CommentModel commentToSave, CommentIcon newIcon)org.zkoss.zul.MenupopupcreateContextMenu(CommentLayerComponent component)Creates context menu component for the right-click actions on the comment layerprotected voidcreateEditPopupContentForComment(org.zkoss.zul.Window newCommentPopup, CommentLayerComponent clComponent, CommentLayerAwareModel clAwareModel, CommentIcon newIcon, CommentModel commentToEdit, boolean create)Create additional content for comment creation and edit popup.protected org.zkoss.zul.WindowcreateEditPopupForComment(CommentLayerComponent clComponent, CommentLayerAwareModel clAwareModel, CommentIcon newIcon, CommentModel commentToEdit, boolean create)protected org.zkoss.zul.WindowcreateEditPopupForComment(CommentLayerAwareModel clAwareModel, CommentIcon newIcon, CommentModel commentToEdit, boolean create)org.zkoss.zul.MenupopupcreateIconContextMenu(CommentLayerComponent component, CommentIcon icon)Creates context menu component for the right-click actions on the icons on comment layerprotected CommentIconcreateNewIcon(CommentIconModel model)protected org.zkoss.zul.WindowcreateReplyPopup(CommentLayerAwareModel model, AbstractCommentModel abstractCommentModel, boolean edit)voiddeleteCommentFromCommentLayer(CommentLayerComponent component, CommentIcon icon)Removes the given icon from the target comment layer component.protected booleandisplayCommentIcon(TypedObject commentLayerTarget, CommentMetadataModel metaData)Determines if comment icon represented by the meta data should be displayed over givencommentLayerTerget.protected booleandisplayCommentIcon(TypedObject commentLayerTarget, CommentMetadataModel metaData, int pageIndex)Determines if comment icon represented by the meta data should be displayed over givencommentLayerTerget.voiddrawCommentLayerOverArea(org.zkoss.zk.ui.HtmlBasedComponent parent, CommentLayerComponent commentLayerComponent)Draws the comment layer over the given parenthtmlcomponent.voideditCommentPopup(CommentLayerAwareModel model, AbstractCommentModel abstractComment)Method for rendering popup for reply edit.CommentIcongetCommentIconForComment(CommentLayerComponent component, CommentModel comment)Returns CommentIcon component for the givenCommentModelwhich is placed on the givenCommentLayerComponent;protected CommentTypeModelgetCommentType()protected UserModelgetCurentUser()protected ComponentModelgetCurrentComponent()protected double[]getDimensionsFromParent(org.zkoss.zk.ui.HtmlBasedComponent area)protected DomainModelgetDomain()protected intgetPagePreviewIndex(ItemModel commentLayerTarget)Computes preview index basing on the comet file code.protected java.lang.IntegergetRealPositionCoordinate(int scaledCoordinate, double scaleFactor)protected TypeServicegetTypeService()double[]getWidthAndHeight(CommentLayerComponent component, double scaleFactor)Return comment layer dimensions according to the given scale factor.voidmoveCommentIcon(CommentLayerComponent commentLayerComponent, CommentIcon icon, int x_Position, int y_Position)Moves the target comment icon on the comment layer component to the target position (x, y).protected voidprepareCommentUpdate(org.zkoss.zul.Window newCommentPopup, AbstractCommentModel commentToSave, boolean create)Prepare comment for saving.protected voidprepareReplyUpdate(org.zkoss.zul.Window replyPopup, AbstractCommentModel abstractCommentModel, boolean edit)Prepare comment for saving.CommentIconrefreshCommentIcon(CommentIcon icon)Refreshes the instance of comment icon.voidrefreshContextList(CommentLayerAwareModel commentLayerAwareModel, boolean refreshItems)Tries to perform refresh of theContextAreaCommentTreeComponentprotected voidrenderSimpleDecisionNavigation(org.zkoss.zk.ui.HtmlBasedComponent container, org.zkoss.zul.Button positiveButton, org.zkoss.zul.Button negativeButton)voidreplyComment(CommentLayerAwareModel model, AbstractCommentModel abstractCommentModel)Renders reply popup for theAbstractCommentModelinstance.voidselectCommentIcon(CommentLayerComponent commentLayerComponent, CommentIcon icon)Marks the target icon as selected on the given comment layer component.voidsetCockpitModelHelper(ModelHelper cockpitModelHelper)voidsetCockpitTypeService(TypeService cockpitTypeService)protected voidsetCommentAttachments(CommentModel comment, java.lang.Object currentValue)voidsetCommentLayerService(CommentLayerService commentLayerService)voidsetCommentService(CommentService commentService)voidsetCommentTooltipRenderer(TooltipRenderer commentTooltipRenderer)voidsetModelService(ModelService modelService)voidsetUiAccessRightService(UIAccessRightService uiAccessRightService)protected voidupdateComment(CommentModel comment, ObjectValueContainer ovc, java.lang.String text)protected voidupdateComponentIcon(CommentLayerComponent clComponent, CommentIcon newIcon, CommentModel commentToSave)protected voidvalidateCommentLayer(CommentLayerComponent component)
-
-
-
Field Detail
-
NORMAL_BORDER
protected static final java.lang.String NORMAL_BORDER
- See Also:
- Constant Field Values
-
LOG
protected static final org.apache.log4j.Logger LOG
-
COMMENT_LAYER_ARG_NAME
protected static final java.lang.String COMMENT_LAYER_ARG_NAME
- See Also:
- Constant Field Values
-
COMMENTLAYER_INDEX
protected static final java.lang.String COMMENTLAYER_INDEX
- See Also:
- Constant Field Values
-
domain
protected DomainModel domain
-
component
protected ComponentModel component
-
commentType
protected CommentTypeModel commentType
-
commentService
protected CommentService commentService
-
modelService
protected ModelService modelService
-
cockpitModelHelper
protected ModelHelper cockpitModelHelper
-
cockpitTypeService
protected TypeService cockpitTypeService
-
commentLayerService
protected CommentLayerService commentLayerService
-
uiAccessRightService
protected UIAccessRightService uiAccessRightService
-
commentTooltipRenderer
protected TooltipRenderer commentTooltipRenderer
-
-
Method Detail
-
drawCommentLayerOverArea
public void drawCommentLayerOverArea(org.zkoss.zk.ui.HtmlBasedComponent parent, CommentLayerComponent commentLayerComponent)Description copied from interface:CommentLayerComponentControllerDraws the comment layer over the given parenthtmlcomponent. Comment icons corresponding to the current state of the model will also be drawn on the layer. The comments are found from the data base according to the :- comments target -
CommentLayerComponentModel.getCommentTarget()and - comment layer target -
CommentLayerComponentModel.getCommentLayerTarget().
- Specified by:
drawCommentLayerOverAreain interfaceCommentLayerComponentController<CommentLayerComponent>- Parameters:
parent- - comment layer targetcommentLayerComponent- - comment layer to draw
- comments target -
-
createContextMenu
public org.zkoss.zul.Menupopup createContextMenu(CommentLayerComponent component)
Description copied from interface:CommentLayerComponentControllerCreates context menu component for the right-click actions on the comment layer- Specified by:
createContextMenuin interfaceCommentLayerComponentController<CommentLayerComponent>- Parameters:
component- - comment layer component
-
canCreateComment
public boolean canCreateComment()
Description copied from interface:CommentLayerComponentControllerChecks if current user can create new comment instances.- Specified by:
canCreateCommentin interfaceCommentLayerComponentController<CommentLayerComponent>- Returns:
- true or false.
-
canCreateComment
protected boolean canCreateComment(TypedObject commentTarget)
-
createIconContextMenu
public org.zkoss.zul.Menupopup createIconContextMenu(CommentLayerComponent component, CommentIcon icon)
Description copied from interface:CommentLayerComponentControllerCreates context menu component for the right-click actions on the icons on comment layer- Specified by:
createIconContextMenuin interfaceCommentLayerComponentController<CommentLayerComponent>icon- - icon from a comment layer component
-
addExistingComments
protected void addExistingComments(CommentLayerComponent commentLayerComponent)
-
displayCommentIcon
protected boolean displayCommentIcon(TypedObject commentLayerTarget, CommentMetadataModel metaData)
Determines if comment icon represented by the meta data should be displayed over givencommentLayerTerget.- Parameters:
commentLayerTarget-metaData- - meta data of the comment under investigation
-
displayCommentIcon
protected boolean displayCommentIcon(TypedObject commentLayerTarget, CommentMetadataModel metaData, int pageIndex)
Determines if comment icon represented by the meta data should be displayed over givencommentLayerTerget.- Parameters:
commentLayerTarget-metaData- - meta data of the comment under investigation
-
getPagePreviewIndex
protected int getPagePreviewIndex(ItemModel commentLayerTarget)
Computes preview index basing on the comet file code.
-
getDimensionsFromParent
protected double[] getDimensionsFromParent(org.zkoss.zk.ui.HtmlBasedComponent area)
-
changeCommentLayerMode
public void changeCommentLayerMode(CommentLayerComponent component, java.lang.String mode)
Description copied from interface:CommentLayerComponentControllerChanges the mode of the comment layer component.- Specified by:
changeCommentLayerModein interfaceCommentLayerComponentController<CommentLayerComponent>- Parameters:
component-CommentLayerComponentmode- - Please use one of the out-of-the-box modes or any other, customized mode.
-
changeCommentLayerToDefaultMode
public void changeCommentLayerToDefaultMode(CommentLayerComponent component)
Description copied from interface:CommentLayerComponentControllerChanges the mode of the target comment layer component to default mode.- Specified by:
changeCommentLayerToDefaultModein interfaceCommentLayerComponentController<CommentLayerComponent>- Parameters:
component-CommentLayerComponent
-
addCommentIcon
public void addCommentIcon(CommentLayerComponent commentLayerComponent, int x_Position, int y_Position)
Description copied from interface:CommentLayerComponentControllerAppends new comment icon on thecommentLayercomponentat the x,y position. Calling this method will create:- new comment instance for the target item
CommentLayerComponentModel.getCommentTarget()) - and additional meta relation (
CommentMetadataModel) with the comment layer target item ( i. e Page preview in print cockpitCommentLayerComponentModel.getCommentLayerTarget()).
- Specified by:
addCommentIconin interfaceCommentLayerComponentController<CommentLayerComponent>- Parameters:
commentLayerComponent- - componentx_Position- - x position (left)y_Position- - y position (top)
- new comment instance for the target item
-
deleteCommentFromCommentLayer
public void deleteCommentFromCommentLayer(CommentLayerComponent component, CommentIcon icon)
Description copied from interface:CommentLayerComponentControllerRemoves the given icon from the target comment layer component. The underlying Comment instance will also be removed.- Specified by:
deleteCommentFromCommentLayerin interfaceCommentLayerComponentController<CommentLayerComponent>- Parameters:
component- - Comment layer componenticon- - icon to remove
-
selectCommentIcon
public void selectCommentIcon(CommentLayerComponent commentLayerComponent, CommentIcon icon)
Description copied from interface:CommentLayerComponentControllerMarks the target icon as selected on the given comment layer component. The icon model's flagCommentIconModel.isSelected()is set to true and also currently selected icon is unselected.- Specified by:
selectCommentIconin interfaceCommentLayerComponentController<CommentLayerComponent>- Parameters:
commentLayerComponent- - parent commentCommentLayerComponentcomponent.icon- - icon to select.
-
getCommentIconForComment
public CommentIcon getCommentIconForComment(CommentLayerComponent component, CommentModel comment)
Description copied from interface:CommentLayerComponentControllerReturns CommentIcon component for the givenCommentModelwhich is placed on the givenCommentLayerComponent;- Specified by:
getCommentIconForCommentin interfaceCommentLayerComponentController<CommentLayerComponent>- Returns:
- corresponding
CommentIconor null if no such icon was found.
-
getCurentUser
protected UserModel getCurentUser()
-
getDomain
protected DomainModel getDomain()
-
getCurrentComponent
protected ComponentModel getCurrentComponent()
-
getCommentType
protected CommentTypeModel getCommentType()
-
prepareCommentUpdate
protected void prepareCommentUpdate(org.zkoss.zul.Window newCommentPopup, AbstractCommentModel commentToSave, boolean create)Prepare comment for saving.- Parameters:
newCommentPopup-commentToSave-create-
-
prepareReplyUpdate
protected void prepareReplyUpdate(org.zkoss.zul.Window replyPopup, AbstractCommentModel abstractCommentModel, boolean edit)Prepare comment for saving.- Parameters:
replyPopup-abstractCommentModel-edit-
-
updateComment
protected void updateComment(CommentModel comment, ObjectValueContainer ovc, java.lang.String text)
-
setCommentAttachments
protected void setCommentAttachments(CommentModel comment, java.lang.Object currentValue)
-
getRealPositionCoordinate
protected java.lang.Integer getRealPositionCoordinate(int scaledCoordinate, double scaleFactor)
-
validateCommentLayer
protected void validateCommentLayer(CommentLayerComponent component)
-
refreshContextList
public void refreshContextList(CommentLayerAwareModel commentLayerAwareModel, boolean refreshItems)
Description copied from interface:CommentLayerComponentControllerTries to perform refresh of theContextAreaCommentTreeComponent- Specified by:
refreshContextListin interfaceCommentLayerComponentController<CommentLayerComponent>
-
getTypeService
protected TypeService getTypeService()
-
canEditComment
public boolean canEditComment(CommentModel comment)
Description copied from interface:CommentLayerComponentControllerEvaluates if current user can edit a comment behind the comment icon on the comment layer component.- Specified by:
canEditCommentin interfaceCommentLayerComponentController<CommentLayerComponent>
-
canReplyToComment
public boolean canReplyToComment(CommentModel comment)
Description copied from interface:CommentLayerComponentControllerEvaluates if current user can reply to a comment behind the comment icon on the comment layer component. The method call finally hits the appropriateCommentPermissionCheckStrategy, which can be customized per project installation.- Specified by:
canReplyToCommentin interfaceCommentLayerComponentController<CommentLayerComponent>- Parameters:
comment- - targetCommentModel- Returns:
- true or false
-
canMoveCommentIcon
public boolean canMoveCommentIcon(CommentIcon icon)
Description copied from interface:CommentLayerComponentControllerEvaluates if current user can move given comment on the comment layer.- Specified by:
canMoveCommentIconin interfaceCommentLayerComponentController<CommentLayerComponent>- Parameters:
icon- - targetCommentIcon- Returns:
- true or false
-
canDeleteComment
public boolean canDeleteComment(CommentModel comment)
Description copied from interface:CommentLayerComponentControllerEvaluates if current user is eligible to delete the target comment instance. The method call finally hits the appropriateCommentPermissionCheckStrategy, which can be customized per project installation.- Specified by:
canDeleteCommentin interfaceCommentLayerComponentController<CommentLayerComponent>- Parameters:
comment- - targetCommentModel
-
createEditPopupContentForComment
protected void createEditPopupContentForComment(org.zkoss.zul.Window newCommentPopup, CommentLayerComponent clComponent, CommentLayerAwareModel clAwareModel, CommentIcon newIcon, CommentModel commentToEdit, boolean create)Create additional content for comment creation and edit popup.- Parameters:
newCommentPopup-clComponent-clAwareModel-newIcon-commentToEdit-create-
-
createEditPopupForComment
protected org.zkoss.zul.Window createEditPopupForComment(CommentLayerComponent clComponent, CommentLayerAwareModel clAwareModel, CommentIcon newIcon, CommentModel commentToEdit, boolean create)
-
createCommentMetadata
protected CommentMetadataModel createCommentMetadata(CommentLayerComponentModel model, CommentModel commentToSave, CommentIcon newIcon)
-
updateComponentIcon
protected void updateComponentIcon(CommentLayerComponent clComponent, CommentIcon newIcon, CommentModel commentToSave)
-
createEditPopupForComment
protected org.zkoss.zul.Window createEditPopupForComment(CommentLayerAwareModel clAwareModel, CommentIcon newIcon, CommentModel commentToEdit, boolean create)
-
renderSimpleDecisionNavigation
protected void renderSimpleDecisionNavigation(org.zkoss.zk.ui.HtmlBasedComponent container, org.zkoss.zul.Button positiveButton, org.zkoss.zul.Button negativeButton)
-
moveCommentIcon
public void moveCommentIcon(CommentLayerComponent commentLayerComponent, CommentIcon icon, int x_Position, int y_Position)
Description copied from interface:CommentLayerComponentControllerMoves the target comment icon on the comment layer component to the target position (x, y).- Specified by:
moveCommentIconin interfaceCommentLayerComponentController<CommentLayerComponent>- Parameters:
commentLayerComponent- -CommentLayerComponenticon- -CommentIconto be movedx_Position- - target x position (HtmlBasedComponent.setLeft(String))y_Position- - target x position (HtmlBasedComponent.setTop(String))
-
createCockpitFCKEditor
protected CockpitBasicFCKEditor createCockpitFCKEditor(java.util.Map<java.lang.String,? extends java.lang.Object> editorParameters)
-
createReplyPopup
protected org.zkoss.zul.Window createReplyPopup(CommentLayerAwareModel model, AbstractCommentModel abstractCommentModel, boolean edit)
-
createNewIcon
protected CommentIcon createNewIcon(CommentIconModel model)
-
replyComment
public void replyComment(CommentLayerAwareModel model, AbstractCommentModel abstractCommentModel)
Description copied from interface:CommentLayerComponentControllerRenders reply popup for theAbstractCommentModelinstance.- Specified by:
replyCommentin interfaceCommentLayerComponentController<CommentLayerComponent>- Parameters:
model- - model of the active comment layerabstractCommentModel- - instance to reply
-
refreshCommentIcon
public CommentIcon refreshCommentIcon(CommentIcon icon)
Description copied from interface:CommentLayerComponentControllerRefreshes the instance of comment icon. Layout parameters are refreshed, but also with theCommentModelinstance residing in theCommentIconModel.- Specified by:
refreshCommentIconin interfaceCommentLayerComponentController<CommentLayerComponent>- Parameters:
icon- -CommentIconto refresh- Returns:
- refreshed
CommentIcon
-
editCommentPopup
public void editCommentPopup(CommentLayerAwareModel model, AbstractCommentModel abstractComment)
Description copied from interface:CommentLayerComponentControllerMethod for rendering popup for reply edit.- Specified by:
editCommentPopupin interfaceCommentLayerComponentController<CommentLayerComponent>- Parameters:
model- -CommentLayerAwareModelabstractComment- -AbstractCommentModelto edit
-
getWidthAndHeight
public double[] getWidthAndHeight(CommentLayerComponent component, double scaleFactor)
Description copied from interface:CommentLayerComponentControllerReturn comment layer dimensions according to the given scale factor. This method allows to influence the actual dimensions of the comment layer component- Specified by:
getWidthAndHeightin interfaceCommentLayerComponentController<CommentLayerComponent>- Parameters:
component- - Comment layerscaleFactor- -target scale factor
-
setCommentLayerService
public void setCommentLayerService(CommentLayerService commentLayerService)
-
setCommentService
public void setCommentService(CommentService commentService)
-
setModelService
public void setModelService(ModelService modelService)
-
setCockpitTypeService
public void setCockpitTypeService(TypeService cockpitTypeService)
-
setUiAccessRightService
public void setUiAccessRightService(UIAccessRightService uiAccessRightService)
-
setCockpitModelHelper
public void setCockpitModelHelper(ModelHelper cockpitModelHelper)
-
changeCommentLayerMode
public void changeCommentLayerMode(CommentLayerContext context, java.lang.String mode)
Description copied from interface:CommentLayerComponentControllerChanges the mode of all comment layer components in the context.- Specified by:
changeCommentLayerModein interfaceCommentLayerComponentController<CommentLayerComponent>- Parameters:
context- -CommentLayerContextmode- - Please use one of the out-of-the-box modes or any other, customized mode.
-
changeCommentLayerToDefaultMode
public void changeCommentLayerToDefaultMode(CommentLayerContext context)
Description copied from interface:CommentLayerComponentControllerChanges the mode of all comment layer components in the context to default mode.- Specified by:
changeCommentLayerToDefaultModein interfaceCommentLayerComponentController<CommentLayerComponent>- Parameters:
context- -CommentLayerContext
-
setCommentTooltipRenderer
public void setCommentTooltipRenderer(TooltipRenderer commentTooltipRenderer)
-
-