Java Code Examples for org.eclipse.jface.resource.ImageDescriptor#getMissingImageDescriptor()

The following examples show how to use org.eclipse.jface.resource.ImageDescriptor#getMissingImageDescriptor() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: hadoop-gpu   File: ImageLibrary.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Register an image from the workspace shared image pool. If the image
 * resource does not exist or fails to load, a default "error" resource is
 * supplied.
 * 
 * @param name name of the image
 * @param sharedName name of the shared image ({@link ISharedImages})
 * @return whether the image has correctly been loaded
 */
private boolean newSharedImage(String name, String sharedName) {
  boolean success = true;
  ImageDescriptor id = getSharedByName(sharedName);

  if (id == null) {
    id = ImageDescriptor.getMissingImageDescriptor();
    // id = getSharedByName(ISharedImages.IMG_OBJS_ERROR_TSK);
    success = false;
  }

  descMap.put(name, id);
  imageMap.put(name, id.createImage(true));

  return success;
}
 
Example 2
/**
 * Returns the image associated with the given image descriptor.
 * 
 * @param descriptor
 *            the image descriptor for which the helper manages an image, or <code>null</code> for a missing image
 *            descriptor
 * @return the image associated with the image descriptor or <code>null</code> if the image descriptor can't create
 *         the requested image.
 */
@Override
public Image getImage(ImageDescriptor descriptor) {
	if (descriptor == null) {
		descriptor = ImageDescriptor.getMissingImageDescriptor();
	}

	Image result = registry.get(descriptor);
	if (result != null) {
		return result;
	}
	result = descriptor.createImage();
	if (result != null) {
		registry.put(descriptor, result);
	}
	return result;
}
 
Example 3
Source Project: RDFS   File: ImageLibrary.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Load and register a new image. If the image resource does not exist or
 * fails to load, a default "error" resource is supplied.
 * 
 * @param name name of the image
 * @param filename name of the file containing the image
 * @return whether the image has correctly been loaded
 */
private boolean newImage(String name, String filename) {
  ImageDescriptor id;
  boolean success;

  try {
    URL fileURL =
        FileLocator.find(bundle, new Path(RESOURCE_DIR + filename), null);
    id = ImageDescriptor.createFromURL(FileLocator.toFileURL(fileURL));
    success = true;

  } catch (Exception e) {

    e.printStackTrace();
    id = ImageDescriptor.getMissingImageDescriptor();
    // id = getSharedByName(ISharedImages.IMG_OBJS_ERROR_TSK);
    success = false;
  }

  descMap.put(name, id);
  imageMap.put(name, id.createImage(true));

  return success;
}
 
Example 4
Source Project: RDFS   File: ImageLibrary.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Register an image from the workspace shared image pool. If the image
 * resource does not exist or fails to load, a default "error" resource is
 * supplied.
 * 
 * @param name name of the image
 * @param sharedName name of the shared image ({@link ISharedImages})
 * @return whether the image has correctly been loaded
 */
private boolean newPluginImage(String name, String pluginId,
    String filename) {

  boolean success = true;
  ImageDescriptor id =
      AbstractUIPlugin.imageDescriptorFromPlugin(pluginId, filename);

  if (id == null) {
    id = ImageDescriptor.getMissingImageDescriptor();
    // id = getSharedByName(ISharedImages.IMG_OBJS_ERROR_TSK);
    success = false;
  }

  descMap.put(name, id);
  imageMap.put(name, id.createImage(true));

  return success;
}
 
Example 5
Source Project: RDFS   File: ImageLibrary.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Register an image from the workspace shared image pool. If the image
 * resource does not exist or fails to load, a default "error" resource is
 * supplied.
 * 
 * @param name name of the image
 * @param sharedName name of the shared image ({@link ISharedImages})
 * @return whether the image has correctly been loaded
 */
private boolean newSharedImage(String name, String sharedName) {
  boolean success = true;
  ImageDescriptor id = getSharedByName(sharedName);

  if (id == null) {
    id = ImageDescriptor.getMissingImageDescriptor();
    // id = getSharedByName(ISharedImages.IMG_OBJS_ERROR_TSK);
    success = false;
  }

  descMap.put(name, id);
  imageMap.put(name, id.createImage(true));

  return success;
}
 
Example 6
Source Project: gama   File: GamaIcon.java    License: GNU General Public License v3.0 6 votes vote down vote up
public ImageDescriptor descriptor() {
	if (descriptor == null) {
		final Image image = GamaIcons.getInstance().getImageInCache(code);
		if (image != null) {
			descriptor = ImageDescriptor.createFromImage(image);
		} else {
			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;
}
 
Example 7
Source Project: hadoop-gpu   File: ImageLibrary.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Load and register a new image. If the image resource does not exist or
 * fails to load, a default "error" resource is supplied.
 * 
 * @param name name of the image
 * @param filename name of the file containing the image
 * @return whether the image has correctly been loaded
 */
private boolean newImage(String name, String filename) {
  ImageDescriptor id;
  boolean success;

  try {
    URL fileURL =
        FileLocator.find(bundle, new Path(RESOURCE_DIR + filename), null);
    id = ImageDescriptor.createFromURL(FileLocator.toFileURL(fileURL));
    success = true;

  } catch (Exception e) {

    e.printStackTrace();
    id = ImageDescriptor.getMissingImageDescriptor();
    // id = getSharedByName(ISharedImages.IMG_OBJS_ERROR_TSK);
    success = false;
  }

  descMap.put(name, id);
  imageMap.put(name, id.createImage(true));

  return success;
}
 
Example 8
Source Project: hadoop-gpu   File: ImageLibrary.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Register an image from the workspace shared image pool. If the image
 * resource does not exist or fails to load, a default "error" resource is
 * supplied.
 * 
 * @param name name of the image
 * @param sharedName name of the shared image ({@link ISharedImages})
 * @return whether the image has correctly been loaded
 */
private boolean newPluginImage(String name, String pluginId,
    String filename) {

  boolean success = true;
  ImageDescriptor id =
      AbstractUIPlugin.imageDescriptorFromPlugin(pluginId, filename);

  if (id == null) {
    id = ImageDescriptor.getMissingImageDescriptor();
    // id = getSharedByName(ISharedImages.IMG_OBJS_ERROR_TSK);
    success = false;
  }

  descMap.put(name, id);
  imageMap.put(name, id.createImage(true));

  return success;
}
 
Example 9
private static ImageDescriptor create(String path, String name) {
	try {
		return ImageDescriptor.createFromURL(makeIconFileURL(path, name));
	} catch (MalformedURLException e) {
		return ImageDescriptor.getMissingImageDescriptor();
	}
}
 
Example 10
Source Project: nebula   File: ExamplesView.java    License: Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Returns an image descriptor for the image file at the given plug-in relative
 * path.
 *
 * @param path the path
 * @return the image descriptor
 */
public static ImageDescriptor getImageDescriptor(String path) {
	try {
		return AbstractUIPlugin.imageDescriptorFromPlugin("org.eclipse.nebula.examples", path);
	} catch (Throwable e) {
		return ImageDescriptor.getMissingImageDescriptor();
	}
}
 
Example 11
Source Project: bonita-studio   File: Pics.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static ImageDescriptor getImageDescriptor(final String imageName, final AbstractUIPlugin plugin) {
    ImageDescriptor desc;
    try {
        desc = ImageDescriptor.createFromURL(
                new URL(
                        plugin.getBundle().getResource("/"), //$NON-NLS-1$
                        "icons/" + imageName)); //$NON-NLS-1$
    } catch (final MalformedURLException e) {
        desc = ImageDescriptor.getMissingImageDescriptor();
    }

    return desc;
}
 
Example 12
Source Project: JAADAS   File: SootPlugin.java    License: GNU General Public License v3.0 5 votes vote down vote up
public static ImageDescriptor getImageDescriptor(String name){
	try {
		URL installURL = getDefault().getDescriptor().getInstallURL();
		URL iconURL = new URL(installURL, ISootConstants.ICON_PATH + name);
		return ImageDescriptor.createFromURL(iconURL);
	}
	catch (MalformedURLException e){
		return ImageDescriptor.getMissingImageDescriptor();
	}
}
 
Example 13
/**
 * Return the image descriptor with the given key.
 * 
 * @param key
 *            java.lang.String
 * @return org.eclipse.jface.resource.ImageDescriptor
 */
public static ImageDescriptor getImageDescriptor(String key) {
	initializeIfNeeded();
	ImageDescriptor id = imageDescriptors.get(key);
	if (id != null)
		return id;

	return ImageDescriptor.getMissingImageDescriptor();
}
 
Example 14
Source Project: saros   File: ImageManager.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns an image from the file at the given plug-in relative path.
 *
 * @param path
 * @return image; the returned image <b>MUST be disposed after usage</b> to free up memory
 */
public static Image getImage(final String path) {
  ImageDescriptor descriptor = getImageDescriptor(path);

  if (descriptor == null) {
    log.warn(
        "could not create image for path '"
            + path
            + "', either the file does not exists or the format is not supported");
    descriptor = ImageDescriptor.getMissingImageDescriptor();
  }

  return new Image(Display.getDefault(), descriptor.getImageData());
}
 
Example 15
Source Project: LogViewer   File: UIImages.java    License: Eclipse Public License 2.0 5 votes vote down vote up
private static void declareRegistryImage(String key, String path) {
       ImageDescriptor desc = ImageDescriptor.getMissingImageDescriptor();
       try {
           desc = ImageDescriptor.createFromURL(makeIconFileURL(path));
       } catch(MalformedURLException me) {
           LogViewerPlugin.getDefault().showErrorMessage(me);
       }
       imageRegistry.put(key, desc);
}
 
Example 16
public static ImageDescriptor createImageDescriptor(Bundle bundle, IPath path, boolean useMissingImageDescriptor)
{
	URL url = FileLocator.find(bundle, path, null);
	if (url != null)
	{
		return ImageDescriptor.createFromURL(url);
	}
	if (useMissingImageDescriptor)
	{
		return ImageDescriptor.getMissingImageDescriptor();
	}
	return null;
}
 
Example 17
public static ImageDescriptor createImageDescriptor(Bundle bundle, IPath path, boolean useMissingImageDescriptor) {
	URL url= FileLocator.find(bundle, path, null);
	if (url != null) {
		return ImageDescriptor.createFromURL(url);
	}
	if (useMissingImageDescriptor) {
		return ImageDescriptor.getMissingImageDescriptor();
	}
	return null;
}
 
Example 18
private static ImageDescriptor create(String name) {
	try {
		return ImageDescriptor.createFromURL(makeIconFileURL(name));
	} catch (MalformedURLException e) {
		return ImageDescriptor.getMissingImageDescriptor();
	}
}
 
Example 19
/**
 * Returns the image descriptor with the given relative path.
 */
protected ImageDescriptor getImageDescriptor(String relativePath) {
	String iconPath = "icons/full/"; //$NON-NLS-1$ 
	URL url = FileLocator.find(WorkbenchNavigatorPlugin.getDefault().getBundle(), new Path(iconPath + relativePath), Collections.EMPTY_MAP);
	if (url == null) {
		return ImageDescriptor.getMissingImageDescriptor();
	}
	return ImageDescriptor.createFromURL(url);
}
 
Example 20
public ImageDescriptor getImageDescriptor() {
	return ImageDescriptor.getMissingImageDescriptor();
}