Example usage for org.eclipse.jface.dialogs Dialog DLG_IMG_INFO

List of usage examples for org.eclipse.jface.dialogs Dialog DLG_IMG_INFO

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs Dialog DLG_IMG_INFO.

Prototype

String DLG_IMG_INFO

To view the source code for org.eclipse.jface.dialogs Dialog DLG_IMG_INFO.

Click Source Link

Document

Image registry key for info image (value "dialog_info_image").

Usage

From source file:raptor.swt.RaptorImageRegistry.java

License:BSD License

/**
 * Returns the image associated with the given key in this registry, or
 * <code>null</code> if none.
 * /* w w  w .j av  a2 s  . c om*/
 * @param key
 *            the key
 * @return the image, or <code>null</code> if none
 */
@SuppressWarnings({ "deprecation" })
public Image get(String key) {

    // can be null
    if (key == null) {
        return null;
    }

    if (display != null) {
        /**
         * NOTE, for backwards compatibility the following images are
         * supported here, they should never be disposed, hence we
         * explicitly return them rather then registering images that SWT
         * will dispose.
         * 
         * Applications should go direclty to SWT for these icons.
         * 
         * @see Display.getSystemIcon(int ID)
         */
        int swtKey = -1;
        if (key.equals(Dialog.DLG_IMG_INFO)) {
            swtKey = SWT.ICON_INFORMATION;
        }
        if (key.equals(Dialog.DLG_IMG_QUESTION)) {
            swtKey = SWT.ICON_QUESTION;
        }
        if (key.equals(Dialog.DLG_IMG_WARNING)) {
            swtKey = SWT.ICON_WARNING;
        }
        if (key.equals(Dialog.DLG_IMG_ERROR)) {
            swtKey = SWT.ICON_ERROR;
        }
        // if we actually just want to return an SWT image do so without
        // looking in the registry
        if (swtKey != -1) {
            final Image[] image = new Image[1];
            final int id = swtKey;
            display.syncExec(new RaptorRunnable() {
                @Override
                public void execute() {
                    image[0] = display.getSystemImage(id);
                }
            });
            return image[0];
        }
    }

    Entry entry = getEntry(key);
    if (entry == null) {
        return null;
    }

    if (entry.image == null) {
        entry.image = manager.createImageWithDefault(entry.descriptor);
    }

    return entry.image;
}