org.vaadin.peter.contextmenu.client
Class ContextMenuItemWidget

java.lang.Object
  extended by com.google.gwt.user.client.ui.UIObject
      extended by com.google.gwt.user.client.ui.Widget
          extended by com.google.gwt.user.client.ui.FocusWidget
              extended by org.vaadin.peter.contextmenu.client.ContextMenuItemWidget
All Implemented Interfaces:
com.google.gwt.event.dom.client.HasAllDragAndDropHandlers, com.google.gwt.event.dom.client.HasAllFocusHandlers, com.google.gwt.event.dom.client.HasAllGestureHandlers, com.google.gwt.event.dom.client.HasAllKeyHandlers, com.google.gwt.event.dom.client.HasAllMouseHandlers, com.google.gwt.event.dom.client.HasAllTouchHandlers, com.google.gwt.event.dom.client.HasBlurHandlers, com.google.gwt.event.dom.client.HasClickHandlers, com.google.gwt.event.dom.client.HasDoubleClickHandlers, com.google.gwt.event.dom.client.HasDragEndHandlers, com.google.gwt.event.dom.client.HasDragEnterHandlers, com.google.gwt.event.dom.client.HasDragHandlers, com.google.gwt.event.dom.client.HasDragLeaveHandlers, com.google.gwt.event.dom.client.HasDragOverHandlers, com.google.gwt.event.dom.client.HasDragStartHandlers, com.google.gwt.event.dom.client.HasDropHandlers, com.google.gwt.event.dom.client.HasFocusHandlers, com.google.gwt.event.dom.client.HasGestureChangeHandlers, com.google.gwt.event.dom.client.HasGestureEndHandlers, com.google.gwt.event.dom.client.HasGestureStartHandlers, com.google.gwt.event.dom.client.HasKeyDownHandlers, com.google.gwt.event.dom.client.HasKeyPressHandlers, com.google.gwt.event.dom.client.HasKeyUpHandlers, com.google.gwt.event.dom.client.HasMouseDownHandlers, com.google.gwt.event.dom.client.HasMouseMoveHandlers, com.google.gwt.event.dom.client.HasMouseOutHandlers, com.google.gwt.event.dom.client.HasMouseOverHandlers, com.google.gwt.event.dom.client.HasMouseUpHandlers, com.google.gwt.event.dom.client.HasMouseWheelHandlers, com.google.gwt.event.dom.client.HasTouchCancelHandlers, com.google.gwt.event.dom.client.HasTouchEndHandlers, com.google.gwt.event.dom.client.HasTouchMoveHandlers, com.google.gwt.event.dom.client.HasTouchStartHandlers, com.google.gwt.event.logical.shared.HasAttachHandlers, com.google.gwt.event.shared.HasHandlers, com.google.gwt.user.client.EventListener, com.google.gwt.user.client.ui.Focusable, com.google.gwt.user.client.ui.HasEnabled, com.google.gwt.user.client.ui.HasFocus, com.google.gwt.user.client.ui.HasVisibility, com.google.gwt.user.client.ui.IsWidget, com.google.gwt.user.client.ui.SourcesClickEvents, com.google.gwt.user.client.ui.SourcesFocusEvents, com.google.gwt.user.client.ui.SourcesKeyboardEvents, com.google.gwt.user.client.ui.SourcesMouseEvents

public class ContextMenuItemWidget
extends com.google.gwt.user.client.ui.FocusWidget

ContextMenuItemWidget is client side widget that represents one menu item in context menu.

Author:
Peter Lehto / Vaadin Ltd

Nested Class Summary
 
Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject
com.google.gwt.user.client.ui.UIObject.DebugIdImpl, com.google.gwt.user.client.ui.UIObject.DebugIdImplEnabled
 
Field Summary
protected  com.google.gwt.dom.client.ImageElement icon
           
 
Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX
 
Constructor Summary
ContextMenuItemWidget()
           
 
Method Summary
 void addSubMenuItem(ContextMenuItemWidget contextMenuItem)
          Adds given context menu item into the sub menu of this item.
 void clearItems()
          Removes all the items from the submenu of this item.
 void closeSiblingMenus()
           
protected  void closeThisAndSelectParent()
           
 boolean eventTargetsPopup(com.google.gwt.user.client.Event nativeEvent)
           
 String getId()
           
 ContextMenuItemWidget getParentItem()
           
 boolean hasSubMenu()
           
 void hideSubMenu()
          Hides the sub menu that's been opened from this item
 boolean isRootItem()
           
 boolean isSubmenuOpen()
           
protected  boolean onItemClicked()
          Called when context menu item is clicked or is focused and enter is pressed.
protected  void selectLowerSibling()
           
protected  void selectUpperSibling()
           
 void setCaption(String caption)
           
 void setEnabled(boolean enabled)
           
 void setFocus(boolean focused)
           
 void setIcon(String url)
           
 void setId(String id)
           
 void setOverlay(org.vaadin.peter.contextmenu.client.ContextMenuOverlay owner)
          Sets the menu component to which this item belongs to
 void setParentItem(ContextMenuItemWidget parentItem)
          Sets parent item meaning that this item is in the sub menu of given parent item.
 void setRootComponent(ContextMenuWidget rootComponent)
           
 void setSeparatorVisible(boolean separatorVisible)
           
 
Methods inherited from class com.google.gwt.user.client.ui.FocusWidget
addBlurHandler, addClickHandler, addClickListener, addDoubleClickHandler, addDragEndHandler, addDragEnterHandler, addDragHandler, addDragLeaveHandler, addDragOverHandler, addDragStartHandler, addDropHandler, addFocusHandler, addFocusListener, addGestureChangeHandler, addGestureEndHandler, addGestureStartHandler, addKeyboardListener, addKeyDownHandler, addKeyPressHandler, addKeyUpHandler, addMouseDownHandler, addMouseListener, addMouseMoveHandler, addMouseOutHandler, addMouseOverHandler, addMouseUpHandler, addMouseWheelHandler, addMouseWheelListener, addTouchCancelHandler, addTouchEndHandler, addTouchMoveHandler, addTouchStartHandler, getFocusImpl, getTabIndex, isEnabled, onAttach, removeClickListener, removeFocusListener, removeKeyboardListener, removeMouseListener, removeMouseWheelListener, setAccessKey, setTabIndex
 
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, isAttached, isOrWasAttached, onBrowserEvent, onDetach, 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, resolvePotentialElement, setElement, setElement, setHeight, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkBitlessEvent, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.google.gwt.event.shared.HasHandlers
fireEvent
 

Field Detail

icon

protected com.google.gwt.dom.client.ImageElement icon
Constructor Detail

ContextMenuItemWidget

public ContextMenuItemWidget()
Method Detail

setFocus

public void setFocus(boolean focused)
Specified by:
setFocus in interface com.google.gwt.user.client.ui.Focusable
Overrides:
setFocus in class com.google.gwt.user.client.ui.FocusWidget

hasSubMenu

public boolean hasSubMenu()
Returns:
true if this item has a sub menu

hideSubMenu

public void hideSubMenu()
Hides the sub menu that's been opened from this item


isRootItem

public boolean isRootItem()
Returns:
true if this item is an item in the root menu, false otherwise

setOverlay

public void setOverlay(org.vaadin.peter.contextmenu.client.ContextMenuOverlay owner)
Sets the menu component to which this item belongs to

Parameters:
owner -

setParentItem

public void setParentItem(ContextMenuItemWidget parentItem)
Sets parent item meaning that this item is in the sub menu of given parent item.

Parameters:
parentItem -

getParentItem

public ContextMenuItemWidget getParentItem()
Returns:
menu item that opened the menu to which this item belongs

isSubmenuOpen

public boolean isSubmenuOpen()
Returns:
true if this menu has a sub menu and it's open

clearItems

public void clearItems()
Removes all the items from the submenu of this item. If this menu item does not have a sub menu, this call has no effect.


addSubMenuItem

public void addSubMenuItem(ContextMenuItemWidget contextMenuItem)
Adds given context menu item into the sub menu of this item.

Parameters:
contextMenuItem -

setCaption

public void setCaption(String caption)

setIcon

public void setIcon(String url)

setRootComponent

public void setRootComponent(ContextMenuWidget rootComponent)

setId

public void setId(String id)

getId

public String getId()

closeSiblingMenus

public void closeSiblingMenus()

selectLowerSibling

protected void selectLowerSibling()

selectUpperSibling

protected void selectUpperSibling()

closeThisAndSelectParent

protected void closeThisAndSelectParent()

onItemClicked

protected boolean onItemClicked()
Called when context menu item is clicked or is focused and enter is pressed.

Returns:
true if context menu was closed after the click, false otherwise

eventTargetsPopup

public boolean eventTargetsPopup(com.google.gwt.user.client.Event nativeEvent)
Parameters:
nativeEvent -
Returns:
true if given event targets the overlay of this menu item or overlay of any of this item's child item.

setSeparatorVisible

public void setSeparatorVisible(boolean separatorVisible)

setEnabled

public void setEnabled(boolean enabled)
Specified by:
setEnabled in interface com.google.gwt.user.client.ui.HasEnabled
Overrides:
setEnabled in class com.google.gwt.user.client.ui.FocusWidget


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