List of usage examples for org.eclipse.jface.resource ImageDescriptor createFromURL
public static ImageDescriptor createFromURL(URL url)
From source file:at.medevit.icons.core.Icon.java
License:Open Source License
/** * Add an image descriptor for a specific key and {@link IconSize} to the * global {@link ImageRegistry}//w w w . j a v a2s . c om * * @param name * @param is * @return <code>true</code> if successfully added, else <code>false</code> */ private static boolean addIconImageDescriptor(String name, IconSize is) { try { ResourceBundle iconsetProperties = ResourceBundle.getBundle("iconset"); String fileName = iconsetProperties.getString(name); URL fileLocation = FileLocator.find(Activator.getDefault().getBundle(), new Path("icons/" + is.name + "/" + fileName), null); ImageDescriptor id = ImageDescriptor.createFromURL(fileLocation); JFaceResources.getImageRegistry().put(name, id); } catch (MissingResourceException | IllegalArgumentException e) { return false; } return true; }
From source file:au.com.cybersearch2.controls.ImageFactory.java
License:Open Source License
/** * Returns impage descriptor for given image path * @param imagePath Image path// ww w. j a va 2s.c o m * @return ImageDescriptor object */ private ImageDescriptor createImageDescriptor(String imagePath) { Bundle bundle = null; if (resourceBundle != null) bundle = resourceBundle; else bundle = FrameworkUtil.getBundle(this.getClass()); URL url = FileLocator.find(bundle, new Path(imagePath), null); return ImageDescriptor.createFromURL(url); }
From source file:au.gov.ga.earthsci.application.about.AboutDialog.java
License:Apache License
/** * Retrieve the "About" image specified in the current product under the key * {@link IProductConstants#ABOUT_IMAGE}, or the default image if none is * specified./*from ww w . ja va 2s . c o m*/ */ private Image openAboutImage() { String aboutImagePath = product.getProperty(IProductConstants.ABOUT_IMAGE); if (aboutImagePath == null) { aboutImagePath = DEFAULT_ABOUT_IMAGE; } URL aboutImageURL = null; try { aboutImageURL = new URL(aboutImagePath); } catch (MalformedURLException e) { logger.error("Unable to find image " + aboutImagePath, e); //$NON-NLS-1$ try { aboutImageURL = new URL(DEFAULT_ABOUT_IMAGE); } catch (MalformedURLException e1) { } } ImageDescriptor descriptor = ImageDescriptor.createFromURL(aboutImageURL); return descriptor.createImage(); }
From source file:au.gov.ga.earthsci.application.ImageRegistry.java
License:Apache License
protected void putResource(String key, String resourceName) { try {//from w w w . jav a2 s . c om URL url = new URL("platform:/plugin/" + Activator.getBundleName() + resourceName); //$NON-NLS-1$ put(key, ImageDescriptor.createFromURL(url)); urlMap.put(key, url); } catch (MalformedURLException e) { logger.error("Error adding image resource", e); //$NON-NLS-1$ } }
From source file:au.gov.ga.earthsci.eclipse.extras.browser.ImageResource.java
License:Open Source License
/** * Register an image with the registry./* w w w . j a v a 2s . c o m*/ * * @param key java.lang.String * @param partialURL java.lang.String */ private static void registerImage(String key, String partialURL) { try { URL url = FileLocator.find(Activator.getDefault().getBundle(), new Path(partialURL), null); ImageDescriptor id = ImageDescriptor.createFromURL(url); imageRegistry.put(key, id); imageDescriptors.put(key, id); } catch (Exception e) { Trace.trace(Trace.WARNING, "Error registering image " + key + " from " + partialURL, e); //$NON-NLS-1$ //$NON-NLS-2$ } }
From source file:au.gov.ga.earthsci.intent.IntentSelectionDialogTableLabelProvider.java
License:Apache License
@Override public Image getColumnImage(Object element, int columnIndex) { IntentFilter filter = (IntentFilter) element; URL url = filter.getIcon();//from ww w. j av a 2 s . co m if (url != null) { Image image = registry.get(url.toString()); if (image == null) { registry.put(url.toString(), ImageDescriptor.createFromURL(url)); image = registry.get(url.toString()); } return image; } return null; }
From source file:b600.emulator.parts.B600Part.java
License:Open Source License
private void createImage(Composite parent) { Bundle bundle = FrameworkUtil.getBundle(B600Part.class); URL url = FileLocator.find(bundle, new Path("icons/b600_bg.png"), null); ImageDescriptor imageDcr = ImageDescriptor.createFromURL(url); this.image = imageDcr.createImage(); this.image = resizeImage(image, parent); }
From source file:b600.emulator.parts.B600Part2.java
License:Open Source License
private void createImage(Composite parent) { Bundle bundle = FrameworkUtil.getBundle(B600Part2.class); URL url = FileLocator.find(bundle, new Path("icons/b600_bg.png"), null); ImageDescriptor imageDcr = ImageDescriptor.createFromURL(url); this.image = imageDcr.createImage(); this.image = resizeImage(image, parent); }
From source file:bndtools.release.Activator.java
License:Open Source License
private static void loadBundleImages(ImageRegistry reg, String rootPath, String parent, String filePattern) { Enumeration<URL> en = plugin.getBundle().findEntries(rootPath + "/" + parent, filePattern, false); if (en == null) { return;/*from ww w. ja va2s . c o m*/ } while (en.hasMoreElements()) { URL url = en.nextElement(); String name = getResourceName(url); ImageDescriptor id = ImageDescriptor.createFromURL(url); reg.put(parent + "_" + name, id); //$NON-NLS-1$ } }
From source file:bndtools.release.ui.BundleTreeImages.java
License:Open Source License
private static void loadImages(File iconRootDirectory, String parent, ImageRegistry registry) throws MalformedURLException { File icons = new File(iconRootDirectory, parent); File[] files = icons.listFiles(); for (File file : files) { if (file.isFile() && file.getName().endsWith(".gif")) { //$NON-NLS-1$ URL url = file.toURI().toURL(); String name = getResourceName(url); ImageDescriptor id = ImageDescriptor.createFromURL(url); registry.put(parent + "_" + name, id); //$NON-NLS-1$ }/*w w w. jav a 2 s . c o m*/ } }