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 ModelHelper
cockpitModelHelper
protected TypeService
cockpitTypeService
protected static java.lang.String
COMMENT_LAYER_ARG_NAME
protected static java.lang.String
COMMENTLAYER_INDEX
protected CommentLayerService
commentLayerService
protected CommentService
commentService
protected TooltipRenderer
commentTooltipRenderer
protected CommentTypeModel
commentType
protected ComponentModel
component
protected DomainModel
domain
protected static org.apache.log4j.Logger
LOG
protected ModelService
modelService
protected static java.lang.String
NORMAL_BORDER
protected UIAccessRightService
uiAccessRightService
-
Constructor Summary
Constructors Constructor Description DefaultCommentLayerComponentController()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addCommentIcon(CommentLayerComponent commentLayerComponent, int x_Position, int y_Position)
Appends new comment icon on thecommentLayercomponent
at the x,y position.protected void
addExistingComments(CommentLayerComponent commentLayerComponent)
boolean
canCreateComment()
Checks if current user can create new comment instances.protected boolean
canCreateComment(TypedObject commentTarget)
boolean
canDeleteComment(CommentModel comment)
Evaluates if current user is eligible to delete the target comment instance.boolean
canEditComment(CommentModel comment)
Evaluates if current user can edit a comment behind the comment icon on the comment layer component.boolean
canMoveCommentIcon(CommentIcon icon)
Evaluates if current user can move given comment on the comment layer.boolean
canReplyToComment(CommentModel comment)
Evaluates if current user can reply to a comment behind the comment icon on the comment layer component.void
changeCommentLayerMode(CommentLayerComponent component, java.lang.String mode)
Changes the mode of the comment layer component.void
changeCommentLayerMode(CommentLayerContext context, java.lang.String mode)
Changes the mode of all comment layer components in the context.void
changeCommentLayerToDefaultMode(CommentLayerComponent component)
Changes the mode of the target comment layer component to default mode.void
changeCommentLayerToDefaultMode(CommentLayerContext context)
Changes the mode of all comment layer components in the context to default mode.protected CockpitBasicFCKEditor
createCockpitFCKEditor(java.util.Map<java.lang.String,? extends java.lang.Object> editorParameters)
protected CommentMetadataModel
createCommentMetadata(CommentLayerComponentModel model, CommentModel commentToSave, CommentIcon newIcon)
org.zkoss.zul.Menupopup
createContextMenu(CommentLayerComponent component)
Creates context menu component for the right-click actions on the comment layerprotected 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.protected org.zkoss.zul.Window
createEditPopupForComment(CommentLayerComponent clComponent, CommentLayerAwareModel clAwareModel, CommentIcon newIcon, CommentModel commentToEdit, boolean create)
protected org.zkoss.zul.Window
createEditPopupForComment(CommentLayerAwareModel clAwareModel, CommentIcon newIcon, CommentModel commentToEdit, boolean create)
org.zkoss.zul.Menupopup
createIconContextMenu(CommentLayerComponent component, CommentIcon icon)
Creates context menu component for the right-click actions on the icons on comment layerprotected CommentIcon
createNewIcon(CommentIconModel model)
protected org.zkoss.zul.Window
createReplyPopup(CommentLayerAwareModel model, AbstractCommentModel abstractCommentModel, boolean edit)
void
deleteCommentFromCommentLayer(CommentLayerComponent component, CommentIcon icon)
Removes the given icon from the target comment layer component.protected boolean
displayCommentIcon(TypedObject commentLayerTarget, CommentMetadataModel metaData)
Determines if comment icon represented by the meta data should be displayed over givencommentLayerTerget
.protected boolean
displayCommentIcon(TypedObject commentLayerTarget, CommentMetadataModel metaData, int pageIndex)
Determines if comment icon represented by the meta data should be displayed over givencommentLayerTerget
.void
drawCommentLayerOverArea(org.zkoss.zk.ui.HtmlBasedComponent parent, CommentLayerComponent commentLayerComponent)
Draws the comment layer over the given parenthtml
component.void
editCommentPopup(CommentLayerAwareModel model, AbstractCommentModel abstractComment)
Method for rendering popup for reply edit.CommentIcon
getCommentIconForComment(CommentLayerComponent component, CommentModel comment)
Returns CommentIcon component for the givenCommentModel
which is placed on the givenCommentLayerComponent
;protected CommentTypeModel
getCommentType()
protected UserModel
getCurentUser()
protected ComponentModel
getCurrentComponent()
protected double[]
getDimensionsFromParent(org.zkoss.zk.ui.HtmlBasedComponent area)
protected DomainModel
getDomain()
protected int
getPagePreviewIndex(ItemModel commentLayerTarget)
Computes preview index basing on the comet file code.protected java.lang.Integer
getRealPositionCoordinate(int scaledCoordinate, double scaleFactor)
protected TypeService
getTypeService()
double[]
getWidthAndHeight(CommentLayerComponent component, double scaleFactor)
Return comment layer dimensions according to the given scale factor.void
moveCommentIcon(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 void
prepareCommentUpdate(org.zkoss.zul.Window newCommentPopup, AbstractCommentModel commentToSave, boolean create)
Prepare comment for saving.protected void
prepareReplyUpdate(org.zkoss.zul.Window replyPopup, AbstractCommentModel abstractCommentModel, boolean edit)
Prepare comment for saving.CommentIcon
refreshCommentIcon(CommentIcon icon)
Refreshes the instance of comment icon.void
refreshContextList(CommentLayerAwareModel commentLayerAwareModel, boolean refreshItems)
Tries to perform refresh of theContextAreaCommentTreeComponent
protected void
renderSimpleDecisionNavigation(org.zkoss.zk.ui.HtmlBasedComponent container, org.zkoss.zul.Button positiveButton, org.zkoss.zul.Button negativeButton)
void
replyComment(CommentLayerAwareModel model, AbstractCommentModel abstractCommentModel)
Renders reply popup for theAbstractCommentModel
instance.void
selectCommentIcon(CommentLayerComponent commentLayerComponent, CommentIcon icon)
Marks the target icon as selected on the given comment layer component.void
setCockpitModelHelper(ModelHelper cockpitModelHelper)
void
setCockpitTypeService(TypeService cockpitTypeService)
protected void
setCommentAttachments(CommentModel comment, java.lang.Object currentValue)
void
setCommentLayerService(CommentLayerService commentLayerService)
void
setCommentService(CommentService commentService)
void
setCommentTooltipRenderer(TooltipRenderer commentTooltipRenderer)
void
setModelService(ModelService modelService)
void
setUiAccessRightService(UIAccessRightService uiAccessRightService)
protected void
updateComment(CommentModel comment, ObjectValueContainer ovc, java.lang.String text)
protected void
updateComponentIcon(CommentLayerComponent clComponent, CommentIcon newIcon, CommentModel commentToSave)
protected void
validateCommentLayer(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:CommentLayerComponentController
Draws the comment layer over the given parenthtml
component. 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:
drawCommentLayerOverArea
in 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:CommentLayerComponentController
Creates context menu component for the right-click actions on the comment layer- Specified by:
createContextMenu
in interfaceCommentLayerComponentController<CommentLayerComponent>
- Parameters:
component
- - comment layer component
-
canCreateComment
public boolean canCreateComment()
Description copied from interface:CommentLayerComponentController
Checks if current user can create new comment instances.- Specified by:
canCreateComment
in 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:CommentLayerComponentController
Creates context menu component for the right-click actions on the icons on comment layer- Specified by:
createIconContextMenu
in 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:CommentLayerComponentController
Changes the mode of the comment layer component.- Specified by:
changeCommentLayerMode
in interfaceCommentLayerComponentController<CommentLayerComponent>
- Parameters:
component
-CommentLayerComponent
mode
- - 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:CommentLayerComponentController
Changes the mode of the target comment layer component to default mode.- Specified by:
changeCommentLayerToDefaultMode
in interfaceCommentLayerComponentController<CommentLayerComponent>
- Parameters:
component
-CommentLayerComponent
-
addCommentIcon
public void addCommentIcon(CommentLayerComponent commentLayerComponent, int x_Position, int y_Position)
Description copied from interface:CommentLayerComponentController
Appends new comment icon on thecommentLayercomponent
at 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:
addCommentIcon
in 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:CommentLayerComponentController
Removes the given icon from the target comment layer component. The underlying Comment instance will also be removed.- Specified by:
deleteCommentFromCommentLayer
in interfaceCommentLayerComponentController<CommentLayerComponent>
- Parameters:
component
- - Comment layer componenticon
- - icon to remove
-
selectCommentIcon
public void selectCommentIcon(CommentLayerComponent commentLayerComponent, CommentIcon icon)
Description copied from interface:CommentLayerComponentController
Marks 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:
selectCommentIcon
in interfaceCommentLayerComponentController<CommentLayerComponent>
- Parameters:
commentLayerComponent
- - parent commentCommentLayerComponent
component.icon
- - icon to select.
-
getCommentIconForComment
public CommentIcon getCommentIconForComment(CommentLayerComponent component, CommentModel comment)
Description copied from interface:CommentLayerComponentController
Returns CommentIcon component for the givenCommentModel
which is placed on the givenCommentLayerComponent
;- Specified by:
getCommentIconForComment
in interfaceCommentLayerComponentController<CommentLayerComponent>
- Returns:
- corresponding
CommentIcon
or 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:CommentLayerComponentController
Tries to perform refresh of theContextAreaCommentTreeComponent
- Specified by:
refreshContextList
in interfaceCommentLayerComponentController<CommentLayerComponent>
-
getTypeService
protected TypeService getTypeService()
-
canEditComment
public boolean canEditComment(CommentModel comment)
Description copied from interface:CommentLayerComponentController
Evaluates if current user can edit a comment behind the comment icon on the comment layer component.- Specified by:
canEditComment
in interfaceCommentLayerComponentController<CommentLayerComponent>
-
canReplyToComment
public boolean canReplyToComment(CommentModel comment)
Description copied from interface:CommentLayerComponentController
Evaluates 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:
canReplyToComment
in interfaceCommentLayerComponentController<CommentLayerComponent>
- Parameters:
comment
- - targetCommentModel
- Returns:
- true or false
-
canMoveCommentIcon
public boolean canMoveCommentIcon(CommentIcon icon)
Description copied from interface:CommentLayerComponentController
Evaluates if current user can move given comment on the comment layer.- Specified by:
canMoveCommentIcon
in interfaceCommentLayerComponentController<CommentLayerComponent>
- Parameters:
icon
- - targetCommentIcon
- Returns:
- true or false
-
canDeleteComment
public boolean canDeleteComment(CommentModel comment)
Description copied from interface:CommentLayerComponentController
Evaluates 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:
canDeleteComment
in 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:CommentLayerComponentController
Moves the target comment icon on the comment layer component to the target position (x, y).- Specified by:
moveCommentIcon
in interfaceCommentLayerComponentController<CommentLayerComponent>
- Parameters:
commentLayerComponent
- -CommentLayerComponent
icon
- -CommentIcon
to 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:CommentLayerComponentController
Renders reply popup for theAbstractCommentModel
instance.- Specified by:
replyComment
in interfaceCommentLayerComponentController<CommentLayerComponent>
- Parameters:
model
- - model of the active comment layerabstractCommentModel
- - instance to reply
-
refreshCommentIcon
public CommentIcon refreshCommentIcon(CommentIcon icon)
Description copied from interface:CommentLayerComponentController
Refreshes the instance of comment icon. Layout parameters are refreshed, but also with theCommentModel
instance residing in theCommentIconModel
.- Specified by:
refreshCommentIcon
in interfaceCommentLayerComponentController<CommentLayerComponent>
- Parameters:
icon
- -CommentIcon
to refresh- Returns:
- refreshed
CommentIcon
-
editCommentPopup
public void editCommentPopup(CommentLayerAwareModel model, AbstractCommentModel abstractComment)
Description copied from interface:CommentLayerComponentController
Method for rendering popup for reply edit.- Specified by:
editCommentPopup
in interfaceCommentLayerComponentController<CommentLayerComponent>
- Parameters:
model
- -CommentLayerAwareModel
abstractComment
- -AbstractCommentModel
to edit
-
getWidthAndHeight
public double[] getWidthAndHeight(CommentLayerComponent component, double scaleFactor)
Description copied from interface:CommentLayerComponentController
Return comment layer dimensions according to the given scale factor. This method allows to influence the actual dimensions of the comment layer component- Specified by:
getWidthAndHeight
in 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:CommentLayerComponentController
Changes the mode of all comment layer components in the context.- Specified by:
changeCommentLayerMode
in interfaceCommentLayerComponentController<CommentLayerComponent>
- Parameters:
context
- -CommentLayerContext
mode
- - 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:CommentLayerComponentController
Changes the mode of all comment layer components in the context to default mode.- Specified by:
changeCommentLayerToDefaultMode
in interfaceCommentLayerComponentController<CommentLayerComponent>
- Parameters:
context
- -CommentLayerContext
-
setCommentTooltipRenderer
public void setCommentTooltipRenderer(TooltipRenderer commentTooltipRenderer)
-
-