List of usage examples for org.eclipse.jface.resource ImageDescriptor createImage
public Image createImage()
From source file:com.axmor.eclipse.typescript.editor.ImageDescriptorRegistry.java
License:Open Source License
/** * Returns the image associated with the given image descriptor. * * @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. *//*from www . jav a 2 s . c om*/ public Image get(ImageDescriptor descriptor) { if (descriptor == null) { descriptor = ImageDescriptor.getMissingImageDescriptor(); } Image result = fRegistry.get(descriptor); if (result != null) { return result; } result = descriptor.createImage(); if (result != null) { fRegistry.put(descriptor, result); } return result; }
From source file:com.b3dgs.lionengine.editor.factory.FactoryView.java
License:Open Source License
/** * Load the object icon if has./*from w w w . j a v a2 s .c o m*/ * * @param objectLabel The object label reference. * @param file The object data file. * @param setup The object setup reference. * @throws LionEngineException If an error occurred when loading the icon. */ private static void loadObjectIcon(Label objectLabel, File file, SetupGame setup) throws LionEngineException { try { final ConfigSurface configSurface = ConfigSurface.create(setup.getConfigurer()); final String icon = configSurface.getIcon(); final File iconPath = new File(file.getParentFile(), icon); if (iconPath.isFile()) { final ImageDescriptor descriptor = ImageDescriptor.createFromURL(iconPath.toURI().toURL()); objectLabel.setImage(descriptor.createImage()); } } catch (final MalformedURLException exception) { throw new LionEngineException(exception); } }
From source file:com.b3dgs.lionengine.editor.UtilEclipse.java
License:Open Source License
/** * Get the icon from its name./*www . j a v a 2 s. c o m*/ * * @param root The icon root. * @param icon The icon name. * @return The icon instance. * @throws LionEngineException If error when getting icon. */ public static Image getIcon(String root, String icon) throws LionEngineException { final Bundle bundle = Activator.getContext().getBundle(); final String path = UtilFile.getPathSeparator("/", UtilEclipse.ICON_FOLDER, root, icon); final URL url = bundle.getEntry(path); if (url == null) { throw new LionEngineException(UtilEclipse.ERROR_ICON_PATH + path); } try { final ImageDescriptor descriptor = ImageDescriptor.createFromURL(FileLocator.toFileURL(url)); final Image image = descriptor.createImage(); if (image == null) { throw new LionEngineException(UtilEclipse.ERROR_ICON_CREATE + path); } return image; } catch (final IOException exception) { throw new LionEngineException(exception); } }
From source file:com.b3dgs.lionengine.editor.utility.UtilIcon.java
License:Open Source License
/** * Get the icon from its name./*from ww w.j av a 2 s. c o m*/ * * @param root The icon root. * @param icon The icon name. * @return The icon instance. * @throws LionEngineException If error when getting icon. */ public static Image get(String root, String icon) { final String path = UtilFolder.getPathSeparator(Constant.SLASH, UtilIcon.ICON_FOLDER, root, icon); final ImageDescriptor descriptor = ImageDescriptor.createFromURL(UtilBundle.getUrl(path)); final Image image = descriptor.createImage(); if (image == null) { throw new LionEngineException(UtilIcon.ERROR_ICON_CREATE, path); } return image; }
From source file:com.blackducksoftware.integration.eclipseplugin.views.providers.DependencyComponentColumnLabelProvider.java
License:Apache License
@Override public Image getImage(Object input) { if (input instanceof ComponentModel) { ComponentModel validObject = ((ComponentModel) input); if (!validObject.getComponentIsKnown() || !validObject.getLicenseIsKnown()) { ImageDescriptor descriptor = Activator.getImageDescriptor(PathsToIconFiles.WARNING); return descriptor == null ? null : descriptor.createImage(); }/*from w w w. j a v a 2 s. c om*/ } return null; }
From source file:com.blackducksoftware.integration.eclipseplugin.views.ui.VulnerabilityView.java
License:Apache License
public void setStatusMessage(String message) { display.asyncExec(new Runnable() { @Override/* w w w . j a v a 2s .c o m*/ public void run() { if (!tableStatus.isDisposed()) { if (message.equals(tableStatus.getText())) { return; } ImageDescriptor newImageDescriptor = null; switch (message) { case InspectionStatus.PROJECT_INSPECTION_ACTIVE: newImageDescriptor = Activator.getImageDescriptor(PathsToIconFiles.WAITING); break; case InspectionStatus.PROJECT_INSPECTION_SCHEDULED: newImageDescriptor = Activator.getImageDescriptor(PathsToIconFiles.WAITING); break; case InspectionStatus.CONNECTION_DISCONNECTED: newImageDescriptor = Activator.getImageDescriptor(PathsToIconFiles.DISCONNECT); break; case InspectionStatus.PROJECT_NEEDS_INSPECTION: newImageDescriptor = Activator.getImageDescriptor(PathsToIconFiles.WARNING); break; default: break; } Image newImage = null; if (newImageDescriptor != null) { newImage = newImageDescriptor.createImage(); } tableStatus.setImage(newImage); tableStatus.setText(message); } } }); }
From source file:com.blackducksoftware.integration.eclipseplugin.views.ui.VulnerabilityView.java
License:Apache License
@Override public Image getTitleImage() { ImageDescriptor descriptor = Activator.getImageDescriptor(PathsToIconFiles.DUCKY); return descriptor == null ? null : descriptor.createImage(); }
From source file:com.boothen.jsonedit.outline.node.JsonTreeNode.java
License:Open Source License
private static Image createMyImage(String urlPath) { URL resource = JsonTreeNode.class.getResource(urlPath); ImageDescriptor imgDescriptor = ImageDescriptor.createFromURL(resource); if (imgDescriptor == null) { return null; }//from w ww . j a v a 2 s . co m return imgDescriptor.createImage(); }
From source file:com.borlander.rac525791.dashboard.layout.data.DashboardImagesImpl.java
License:Open Source License
private Image getImage(String filePath) { Image result = myImages.get(filePath); if (result == null || result.isDisposed()) { // XXX: Strange, but it does not always work for png images // Issues with alpha channel were found // result = new Image(myDisplay, filePath); ImageDescriptor desc = Activator.getImageDescriptor(filePath); // ImageLoader loader = new ImageLoader(); // loader.load(filePath); // result = new Image(myDisplay, loader.data[0]); result = desc.createImage(); myImages.put(filePath, result);/*from w ww . j a v a2s . c o m*/ } return result; }
From source file:com.breskeby.eclipse.gradle.ImageDescriptorRegistry.java
License:Open Source License
/** * Returns the image associated with the given image descriptor. * // w w w .j a v a 2s . co m * @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 = (Image) fRegistry.get(descriptor); if (result != null) return result; Assert.isTrue(fDisplay == GradlePlugin.getStandardDisplay(), GradleModelMessages.ImageDescriptorRegistry_Allocating_image_for_wrong_display_1); result = descriptor.createImage(); if (result != null) fRegistry.put(descriptor, result); return result; }