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 Details

  • 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:
    • 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.