Package org.eclipse.ui.menus
Class UIElement
java.lang.Object
org.eclipse.ui.menus.UIElement
Allow a command or application to provide feedback to a user through updating
a MenuItem or ToolItem. Initially used to update properties for UI elements
created by the CommandContributionItem.
This class may be extended by clients.
- Since:
- 3.3
-
Constructor Summary
ModifierConstructorDescriptionprotected
UIElement
(IServiceLocator serviceLocator) Construct a new instance of this class keyed off of the provided service locator. -
Method Summary
Modifier and TypeMethodDescriptionfinal IServiceLocator
Get the service locator scope in which this UI element resides.abstract void
setChecked
(boolean checked) Update the checked state on this UI element.abstract void
Update the disabled icon on this UI element.void
setDropDownId
(String id) Set the menu contribution id to use.abstract void
setHoverIcon
(ImageDescriptor desc) Update the hover icon on this UI element.abstract void
setIcon
(ImageDescriptor desc) Update the icon on this UI element.abstract void
Update the label on this UI element.abstract void
setTooltip
(String text) Update the tooltip on this UI element.
-
Constructor Details
-
UIElement
Construct a new instance of this class keyed off of the provided service locator.- Parameters:
serviceLocator
- the locator. May not benull
.- Throws:
IllegalArgumentException
-
-
Method Details
-
setText
Update the label on this UI element.- Parameters:
text
- The new label to display.
-
setTooltip
Update the tooltip on this UI element. Tooltips are currently only valid for toolbar contributions.- Parameters:
text
- The new tooltip to display.
-
setIcon
Update the icon on this UI element.- Parameters:
desc
- The descriptor for the new icon to display.
-
setDisabledIcon
Update the disabled icon on this UI element.- Parameters:
desc
- The descriptor for the new icon to display.
-
setHoverIcon
Update the hover icon on this UI element.- Parameters:
desc
- The descriptor for the new icon to display.
-
setChecked
public abstract void setChecked(boolean checked) Update the checked state on this UI element. For example, if this was a toggle or radio button.- Parameters:
checked
- true to set toggle on
-
getServiceLocator
Get the service locator scope in which this UI element resides. May not benull
.The locator may be used to obtain services that are scoped in the same way as the
UIElement
. Such services include but are not limited toIWorkbench
,IWorkbenchWindow
, andIWorkbenchPartSite
. While this method may not returnnull
requests for any of these particular services may returnnull
.- Returns:
- the service locator for this element
- See Also:
-
setDropDownId
Set the menu contribution id to use. This is only applicable to menu contributions that support a drop-down style menu. The default implementation does nothing.Example: element.setDropdownId("org.eclipse.ui.navigate.back.my.menu");
- Parameters:
id
- used to populate the dropdown menu. Must not benull
.
-