List of usage examples for org.eclipse.jface.resource ImageDescriptor getMissingImageDescriptor
public static ImageDescriptor getMissingImageDescriptor()
From source file:org.eclipse.jdt.jeview.JEPluginImages.java
License:Open Source License
private static ImageDescriptor create(String name) { try {//from w w w. j ava 2 s .c om return ImageDescriptor.createFromURL(new URL(fgIconBaseURL, name)); } catch (MalformedURLException e) { return ImageDescriptor.getMissingImageDescriptor(); } }
From source file:org.eclipse.jpt.common.ui.internal.jface.OverlayImageDescriptor.java
License:Open Source License
private ImageData convertToImageData(ImageDescriptor imageDescriptor) { ImageData imageData = imageDescriptor.getImageData(); return (imageData != null) ? imageData : ImageDescriptor.getMissingImageDescriptor().getImageData(); }
From source file:org.eclipse.jsp.JspPluginImages.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. ja v a 2 s . c o m*/ private final static void declareRegistryImage(String key, String path) { ImageDescriptor desc = ImageDescriptor.getMissingImageDescriptor(); try { desc = ImageDescriptor.createFromURL(makeIconFileURL(path)); } catch (MalformedURLException me) { DebugPlugin.log(me); } imageRegistry.put(key, desc); imageDescriptors.put(key, desc); }
From source file:org.eclipse.jst.jsf.common.ui.internal.guiutils.IntroductionSection.java
License:Open Source License
/** * add the extension elements to the page * /*from w ww. j a v a 2 s . c o m*/ * @param parent * @param toolkit_ * @param element */ private void processItems(Composite parent, FormToolkit toolkit_, IConfigurationElement element) { String hyperlink = element.getAttribute("hyperlink"); //$NON-NLS-1$ String iconPath = element.getAttribute("icon"); //$NON-NLS-1$ String text = element.getAttribute("text"); //$NON-NLS-1$ String heading = element.getAttribute("heading"); //$NON-NLS-1$ String action = element.getAttribute("hyperlinkaction"); //$NON-NLS-1$ //String actionparameters = element.getAttribute("actionparameters"); //$NON-NLS-1$ if (iconPath != null && iconPath.length() > 0) { // add an icon to the page String iconName; if (iconPath.indexOf(IPath.SEPARATOR) != -1) { iconName = new Path(iconPath).lastSegment(); } else { iconName = iconPath; } ImageDescriptor imageDescriptor = AbstractUIPlugin.imageDescriptorFromPlugin( element.getDeclaringExtension().getContributor().getName(), iconPath); if (imageDescriptor != null) { ImageRegistry imageRegistry = JSFUICommonPlugin.getDefault().getImageRegistry(); Image image = imageRegistry.get(iconName); if (image == null) { image = imageDescriptor.createImage(); if (image != null) { imageRegistry.put(iconName, image); } else { image = ImageDescriptor.getMissingImageDescriptor().createImage(); } } if (image != null) { ImageContainer img = new ImageContainer(parent); img.setImage(image); TableWrapData td = new TableWrapData(); td.rowspan = 2; img.setLayoutData(td); } else { JSFUICommonPlugin.getLogger(this.getClass()) .error(new Throwable("Image not created for " + element)); //$NON-NLS-1$ } } else { JSFUICommonPlugin.getLogger(this.getClass()) .error(new Throwable("Image Descriptor not found for " + element)); //$NON-NLS-1$ } } if (heading != null && heading.length() > 0) { // add a header Label lbl = toolkit_.createLabel(parent, heading); lbl.setFont(JFaceResources.getHeaderFont()); } if (hyperlink != null && hyperlink.length() > 0) { Hyperlink hypr = toolkit_.createHyperlink(parent, hyperlink, SWT.NONE); if (action != null && action.length() > 0) { try { final IAction thisAction = (IAction) element.createExecutableExtension("hyperlinkaction"); //$NON-NLS-1$ hypr.addHyperlinkListener(new HyperlinkAdapter() { public void linkActivated(HyperlinkEvent e) { thisAction.run(); } }); } catch (Exception ee) { // log.IntroductionSection.action.error=Failed to launch the // link {0}. _log.error("log.IntroductionSection.action.error", //$NON-NLS-1$ hyperlink, ee); JSFUICommonPlugin.getAlerts().detailError(hyperlink, "log.IntroductionSection.action.error", //$NON-NLS-1$ hyperlink, ee); } } } if (text != null && text.length() > 0) { FormText form = toolkit_.createFormText(parent, false); form.setText(text, false, false); } }
From source file:org.eclipse.jst.jsf.common.ui.internal.utils.PluginImageHelper.java
License:Open Source License
/** * Creates an image from the given resource and adds the image to the image * registry./*from w w w . j a va 2 s . com*/ * * @param resource * @param pluginId * @return Image */ private Image createImage(String resource, String pluginId) { ImageDescriptor desc = getImageDescriptor(resource, pluginId); Image image = null; if (desc != null) { image = desc.createImage(); // dont add the missing image descriptor image to the image // registry if (!desc.equals(ImageDescriptor.getMissingImageDescriptor())) { String thePluginId = pluginId; if (thePluginId == null) { return null; } String key = thePluginId + PLUGIN_SEPARATOR + resource; getImageRegistry().put(key, image); } } return image; }
From source file:org.eclipse.jst.jsf.common.ui.internal.utils.PluginImageHelper.java
License:Open Source License
/** * Creates an image descriptor from the given imageFilePath in the given * pluginId and adds the image descriptor to the image descriptor registry. * If an image descriptor could not be created, the default "missing" image * descriptor is returned but not added to the image descriptor registry. * //from w w w .ja va2s .c om * @param imageFilePath * @param pluginId * if null, look in this plugin * @return ImageDescriptor image descriptor for imageFilePath or default * "missing" image descriptor if resource could not be found */ private ImageDescriptor createImageDescriptor(String imageFilePath, String pluginId) { String thePluginId = pluginId; if (thePluginId == null) { return null; } ImageDescriptor imageDescriptor = AbstractUIPlugin.imageDescriptorFromPlugin(thePluginId, imageFilePath); if (imageDescriptor != null) { String key = thePluginId + PLUGIN_SEPARATOR + imageFilePath; getImageDescriptorRegistry().put(key, imageDescriptor); } else { imageDescriptor = ImageDescriptor.getMissingImageDescriptor(); } return imageDescriptor; }
From source file:org.eclipse.jst.jsf.ui.internal.common.MetadataTagImageManager.java
License:Open Source License
private ImageDescriptor getIconImageDescriptor(final ITaglibDomainMetaDataQuery query, final Model model, final String tagName, final boolean small) { ImageDescriptor icon = null;/*from w w w . j a v a2 s . co m*/ // use palette infos if available final Trait trait = query.findTrait(model, "paletteInfos"); //$NON-NLS-1$ if (trait != null) { final PaletteInfos tags = (PaletteInfos) trait.getValue(); for (final Iterator it = tags.getInfos().iterator(); it.hasNext();) { final PaletteInfo tag = (PaletteInfo) it.next(); if (tag.getId().equalsIgnoreCase(tagName)) { final IMetaDataSourceModelProvider sourceProvider = ((Trait) tag.eContainer().eContainer()) .getSourceModelProvider(); if (small) { icon = getImageDescriptorFromString(sourceProvider, tag.getSmallIcon()); } else { icon = getImageDescriptorFromString(sourceProvider, tag.getLargeIcon()); } break; } } } else { for (final Iterator it = model.getChildEntities().iterator(); it.hasNext();) { final Entity tagAsEntity = (Entity) it.next(); if (tagAsEntity.getId().equalsIgnoreCase(tagName)) { if (small) { icon = getImageDescriptorFromTagTraitValueAsString(query, tagAsEntity, TRAIT_ICON_SMALL, ImageDescriptor.getMissingImageDescriptor()); } else { icon = getImageDescriptorFromTagTraitValueAsString(query, tagAsEntity, TRAIT_ICON_LARGE, ImageDescriptor.getMissingImageDescriptor()); } break; } } } return icon; }
From source file:org.eclipse.jst.jsp.ui.internal.editor.JSPEditorPluginImageHelper.java
License:Open Source License
/** * Retrieves the Image associated with ImageDescriptor from the image * descriptor registry. If the Image cannot be retrieved, it is created * from the ImageDescriptor//from w w w. j av a 2 s . c om * * @param resource * the image descriptor to retrieve * @return Image the associated with the ImageDescriptor or * the default "missing" image descriptor if one could not be * found */ public Image getImage(ImageDescriptor descriptor) { if (descriptor == null) descriptor = ImageDescriptor.getMissingImageDescriptor(); Image result = (Image) getImageDescriptorRegistry().get(descriptor); if (result != null) return result; result = descriptor.createImage(); if (result != null) getImageDescriptorRegistry().put(descriptor, result); return result; }
From source file:org.eclipse.jst.jsp.ui.internal.editor.JSPEditorPluginImageHelper.java
License:Open Source License
/** * Creates an image from the given resource and adds the image to the * image registry./*from w w w . j av a2s . c om*/ * * @param resource * @return Image */ private Image createImage(String resource) { ImageDescriptor desc = getImageDescriptor(resource); Image image = null; if (desc != null) { image = desc.createImage(); // dont add the missing image descriptor image to the image registry if (!desc.equals(ImageDescriptor.getMissingImageDescriptor())) getImageRegistry().put(resource, image); } return image; }
From source file:org.eclipse.jst.jsp.ui.internal.editor.JSPEditorPluginImageHelper.java
License:Open Source License
/** * Creates an image descriptor from the given imageFilePath and adds the * image descriptor to the image descriptor registry. If an image * descriptor could not be created, the default "missing" image descriptor * is returned but not added to the image descriptor registry. * /*w w w.ja va 2s .c o m*/ * @param imageFilePath * @return ImageDescriptor image descriptor for imageFilePath or default * "missing" image descriptor if resource could not be found */ private ImageDescriptor createImageDescriptor(String imageFilePath) { ImageDescriptor imageDescriptor = AbstractUIPlugin.imageDescriptorFromPlugin(PLUGINID, imageFilePath); if (imageDescriptor != null) { getImageDescriptorRegistry().put(imageFilePath, imageDescriptor); } else { imageDescriptor = ImageDescriptor.getMissingImageDescriptor(); } return imageDescriptor; }