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
Modifier and TypeClassDescriptionstatic class
ContextMenuClosedEvent is an event fired by the context menu when it's closed.static interface
ContextMenuClosedListener 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.class
ContextMenuItem represents one clickable item in the context menu.static class
ContextMenuItemClickEvent is an event produced by the context menu item when it is clicked.static interface
ContextMenuItemClickListener is listener for context menu items wanting to notify listeners about item clickstatic interface
ContextMenuOpenedListener is used to modify the content of context menu based on what was clicked.static class
ContextMenuOpenedOnComponentEvent is an event fired by the context menu when it's opened from a component.static class
ContextMenuOpenedOnTableFooterEvent is an event that is fired by the context menu when it's opened by clicking on table footerstatic class
ContextMenuOpenedOnTableHeaderEvent is an event fired by the context menu when it's opened by clicking on table header row.static class
ContextMenuOpenedOnTableRowEvent is an event that is fired when context menu is opened by clicking on table row.static class
ContextMenuOpenedOnTreeItemEvent 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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addContextMenuCloseListener
(CmsContextMenu.ContextMenuClosedListener contextMenuClosedListener) Adds listener that will be invoked when context menu is closed.void
addContextMenuComponentListener
(CmsContextMenu.ContextMenuOpenedListener.ComponentListener contextMenuComponentListener) Adds listener that will be invoked when context menu is opened from the component to which it's assigned to.void
addContextMenuTableListener
(CmsContextMenu.ContextMenuOpenedListener.TableListener contextMenuTableListener) Adds listener that will be invoked when context menu is opened from com.vaadin.ui.Table component.void
addContextMenuTreeListener
(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.void
addItemClickListener
(CmsContextMenu.ContextMenuItemClickListener clickListener) Adds click listener to context menu.void
extend
(com.vaadin.server.AbstractClientConnector target) protected void
fireEvent
(EventObject event) Added to increase method visibility.protected String
Returns a new UUID.protected com.vaadin.server.Resource
getResource
(String key) Added to increase visibility.protected CmsContextMenuState
getState()
void
hide()
Closes the context menu from server side.boolean
Returns if the menu is set to hide automatically.boolean
Returns if the menu is set to open automatically.void
open
(int x, int y) Opens the context menu to given coordinates.void
open
(com.vaadin.ui.Component component) Opens the menu for the given component.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.void
openForTable
(com.vaadin.v7.event.ItemClickEvent event, com.vaadin.v7.ui.Table table) Opens the context menu of the given table.void
openForTree
(com.vaadin.v7.event.ItemClickEvent event, com.vaadin.v7.ui.Tree tree) Opens the context menu of the given tree.void
Removes all items from the context menu.void
removeItem
(CmsContextMenu.ContextMenuItem contextMenuItem) Removes given context menu item from the context menu.void
setAsContextMenuOf
(com.vaadin.server.AbstractClientConnector component) Assigns this as context menu of given component which will react to right mouse button click.void
setAsTableContextMenu
(com.vaadin.v7.ui.Table table) Assigns this as the context menu of given table.void
setAsTreeContextMenu
(com.vaadin.v7.ui.Tree tree) Assigns this as context menu of given tree.<T> void
setEntries
(Collection<I_CmsSimpleContextMenuEntry<T>> entries, T data) Sets the context menu entries.void
setHideAutomatically
(boolean hideAutomatically) Sets menu to hide automatically after mouse cliks on menu items or area off the menu.void
setOpenAutomatically
(boolean openAutomatically) Enables or disables open automatically feature.protected void
setResource
(String key, com.vaadin.server.Resource resource) Added to increase visibility.Methods inherited from class com.vaadin.server.AbstractExtension
getParent, getSupportedParentType, remove, setParent
Methods 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, updateDiffstate
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods 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, setErrorHandler
Methods 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:
extend
in classcom.vaadin.server.AbstractExtension
- See Also:
-
AbstractExtension.extend(com.vaadin.server.AbstractClientConnector)
-
hide
Closes the context menu from server side. -
isHideAutomatically
Returns if the menu is set to hide automatically.- Returns:
true
if context menu is hiding automatically after clicks
-
isOpenAutomatically
Returns if the menu is set to open automatically.- Returns:
true
if 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 {@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:
fireEvent
in classcom.vaadin.server.AbstractClientConnector
- See Also:
-
AbstractClientConnector.fireEvent(java.util.EventObject)
-
getNextId
Returns a new UUID.- Returns:
- a new UUID
-
getResource
Added to increase visibility.- Overrides:
getResource
in classcom.vaadin.server.AbstractClientConnector
- See Also:
-
AbstractClientConnector.getResource(java.lang.String)
-
getState
- Overrides:
getState
in classcom.vaadin.server.AbstractClientConnector
- See Also:
-
AbstractClientConnector.getState()
-
setResource
Added to increase visibility.- Overrides:
setResource
in classcom.vaadin.server.AbstractClientConnector
- See Also:
-
AbstractClientConnector.setResource(java.lang.String, com.vaadin.server.Resource)