List of usage examples for org.eclipse.jface.resource ImageDescriptor getMissingImageDescriptor
public static ImageDescriptor getMissingImageDescriptor()
From source file:com.cisco.yangide.ui.internal.YangUIImages.java
License:Open Source License
/** * Declare an Image in the registry table. * * @param key The key to use when registering the image * @param path The path where the image can be found. This path is relative to where this plugin * class is found (i.e. typically the packages directory) *///from ww w . j a va2s . c o m private final static void declareRegistryImage(String key, String path) { ImageDescriptor desc = ImageDescriptor.getMissingImageDescriptor(); Bundle bundle = Platform.getBundle(YangUIPlugin.PLUGIN_ID); URL url = null; if (bundle != null) { url = FileLocator.find(bundle, new Path(path), null); desc = ImageDescriptor.createFromURL(url); } imageRegistry.put(key, desc); }
From source file:com.clustercontrol.startup.view.StartUpView.java
License:Open Source License
private static Image loadImage(String fileName) { Image image = null;//from w ww. j a v a 2s . c o m ImageDescriptor desc; try { URL url = new URL(ClusterControlPlugin.getDefault().getBundle().getEntry("/"), "icons/" + fileName); desc = ImageDescriptor.createFromURL(url); } catch (MalformedURLException e1) { desc = ImageDescriptor.getMissingImageDescriptor(); } image = desc.createImage(); return image; }
From source file:com.drgarbage.bytecodevisualizer.BytecodeVisualizerPlugin.java
License:Apache License
private void registerImage(String path, ImageRegistry registry) { ImageDescriptor desc = ImageDescriptor.getMissingImageDescriptor(); Bundle bundle = getBundle();/*from w ww. j av a2 s .c o m*/ URL url = null; if (bundle != null) { url = FileLocator.find(bundle, new Path(ICONS_PATH + path), null); desc = ImageDescriptor.createFromURL(url); } registry.put(path, desc); }
From source file:com.essiembre.eclipse.rbe.RBEPlugin.java
License:Apache License
/** * Gets an image descriptor./*from w w w .j av a2s . c om*/ * @param name image name * @return image descriptor */ public static ImageDescriptor getImageDescriptor(String name) { String iconPath = "icons/"; try { URL installURL = RBEPlugin.getDefault().getBundle().getEntry("/"); URL url = new URL(installURL, iconPath + name); return ImageDescriptor.createFromURL(url); } catch (MalformedURLException e) { // should not happen return ImageDescriptor.getMissingImageDescriptor(); } }
From source file:com.feup.contribution.druid.view.SharedImages.java
License:Open Source License
@SuppressWarnings("deprecation") public static ImageDescriptor getImageDescriptor(String name) { String iconPath = "icons/"; try {//from w ww . j a v a 2 s.c om URL installURL = DruidPlugin.getPlugin().getDescriptor().getInstallURL(); URL url = new URL(installURL, iconPath + name); return ImageDescriptor.createFromURL(url); } catch (MalformedURLException e) { e.printStackTrace(); return ImageDescriptor.getMissingImageDescriptor(); } }
From source file:com.foglyn.ui.FoglynImages.java
License:Open Source License
private static ImageDescriptor create(String name) { try {/*ww w . jav a 2 s. co m*/ return ImageDescriptor.createFromURL(makeIconFileURL(name)); } catch (MalformedURLException e) { return ImageDescriptor.getMissingImageDescriptor(); } }
From source file:com.github.haixing_hu.swt.action.ActionContributionItemEx.java
License:Open Source License
/** * Updates the images for this action.//from w w w .j a v a2 s . co m * * @param forceImage * <code>true</code> if some form of image is compulsory, and * <code>false</code> if it is acceptable for this item to have no * image * @return <code>true</code> if there are images for this action, * <code>false</code> if not */ private boolean updateImages(boolean forceImage) { final ResourceManager parentResourceManager = JFaceResources.getResources(); if (widget instanceof ToolItem) { if (USE_COLOR_ICONS) { ImageDescriptor image = action.getHoverImageDescriptor(); if (image == null) { image = action.getImageDescriptor(); } final ImageDescriptor disabledImage = action.getDisabledImageDescriptor(); // Make sure there is a valid image. if ((image == null) && forceImage) { image = ImageDescriptor.getMissingImageDescriptor(); } final LocalResourceManager localManager = new LocalResourceManager(parentResourceManager); // performance: more efficient in SWT to set disabled and hot // image before regular image ((ToolItem) widget).setDisabledImage( disabledImage == null ? null : localManager.createImageWithDefault(disabledImage)); ((ToolItem) widget).setImage(image == null ? null : localManager.createImageWithDefault(image)); disposeOldImages(); imageManager = localManager; return image != null; } ImageDescriptor image = action.getImageDescriptor(); ImageDescriptor hoverImage = action.getHoverImageDescriptor(); final ImageDescriptor disabledImage = action.getDisabledImageDescriptor(); // If there is no regular image, but there is a hover image, // convert the hover image to gray and use it as the regular image. if ((image == null) && (hoverImage != null)) { image = ImageDescriptor.createWithFlags(action.getHoverImageDescriptor(), SWT.IMAGE_GRAY); } else { // If there is no hover image, use the regular image as the // hover image, // and convert the regular image to gray if ((hoverImage == null) && (image != null)) { hoverImage = image; image = ImageDescriptor.createWithFlags(action.getImageDescriptor(), SWT.IMAGE_GRAY); } } // Make sure there is a valid image. if ((hoverImage == null) && (image == null) && forceImage) { image = ImageDescriptor.getMissingImageDescriptor(); } // Create a local resource manager to remember the images we've // allocated for this tool item final LocalResourceManager localManager = new LocalResourceManager(parentResourceManager); // performance: more efficient in SWT to set disabled and hot image // before regular image ((ToolItem) widget).setDisabledImage( disabledImage == null ? null : localManager.createImageWithDefault(disabledImage)); ((ToolItem) widget) .setHotImage(hoverImage == null ? null : localManager.createImageWithDefault(hoverImage)); ((ToolItem) widget).setImage(image == null ? null : localManager.createImageWithDefault(image)); // Now that we're no longer referencing the old images, clear them // out. disposeOldImages(); imageManager = localManager; return image != null; } else if ((widget instanceof Item) || (widget instanceof Button)) { // Use hover image if there is one, otherwise use regular image. ImageDescriptor image = action.getHoverImageDescriptor(); if (image == null) { image = action.getImageDescriptor(); } // Make sure there is a valid image. if ((image == null) && forceImage) { image = ImageDescriptor.getMissingImageDescriptor(); } // Create a local resource manager to remember the images we've // allocated for this widget final LocalResourceManager localManager = new LocalResourceManager(parentResourceManager); if (widget instanceof Item) { ((Item) widget).setImage(image == null ? null : localManager.createImageWithDefault(image)); } else if (widget instanceof Button) { ((Button) widget).setImage(image == null ? null : localManager.createImageWithDefault(image)); } // Now that we're no longer referencing the old images, clear them // out. disposeOldImages(); imageManager = localManager; return image != null; } return false; }
From source file:com.google.dart.tools.ui.internal.compare.DartCompareUtilities.java
License:Open Source License
static ImageDescriptor getImageDescriptor(int type) { switch (type) { // case DartElement.INITIALIZER: case DartElement.METHOD: return getImageDescriptor("obj16/compare_method.gif"); //$NON-NLS-1$ case DartElement.FIELD: return getImageDescriptor("obj16/compare_field.gif"); //$NON-NLS-1$ // case DartElement.PACKAGE_DECLARATION: // return DartPluginImages.DESC_OBJS_PACKDECL; // case DartElement.IMPORT_DECLARATION: // return DartPluginImages.DESC_OBJS_IMPDECL; case DartElement.IMPORT_CONTAINER: return DartPluginImages.DESC_OBJS_IMPCONT; case DartElement.COMPILATION_UNIT: return DartPluginImages.DESC_OBJS_CUNIT; }//from www . j ava 2 s. c om return ImageDescriptor.getMissingImageDescriptor(); }
From source file:com.google.dart.tools.ui.internal.viewsupport.ImageDescriptorRegistry.java
License:Open Source License
/** * Returns the image associated with the given image descriptor. * /*from w w w. j av a 2 s. com*/ * @param descriptor the image descriptor for which the registry manages an image, or * <code>null</code> for a missing image descriptor * @return the image associated with the image descriptor or <code>null</code> if the image * descriptor can't create the requested image. */ public Image get(ImageDescriptor descriptor) { if (descriptor == null) { descriptor = ImageDescriptor.getMissingImageDescriptor(); } Image result = fRegistry.get(descriptor); if (result != null) { return result; } Assert.isTrue(fDisplay == SWTUtil.getStandardDisplay(), "Allocating image for wrong display."); //$NON-NLS-1$ result = descriptor.createImage(); if (result != null) { fRegistry.put(descriptor, result); } return result; }
From source file:com.googlecode.osde.internal.Activator.java
License:Apache License
public ImageDescriptor createImageDescriptor(String url) { ImageRegistry registry = getImageRegistry(); ImageDescriptor imageDescriptor = registry.getDescriptor(url); if (imageDescriptor == null) { try {// w w w . ja v a 2 s .c om imageDescriptor = ImageDescriptor.createFromURL(new URL(url)); } catch (MalformedURLException e) { imageDescriptor = ImageDescriptor.getMissingImageDescriptor(); } registry.put(url, imageDescriptor); } return imageDescriptor; }