org.eclipse.jface.resource.ResourceLocator Java Examples

The following examples show how to use org.eclipse.jface.resource.ResourceLocator. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TabDescriptor.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructor for TabDescriptor.
 *
 * @param configurationElement
 *            the configuration element for the tab descriptor.
 */
public TabDescriptor(IConfigurationElement configurationElement) {
	super();
	if (configurationElement != null) {
		id = configurationElement.getAttribute(ATT_ID);
		label = configurationElement.getAttribute(ATT_LABEL);
		String imageString = configurationElement.getAttribute(ATT_IMAGE);
		if (imageString != null) {
			String name = configurationElement.getDeclaringExtension().getContributor().getName();
			ResourceLocator.imageDescriptorFromBundle(name, imageString).ifPresent(d -> image = d.createImage());
		}
		String indentedString = configurationElement.getAttribute(ATT_INDENTED);
		indented = indentedString != null && indentedString.equals("true"); //$NON-NLS-1$
		category = configurationElement.getAttribute(ATT_CATEGORY);
		afterTab = configurationElement.getAttribute(ATT_AFTER_TAB);
		if (id == null || label == null || category == null) {
			// the tab id, label and category are mandatory - log error
			handleTabError(configurationElement, null);
		}
	}
	selected = false;
}
 
Example #2
Source File: SARLEclipsePlugin.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Replies the image descriptor for the given image path.
 *
 * @param imagePath path of the image.
 * @return the image descriptor.
 */
public ImageDescriptor getImageDescriptor(String imagePath) {
	ImageDescriptor descriptor = getImageRegistry().getDescriptor(imagePath);
	if (descriptor == null) {
		descriptor = ResourceLocator.imageDescriptorFromBundle(SARLEclipsePlugin.PLUGIN_ID, imagePath).orElse(null);
		if (descriptor != null) {
			getImageRegistry().put(imagePath, descriptor);
		}
	}
	return descriptor;
}
 
Example #3
Source File: AbstractGeneratorConfigurationBlock.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Replies the image descriptor.
 *
 * @param imagePath the image path.
 * @return the image descriptor.
 */
@SuppressWarnings("static-method")
protected ImageDescriptor getImageDescriptor(String imagePath) {
	final LangActivator activator = LangActivator.getInstance();
	final ImageRegistry registry = activator.getImageRegistry();
	ImageDescriptor descriptor = registry.getDescriptor(imagePath);
	if (descriptor == null) {
		descriptor = ResourceLocator.imageDescriptorFromBundle(activator.getBundle().getSymbolicName(), imagePath).orElse(null);
		if (descriptor != null) {
			registry.put(imagePath, descriptor);
		}
	}
	return descriptor;
}
 
Example #4
Source File: PyGeneratorUiPlugin.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Replies the image descriptor for the given image path.
 *
 * @param imagePath path of the image.
 * @return the image descriptor.
 */
public ImageDescriptor getImageDescriptor(String imagePath) {
	ImageDescriptor descriptor = getImageRegistry().getDescriptor(imagePath);
	if (descriptor == null) {
		descriptor = ResourceLocator.imageDescriptorFromBundle(PLUGIN_ID, imagePath).orElse(null);
		if (descriptor != null) {
			getImageRegistry().put(imagePath, descriptor);
		}
	}
	return descriptor;
}
 
Example #5
Source File: XpectLabelProvider.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
public static ImageDescriptor getImageDescriptor(String name) {
	String iconPath = "icons/";
	return ResourceLocator.imageDescriptorFromBundle(N4IDEXpectUIPlugin.PLUGIN_ID, iconPath + name).orElse(null);
}
 
Example #6
Source File: TesterUiActivator.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
public ImageDescriptor imageDescriptor(final String path) {
	return ResourceLocator.imageDescriptorFromBundle(PLUGIN_ID, PATH_TO_ICONS + path).orElse(null);
}
 
Example #7
Source File: N4ProductActivator.java    From n4js with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Returns an image descriptor for the image file at the given plug-in relative path.
 *
 * @param path
 *            the path.
 * @return the image descriptor.
 */
public static ImageDescriptor getImageDescriptor(final String path) {
	return ResourceLocator.imageDescriptorFromBundle(PLUGIN_ID, path).orElse(null);
}