public class PopupMenu
extends java.lang.Object
The show()
method returns false if the user cancelled the
gesture or clicked outside the popup.
The getResult()
method returns the result which is the object
from the content list that the user selected, or in the case of cascading
menus, a list of the results from each popup.
Modifier and Type | Class and Description |
---|---|
static class |
PopupMenu.CascadingMenu
An instance of this class can be created to add a submenu to a menu item
in a
PopupMenu . |
Constructor and Description |
---|
PopupMenu(java.util.List<?> aContent,
ILabelProvider aLabelProvider)
Creates a new
PopupMenu . |
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
getResult()
Gets the result which is the object from the content list that the user
selected, or in the case of cascading menus, a list of the results from
each popup.
|
void |
setContent(java.util.List<?> aContent)
Sets the content.
|
void |
setLabelProvider(ILabelProvider aLabelProvider)
Sets the labelProvider.
|
boolean |
show(Control parent)
Shows the popup menu and sets the resultList selected by the user.
|
public PopupMenu(java.util.List<?> aContent, ILabelProvider aLabelProvider)
PopupMenu
.aContent
- the content for the menu, each object in the list represents a
menu itemaLabelProvider
- the label provider used to provide the text for each object in
the content listpublic boolean show(Control parent)
parent
- menu will be shown in this parent Controlpublic void setContent(java.util.List<?> aContent)
aContent
- The content of this menu. Each entry in the list becomes a
menu item.public void setLabelProvider(ILabelProvider aLabelProvider)
aLabelProvider
- Provides the text and icon for each menu item.public java.lang.Object getResult()