List of usage examples for org.eclipse.jface.resource ImageDescriptor createImage
public Image createImage()
From source file:com.google.devtools.depan.platform.PlatformResources.java
License:Apache License
public static Image getImage(ImageDescriptor descriptor) { try {/*from ww w. j a v a 2s .c o m*/ return descriptor.createImage(); } catch (RuntimeException errAny) { String msg = MessageFormat.format("Unable to open image from descriptor {0}", descriptor); PlatformLogger.LOG.error(msg, errAny); } return null; }
From source file:com.google.eclipse.mechanic.plugin.ui.MechanicStatusControlContribution.java
License:Open Source License
/** * Initializes the image cache.//from w w w. ja va 2 s. co m */ private void initImageCache() { Map<DisplayStatus, Image> map = Maps.newHashMap(); for (DisplayStatus ds : DisplayStatus.values()) { String path = String.format("icons/%s.png", ds.name().toLowerCase()); ImageDescriptor desc = MechanicPlugin.getImageDescriptor(path); if (desc == null) { MechanicLog.getDefault().log(new Status(IStatus.ERROR, MechanicPlugin.PLUGIN_ID, "Can't find image descriptor for resource " + path)); } else { Image image = desc.createImage(); map.put(ds, image); } } images = map; }
From source file:com.google.gdt.eclipse.designer.util.type.ChooseBeanTypeSelectionExtension.java
License:Open Source License
@Override public Control createContentArea(Composite parent) { // type selection area Composite area = new Composite(parent, SWT.NONE); GridDataFactory.create(area).grab().fill(); GridLayoutFactory.create(area).noMargins(); // Styles group if (m_contributors.size() > 0) { int numColumns = 1 + m_contributors.size() * 2; Composite contributorComposite = new Composite(area, SWT.NONE); GridDataFactory.create(contributorComposite).grabH().fillH(); GridLayoutFactory.create(contributorComposite).columns(numColumns).noMargins(); ///*from ww w. j av a 2 s. co m*/ { Label contributorLabel = new Label(contributorComposite, SWT.NONE); GridDataFactory.create(contributorLabel).spanH(numColumns); contributorLabel.setText("Styles:"); } // add spacer (for indentation) new Label(contributorComposite, SWT.NONE); // add image and button for each contributor final String contributorKey = "contributor"; m_contributorButtons = new Button[m_contributors.size()]; for (int i = 0; i < m_contributors.size(); i++) { IChooseBeanContributor contributor = m_contributors.get(i); // add image label for contributor { Label imageLabel = new Label(contributorComposite, SWT.NONE); ImageDescriptor imageDescriptor = contributor.getImage(); final Image image = imageDescriptor == null ? null : imageDescriptor.createImage(); if (image != null) { imageLabel.setImage(image); imageLabel.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { image.dispose(); } }); } } // add button Button button = new Button(contributorComposite, SWT.RADIO); m_contributorButtons[i] = button; button.setText(contributor.getName()); button.setData(contributorKey, contributor); button.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { Button button = (Button) e.getSource(); if (button.getSelection()) { IChooseBeanContributor contributor = (IChooseBeanContributor) button .getData(contributorKey); selectContributor(contributor); } } public void widgetDefaultSelected(SelectionEvent e) { widgetSelected(e); } }); } // select button for selected (first) contributor if (m_selectedContributor != null) { int index = m_contributors.indexOf(m_selectedContributor); m_contributorButtons[index].setSelection(true); } } // finished return area; }
From source file:com.google.gdt.eclipse.gph.ProjectHostingUIPlugin.java
License:Open Source License
/** * Create and cache an image from the given ImageDescriptor. * // w w w. j av a 2 s .co m * @param key * @param imageDescriptor * @return */ public static Image createImage(String key, ImageDescriptor imageDescriptor) { ImageRegistry registry = getPlugin().getImageRegistry(); if (registry.get(key) == null) { registry.put(key, imageDescriptor.createImage()); } return registry.get(key); }
From source file:com.google.test.metric.eclipse.ui.plugin.Activator.java
License:Apache License
public Image getImage(String path) throws ImageNotFoundException { Image image = images.get(path); if (image == null) { String pluginLocation = Activator.getDefault().getBundle().getLocation(); if (pluginLocation.startsWith("reference:")) { pluginLocation = pluginLocation.substring(10); }//from w ww .j a v a2s . c o m URL url; try { url = new URL(pluginLocation + path); } catch (MalformedURLException e) { throw new ImageNotFoundException("Image : " + path + " not found"); } ImageDescriptor projectImageDescriptor = ImageDescriptor.createFromURL(url); image = projectImageDescriptor.createImage(); images.put(path, image); } return image; }
From source file:com.googlecode.goclipse.ui.navigator.GoNavigatorLabelProvider.java
License:Open Source License
@Override public Image getImage(Object element) { if (element instanceof IGoProjectElement) { if (element instanceof GoRootElement) { return GoPluginImages.NAVIGATOR_GOROOT_ENTRY.getImage(); }/*from ww w. j a va 2s .c om*/ if (element instanceof GoPathEntryElement) { return GoPluginImages.NAVIGATOR_GOPATH_ENTRY.getImage(); } assertFail(); } if (element instanceof IFileStore) { IFileStore fileStore = (IFileStore) element; try { if (fileStore.fetchInfo().isDirectory()) { return GoPluginImages.NAVIGATOR_SOURCE_PACKAGE_FOLDER.getImage(); } // TODO: should cleanup up this. IEditorDescriptor descriptor = IDE.getEditorDescriptor(fileStore.getName()); if (descriptor != null) { return descriptor.getImageDescriptor().createImage(); } else { return PlatformUI.getWorkbench().getSharedImages() .getImageDescriptor(ISharedImages.IMG_OBJ_FILE).createImage(); } } catch (PartInitException e) { } } if (element instanceof IResource) { IResource resource = (IResource) element; try { assertTrue(resource.getProject().hasNature(LangNature.NATURE_ID)); } catch (CoreException e) { assertFail(); } ImageDescriptor decoratedImage = getResourceImageDescriptor(resource); if (decoratedImage != null) { return decoratedImage.createImage(); } } return null; }
From source file:com.googlecode.osde.internal.editors.basic.FreeFeaturesListLabelProvider.java
License:Apache License
public Image getColumnImage(Object element, int columnIndex) { switch (columnIndex) { case 0://from ww w.java 2 s .c o m ImageDescriptor descriptor = Activator.getDefault().getImageRegistry() .getDescriptor("icons/icon_extension.gif"); return descriptor.createImage(); default: return null; } }
From source file:com.googlecode.osde.internal.editors.contents.SupportedViewListLabelProvider.java
License:Apache License
public Image getColumnImage(Object element, int columnIndex) { switch (columnIndex) { case 0:/*w w w . ja va2 s . co m*/ ImageDescriptor descriptor = Activator.getDefault().getImageRegistry() .getDescriptor("icons/page_component.gif"); return descriptor.createImage(); default: return null; } }
From source file:com.googlecode.osde.internal.editors.locale.MessagesListLabelProvider.java
License:Apache License
public Image getColumnImage(Object element, int columnIndex) { switch (columnIndex) { case 0:/* w w w.j a va 2 s . c o m*/ ImageDescriptor descriptor = Activator.getDefault().getImageRegistry() .getDescriptor("icons/16-em-pencil.gif"); return descriptor.createImage(); default: return null; } }
From source file:com.googlecode.osde.internal.editors.locale.SupportedLocaleListLabelProvider.java
License:Apache License
public Image getColumnImage(Object element, int columnIndex) { switch (columnIndex) { case 0://from www . j a va 2 s.c o m ImageDescriptor descriptor = Activator.getDefault().getImageRegistry() .getDescriptor("icons/icon_world.gif"); return descriptor.createImage(); default: return null; } }