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.DebugIdImplEnabled
Nested classes/interfaces inherited from interface HasDirection
HasDirection.Direction
Nested classes/interfaces inherited from interface HasHorizontalAlignment
HasHorizontalAlignment.AutoHorizontalAlignmentConstant, HasHorizontalAlignment.HorizontalAlignmentConstant
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ContextMenu
Reference to submenu if this menu item controls one andnull
otherwise.(package private) Scheduler.ScheduledCommand
Command that gets executed when selecting this menu item andnull
if this menu item controls a submenu.private boolean
Flag to indicate whether menu item is enabled.Fields inherited from class Label
DEFAULT_DIRECTION_ESTIMATOR
Fields inherited from class UIObject
DEBUG_ID_PREFIX
Fields inherited from interface HasAutoHorizontalAlignment
ALIGN_CONTENT_END, ALIGN_CONTENT_START
Fields 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 titlename
and triggers the commandcmd
when selected.ContextMenuItem
(String name, ContextMenu child) Create a new context menu item with the titlename
that controls the submenuchild
. -
Method Summary
Modifier and TypeMethodDescriptionprivate void
_open()
Open submenu.void
action()
Entry method when context menu item is selected.void
close()
Set timer to close submenu, if there is one, otherwise close this context menu without delay.protected void
closeNow()
Close submenu without delay.boolean
Check if context menu item controls a submenu.boolean
void
onClick
(ClickEvent event) void
onContextMenu
(ContextMenuEvent event) void
onMouseOut
(MouseOutEvent event) void
onMouseOver
(MouseOverEvent event) boolean
open()
Open submenu if context menu item is enabled and controls a submenu withautoOpen
set totrue
.void
setEnabled
(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, wrap
Methods inherited from class LabelBase
getAutoHorizontalAlignment, getDirectionEstimator, getHorizontalAlignment, getWordWrap, setAutoHorizontalAlignment, setDirectionEstimator, setDirectionEstimator, setHorizontalAlignment, setWordWrap, updateHorizontalAlignment
Methods 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, unsinkEvents
Methods 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, toString
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface HasHandlers
fireEvent
-
Field Details
-
cmd
Command that gets executed when selecting this menu item andnull
if this menu item controls a submenu. -
childMenu
Reference to submenu if this menu item controls one andnull
otherwise. -
isEnabled
private boolean isEnabledFlag to indicate whether menu item is enabled.
-
-
Constructor Details
-
ContextMenuItem
Create a new context menu item with the titlename
and triggers the commandcmd
when selected.- Parameters:
name
- title of context menu itemcmd
- command to execute when selected
-
ContextMenuItem
Create a new context menu item with the titlename
that controls the submenuchild
. For CSS styling, context menu items that control a submenu have the classsubmenu
added.- 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 withautoOpen
set totrue
.- Returns:
true
if submenu has been opened andfalse
otherwise
-
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:
setEnabled
in interfaceHasEnabled
-
isEnabled
public boolean isEnabled()- Specified by:
isEnabled
in interfaceHasEnabled
-
onMouseOut
Close submenu, if context menu item controls one, and if the submenu has
autoClose
set totrue
, unless pointer now hovers over submenu.- Specified by:
onMouseOut
in interfaceMouseOutHandler
-
onMouseOver
Open submenu, if context menu item controls one, and if the submenu has
autoOpen
set totrue
. Otherwise do nothing.- Specified by:
onMouseOver
in interfaceMouseOverHandler
-
onClick
Context menu item selected. Execute associated action or toggle visibility of submenu
autoOpen
andautoClose
arefalse
.- Specified by:
onClick
in interfaceClickHandler
- See Also:
-
onContextMenu
Suppress default context menu.
- Specified by:
onContextMenu
in interfaceContextMenuHandler
-