Package org.eclipse.ui.menus

# Class UIElement

java.lang.Object
org.eclipse.ui.menus.UIElement

public abstract class UIElement extends Object
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

Constructors
Modifier
Constructor
Description
`protected`
`UIElement(IServiceLocator serviceLocator)`
Construct a new instance of this class keyed off of the provided service locator.

## Method Summary

Modifier and Type
Method
Description
`final IServiceLocator`
`getServiceLocator()`
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`
`setDisabledIcon(ImageDescriptor desc)`
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`
`setText(String text)`
Update the label on this UI element.
`abstract void`
`setTooltip(String text)`
Update the tooltip on this UI element.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### UIElement

protected UIElement(IServiceLocator serviceLocator) throws IllegalArgumentException
Construct a new instance of this class keyed off of the provided service locator.

Parameters:
  `serviceLocator` - the locator. May not be `null`.
Throws:
  `IllegalArgumentException`

## Method Details

### setText

public abstract void setText(String text)
Update the label on this UI element.

Parameters:
  `text` - The new label to display.

### setTooltip

public abstract void setTooltip(String text)
Update the tooltip on this UI element. Tooltips are currently only valid for toolbar contributions.

Parameters:
  `text` - The new tooltip to display.

### setIcon

public abstract void setIcon(ImageDescriptor desc)
Update the icon on this UI element.

Parameters:
  `desc` - The descriptor for the new icon to display.

### setDisabledIcon

public abstract void setDisabledIcon(ImageDescriptor desc)
Update the disabled icon on this UI element.

Parameters:
  `desc` - The descriptor for the new icon to display.

### setHoverIcon

public abstract void setHoverIcon(ImageDescriptor desc)
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

public final IServiceLocator getServiceLocator()
Get the service locator scope in which this UI element resides. May not be `null`.

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 to `IWorkbench`, `IWorkbenchWindow`, and `IWorkbenchPartSite`. While this method may not return `null` requests for any of these particular services may return `null`.

Returns:
  the service locator for this element
See Also:
  - `IServiceLocator.getService(Class)`

### setDropDownId

public void setDropDownId(String id)
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 be `null`.