List of usage examples for org.eclipse.jface.resource ImageDescriptor getMissingImageDescriptor
public static ImageDescriptor getMissingImageDescriptor()
From source file:org.eclipse.ui.tests.TestPlugin.java
License:Open Source License
/** * Returns the image descriptor with the given relative path. *///from w w w . java 2s .c o m public ImageDescriptor getImageDescriptor(String relativePath) { String iconPath = "icons/"; try { URL installURL = getDescriptor().getInstallURL(); URL url = new URL(installURL, iconPath + relativePath); return ImageDescriptor.createFromURL(url); } catch (MalformedURLException e) { // should not happen return ImageDescriptor.getMissingImageDescriptor(); } }
From source file:org.eclipse.ui.texteditor.MarkerAnnotationPreferences.java
License:Open Source License
/** * Returns the image descriptor for the icon path specified by the given configuration * element./*from w w w . j a va 2 s. c o m*/ * * @param iconPath the icon path * @param element the configuration element * @return the image descriptor * @since 3.0 */ private ImageDescriptor getImageDescriptor(String iconPath, IConfigurationElement element) { String pluginId = element.getContributor().getName(); Bundle bundle = Platform.getBundle(pluginId); if (bundle == null) return null; URL url = FileLocator.find(bundle, new Path(iconPath), null); if (url != null) return ImageDescriptor.createFromURL(url); return ImageDescriptor.getMissingImageDescriptor(); }
From source file:org.eclipse.ui.texteditor.templates.TemplatesPageImages.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 w w w . ja v a 2 s.c o m private final static void declareRegistryImage(String key, String path) { ImageDescriptor desc = ImageDescriptor.getMissingImageDescriptor(); Bundle bundle = Platform.getBundle(TextEditorPlugin.PLUGIN_ID); URL url = null; if (bundle != null) { url = FileLocator.find(bundle, new Path(path), null); desc = ImageDescriptor.createFromURL(url); } fgImageRegistry.put(key, desc); }
From source file:org.eclipse.virgo.ide.bundlor.ui.BundlorUiPlugin.java
License:Open Source License
public static Image getImage(String path) { ImageRegistry imageRegistry = getDefault().getImageRegistry(); Image image = imageRegistry.get(path); if (image == null) { ImageDescriptor imageDescriptor = getImageDescriptor(path); if (imageDescriptor == null) { imageDescriptor = ImageDescriptor.getMissingImageDescriptor(); }//from www . j a v a 2 s.co m image = imageDescriptor.createImage(true); imageRegistry.put(path, image); } return image; }
From source file:org.eclipse.virgo.ide.jdt.internal.ui.decoration.JdtUiImages.java
License:Open Source License
private static ImageDescriptor createManaged(String prefix, String name) { try {//from w w w .ja v a 2s.c o m ImageDescriptor result = ImageDescriptor .createFromURL(makeIconFileURL(prefix, name.substring(NAME_PREFIX_LENGTH))); if (imageDescriptors == null) { imageDescriptors = new HashMap<String, ImageDescriptor>(); } imageDescriptors.put(name, result); if (imageRegistry != null) { } return result; } catch (MalformedURLException e) { return ImageDescriptor.getMissingImageDescriptor(); } }
From source file:org.eclipse.virgo.ide.runtime.internal.ui.ServerUiImages.java
License:Open Source License
private static ImageDescriptor createManaged(String prefix, String name) { try {/* w w w . j av a2s . c o m*/ ImageDescriptor result = ImageDescriptor .createFromURL(makeIconFileURL(prefix, name.substring(NAME_PREFIX_LENGTH))); if (imageDescriptors == null) { imageDescriptors = new HashMap<String, ImageDescriptor>(); } imageDescriptors.put(name, result); return result; } catch (MalformedURLException e) { ServerUiPlugin.log(e); return ImageDescriptor.getMissingImageDescriptor(); } }
From source file:org.eclipse.virgo.ide.runtime.internal.ui.ServerUiImages.java
License:Open Source License
private static ImageDescriptor create(String prefix, String name) { try {/*from w w w . j ava 2 s . c om*/ return ImageDescriptor.createFromURL(makeIconFileURL(prefix, name)); } catch (MalformedURLException e) { ServerUiPlugin.log(e); return ImageDescriptor.getMissingImageDescriptor(); } }
From source file:org.eclipse.wb.internal.core.wizards.actions.OpenTypeWizardAction.java
License:Open Source License
private ImageDescriptor getIconFromConfig(IConfigurationElement config) { try {//from w w w.jav a2 s.co m return ExternalFactoriesHelper.getImageDescriptor(config, ATT_ICON); } catch (Throwable e) { DesignerPlugin.log("Unable to load wizard icon", e); } return ImageDescriptor.getMissingImageDescriptor(); }
From source file:org.eclipse.wst.common.snippets.internal.palette.SnippetImageDescriptorHelper.java
License:Open Source License
public ImageDescriptor getImageDescriptor(SnippetPaletteDrawer category, boolean largeIcon) { String iconName = largeIcon ? category.getLargeIconName() : category.getSmallIconName(); if (largeIcon && (iconName == null || iconName.length() == 0)) iconName = category.getSmallIconName(); if (category == null || iconName == null || iconName.length() == 0) return getDefaultDescriptor(); ImageDescriptor image = null;//ww w . j a v a2 s .c o m if (category.getSourceType() == ISnippetsEntry.SNIPPET_SOURCE_PLUGINS) { PluginRecord record = (PluginRecord) category.getSourceDescriptor(); if (record != null && record.getPluginName() != null) { image = getInstalledImage(record.getPluginName(), iconName); } } else { image = getImageDescriptor(iconName); } if (image == null || image.equals(ImageDescriptor.getMissingImageDescriptor())) image = getDefaultDescriptor(); return image; }
From source file:org.eclipse.wst.common.snippets.internal.palette.SnippetImageDescriptorHelper.java
License:Open Source License
public ImageDescriptor getImageDescriptor(SnippetPaletteItem item, boolean largeIcon) { ImageDescriptor image = null;//w ww .j a v a 2 s. c om String iconName = largeIcon ? item.getLargeIconName() : item.getSmallIconName(); if (largeIcon && (iconName == null || iconName.length() == 0)) iconName = item.getSmallIconName(); if (item.getSourceType() == ISnippetsEntry.SNIPPET_SOURCE_PLUGINS) { PluginRecord record = (PluginRecord) item.getSourceDescriptor(); if (record != null && record.getPluginName() != null) { image = getInstalledImage(record.getPluginName(), iconName); if (image == null && item.getCategory() != null) { image = getImageDescriptor((SnippetPaletteDrawer) item.getCategory(), largeIcon); } } } else { if (iconName == null || iconName.length() < 1) image = getImageDescriptor((SnippetPaletteDrawer) item.getCategory(), largeIcon); else image = getImageDescriptor(iconName); } if (image == null || image.equals(ImageDescriptor.getMissingImageDescriptor())) image = getDefaultDescriptor(); return image; }