org.eclipse.ui.menus.UIElement Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of workbench Show documentation
Show all versions of workbench Show documentation
This plug-in contains the bulk of the Workbench implementation, and depends on JFace, SWT, and Core Runtime. It cannot be used independently from org.eclipse.ui. Workbench client plug-ins should not depend directly on this plug-in.
The newest version!
/*******************************************************************************
* Copyright (c) 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
******************************************************************************/
package org.eclipse.ui.menus;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPartSite;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.services.IServiceLocator;
/**
* 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
*/
public abstract class UIElement {
private IServiceLocator serviceLocator;
/**
* Construct a new instance of this class keyed off of the provided service
* locator.
*
* @param serviceLocator
* the locator. May not be null
.
*/
protected UIElement(IServiceLocator serviceLocator)
throws IllegalArgumentException {
if (serviceLocator == null)
throw new IllegalArgumentException();
this.serviceLocator = serviceLocator;
}
/**
* Update the label on this UI element.
*
* @param text
* The new label to display.
*/
public abstract void setText(String text);
/**
* Update the tooltip on this UI element. Tooltips are currently only valid
* for toolbar contributions.
*
* @param text
* The new tooltip to display.
*/
public abstract void setTooltip(String text);
/**
* Update the icon on this UI element.
*
* @param desc
* The descriptor for the new icon to display.
*/
public abstract void setIcon(ImageDescriptor desc);
/**
* Update the disabled icon on this UI element.
*
* @param desc
* The descriptor for the new icon to display.
*/
public abstract void setDisabledIcon(ImageDescriptor desc);
/**
* Update the hover icon on this UI element.
*
* @param desc
* The descriptor for the new icon to display.
*/
public abstract void setHoverIcon(ImageDescriptor desc);
/**
* Update the checked state on this UI element. For example, if this was a
* toggle or radio button.
*
* @param checked
* true to set toggle on
*/
public abstract void setChecked(boolean checked);
/**
* 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 {@link UIElement}. Such services include but are not limited
* to {@link IWorkbench}, {@link IWorkbenchWindow}, and
* {@link IWorkbenchPartSite}. While this method may not return
* null
requests for any of these particular services may
* return null
.
*
*
* @return the service locator for this element
* @see IServiceLocator#getService(Class)
*/
public final IServiceLocator getServiceLocator() {
return serviceLocator;
}
/**
* 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");
*
*
* @param id
* used to populate the dropdown menu. Must not be
* null
.
*/
public void setDropDownId(String id) {
// This does nothing.
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy