Package org.opencms.ui.contextmenu
Class CmsContextMenu
java.lang.Object
com.vaadin.server.AbstractClientConnector
com.vaadin.server.AbstractExtension
org.opencms.ui.contextmenu.CmsContextMenu
- All Implemented Interfaces:
com.vaadin.event.MethodEventSource,com.vaadin.server.ClientConnector,com.vaadin.server.Extension,com.vaadin.shared.Connector,Serializable
ContextMenu is an extension which can be attached to any Vaadin component to
display a popup context menu. Most useful the menu is when attached for
example to Tree or Table which support item and property based context menu
detection.
Adapted from ContextMenu by Peter Lehto / Vaadin Ltd.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classContextMenuClosedEvent is an event fired by the context menu when it's closed.static interfaceContextMenuClosedListener is used to listen for the event that the context menu is closed, either when a item is clicked or when the popup is canceled.classContextMenuItem represents one clickable item in the context menu.static classContextMenuItemClickEvent is an event produced by the context menu item when it is clicked.static interfaceContextMenuItemClickListener is listener for context menu items wanting to notify listeners about item clickstatic interfaceContextMenuOpenedListener is used to modify the content of context menu based on what was clicked.static classContextMenuOpenedOnComponentEvent is an event fired by the context menu when it's opened from a component.static classContextMenuOpenedOnTableFooterEvent is an event that is fired by the context menu when it's opened by clicking on table footerstatic classContextMenuOpenedOnTableHeaderEvent is an event fired by the context menu when it's opened by clicking on table header row.static classContextMenuOpenedOnTableRowEvent is an event that is fired when context menu is opened by clicking on table row.static classContextMenuOpenedOnTreeItemEvent is an event fired by the context menu when it's opened by clicking on tree item.Nested classes/interfaces inherited from interface com.vaadin.server.ClientConnector
com.vaadin.server.ClientConnector.AttachEvent, com.vaadin.server.ClientConnector.AttachListener, com.vaadin.server.ClientConnector.ConnectorErrorEvent, com.vaadin.server.ClientConnector.DetachEvent, com.vaadin.server.ClientConnector.DetachListener -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddContextMenuCloseListener(CmsContextMenu.ContextMenuClosedListener contextMenuClosedListener) Adds listener that will be invoked when context menu is closed.voidaddContextMenuComponentListener(CmsContextMenu.ContextMenuOpenedListener.ComponentListener contextMenuComponentListener) Adds listener that will be invoked when context menu is opened from the component to which it's assigned to.voidaddContextMenuTableListener(CmsContextMenu.ContextMenuOpenedListener.TableListener contextMenuTableListener) Adds listener that will be invoked when context menu is opened from com.vaadin.ui.Table component.voidaddContextMenuTreeListener(CmsContextMenu.ContextMenuOpenedListener.TreeListener contextMenuTreeListener) Adds listener that will be invoked when context menu is opened from com.vaadin.ui.Tree component.addItem(com.vaadin.server.Resource icon) Adds new item to context menu root with given icon without caption.Adds new item to context menu root with given caption.Adds new item to context menu root with given caption and icon.voidaddItemClickListener(CmsContextMenu.ContextMenuItemClickListener clickListener) Adds click listener to context menu.voidextend(com.vaadin.server.AbstractClientConnector target) protected voidfireEvent(EventObject event) Added to increase method visibility.protected StringReturns a new UUID.protected com.vaadin.server.ResourcegetResource(String key) Added to increase visibility.protected CmsContextMenuStategetState()voidhide()Closes the context menu from server side.booleanReturns if the menu is set to hide automatically.booleanReturns if the menu is set to open automatically.voidopen(int x, int y) Opens the context menu to given coordinates.voidopen(com.vaadin.ui.Component component) Opens the menu for the given component.voidopenForTable(com.vaadin.event.MouseEvents.ClickEvent event, Object itemId, Object propertyId, com.vaadin.v7.ui.Table table) Opens the context menu of the given table.voidopenForTable(com.vaadin.v7.event.ItemClickEvent event, com.vaadin.v7.ui.Table table) Opens the context menu of the given table.voidopenForTree(com.vaadin.v7.event.ItemClickEvent event, com.vaadin.v7.ui.Tree tree) Opens the context menu of the given tree.voidRemoves all items from the context menu.voidremoveItem(CmsContextMenu.ContextMenuItem contextMenuItem) Removes given context menu item from the context menu.voidsetAsContextMenuOf(com.vaadin.server.AbstractClientConnector component) Assigns this as context menu of given component which will react to right mouse button click.voidsetAsTableContextMenu(com.vaadin.v7.ui.Table table) Assigns this as the context menu of given table.voidsetAsTreeContextMenu(com.vaadin.v7.ui.Tree tree) Assigns this as context menu of given tree.<T> voidsetEntries(Collection<I_CmsSimpleContextMenuEntry<T>> entries, T data) Sets the context menu entries.voidsetHideAutomatically(boolean hideAutomatically) Sets menu to hide automatically after mouse cliks on menu items or area off the menu.voidsetOpenAutomatically(boolean openAutomatically) Enables or disables open automatically feature.protected voidsetResource(String key, com.vaadin.server.Resource resource) Added to increase visibility.Methods inherited from class com.vaadin.server.AbstractExtension
getParent, getSupportedParentType, remove, setParentMethods inherited from class com.vaadin.server.AbstractClientConnector
addAttachListener, addDetachListener, addExtension, addListener, addListener, addListener, addListener, addListener, addListener, addMethodInvocationToQueue, attach, beforeClientResponse, createState, detach, encodeState, equals, getAllChildrenIterable, getConnectorId, getErrorHandler, getExtensions, getListeners, getRpcManager, getRpcProxy, getSession, getState, getStateType, getUI, handleConnectorRequest, hashCode, hasListeners, isAttached, isConnectorEnabled, isThis, markAsDirty, markAsDirtyRecursive, registerRpc, registerRpc, removeAttachListener, removeDetachListener, removeExtension, removeListener, removeListener, removeListener, removeListener, removeListener, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler, updateDiffstateMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.server.ClientConnector
addAttachListener, addDetachListener, attach, beforeClientResponse, detach, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, getUI, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandlerMethods inherited from interface com.vaadin.shared.Connector
getConnectorId
-
Constructor Details
-
CmsContextMenu
public CmsContextMenu()Constructor.
-
-
Method Details
-
addItem
Adds new item to context menu root with given icon without caption.- Parameters:
icon- the icon- Returns:
- reference to newly added item
-
addItem
Adds new item to context menu root with given caption.- Parameters:
caption- the caption- Returns:
- reference to newly added item
-
addItem
Adds new item to context menu root with given caption and icon.- Parameters:
caption- the captionicon- the icon- Returns:
- reference to newly added item
-
extend
- Overrides:
extendin classcom.vaadin.server.AbstractExtension- See Also:
-
hide
Closes the context menu from server side. -
isHideAutomatically
Returns if the menu is set to hide automatically.- Returns:
trueif context menu is hiding automatically after clicks
-
isOpenAutomatically
Returns if the menu is set to open automatically.- Returns:
trueif open automatically is on. If open automatically is on, it means that context menu will always be opened when it's host component is right clicked. If automatic opening is turned off, context menu will only open when server side open(x, y) is called. Automatic opening avoid having to make server roundtrip whereas "manual" opening allows to have logic in menu before opening it.
-
open
Opens the menu for the given component.- Parameters:
component- the component
-
open
Opens the context menu to given coordinates. ContextMenu must extend component before calling this method. This method is only intended for opening the context menu from server side when using}.invalid @link
{@link #ContextMenuOpenedListener.ComponentListener- Parameters:
x- the client x positiony- the client y position
-
openForTable
public void openForTable(com.vaadin.event.MouseEvents.ClickEvent event, Object itemId, Object propertyId, com.vaadin.v7.ui.Table table) Opens the context menu of the given table.- Parameters:
event- the click eventitemId- of clicked itempropertyId- of clicked itemtable- the table
-
openForTable
Opens the context menu of the given table.- Parameters:
event- the click eventtable- the table
-
openForTree
Opens the context menu of the given tree.- Parameters:
event- the click eventtree- the tree
-
removeAllItems
Removes all items from the context menu. -
setAsContextMenuOf
Assigns this as context menu of given component which will react to right mouse button click.- Parameters:
component- the component
-
setAsTableContextMenu
Assigns this as the context menu of given table.- Parameters:
table- the table
-
setAsTreeContextMenu
Assigns this as context menu of given tree.- Parameters:
tree- the tree
-
setEntries
Sets the context menu entries. Removes all previously present entries.- Parameters:
entries- the entriesdata- the context data
-
setHideAutomatically
Sets menu to hide automatically after mouse cliks on menu items or area off the menu. If automatic hiding is disabled menu will stay open as long as hide is called from the server side.- Parameters:
hideAutomatically- whether to hide automatically
-
setOpenAutomatically
Enables or disables open automatically feature. If open automatically is on, it means that context menu will always be opened when it's host component is right clicked. This will happen on client side without server round trip. If automatic opening is turned off, context menu will only open when server side open(x, y) is called. If automatic opening is disabled you will need a listener implementation for context menu that is called upon client side click event. Another option is to extend context menu and handle the right clicking internally with case specific listener implementation and inside it call open(x, y) method.- Parameters:
openAutomatically- whether to open automatically
-
fireEvent
Added to increase method visibility.- Overrides:
fireEventin classcom.vaadin.server.AbstractClientConnector- See Also:
-
getNextId
Returns a new UUID.- Returns:
- a new UUID
-
getResource
Added to increase visibility.- Overrides:
getResourcein classcom.vaadin.server.AbstractClientConnector- See Also:
-
getState
- Overrides:
getStatein classcom.vaadin.server.AbstractClientConnector- See Also:
-
setResource
Added to increase visibility.- Overrides:
setResourcein classcom.vaadin.server.AbstractClientConnector- See Also: