List of usage examples for org.eclipse.jface.resource ImageDescriptor createFromURL
public static ImageDescriptor createFromURL(URL url)
From source file:fr.inria.featureDiagramEditor.ui.wizard.ImportElementWizard.java
License:Open Source License
/** Constructor */ public ImportElementWizard() { super();//from w w w . j av a2s .c o m this.setForcePreviousAndNextButtons(true); this.setNeedsProgressMonitor(true); this.setWindowTitle("Add model elements to features"); this.pathFile = ""; // Add later an image ImageDescriptor image = null; try { URL url = FileLocator.find(fr.inria.featureDiagramEditor.ui.Activator.getPlugin().getBundle(), new Path("icons/ModelElement.png"), null); image = ImageDescriptor.createFromURL(url); if (image == null) { this.setDefaultPageImageDescriptor(image); } } catch (Exception e) { } this.setNeedsProgressMonitor(true); }
From source file:fr.inria.linuxtools.tmf.ui.project.model.TmfNavigatorLabelProvider.java
License:Open Source License
private static Image loadIcon(Bundle bundle, String url) { Activator plugin = Activator.getDefault(); String key = bundle.getSymbolicName() + "/" + url; //$NON-NLS-1$ Image icon = plugin.getImageRegistry().get(key); if (icon == null) { URL imageURL = bundle.getResource(url); ImageDescriptor descriptor = ImageDescriptor.createFromURL(imageURL); if (descriptor != null) { icon = descriptor.createImage(); plugin.getImageRegistry().put(key, icon); }/*from ww w.j a v a 2 s. c o m*/ } return icon; }
From source file:fr.inria.linuxtools.tmf.ui.views.uml2sd.drawings.impl.ImageImpl.java
License:Open Source License
/** * Returns Image object from file name.//from www. j a va 2s .co m * * @param name File name of image file * @return image object or <code>null</code> */ private static Image createResourceImage(String name) { try { URL BASIC_URL = new URL("platform", "localhost", "plugin");//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ URL url = new URL(BASIC_URL, "plugin/fr.inria.linuxtools.tmf.ui/icons/" + name);//$NON-NLS-1$ ImageDescriptor img = ImageDescriptor.createFromURL(url); return img.createImage(); } catch (MalformedURLException e) { Activator.getDefault().logError("Error opening image file", e); //$NON-NLS-1$ } return null; }
From source file:fr.irisa.triskell.kermeta.KermetaIcons.java
/** * Loads some images whose name come from KermetaConstants class. * *//* ww w. j a va2s. c o m*/ private void initialize() { try { Image icon_folder = ImageDescriptor.createFromURL(new URL(pluginURL, "/images/folder.gif")) .createImage(); Image icon_file = ImageDescriptor.createFromURL(new URL(pluginURL, "/images/kermeta.png")) .createImage(); Image icon_project = ImageDescriptor.createFromURL(new URL(pluginURL, "/images/project.gif")) .createImage(); Image icon_logo = ImageDescriptor.createFromURL(new URL(pluginURL, "/images/kermeta_logo.gif")) .createImage(); Image icon_ecoreModelFile = ImageDescriptor .createFromURL(new URL(pluginURL, "/images/EcoreModelFile.gif")).createImage(); Image icon_generatedPackage = ImageDescriptor .createFromURL(new URL(pluginURL, "/images/generated_package.gif")).createImage(); icons.put(KermetaConstants.FOLDER, icon_folder); // instance icons.put(KermetaConstants.FILE, icon_file); icons.put(KermetaConstants.PROJECT, icon_project); icons.put(KermetaConstants.KLOGO, icon_logo); icons.put(KermetaConstants.IMG_ECORE_FILE, icon_ecoreModelFile); icons.put(KermetaConstants.IMG_GENERATED_PACKAGE, icon_generatedPackage); } catch (MalformedURLException e) { e.printStackTrace(); } }
From source file:fr.liglab.adele.cilia.workbench.common.misc.ImageBuilder.java
License:Apache License
private static Image createImage(String imagePath) { Bundle bundle = Activator.getInstance().getBundle(); URL url = FileLocator.find(bundle, new Path(imagePath), null); try {// w ww. j a v a2 s .c o m url = new URL("platform:/plugin/fr.liglab.adele.cilia.workbench.common/" + imagePath); } catch (MalformedURLException e) { e.printStackTrace(); } ImageDescriptor imageDesc = ImageDescriptor.createFromURL(url); return imageDesc.createImage(); }
From source file:fr.liglab.adele.cilia.workbench.monitoring.topologyview.providers.CiliaLabelProvider.java
License:Apache License
public Image getImage(Object obj) { String imageName;/*from w ww . ja v a 2s . c o m*/ if (obj instanceof MonitoredApplication) imageName = "icons/16/start.png"; else if (obj instanceof CiliaContextReadOnly) imageName = "icons/16/chain.png"; else if (obj instanceof ChainReadOnly) imageName = "icons/16/chain.png"; else if (obj instanceof AdapterReadOnly) { AdapterReadOnly adapter = (AdapterReadOnly) obj; // adapter.getPattern().equal(PatternType.IN_ONLY) // adapter.getPattern().equal(PatternType.OUT_ONLY) int in = adapter.getInBindings() == null ? 0 : adapter.getInBindings().length; int out = adapter.getOutBindings() == null ? 0 : adapter.getOutBindings().length; if (in == 0 && out != 0) imageName = "icons/16/adapterIn.png"; else if (in != 0 && out == 0) imageName = "icons/16/adapterOut.png"; else imageName = "icons/16/mediator.png"; } else if (obj instanceof MediatorReadOnly) imageName = "icons/16/mediator.png"; else if (obj instanceof EntityConnectionData) { imageName = null; } else throw new RuntimeException("Unsupported type: " + obj.getClass()); if (imageName != null) { Bundle bundle = Activator.getDefault().getBundle(); URL url = FileLocator.find(bundle, new Path(imageName), null); try { url = new URL("platform:/plugin/fr.liglab.adele.cilia.workbench.common/" + imageName); } catch (MalformedURLException e) { e.printStackTrace(); } ImageDescriptor imageDesc = ImageDescriptor.createFromURL(url); return imageDesc.createImage(); } else return null; }
From source file:fr.lip6.move.coloane.projects.its.ui.forms.ITSEditorPlugin.java
License:Open Source License
/** * Add an image to registry//from w w w . jav a2 s . co m * * @param registry * the referential * @param key * the image id * @param fileName * the image file path */ private void registerImage(ImageRegistry registry, String key, String fileName) { try { IPath path = new Path("resources/icons/" + fileName); //$NON-NLS-1$ URL url = FileLocator.find(getBundle(), path, null); if (url != null) { ImageDescriptor desc = ImageDescriptor.createFromURL(url); registry.put(key, desc); } } catch (Exception e) { warning("An error occured while loading image for plugin:" + e.getLocalizedMessage()); } }
From source file:fr.obeo.intent.specification.parser.SpecificationParserActivator.java
License:Open Source License
/** * Returns an image descriptor for the image file at the given plug-in * relative path.//w w w . ja v a 2 s. co m * * @param imagePath * path of the image to load (plug-in relative path) * @return the image descriptor of the image corresponding to the given path */ @SuppressWarnings("restriction") private ImageDescriptor getImageDescriptor(final String imagePath) { URL fullPathString = BundleUtility.find(getBundle(), imagePath); if (fullPathString == null) { try { fullPathString = new URL(imagePath); } catch (MalformedURLException e) { return null; } } return ImageDescriptor.createFromURL(fullPathString); }
From source file:fr.opensagres.eclipse.jsbuild.grunt.internal.ui.ImageResource.java
License:Open Source License
/** * Register an image with the registry.//from ww w . java 2 s. c o m * * @param key * java.lang.String * @param partialURL * java.lang.String */ public static void registerImage(String key, String partialURL) { try { ImageDescriptor id = ImageDescriptor.createFromURL(new URL(ICON_BASE_URL, partialURL)); registerImageDescriptor(key, id); } catch (Exception e) { Logger.logException("Error registering image " + key + " from " + partialURL, e); } }