Class PopupMenu
java.lang.Object
org.eclipse.graphiti.ui.internal.util.ui.PopupMenu
A simple pop-up menu with a list from which the user can select one item.
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.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
An instance of this class can be created to add a submenu to a menu item in aPopupMenu
. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
createMenuItems
(org.eclipse.swt.widgets.Menu parentMenu, PopupMenu rootMenu, List<Object> resultThusFar) Creates the menu items based on the content list.protected List<?>
Gets the content.protected org.eclipse.jface.viewers.ILabelProvider
Gets the labelProvider.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
(List<?> aContent) Sets the content.void
setLabelProvider
(org.eclipse.jface.viewers.ILabelProvider aLabelProvider) Sets the labelProvider.protected void
Sets the resultList.boolean
show
(org.eclipse.swt.widgets.Control parent) Shows the popup menu and sets the resultList selected by the user.
-
Constructor Details
-
PopupMenu
Creates a newPopupMenu
.- Parameters:
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 list
-
-
Method Details
-
show
public boolean show(org.eclipse.swt.widgets.Control parent) Shows the popup menu and sets the resultList selected by the user.- Parameters:
parent
- menu will be shown in this parent Control- Returns:
- true if this succeeded, false otherwise (e.g. if the user cancelled the gesture).
-
createMenuItems
protected void createMenuItems(org.eclipse.swt.widgets.Menu parentMenu, PopupMenu rootMenu, List<Object> resultThusFar) Creates the menu items based on the content list.- Parameters:
parentMenu
- the parent Menu that the menu items will be created inrootMenu
- the root level MenuresultThusFar
- List of content objects, e.g. CascadingMenu objects
-
getContent
Gets the content.- Returns:
- Returns the content.
-
setContent
Sets the content.- Parameters:
aContent
- The content of this menu. Each entry in the list becomes a menu item.
-
getLabelProvider
protected org.eclipse.jface.viewers.ILabelProvider getLabelProvider()Gets the labelProvider.- Returns:
- Returns the labelProvider.
-
setLabelProvider
public void setLabelProvider(org.eclipse.jface.viewers.ILabelProvider aLabelProvider) Sets the labelProvider.- Parameters:
aLabelProvider
- Provides the text and icon for each menu item.
-
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.- Returns:
- Returns the resultList.
-
setResult
Sets the resultList.- Parameters:
aResultList
- The resultList to set.
-