List of usage examples for org.eclipse.jface.resource ImageDescriptor getMissingImageDescriptor
public static ImageDescriptor getMissingImageDescriptor()
From source file:org.eclipse.cdt.internal.ui.CPluginImages.java
License:Open Source License
/** * Creates an image descriptor for the given prefix and name in the JDT UI bundle. The path can * contain variables like $NL$./*from ww w . j av a2 s .c o m*/ * If no image could be found, the 'missing image descriptor' is returned. */ private static ImageDescriptor createUnManaged(String prefix, String name) { try { return create(prefix, name, true); } catch (Throwable e) { CUIPlugin.log(e.getMessage(), e); } return ImageDescriptor.getMissingImageDescriptor(); }
From source file:org.eclipse.cdt.internal.ui.CPluginImages.java
License:Open Source License
/** * Creates an image descriptor for the given path in a bundle. The path can contain variables * like $NL$.// w w w . j av a2s .co m * If no image could be found, <code>useMissingImageDescriptor</code> decides if either * the 'missing image descriptor' is returned or <code>null</code>. * Added for 3.1.1. */ public static ImageDescriptor createImageDescriptor(Bundle bundle, IPath path, boolean useMissingImageDescriptor) { URL url = FileLocator.find(bundle, path, null); if (url != null) { return ImageDescriptor.createFromURL(url); } Exception e = new Exception( NLS.bind(CUIMessages.CPluginImages_MissingImage, path, bundle.getSymbolicName())); CUIPlugin.log(e.getMessage(), e); if (useMissingImageDescriptor) { return ImageDescriptor.getMissingImageDescriptor(); } return null; }
From source file:org.eclipse.cdt.internal.ui.cview.CViewActionGroup.java
License:Open Source License
/** * Returns the image descriptor with the given relative path. *///from ww w . ja v a 2s. c o m protected ImageDescriptor getImageDescriptor(String relativePath) { String iconPath = "icons/"; //$NON-NLS-1$ try { URL installURL = CUIPlugin.getDefault().getBundle().getEntry("/"); //$NON-NLS-1$ 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.cdt.internal.ui.util.ImageDescriptorRegistry.java
License:Open Source License
/** * Returns the image assiciated with the given image descriptor. * //from w w w .j a va2 s. c om * @param descriptor the image descriptor for which the registry manages an image * @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:org.eclipse.cdt.internal.ui.wizards.OpenNewWizardAction.java
License:Open Source License
private ImageDescriptor getIconFromConfig(IConfigurationElement config) { try {/* ww w . j a v a 2 s. c o m*/ String iconName = config.getAttribute(ATT_ICON); if (iconName != null) { URL pluginInstallUrl = Platform.getBundle(config.getDeclaringExtension().getContributor().getName()) .getEntry("/"); //$NON-NLS-1$ return ImageDescriptor.createFromURL(new URL(pluginInstallUrl, iconName)); } return null; } catch (MalformedURLException exception) { CUIPlugin.logError("Unable to load wizard icon"); //$NON-NLS-1$ } return ImageDescriptor.getMissingImageDescriptor(); }
From source file:org.eclipse.cdt.managedbuilder.internal.ui.language.settings.providers.ScannerDiscoveryGlobalConsole.java
License:Open Source License
@Override public void init(String consoleId, String name, URL defaultIconUrl) { console = null;/*from w w w . j a v a 2 s .c om*/ IConsoleManager consoleManager = ConsolePlugin.getDefault().getConsoleManager(); IConsole[] allConsoles = consoleManager.getConsoles(); for (IConsole con : allConsoles) { if (name.equals(con.getName()) && con instanceof MessageConsole) { console = (MessageConsole) con; console.clearConsole(); break; } } if (console == null) { URL iconUrl = LanguageSettingsProvidersImages.getImageUrl(consoleId); if (iconUrl == null) { iconUrl = defaultIconUrl; } ImageDescriptor imageDescriptor; if (iconUrl != null) { imageDescriptor = CDTSharedImages.getImageDescriptor(iconUrl.toString()); } else { imageDescriptor = ImageDescriptor.getMissingImageDescriptor(); } console = new MessageConsole(name, imageDescriptor); console.activate(); consoleManager.addConsoles(new IConsole[] { console }); } }
From source file:org.eclipse.cdt.testsrunner.internal.TestsRunnerPlugin.java
License:Open Source License
/** * Creates an image descriptor for the given path in a bundle. The path can * contain variables like $NL$. If no image could be found, * <code>useMissingImageDescriptor</code> decides if either the 'missing * image descriptor' is returned or <code>null</code>. * /*w w w .j a v a 2 s .c o m*/ * @param bundle a bundle * @param path path in the bundle * @param useMissingImageDescriptor if <code>true</code>, returns the shared * image descriptor for a missing image. Otherwise, returns * <code>null</code> if the image could not be found * @return an {@link ImageDescriptor}, or <code>null</code> iff there's no * image at the given location and <code>useMissingImageDescriptor</code> is * <code>true</code> */ private ImageDescriptor createImageDescriptor(Bundle bundle, IPath path, boolean useMissingImageDescriptor) { URL url = FileLocator.find(bundle, path, null); if (url != null) { return ImageDescriptor.createFromURL(url); } if (useMissingImageDescriptor) { return ImageDescriptor.getMissingImageDescriptor(); } return null; }
From source file:org.eclipse.cdt.ui.CDTUIImages.java
License:Open Source License
/** * Creates an image descriptor which is managed by internal registry in CDTSharedImages. * {@code name} is assumed to start with "org.eclipse.cdt.ui." *///from w w w. j a v a 2s. c om private static ImageDescriptor createManaged(String prefix, String name) { try { String convertedKey = ICONS + prefix + name.substring(NAME_PREFIX_LENGTH); fPathMap.put(name, convertedKey); return CDTSharedImages.getImageDescriptor(convertedKey); } catch (Throwable e) { CUIPlugin.log(e); } return ImageDescriptor.getMissingImageDescriptor(); }
From source file:org.eclipse.compare.internal.patch.DecoratorOverlayIcon.java
License:Open Source License
/** * Draw the overlays for the receiver./*from w ww . j av a2 s .c o m*/ * @param overlaysArray the overlay images */ protected void drawOverlays(ImageDescriptor[] overlaysArray) { for (int i = 0; i < overlays.length; i++) { ImageDescriptor overlay = overlaysArray[i]; if (overlay == null) { continue; } ImageData overlayData = overlay.getImageData(); //Use the missing descriptor if it is not there. if (overlayData == null) { overlayData = ImageDescriptor.getMissingImageDescriptor().getImageData(); } switch (i) { case IDecoration.TOP_LEFT: drawImage(overlayData, 0, 0); break; case IDecoration.TOP_RIGHT: drawImage(overlayData, size.x - overlayData.width, 0); break; case IDecoration.BOTTOM_LEFT: drawImage(overlayData, 0, size.y - overlayData.height); break; case IDecoration.BOTTOM_RIGHT: drawImage(overlayData, size.x - overlayData.width, size.y - overlayData.height); break; } } }
From source file:org.eclipse.contribution.jdt.JDTWeavingPlugin.java
License:Open Source License
public static ImageDescriptor createDescriptor(String path) { URL url = getInstance().getBundle().getEntry(path); ImageDescriptor descriptor = url == null ? ImageDescriptor.getMissingImageDescriptor() : ImageDescriptor.createFromURL(url); return descriptor; }