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.hudson.hibernatesynchronizer.wizard.NewMappingWizard.java

License:GNU General Public License

/**
 * Constructor for NewMappingWizard./*from www .  j  a  v  a2  s .  c  o  m*/
 */
public NewMappingWizard() {
    super();
    setNeedsProgressMonitor(true);

    try {
        URL prefix = new URL(Plugin.getDefault().getDescriptor().getInstallURL(), "icons/");
        ImageDescriptor id = ImageDescriptor.createFromURL(new URL(prefix, "new_wizard.gif"));
        setDefaultPageImageDescriptor(id);
    } catch (MalformedURLException e) {
    }
}

From source file:com.hydra.project.myplugin_nebula.xviewer.util.internal.images.XViewerImageCache.java

License:Open Source License

public static ImageDescriptor getImageDescriptor(String imageName) {
    if (!imageDescriptorCache.containsKey(imageName)) {
        URL url = XViewerImageCache.class.getResource(imageName);
        imageDescriptorCache.put(imageName, ImageDescriptor.createFromURL(url));
    }/*from www  .  ja va  2s  .c o  m*/
    return imageDescriptorCache.get(imageName);
}

From source file:com.hydra.projects.XViewer.Main.images.MyImageCache.java

License:Open Source License

public static ImageDescriptor getImageDescriptor(String imageName) {
    if (!imageDescriptorCache.containsKey(imageName)) {
        URL url = MyImageCache.class.getResource(imageName);
        imageDescriptorCache.put(imageName, ImageDescriptor.createFromURL(url));
    }//from www .j  a  v  a2s  .c o  m
    return imageDescriptorCache.get(imageName);
}

From source file:com.ibm.collaboration.realtime.sample.alerts.MyAlertWindow.java

License:Open Source License

/**
 * utility to set an image in a label given a person.
 * @param person/*from  w  w  w .j a v  a 2s.  c  om*/
 * @param label
 * @param size
 */
private void setPersonImageInLabel(Person person, Label label, Point size) {
    try {
        if (person == null || person.getDirectoryInfo() == null) {
            return;
        }
        String url = (String) person.getDirectoryInfo().get(DirectoryInfo.IMAGE_PATH);
        if (url == null) {
            return;
        }
        if (url.indexOf("http") != 0) {
            url = "file:///" + url;
        }
        URL urlURL = new URL(url); //$NON-NLS-1$
        final ImageDescriptor descriptor = ImageDescriptor.createFromURL(urlURL);
        if (descriptor != null) {
            Image newImage = descriptor.createImage(false);
            if (size != null) {
                Image sizedImage = new Image(label.getDisplay(), size.x, size.y);
                GC gc = new GC(sizedImage);
                gc.drawImage(newImage, 0, 0, newImage.getImageData().width, newImage.getImageData().height, 0,
                        0, size.x, size.y);
                gc.dispose();
                newImage.dispose();
                label.setImage(sizedImage);
                label.addDisposeListener(new DisposeListener() {
                    public void widgetDisposed(DisposeEvent e) {
                        ((Label) e.getSource()).getImage().dispose();
                    }
                });
            } else {
                label.setImage(newImage);
                label.addDisposeListener(new DisposeListener() {
                    public void widgetDisposed(DisposeEvent e) {
                        ((Label) e.getSource()).getImage().dispose();
                    }
                });
            }
        }
    } catch (Exception e) {
    }
}

From source file:com.ibm.domino.osgi.debug.Activator.java

License:Open Source License

/**
 * @param path/*from ww w  .  j  a va 2 s  .  c  o m*/
 * @return
 */
private ImageDescriptor createImageDescriptor(String path) {
    URL url = FileLocator.find(getBundle(), new Path(path), null);
    return url != null ? ImageDescriptor.createFromURL(url) : null;
}

From source file:com.ibm.etools.mft.pattern.bpm.integration.code.designer.ResourceManager.java

License:Open Source License

public static ImageDescriptor getImageDescriptor(String path) {
    try {/*from w  ww  . ja  v a 2  s  . c om*/
        return ImageDescriptor.createFromURL((new File(path)).toURI().toURL());
    } catch (MalformedURLException exception) {
        return null;
    }
}

From source file:com.ibm.etools.mft.pattern.bpm.integration.code.designer.ResourceManager.java

License:Open Source License

public static ImageDescriptor getPluginImageDescriptor(Object plugin, String name) {
    try {/* w  ww  . j  a va 2 s. c  om*/
        try {
            URL url = getPluginImageURL(plugin, name);
            return ImageDescriptor.createFromURL(url);
        } catch (Throwable exception) {
            // Ignore any exceptions
        }
    } catch (Throwable exception) {
        // Ignore any exceptions
    }
    return null;
}

From source file:com.ibm.etools.mft.pattern.bpm.integration.code.designer.ResourceManager.java

License:Open Source License

public static ImageDescriptor getPluginImageDescriptor(String symbolicName, String path) {
    try {/*from   w  w w  .  j a v a  2 s  .  com*/
        URL url = getPluginImageURL(symbolicName, path);
        if (url != null) {
            return ImageDescriptor.createFromURL(url);
        }
    } catch (Throwable exception) {
        // Ignore any exceptions
    }
    return null;
}

From source file:com.ibm.research.tours.ToursPlugin.java

License:Open Source License

protected void loadPaletteExtensions() {
    IExtensionRegistry registry = Platform.getExtensionRegistry();
    IExtensionPoint paletteExtensionPt = registry.getExtensionPoint(PALETTE_EXTENSION_ID);
    IExtension[] paletteExtensions = paletteExtensionPt.getExtensions();

    if (paletteExtensions != null) {
        for (int i = 0; i < paletteExtensions.length; i++) {
            IExtension extension = paletteExtensions[i];
            IConfigurationElement[] config = extension.getConfigurationElements();

            for (int j = 0; j < config.length; j++) {
                try {
                    ITourElementProvider provider = (ITourElementProvider) config[j]
                            .createExecutableExtension("class");

                    String id = config[j].getAttribute("id");

                    if (id == null)
                        continue;

                    String label = config[j].getAttribute("text");
                    String description = config[j].getAttribute("description");
                    String icon = config[j].getAttribute("icon");

                    URL iconUrl = null;

                    try {
                        String namespace = extension.getNamespaceIdentifier();
                        Bundle bundle = Platform.getBundle(namespace);
                        iconUrl = new URL(bundle.getEntry("/"), icon);
                        //iconUrl = new URL(extension.getDeclaringPluginDescriptor().getInstallURL(),icon);
                    } catch (MalformedURLException e) {
                        log("Malformed url", e);
                    }/*w w  w .  j av a2  s  . c o m*/

                    Image iconImage = ImageDescriptor.createFromURL(iconUrl).createImage();

                    if (id != null) {
                        IPaletteEntry entry = new PaletteEntry(id, provider, iconImage, label, description);
                        getImageRegistry().put(id, iconImage);
                        fPaletteModel.addPaletteEntry(entry);
                    }
                } catch (CoreException e) {
                    log("Error loading palette extensions", e);
                }
            }
        }
    }
}

From source file:com.ibm.xsp.extlib.designer.bluemix.BluemixPlugin.java

License:Open Source License

public static ImageDescriptor getImageDescriptor(String location) {
    String iconPath = "images/"; // $NON-NLS-1$
    URL imageUrl = getDefault().getBundle().getEntry(iconPath + location);
    if (imageUrl != null) {
        return ImageDescriptor.createFromURL(imageUrl);
    }/*from  w w  w .java 2 s . c o  m*/
    return null;
}