Class CmsContextMenu
- java.lang.Object
-
- com.google.gwt.user.client.ui.UIObject
-
- com.google.gwt.user.client.ui.Widget
-
- com.google.gwt.user.client.ui.Composite
-
- org.opencms.gwt.client.ui.contextmenu.CmsContextMenu
-
- All Implemented Interfaces:
com.google.gwt.event.logical.shared.HasAttachHandlers
,com.google.gwt.event.logical.shared.ResizeHandler
,com.google.gwt.event.shared.EventHandler
,com.google.gwt.event.shared.HasHandlers
,com.google.gwt.user.client.EventListener
,com.google.gwt.user.client.ui.HasVisibility
,com.google.gwt.user.client.ui.IsRenderable
,com.google.gwt.user.client.ui.IsWidget
,I_CmsAutoHider
public class CmsContextMenu extends com.google.gwt.user.client.ui.Composite implements com.google.gwt.event.logical.shared.ResizeHandler, I_CmsAutoHider
A implementation for a context menu.- Since:
- version 8.0.0
-
-
Constructor Summary
Constructors Constructor Description CmsContextMenu(java.util.List<I_CmsContextMenuEntry> menuData, boolean isFixed, I_CmsAutoHider autoHideParent)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAutoHidePartner(com.google.gwt.dom.client.Element partner)
Mouse events that occur within an autoHide partner will not hide a panel set to autoHide.void
addItem(A_CmsContextMenuItem item)
Adds a menu item to this menu.void
addSeparator()
Adds a separator to this menu.protected A_CmsContextMenuItem
getSelectedItem()
Returns the selected item of this menu.void
hide()
Hides the widget.void
hideAll()
Hides this menu and all its parent menus.boolean
isAutoHideEnabled()
Returns if the auto hide feature is enabled.boolean
isAutoHideOnHistoryEventsEnabled()
Returns if the auto hide on history event feature is enabled.protected void
onClose()
Action on close.void
onResize(com.google.gwt.event.logical.shared.ResizeEvent event)
If the browser's window is resized this method rearranges the sub menus of the selected item.protected void
openPopup(A_CmsContextMenuItem item)
Opens a sub menu and sets its position.void
removeAutoHidePartner(com.google.gwt.dom.client.Element partner)
Removes an auto-hide partner.void
setAutoHideEnabled(boolean autoHide)
Enable or disable the autoHide feature.void
setAutoHideOnHistoryEventsEnabled(boolean enabled)
Enable or disable autoHide on history change events.void
setParentItem(A_CmsContextMenuItem parentItem)
Sets the parent item.protected void
setSelectedItem(A_CmsContextMenuItem selectedItem)
Sets the selected item of this menu.protected void
setSubMenuPosition(A_CmsContextMenuItem item)
Sets the position of the sub menu popup.-
Methods inherited from class com.google.gwt.user.client.ui.Composite
claimElement, getWidget, initializeClaimedElement, initWidget, isAttached, onAttach, onBrowserEvent, onDetach, render, render, resolvePotentialElement, setWidget
-
Methods inherited from class com.google.gwt.user.client.ui.Widget
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, doAttachChildren, doDetachChildren, fireEvent, getHandlerCount, getLayoutData, getParent, isOrWasAttached, onLoad, onUnload, removeFromParent, setLayoutData, sinkEvents, unsinkEvents
-
Methods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, onEnsureDebugId, removeStyleDependentName, removeStyleName, setElement, setElement, setHeight, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkBitlessEvent, toString
-
-
-
-
Constructor Detail
-
CmsContextMenu
public CmsContextMenu(java.util.List<I_CmsContextMenuEntry> menuData, boolean isFixed, I_CmsAutoHider autoHideParent)
Constructor.- Parameters:
menuData
- the data structure for the context menuisFixed
- indicating if the position of the menu should be fixed.autoHideParent
- the menu auto hide parent
-
-
Method Detail
-
addAutoHidePartner
public void addAutoHidePartner(com.google.gwt.dom.client.Element partner)
Description copied from interface:I_CmsAutoHider
Mouse events that occur within an autoHide partner will not hide a panel set to autoHide.- Specified by:
addAutoHidePartner
in interfaceI_CmsAutoHider
- Parameters:
partner
- the auto hide partner to add- See Also:
I_CmsAutoHider.addAutoHidePartner(com.google.gwt.dom.client.Element)
-
addItem
public void addItem(A_CmsContextMenuItem item)
Adds a menu item to this menu.- Parameters:
item
- the item to be added
-
addSeparator
public void addSeparator()
Adds a separator to this menu.
-
hide
public void hide()
Description copied from interface:I_CmsAutoHider
Hides the widget.- Specified by:
hide
in interfaceI_CmsAutoHider
- See Also:
I_CmsAutoHider.hide()
-
hideAll
public void hideAll()
Hides this menu and all its parent menus.
-
isAutoHideEnabled
public boolean isAutoHideEnabled()
Description copied from interface:I_CmsAutoHider
Returns if the auto hide feature is enabled.- Specified by:
isAutoHideEnabled
in interfaceI_CmsAutoHider
- Returns:
- true if auto hide is enabled
- See Also:
I_CmsAutoHider.isAutoHideEnabled()
-
isAutoHideOnHistoryEventsEnabled
public boolean isAutoHideOnHistoryEventsEnabled()
Description copied from interface:I_CmsAutoHider
Returns if the auto hide on history event feature is enabled.- Specified by:
isAutoHideOnHistoryEventsEnabled
in interfaceI_CmsAutoHider
- Returns:
- true if auto hide is enabled
- See Also:
I_CmsAutoHider.isAutoHideOnHistoryEventsEnabled()
-
onResize
public void onResize(com.google.gwt.event.logical.shared.ResizeEvent event)
If the browser's window is resized this method rearranges the sub menus of the selected item.- Specified by:
onResize
in interfacecom.google.gwt.event.logical.shared.ResizeHandler
- See Also:
ResizeHandler.onResize(com.google.gwt.event.logical.shared.ResizeEvent)
-
removeAutoHidePartner
public void removeAutoHidePartner(com.google.gwt.dom.client.Element partner)
Description copied from interface:I_CmsAutoHider
Removes an auto-hide partner.- Specified by:
removeAutoHidePartner
in interfaceI_CmsAutoHider
- Parameters:
partner
- the auto-hide partner to remove- See Also:
I_CmsAutoHider.removeAutoHidePartner(com.google.gwt.dom.client.Element)
-
setAutoHideEnabled
public void setAutoHideEnabled(boolean autoHide)
Description copied from interface:I_CmsAutoHider
Enable or disable the autoHide feature. When enabled, the popup will be automatically hidden when the user clicks outside of it.- Specified by:
setAutoHideEnabled
in interfaceI_CmsAutoHider
- Parameters:
autoHide
- enable true to enable, false to disable- See Also:
I_CmsAutoHider.setAutoHideEnabled(boolean)
-
setAutoHideOnHistoryEventsEnabled
public void setAutoHideOnHistoryEventsEnabled(boolean enabled)
Description copied from interface:I_CmsAutoHider
Enable or disable autoHide on history change events. When enabled, the popup will be automatically hidden when the history token changes, such as when the user presses the browser's back button. Disabled by default.- Specified by:
setAutoHideOnHistoryEventsEnabled
in interfaceI_CmsAutoHider
- Parameters:
enabled
- enable true to enable, false to disable- See Also:
I_CmsAutoHider.setAutoHideOnHistoryEventsEnabled(boolean)
-
setParentItem
public void setParentItem(A_CmsContextMenuItem parentItem)
Sets the parent item.- Parameters:
parentItem
- the parent item
-
getSelectedItem
protected A_CmsContextMenuItem getSelectedItem()
Returns the selected item of this menu.- Returns:
- the selected item of this menu
-
onClose
protected void onClose()
Action on close.On close all sub menus should be hidden, the currently selected item should be deselected and the popup will be closed.
-
openPopup
protected void openPopup(A_CmsContextMenuItem item)
Opens a sub menu and sets its position.- Parameters:
item
- the item to show the sub menu of
-
setSelectedItem
protected void setSelectedItem(A_CmsContextMenuItem selectedItem)
Sets the selected item of this menu.- Parameters:
selectedItem
- the item to select
-
setSubMenuPosition
protected void setSubMenuPosition(A_CmsContextMenuItem item)
Sets the position of the sub menu popup.First calculates the best space where to show the popup.
The following list shows the possibilities, beginning with the best and ending with the worst.
- bottom-right
- bottom-left
- top-right
- top-left
Finally the position of the sub menu popup is set to the calculated values.
- Parameters:
item
- the item to show the sub menu of
-
-