Package org.evoludo.ui
Class ContextMenuItem
- All Implemented Interfaces:
IsEditor<LeafValueEditor<String>>,ClickHandler,ContextMenuHandler,HasAllDragAndDropHandlers,HasAllGestureHandlers,HasAllMouseHandlers,HasAllTouchHandlers,HasClickHandlers,HasDoubleClickHandlers,HasDragEndHandlers,HasDragEnterHandlers,HasDragHandlers,HasDragLeaveHandlers,HasDragOverHandlers,HasDragStartHandlers,HasDropHandlers,HasGestureChangeHandlers,HasGestureEndHandlers,HasGestureStartHandlers,HasMouseDownHandlers,HasMouseMoveHandlers,HasMouseOutHandlers,HasMouseOverHandlers,HasMouseUpHandlers,HasMouseWheelHandlers,HasTouchCancelHandlers,HasTouchEndHandlers,HasTouchMoveHandlers,HasTouchStartHandlers,MouseOutHandler,MouseOverHandler,HasAttachHandlers,EventHandler,HasHandlers,HasDirection,HasDirectionEstimator,EventListener,HasAutoHorizontalAlignment,HasDirectionalText,HasEnabled,HasHorizontalAlignment,HasText,HasVisibility,HasWordWrap,IsWidget,SourcesClickEvents,SourcesMouseEvents
- Direct Known Subclasses:
ContextMenuCheckBoxItem
public class ContextMenuItem
extends Label
implements HasEnabled, MouseOverHandler, MouseOutHandler, ClickHandler, ContextMenuHandler
Component of the context menu extension to GWT's user interface.
Represents a menu item in the context menu. The context menu item may either execute a command when selected or control the visibility of a submenu.
CSS Style Rules
- .gwt-ContextMenuItem
- the context menu item element.
- .gwt-ContextMenuItem-disabled
- if the context menu item is disabled.
- .submenu
- if the context menu item controls a submenu.
- Author:
- Christoph Hauert
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class UIObject
UIObject.DebugIdImpl, UIObject.DebugIdImplEnabledNested classes/interfaces inherited from interface HasDirection
HasDirection.DirectionNested classes/interfaces inherited from interface HasHorizontalAlignment
HasHorizontalAlignment.AutoHorizontalAlignmentConstant, HasHorizontalAlignment.HorizontalAlignmentConstant -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ContextMenuReference to submenu if this menu item controls one andnullotherwise.(package private) Scheduler.ScheduledCommandCommand that gets executed when selecting this menu item andnullif this menu item controls a submenu.private booleanFlag to indicate whether menu item is enabled.Fields inherited from class Label
DEFAULT_DIRECTION_ESTIMATORFields inherited from class UIObject
DEBUG_ID_PREFIXFields inherited from interface HasAutoHorizontalAlignment
ALIGN_CONTENT_END, ALIGN_CONTENT_STARTFields inherited from interface HasHorizontalAlignment
ALIGN_CENTER, ALIGN_DEFAULT, ALIGN_JUSTIFY, ALIGN_LEFT, ALIGN_LOCALE_END, ALIGN_LOCALE_START, ALIGN_RIGHT -
Constructor Summary
ConstructorsConstructorDescriptionContextMenuItem(String name, Scheduler.ScheduledCommand cmd) Create a new context menu item with the titlenameand triggers the commandcmdwhen selected.ContextMenuItem(String name, ContextMenu child) Create a new context menu item with the titlenamethat controls the submenuchild. -
Method Summary
Modifier and TypeMethodDescriptionprivate void_open()Open submenu.voidaction()Entry method when context menu item is selected.voidclose()Set timer to close submenu, if there is one, otherwise close this context menu without delay.protected voidcloseNow()Close submenu without delay.booleanCheck if context menu item controls a submenu.booleanvoidonClick(ClickEvent event) voidonContextMenu(ContextMenuEvent event) voidonMouseOut(MouseOutEvent event) voidonMouseOver(MouseOverEvent event) booleanopen()Open submenu if context menu item is enabled and controls a submenu withautoOpenset totrue.voidsetEnabled(boolean enabled) Methods inherited from class Label
addClickHandler, addClickListener, addDoubleClickHandler, addDragEndHandler, addDragEnterHandler, addDragHandler, addDragLeaveHandler, addDragOverHandler, addDragStartHandler, addDropHandler, addGestureChangeHandler, addGestureEndHandler, addGestureStartHandler, addMouseDownHandler, addMouseListener, addMouseMoveHandler, addMouseOutHandler, addMouseOverHandler, addMouseUpHandler, addMouseWheelHandler, addMouseWheelListener, addTouchCancelHandler, addTouchEndHandler, addTouchMoveHandler, addTouchStartHandler, asEditor, getDirection, getText, getTextDirection, removeClickListener, removeMouseListener, removeMouseWheelListener, setDirection, setText, setText, wrapMethods inherited from class LabelBase
getAutoHorizontalAlignment, getDirectionEstimator, getHorizontalAlignment, getWordWrap, setAutoHorizontalAlignment, setDirectionEstimator, setDirectionEstimator, setHorizontalAlignment, setWordWrap, updateHorizontalAlignmentMethods inherited from class Widget
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, doAttachChildren, doDetachChildren, fireEvent, getHandlerCount, getLayoutData, getParent, isAttached, isOrWasAttached, onAttach, onBrowserEvent, onDetach, onLoad, onUnload, removeFromParent, setLayoutData, sinkEvents, unsinkEventsMethods inherited from class 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, toStringMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface HasHandlers
fireEvent
-
Field Details
-
cmd
Command that gets executed when selecting this menu item andnullif this menu item controls a submenu. -
childMenu
Reference to submenu if this menu item controls one andnullotherwise. -
isEnabled
private boolean isEnabledFlag to indicate whether menu item is enabled.
-
-
Constructor Details
-
ContextMenuItem
Create a new context menu item with the titlenameand triggers the commandcmdwhen selected.- Parameters:
name- title of context menu itemcmd- command to execute when selected
-
ContextMenuItem
Create a new context menu item with the titlenamethat controls the submenuchild. For CSS styling, context menu items that control a submenu have the classsubmenuadded.- Parameters:
name- title of context menu itemchild- submenu to control
-
-
Method Details
-
action
public void action()Entry method when context menu item is selected. Nothing happens if the context menu item is disabled. If it controls a submenu then the submenu is opened or closed, respectively. Finally, if a command is assigned then the command is executed. -
_open
private void _open()Open submenu. -
open
public boolean open()Open submenu if context menu item is enabled and controls a submenu withautoOpenset totrue.- Returns:
trueif submenu has been opened andfalseotherwise
-
close
public void close()Set timer to close submenu, if there is one, otherwise close this context menu without delay. -
closeNow
protected void closeNow()Close submenu without delay. -
setEnabled
public void setEnabled(boolean enabled) - Specified by:
setEnabledin interfaceHasEnabled
-
isEnabled
public boolean isEnabled()- Specified by:
isEnabledin interfaceHasEnabled
-
onMouseOut
Close submenu, if context menu item controls one, and if the submenu has
autoCloseset totrue, unless pointer now hovers over submenu.- Specified by:
onMouseOutin interfaceMouseOutHandler
-
onMouseOver
Open submenu, if context menu item controls one, and if the submenu has
autoOpenset totrue. Otherwise do nothing.- Specified by:
onMouseOverin interfaceMouseOverHandler
-
onClick
Context menu item selected. Execute associated action or toggle visibility of submenu
autoOpenandautoClosearefalse.- Specified by:
onClickin interfaceClickHandler- See Also:
-
onContextMenu
Suppress default context menu.
- Specified by:
onContextMenuin interfaceContextMenuHandler
-