List of usage examples for org.eclipse.jface.resource ImageDescriptor getMissingImageDescriptor
public static ImageDescriptor getMissingImageDescriptor()
From source file:org.modelio.mda.infra.service.IncompatibleModule.java
License:Open Source License
/** * Get the image descriptor provided by the module for a given stereotype. The module should return an image if the * stereotype is provided by itself, null in the other case. * @param stereotype a stereotype/*from w w w . j a v a 2 s. c o m*/ * @param imageType the image type * @return the stereotype image, or null if the module provides none. */ @objid("b3216e85-f11c-11e1-af52-001ec947c8cc") private ImageDescriptor getImageDescriptor(Stereotype stereotype, ImageType imageType) { // If the stereotype is not owned by the current module we return null. if (!this.isStereotypeOwner(stereotype)) { return null; } ImageDescriptor desc = null; Path moduleDirectory = this.getConfiguration().getModuleResourcesPath(); String relativePath = null; if (imageType == ImageType.ICON) { relativePath = stereotype.getIcon(); } else if (imageType == ImageType.IMAGE) { relativePath = stereotype.getImage(); } if (relativePath == null || relativePath.equals("")) { return null; } URL imageUrl; try { Path imageFile = moduleDirectory.resolve(relativePath); // Compatibility with Modelio 1.2 : stereotype image path might // start with the module name, that concludes the module directory. if (!Files.isRegularFile(imageFile) && relativePath.startsWith(moduleDirectory.getFileName().toString())) { imageFile = moduleDirectory.getParent().resolve(relativePath); } if (Files.isRegularFile(imageFile)) { imageUrl = imageFile.toUri().toURL(); desc = ImageDescriptor.createFromURL(imageUrl); if (desc != ImageDescriptor.getMissingImageDescriptor()) { return desc; } else { return null; } } } catch (MalformedURLException e) { e.printStackTrace(); } return desc; }
From source file:org.mwc.asset.scenariocontroller2.views.MultiScenarioView.java
License:Open Source License
protected void openPlotter() { final IWorkbenchPage page = this.getViewSite().getPage(); final IEditorInput ie = new IEditorInput() { public boolean exists() { return true; }/*from w w w. j av a 2 s.c o m*/ @SuppressWarnings("rawtypes") public Object getAdapter(final Class adapter) { return null; } public ImageDescriptor getImageDescriptor() { return ImageDescriptor.getMissingImageDescriptor(); } public String getName() { return "Pending"; } public IPersistableElement getPersistable() { return null; } public String getToolTipText() { return "Pending plot"; } }; try { // first, open the editor page.openEditor(ie, "org.mwc.asset.ASSETPlotEditor"); // now fire ourselves as active activate(); } catch (final PartInitException e) { ASSETPlugin.logThisError(IStatus.ERROR, "trouble opening ScenarioPlotter", e); e.printStackTrace(); } }
From source file:org.nuxeo.ide.common.Activator.java
License:Open Source License
public ImageDescriptor getImageDescriptor(String path) { URL url = getBundle().getEntry(path); if (url != null) { return ImageDescriptor.createFromURL(url); }/* www . java 2 s . c o m*/ return ImageDescriptor.getMissingImageDescriptor(); }
From source file:org.objectstyle.wolips.jdt.PluginImages.java
License:Open Source License
/** * Utility method to create an <code>ImageDescriptor</code> from a path to * a file.//from ww w . ja va 2 s . c o m * * @param path * @return */ public static ImageDescriptor createImageDescriptor(String path) { Bundle bundle = JdtPlugin.getDefault().getBundle(); if (bundle != null) { URL url = FileLocator.find(bundle, new Path(path), null); if (url != null) { return ImageDescriptor.createFromURL(url); } } return ImageDescriptor.getMissingImageDescriptor(); }
From source file:org.openhealthtools.mdht.uml.hdf.tooling.rsm.utils.RIMUtil.java
License:Open Source License
/** * @generated/*from w w w.j a v a 2 s.c o m*/ */ public static ImageDescriptor getImageDescriptor(String imageFilePath) { if (imageFilePath == null || imageFilePath.length() == 0) { return null; } URL result = org.openhealthtools.mdht.uml.hdf.tooling.rsm.internal.Activator.getDefault().getBundle() .getEntry(imageFilePath); return result == null ? ImageDescriptor.getMissingImageDescriptor() : ImageDescriptor.createFromURL(result); }
From source file:org.openscada.vi.ui.draw2d.primitives.ImageController.java
License:Open Source License
public void setImage(final String uri) { if (this.currentImage != null) { this.manager.destroyImage(this.currentImage); this.currentImage = null; }//from w w w. ja va2s . com if (uri == null || uri.isEmpty()) { this.figure.setIcon(null); } else { try { this.figure.setIcon(this.manager .createImageWithDefault(this.currentImage = ImageDescriptor.createFromURL(new URL(uri)))); } catch (final MalformedURLException e) { this.figure .setIcon(this.manager.createImageWithDefault(ImageDescriptor.getMissingImageDescriptor())); } } }
From source file:org.org.eclipse.core.utils.platform.images.Images.java
License:Open Source License
public ImageDescriptor addImage(AbstractUIPlugin plugin, String path, String key) { try {/*from ww w . java2 s. c o m*/ URL baseURL = PluginToolBox.getPluginInstallationURL(plugin); ImageDescriptor result = ImageDescriptor.createFromURL(makeIconFileURL(baseURL, path)); if (imageDescriptors == null) { imageDescriptors = new HashMap<String, ImageDescriptor>(); } imageDescriptors.put(key, result); if (imageRegistry != null) { logger.debug("Image registry already defined."); } return result; } catch (MalformedURLException e) { logger.error("URL is malformed for image : " + path, e); return ImageDescriptor.getMissingImageDescriptor(); } }
From source file:org.osate.ui.navigator.AadlElementImageDescriptor.java
License:Open Source License
private static ImageDescriptor create(String name) { try {/* ww w . ja v a 2 s. com*/ URL baseURL = OsateUiPlugin.getDefault().getBundle().getEntry("/icons/"); URL iconURL = new URL(baseURL, name); return ImageDescriptor.createFromURL(iconURL); } catch (MalformedURLException e) { return ImageDescriptor.getMissingImageDescriptor(); } }
From source file:org.ow2.aspirerfid.ide.bpwme.navigator.BpwmeLabelProvider.java
License:Open Source License
/** * Returns the image for each element//from www. j a v a 2s.c o m */ private Image getImageImage(String path, String pluginPath) { Image image = JFaceResources.getImageRegistry().get(path); if (image == null) { ImageDescriptor descriptor = AbstractUIPlugin.imageDescriptorFromPlugin(pluginPath, path); if (descriptor == null) { descriptor = ImageDescriptor.getMissingImageDescriptor(); } JFaceResources.getImageRegistry().put(path, image = descriptor.createImage()); } return image; }
From source file:org.ow2.aspirerfid.ide.MasterDataEditorGMF.images.ImageNodeShape.java
License:Open Source License
protected Image getImageImage(String path) { Image image = JFaceResources.getImageRegistry().get(path); if (image == null) { ImageDescriptor descriptor = AbstractUIPlugin .imageDescriptorFromPlugin("org.ow2.aspirerfid.ide.MasterDataEditorGMF", path); if (descriptor == null) { descriptor = ImageDescriptor.getMissingImageDescriptor(); }/* ww w . java 2s . c o m*/ JFaceResources.getImageRegistry().put(path, image = descriptor.createImage()); } return image; }