org.vaadin.peter.contextmenu
Class ContextMenu

java.lang.Object
  extended by com.vaadin.server.AbstractClientConnector
      extended by com.vaadin.server.AbstractExtension
          extended by org.vaadin.peter.contextmenu.ContextMenu
All Implemented Interfaces:
com.vaadin.event.MethodEventSource, com.vaadin.server.ClientConnector, com.vaadin.server.Extension, com.vaadin.shared.Connector, Serializable
Direct Known Subclasses:
ActionPopup, UserMenu

public class ContextMenu
extends com.vaadin.server.AbstractExtension

See Also:
Serialized Form

Nested Class Summary
static class ContextMenu.ContextMenuClosedEvent
          ContextMenuClosedEvent is an event fired by the context menu when it's closed.
static interface ContextMenu.ContextMenuClosedListener
          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 ContextMenu.ContextMenuItem
          ContextMenuItem represents one clickable item in the context menu.
static class ContextMenu.ContextMenuItemClickEvent
          ContextMenuItemClickEvent is an event produced by the context menu item when it is clicked.
static interface ContextMenu.ContextMenuItemClickListener
          ContextMenuItemClickListener is listener for context menu items wanting to notify listeners about item click
static interface ContextMenu.ContextMenuOpenedListener
          ContextMenuOpenedListener is used to modify the content of context menu based on what was clicked.
static class ContextMenu.ContextMenuOpenedOnComponentEvent
          ContextMenuOpenedOnComponentEvent is an event fired by the context menu when it's opened from a component
static class ContextMenu.ContextMenuOpenedOnTableFooterEvent
          ContextMenuOpenedOnTableFooterEvent is an event that is fired by the context menu when it's opened by clicking on table footer
static class ContextMenu.ContextMenuOpenedOnTableHeaderEvent
          ContextMenuOpenedOnTableHeaderEvent is an event fired by the context menu when it's opened by clicking on table header row.
static class ContextMenu.ContextMenuOpenedOnTableRowEvent
          ContextMenuOpenedOnTableRowEvent is an event that is fired when context menu is opened by clicking on table row.
static class ContextMenu.ContextMenuOpenedOnTreeItemEvent
          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
ContextMenu()
           
 
Method Summary
 void addContextMenuCloseListener(ContextMenu.ContextMenuClosedListener contextMenuClosedListener)
          Adds listener that will be invoked when context menu is closed.
 void addContextMenuComponentListener(ContextMenu.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(ContextMenu.ContextMenuOpenedListener.TableListener contextMenuTableListener)
          Adds listener that will be invoked when context menu is opened from com.vaadin.ui.Table component.
 void addContextMenuTreeListener(ContextMenu.ContextMenuOpenedListener.TreeListener contextMenuTreeListener)
          Adds listener that will be invoked when context menu is openef from com.vaadin.ui.Tree component.
 ContextMenu.ContextMenuItem addItem(com.vaadin.server.Resource icon)
          Adds new item to context menu root with given icon without caption.
 ContextMenu.ContextMenuItem addItem(String caption)
          Adds new item to context menu root with given caption.
 ContextMenu.ContextMenuItem addItem(String caption, com.vaadin.server.Resource icon)
          Adds new item to context menu root with given caption and icon.
 void addItemClickListener(ContextMenu.ContextMenuItemClickListener clickListener)
          Adds click listener to context menu.
protected  String getNextId()
           
protected  ContextMenuState getState()
           
 void open(int x, int y)
          Opens the context menu to given coordinates.
 void removeAllItems()
          Removes all items from the context menu.
 void removeRootItem(ContextMenu.ContextMenuItem contextMenuItem)
          Removes given root 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.ui.Table table)
          Assigns this as the context menu of given table.
 void setAsTreeContextMenu(com.vaadin.ui.Tree tree)
          Assigns this as context menu of given tree.
 void setOpenAutomatically(boolean openAutomatically)
          Enables or disables open automatically feature.
 
Methods inherited from class com.vaadin.server.AbstractExtension
extend, getParent, getSupportedParentType, remove, setParent
 
Methods inherited from class com.vaadin.server.AbstractClientConnector
addAttachListener, addDetachListener, addExtension, addListener, addListener, addListener, addMethodInvocationToQueue, attach, beforeClientResponse, createState, detach, encodeState, fireEvent, getAllChildrenIterable, getConnectorId, getErrorHandler, getExtensions, getListeners, getResource, getRpcManager, getRpcProxy, getSession, getState, getStateType, getUI, handleConnectorRequest, hasListeners, isAttached, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, registerRpc, registerRpc, removeAttachListener, removeDetachListener, removeExtension, removeListener, removeListener, removeListener, removeListener, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler, setResource
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, 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 Detail

ContextMenu

public ContextMenu()
Method Detail

getNextId

protected String getNextId()

setOpenAutomatically

public void setOpenAutomatically(boolean openAutomatically)
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 -

addItem

public ContextMenu.ContextMenuItem addItem(String caption)
Adds new item to context menu root with given caption.

Parameters:
caption -
Returns:
reference to newly added item

addItem

public ContextMenu.ContextMenuItem addItem(com.vaadin.server.Resource icon)
Adds new item to context menu root with given icon without caption.

Parameters:
icon -
Returns:
reference to newly added item

addItem

public ContextMenu.ContextMenuItem addItem(String caption,
                                           com.vaadin.server.Resource icon)
Adds new item to context menu root with given caption and icon.

Parameters:
caption -
icon -
Returns:
reference to newly added item

removeRootItem

public void removeRootItem(ContextMenu.ContextMenuItem contextMenuItem)
Removes given root item from the context menu

Parameters:
contextMenuItem -

removeAllItems

public void removeAllItems()
Removes all items from the context menu.


setAsTableContextMenu

public void setAsTableContextMenu(com.vaadin.ui.Table table)
Assigns this as the context menu of given table.

Parameters:
table -

setAsTreeContextMenu

public void setAsTreeContextMenu(com.vaadin.ui.Tree tree)
Assigns this as context menu of given tree.

Parameters:
tree -

setAsContextMenuOf

public void setAsContextMenuOf(com.vaadin.server.AbstractClientConnector component)
Assigns this as context menu of given component which will react to right mouse button click.

Parameters:
component -

open

public void open(int x,
                 int y)
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. Using this method is not recommended and should be used only when there is no reasonable way for listeners to detect that menu was otherwise opened.

Parameters:
x -
y -

getState

protected ContextMenuState getState()
Overrides:
getState in class com.vaadin.server.AbstractClientConnector

addItemClickListener

public void addItemClickListener(ContextMenu.ContextMenuItemClickListener clickListener)
Adds click listener to context menu. This listener will be invoked when any of the menu items in this menu are clicked.

Parameters:
clickListener -

addContextMenuTableListener

public void addContextMenuTableListener(ContextMenu.ContextMenuOpenedListener.TableListener contextMenuTableListener)
Adds listener that will be invoked when context menu is opened from com.vaadin.ui.Table component.

Parameters:
contextMenuTableListener -

addContextMenuTreeListener

public void addContextMenuTreeListener(ContextMenu.ContextMenuOpenedListener.TreeListener contextMenuTreeListener)
Adds listener that will be invoked when context menu is openef from com.vaadin.ui.Tree component.

Parameters:
contextMenuTreeListener -

addContextMenuCloseListener

public void addContextMenuCloseListener(ContextMenu.ContextMenuClosedListener contextMenuClosedListener)
Adds listener that will be invoked when context menu is closed.

Parameters:
contextMenuClosedListener -

addContextMenuComponentListener

public void addContextMenuComponentListener(ContextMenu.ContextMenuOpenedListener.ComponentListener contextMenuComponentListener)
Adds listener that will be invoked when context menu is opened from the component to which it's assigned to.

Parameters:
contextMenuComponentListener -


Copyright © 2013 Magnolia International Ltd.. All Rights Reserved.