Java Code Examples for org.eclipse.jface.resource.ImageRegistry#remove()

The following examples show how to use org.eclipse.jface.resource.ImageRegistry#remove() . 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 File: LivingApplicationPlugin.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
public static Image getImage(final String imageName) {
    final ImageRegistry reg = getDefault().getImageRegistry();

    Image result = reg.get(imageName);

    if (result != null && !result.isDisposed()) {//prevent from bad dispose
        return result;
    }

    final ImageDescriptor descriptor = ImageDescriptor.createFromURL(getDefault().getBundle().getResource(imageName));
    if (descriptor != null) {
        result = descriptor.createImage();
    }

    reg.remove(imageName);
    if (result != null) {
        reg.put(imageName, result);
    }

    return result;
}
 
Example 2
Source File: UIPlugin.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
public static Image getImage(final String imageName) {
    final ImageRegistry reg = getDefault().getImageRegistry();

    Image result = reg.get(imageName);

    if (result != null && !result.isDisposed()) {//prevent from bad dispose
        return result;
    }

    final ImageDescriptor descriptor = ImageDescriptor.createFromURL(getDefault().getBundle().getResource(imageName));
    if (descriptor != null) {
        result = descriptor.createImage();
    }

    reg.remove(imageName);
    if (result != null) {
        reg.put(imageName, result);
    }

    return result;
}
 
Example 3
Source File: UIPlugin.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
public static ImageDescriptor getImageDescriptor(String imageName) {
    final ImageRegistry reg = getDefault().getImageRegistry();

    ImageDescriptor result = reg.getDescriptor(imageName);

    if (result != null) {
        return result;
    }

    final ImageDescriptor descriptor = ImageDescriptor.createFromURL(getDefault().getBundle().getResource(imageName));
    if (descriptor != null) {
        result = descriptor;
    }

    reg.remove(imageName);
    if (result != null) {
        reg.put(imageName, result);
    }

    return result;
}
 
Example 4
Source File: BusinessObjectPlugin.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
public static Image getImage(final String imageName) {
    final ImageRegistry reg = getDefault().getImageRegistry();

    Image result = reg.get(imageName);

    if (result != null && !result.isDisposed()) {//prevent from bad dispose
        return result;
    }

    final ImageDescriptor descriptor = ImageDescriptor.createFromURL(getDefault().getBundle().getResource(imageName));
    if (descriptor != null) {
        result = descriptor.createImage();
    }

    reg.remove(imageName);
    if (result != null) {
        reg.put(imageName, result);
    }

    return result;
}
 
Example 5
Source File: Pics.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
public static Image getImage(final String imageName, final AbstractUIPlugin plugin) {
    if (plugin == null) {
        return null;
    }
    final ImageRegistry reg = plugin.getImageRegistry();

    Image result = reg.get(imageName);

    if (result != null && !result.isDisposed()) {//prevent from bad dispose
        return result;
    }

    final ImageDescriptor descriptor = getImageDescriptor(imageName, plugin);
    if (descriptor != null) {
        result = descriptor.createImage();
    }

    reg.remove(imageName);
    if (result != null) {
        reg.put(imageName, result);
    }

    return result;
}
 
Example 6
Source File: Pics.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
 * get the system image resized in 16x16 (only used in connectors label provider)
 *
 * @param id
 * @return
 */
public static Image getSystemImage(final int id) {
    final ImageRegistry reg = plugin.getImageRegistry();

    final String imageName = id + "";
    Image result = reg.get(imageName);

    if (result != null && !result.isDisposed()) {//prevent from bad dispose
        return result;
    }
    result = Display.getCurrent().getSystemImage(id);
    final Image scaled = new Image(Display.getDefault(), 16, 16);
    final GC gc = new GC(scaled);
    gc.setAntialias(SWT.ON);
    gc.setInterpolation(SWT.HIGH);
    gc.drawImage(result, 0, 0, result.getBounds().width, result.getBounds().height, 0, 0, 16, 16);
    gc.dispose();
    result = scaled;
    reg.remove(imageName);
    reg.put(imageName, result);
    return result;
}
 
Example 7
Source File: BosArchiveImporterPlugin.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
public static Image getImage(final String imageName) {
    final ImageRegistry reg = getDefault().getImageRegistry();

    Image result = reg.get(imageName);

    if (result != null && !result.isDisposed()) {//prevent from bad dispose
        return result;
    }

    final ImageDescriptor descriptor = ImageDescriptor.createFromURL(getDefault().getBundle().getResource(imageName));
    if (descriptor != null) {
        result = descriptor.createImage();
    }

    reg.remove(imageName);
    if (result != null) {
        reg.put(imageName, result);
    }

    return result;
}