Example usage for org.eclipse.jface.resource ImageDescriptor createFromURL

List of usage examples for org.eclipse.jface.resource ImageDescriptor createFromURL

Introduction

In this page you can find the example usage for org.eclipse.jface.resource ImageDescriptor createFromURL.

Prototype

public static ImageDescriptor createFromURL(URL url) 

Source Link

Document

Creates and returns a new image descriptor from a URL.

Usage

From source file:com.arc.embeddedcdt.LaunchImages.java

License:Open Source License

private static ImageDescriptor createManaged(ImageRegistry registry, String prefix, String name) {
    ImageDescriptor result = ImageDescriptor
            .createFromURL(makeIconFileURL(prefix, name.substring(NAME_PREFIX_LENGTH)));
    registry.put(name, result);/*from ww w .j a  v a 2s  .c om*/
    return result;
}

From source file:com.architexa.diagrams.jdt.model.CodeUnit.java

License:Open Source License

public static ImageDescriptor getImageDescriptorFromKey(String iconKey) {
    if (iconKey == null)
        iconKey = JavaPluginImages.IMG_OBJS_UNKNOWN;

    if (ImageCache.getDescriptor(iconKey) != null)
        return ImageCache.getDescriptor(iconKey);

    // isi.getImageDescriptor does not support some of the icons (like fields)
    //  so we use internal methods
    int NAME_PREFIX_LENGTH = "org.eclipse.jdt.ui.".length();
    String bundleEntry = "/icons/full/obj16/" + iconKey.substring(NAME_PREFIX_LENGTH);
    URL iconFileURL = Platform.getBundle("org.eclipse.jdt.ui").getEntry(bundleEntry);
    ImageCache.add(iconKey, ImageDescriptor.createFromURL(iconFileURL));
    return ImageCache.getDescriptor(iconKey);
}

From source file:com.architexa.diagrams.relo.ui.ReloDocWizard.java

License:Open Source License

protected void initializeDefaultPageImageDescriptor() {
    // TODO: needed (perhaps) for Eclipse 3.4
    //setDefaultPageImageDescriptor(WorkbenchImages
    //        .getImageDescriptor(IWorkbenchGraphicConstants.IMG_WIZBAN_NEW_WIZ));
    String iconPath = "icons/full/";
    try {// w ww . j a v a2  s. c o m
        URL installURL = ReloPlugin.getDefault().getBundle().getEntry("/");
        URL url = new URL(installURL, iconPath + "wizban/newfile_wiz.gif");//$NON-NLS-1$
        ImageDescriptor desc = ImageDescriptor.createFromURL(url);
        setDefaultPageImageDescriptor(desc);
    } catch (MalformedURLException e) {
        // Should not happen. Ignore.
    }
}

From source file:com.aspose.eclipse.maven.wizard.AsposeMavenNewProjectWizard.java

License:Open Source License

/**
 * //ww w  .  ja  va  2 s. c o  m
 */
@Override
public void addPages() {
    super.addPages();

    _pageTwo = new AsposeNewMavenProjectWizardPageCustom(AsposeConstants.FIRST_PAGE_NAME);

    _pageTwo.setTitle(AsposeConstants.FIRST_PAGE_TITLE);
    _pageTwo.setDescription(AsposeConstants.FIRST_PAGE_DESCRIPTION);
    URL imageurl = getClass().getResource("/images/long_banner.PNG");
    ImageDescriptor image = ImageDescriptor.createFromURL(imageurl);
    _pageTwo.setImageDescriptor(image);

    _pageOne = new AsposeMavenProjectWizardArtifactPage(AsposeConstants.FIRST_PAGE_NAME);

    addPage(_pageOne);
    addPage(_pageTwo);

}

From source file:com.atlassian.clover.eclipse.core.CloverPlugin.java

public static Image getImage(String path) {
    ImageRegistry reg = getInstance().getImageRegistry();
    if (reg.getDescriptor(path) == null) {
        reg.put(path, ImageDescriptor.createFromURL(instance.getBundle().getEntry(path)));
    }/*from  w  w w .  j a  v a2 s .com*/
    return reg.get(path);
}

From source file:com.atlassian.connector.eclipse.internal.crucible.ui.CrucibleImages.java

License:Open Source License

private static ImageDescriptor create(String prefix, String name) {
    try {//from  ww w  .j  ava2 s  .c  o m
        return ImageDescriptor.createFromURL(makeIconFileURL(prefix, name));
    } catch (MalformedURLException e) {
        return ImageDescriptor.getMissingImageDescriptor();
    }
}

From source file:com.axmor.eclipse.typescript.editor.TypeScriptUIImages.java

License:Open Source License

/**
 * Declare an Image in the registry table.
 * /*  w  w w  .  j a  va  2  s  .  co  m*/
 * @param key
 *            The key to use when registering the image
 * @param path
 *            The path where the image can be found. This path is relative to where this plugin
 *            class is found (i.e. typically the packages directory)
 */
private static void declareRegistryImage(String key, String path) {
    ImageDescriptor desc = ImageDescriptor.getMissingImageDescriptor();
    Bundle bundle = Platform.getBundle(Activator.PLUGIN_ID);
    URL url = null;
    if (bundle != null) {
        url = FileLocator.find(bundle, new Path(path), null);
        desc = ImageDescriptor.createFromURL(url);
    }
    imageRegistry.put(key, desc);
}

From source file:com.b3dgs.lionengine.editor.factory.FactoryView.java

License:Open Source License

/**
 * Load the object icon if has.//from   w w  w. java  2  s .c om
 * 
 * @param objectLabel The object label reference.
 * @param file The object data file.
 * @param setup The object setup reference.
 * @throws LionEngineException If an error occurred when loading the icon.
 */
private static void loadObjectIcon(Label objectLabel, File file, SetupGame setup) throws LionEngineException {
    try {
        final ConfigSurface configSurface = ConfigSurface.create(setup.getConfigurer());
        final String icon = configSurface.getIcon();
        final File iconPath = new File(file.getParentFile(), icon);
        if (iconPath.isFile()) {
            final ImageDescriptor descriptor = ImageDescriptor.createFromURL(iconPath.toURI().toURL());
            objectLabel.setImage(descriptor.createImage());
        }
    } catch (final MalformedURLException exception) {
        throw new LionEngineException(exception);
    }
}

From source file:com.b3dgs.lionengine.editor.UtilEclipse.java

License:Open Source License

/**
 * Get the icon from its name.//from   w  w w .  j  av  a 2s  .  c om
 * 
 * @param root The icon root.
 * @param icon The icon name.
 * @return The icon instance.
 * @throws LionEngineException If error when getting icon.
 */
public static Image getIcon(String root, String icon) throws LionEngineException {
    final Bundle bundle = Activator.getContext().getBundle();
    final String path = UtilFile.getPathSeparator("/", UtilEclipse.ICON_FOLDER, root, icon);
    final URL url = bundle.getEntry(path);
    if (url == null) {
        throw new LionEngineException(UtilEclipse.ERROR_ICON_PATH + path);
    }
    try {
        final ImageDescriptor descriptor = ImageDescriptor.createFromURL(FileLocator.toFileURL(url));
        final Image image = descriptor.createImage();
        if (image == null) {
            throw new LionEngineException(UtilEclipse.ERROR_ICON_CREATE + path);
        }
        return image;
    } catch (final IOException exception) {
        throw new LionEngineException(exception);
    }
}

From source file:com.b3dgs.lionengine.editor.utility.UtilIcon.java

License:Open Source License

/**
 * Get the icon from its name.//from w  ww .  j  a  v a 2s  .  c  o m
 * 
 * @param root The icon root.
 * @param icon The icon name.
 * @return The icon instance.
 * @throws LionEngineException If error when getting icon.
 */
public static Image get(String root, String icon) {
    final String path = UtilFolder.getPathSeparator(Constant.SLASH, UtilIcon.ICON_FOLDER, root, icon);
    final ImageDescriptor descriptor = ImageDescriptor.createFromURL(UtilBundle.getUrl(path));
    final Image image = descriptor.createImage();
    if (image == null) {
        throw new LionEngineException(UtilIcon.ERROR_ICON_CREATE, path);
    }
    return image;
}