public class MenuCombo extends com.google.gwt.user.client.ui.FlowPanel implements IMenuCombo
MenuCombo
makes it simpler and safer to build Menu
s. It
absorbs the complexity of creating a Menu
and its related action
Button
. In fact, for the Menu
to work properly some
requirements must be satisfied. With mdl, these requirement are the
responsibility of the developer. This component's goal is to encapsulate
these requirements and to hide them from the developer. By enforcing these
rules inside the menu, the developer's full attention goes to the application
logic. These requirements are as follows :Menu
is. Otherwise, the Menu
won't be able to attach its
event handlers to it.Button
.Menu
should reference the id of its related Button
in
order for mdl to bind them together. The developer should provide an id for
the Button
which should then be fed to the Menu
.
Button
.com.google.gwt.user.client.ui.UIObject.DebugIdImpl, com.google.gwt.user.client.ui.UIObject.DebugIdImplEnabled
Modifier and Type | Method and Description |
---|---|
void |
addItem(String item,
boolean enabled)
Syntactic sugar for
IMenu.addItem(String, String, boolean) where
the text and value are the same. |
void |
addItem(String text,
String value,
boolean enabled)
Adds a new option to the list of options in the menu.
|
void |
addItem(String text,
String value,
int index,
boolean enabled)
Adds a an option into the set of options of the menu at a specified
position.
|
void |
addItemClickListener(Menu.ItemClickListener listener)
When an object needs to be notified upon a
MenuItem click, it must
be be registered to the Menu as an Menu.ItemClickListener .In order to receive item click notifications, the object should : Implement the Menu.ItemClickListener interface
Define the actions that should be performed when a MenuItem is
clicked inside Menu.ItemClickListener.onItemClicked(ItemClickEvent)
Call Menu.addItemClickListener(ItemClickListener) to register
itself to the menu and receive click notifications
|
void |
clearMenu()
Remove all items from the menu.
|
int |
getItemCount()
Returns the items count in a menu.
|
String |
getItemText(int index)
return the text of the item located at the position provided as input.
|
int |
getTabIndex() |
String |
getValue(int index)
return the value of the item located at the position provided as input.
|
boolean |
isEnabled() |
boolean |
isEnabled(int index)
Modify the enabled state of an item.
|
boolean |
isUpgraded() |
void |
removeItem(int index)
Removes an item from the menu.
|
void |
setAccessKey(char key) |
void |
setAnchor(MenuAnchor anchor)
Sets the position of the
Menu on the screen related to its
associated action button using one of the available anchoring options
provided by MenuAnchor .An extra care should be taken when anchoring the menu. |
void |
setEnabled(boolean enable) |
boolean |
setEnabled(int index,
boolean enabled)
Modify the enabled state of an item.
|
void |
setEventSource(Object inputSource) |
void |
setFocus(boolean focused) |
void |
setTabIndex(int index) |
void |
upgrade()
Causes the component to be upgraded.
|
add, add, adjustIndex, checkIndexBoundsForAccess, checkIndexBoundsForInsertion, getChildren, getWidget, getWidgetCount, getWidgetIndex, getWidgetIndex, insert, insert, iterator, remove, remove
add, adopt, doAttachChildren, doDetachChildren, orphan, remove
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, fireEvent, getHandlerCount, getLayoutData, getParent, isAttached, isOrWasAttached, onAttach, onBrowserEvent, onDetach, onLoad, onUnload, removeFromParent, setLayoutData, sinkEvents, unsinkEvents
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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
public MenuCombo(Button btn)
MenuCombo
.Button
and a Menu
that works
together to display the menu to the user when the button is clicked. Using
this constructor, the user provides the instance of the button. The menu
property is managed behind the scene at the combo.btn
- the action button for the menupublic void setEventSource(Object inputSource)
setEventSource
in interface IHasEventSource
inputSource
- the object that designated as the source of events published by
the menupublic void setEnabled(boolean enable)
setEnabled
in interface IMenuCombo
enable
- if true
then the action button of the menu is set to
be enabled, false
then the action button is disabledpublic boolean isEnabled()
isEnabled
in interface IMenuCombo
true
if the menu's action button is enabled,
false
if it is disabled.public final void setAnchor(MenuAnchor anchor)
IMenu
Menu
on the screen related to its
associated action button using one of the available anchoring options
provided by MenuAnchor
.public final void clearMenu()
IMenu
public final void addItem(String text, String value, boolean enabled)
IMenu
public final void addItem(String item, boolean enabled)
IMenu
IMenu.addItem(String, String, boolean)
where
the text and value are the same.public void addItem(String text, String value, int index, boolean enabled)
IMenu
public final void addItemClickListener(Menu.ItemClickListener listener)
IMenu
MenuItem
click, it must
be be registered to the Menu
as an Menu.ItemClickListener
.Menu.ItemClickListener
interfaceMenuItem
is
clicked inside Menu.ItemClickListener.onItemClicked(ItemClickEvent)
Menu.addItemClickListener(ItemClickListener)
to register
itself to the menu and receive click notificationsaddItemClickListener
in interface IMenu
listener
- The object to be notified when a MenuItem
is clicked.Menu.ItemClickListener
public final int getItemCount()
IMenu
getItemCount
in interface IMenu
public final String getItemText(int index)
IMenu
getItemText
in interface IMenu
index
- the position of the itempublic final String getValue(int index)
IMenu
public final boolean setEnabled(int index, boolean enabled)
IMenu
setEnabled
in interface IMenu
index
- the position of the item in the item list of the menuenabled
- the state to be set for the itemtrue
if the state was modified, false
otherwise.public final boolean isEnabled(int index)
IMenu
public void removeItem(int index)
IMenu
removeItem
in interface IMenu
index
- the position of the item to be removedpublic int getTabIndex()
getTabIndex
in interface com.google.gwt.user.client.ui.Focusable
public void setAccessKey(char key)
setAccessKey
in interface com.google.gwt.user.client.ui.Focusable
public void setFocus(boolean focused)
setFocus
in interface com.google.gwt.user.client.ui.Focusable
public void setTabIndex(int index)
setTabIndex
in interface com.google.gwt.user.client.ui.Focusable
public void upgrade()
IUpgrade
public boolean isUpgraded()
isUpgraded
in interface IUpgrade
Copyright © 2016 com.github.ilyes4j. All rights reserved.