List of usage examples for org.eclipse.jface.resource ImageDescriptor createFromImage
public static ImageDescriptor createFromImage(Image img)
From source file:uk.ac.diamond.scisoft.analysis.rcp.views.plot.StaticScanPlotView.java
License:Apache License
/** * Action designed to take an AbstractPlotView and open it in a static plot. * /*from w ww . ja v a 2s .c o m*/ * @param abs * @return action to open static */ public static IAction getOpenStaticPlotAction(final PlotView abs) { final Action action = new Action() { @Override public void run() { try { final IWorkbenchPage page = abs.getSite().getPage(); final String secondId = getUniqueSecondId(); StaticScanPlotView view = (StaticScanPlotView) page.showView(StaticScanPlotView.ID, secondId, IWorkbenchPage.VIEW_ACTIVATE); view.setPlotter(abs); view.setSecondId(secondId); } catch (PartInitException e) { logger.error("Cannot find view " + StaticScanPlotView.ID, e); } } }; action.setToolTipText("Save plot to separate window. Used for comparing and saving plots."); final Image icon = SWTResourceManager.getImage(StaticScanPlotView.class, "/icons/chart_curve_add.png"); final ImageDescriptor d = ImageDescriptor.createFromImage(icon); action.setImageDescriptor(d); return action; }
From source file:ummisco.gama.ui.resources.GamaIcon.java
public ImageDescriptor descriptor() { if (descriptor == null) { final Image image = GamaIcons.getInstance().getImageInCache(code); if (image != null) { descriptor = ImageDescriptor.createFromImage(image); } else {//from w ww. j a v a2 s. co m descriptor = AbstractUIPlugin.imageDescriptorFromPlugin(plugin, GamaIcons.DEFAULT_PATH + path + ".png"); } if (descriptor == null) { DEBUG.ERR("ERROR: Cannot find icon " + GamaIcons.DEFAULT_PATH + path + ".png in plugin: " + plugin); descriptor = ImageDescriptor.getMissingImageDescriptor(); } } return descriptor; }