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

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

Introduction

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

Prototype

public static ImageDescriptor getMissingImageDescriptor() 

Source Link

Document

Returns the shared image descriptor for a missing image.

Usage

From source file:com.mercatis.lighthouse3.base.ui.editors.EventEditorInput.java

License:Apache License

public ImageDescriptor getImageDescriptor() {
    return ImageDescriptor.getMissingImageDescriptor();
}

From source file:com.mercatis.lighthouse3.ui.swimlaneeditor.gef.model.ProcessTaskModelFigure.java

License:Apache License

private Image createImage(ProcessTaskType type, ProcessTaskState state) {
    switch (type) {
    case TASK_START:
    case TASK_STOP:
    case TASK_STEP:
        switch (state) {
        case NONE:
            return TASK_STEP_NONE.createImage();
        case OK://w w w.  j  ava2  s  .c o  m
            return TASK_STEP_OK.createImage();
        case ERROR:
            return TASK_STEP_ERROR.createImage();
        case STALE:
            return TASK_STEP_STALE.createImage();
        }
    case GROUP_START:
    case GROUP_STOP:
    case GROUP_STEP:
        switch (state) {
        case NONE:
            return GROUP_STEP_NONE.createImage();
        case OK:
            return GROUP_STEP_OK.createImage();
        case ERROR:
            return GROUP_STEP_ERROR.createImage();
        case STALE:
            return GROUP_STEP_STALE.createImage();
        }
    }
    return ImageDescriptor.getMissingImageDescriptor().createImage();
}

From source file:com.microsoft.tfs.client.common.ui.framework.image.ImageHelper.java

License:Open Source License

/**
 * <p>/*from  w w w  .  j ava2s  .c om*/
 * Obtains an {@link ImageDescriptor} from this {@link ImageHelper}. If this
 * {@link ImageHelper} has not already created an {@link ImageDescriptor}
 * corresponding to the specified plugin ID and image file path, a new
 * {@link ImageDescriptor} will be created. Otherwise, a cached
 * {@link ImageDescriptor} will be returned. If no image is found at the
 * specified image file path, a warning will be logged and a standard
 * "missing image" {@link ImageDescriptor} will be returned.
 * </p>
 *
 * @param pluginId
 *        specifies the plugin to resolve the relative image path with (must
 *        not be <code>null</code>)
 * @param imageFilePath
 *        the image file path (must not be <code>null</code>, also see
 *        comments on this class about specifying image file paths)
 * @return an {@link ImageDescriptor} corresponding to the specified image
 *         file path (never <code>null</code>)
 */
public ImageDescriptor getImageDescriptor(final String pluginId, final String imageFilePath) {
    Check.notNull(pluginId, "pluginId"); //$NON-NLS-1$
    Check.notNull(imageFilePath, "imageFilePath"); //$NON-NLS-1$

    final ImageDescriptorKey key = new ImageDescriptorKey(pluginId, imageFilePath);
    synchronized (createdImageDescriptors) {
        ImageDescriptor descriptor = (ImageDescriptor) createdImageDescriptors.get(key);
        if (descriptor != null) {
            return descriptor;
        }

        descriptor = AbstractUIPlugin.imageDescriptorFromPlugin(pluginId, imageFilePath);

        if (descriptor == null) {
            final String messageFormat = "image missing: pluginId=[{0}] path=[{1}]"; //$NON-NLS-1$
            final String message = MessageFormat.format(messageFormat, pluginId, imageFilePath);
            log.warn(message);
            descriptor = ImageDescriptor.getMissingImageDescriptor();
        } else {
            if (log.isTraceEnabled()) {
                final String messageFormat = "created an image descriptor (pluginId=[{0}] path=[{1}]):{2}"; //$NON-NLS-1$
                final String message = MessageFormat.format(messageFormat, pluginId, imageFilePath, descriptor);
                log.trace(message);
            }
        }

        createdImageDescriptors.put(key, descriptor);
        return descriptor;
    }
}

From source file:com.microsoft.tfs.client.common.ui.teambuild.editors.BuildExplorerEditorInput.java

License:Open Source License

/**
 * @see org.eclipse.ui.IEditorInput#getImageDescriptor()
 */
@Override
public ImageDescriptor getImageDescriptor() {
    return ImageDescriptor.getMissingImageDescriptor();
}

From source file:com.nokia.carbide.cpp.internal.project.ui.views.SPNViewActionGroup.java

License:Open Source License

protected ImageDescriptor getImageDescriptor(String relativePath) {
    String iconPath = "icons/"; //$NON-NLS-1$
    try {/* www  . j a v  a 2 s.  com*/
        URL installURL = CUIPlugin.getDefault().getBundle().getEntry("/"); //$NON-NLS-1$
        URL url = new URL(installURL, iconPath + relativePath);
        return ImageDescriptor.createFromURL(url);
    } catch (MalformedURLException e) {
        // should not happen
        return ImageDescriptor.getMissingImageDescriptor();
    }
}

From source file:com.nokia.carbide.cpp.internal.ui.SharedImages.java

License:Open Source License

private ImageDescriptor createImageDescriptor(IPath path) {
    ImageDescriptor result;/*  w ww. j av a2 s  .co  m*/
    URL url = FileLocator.find(CarbideUIPlugin.getDefault().getBundle(), path, null);
    if (url != null) {
        result = ImageDescriptor.createFromURL(url);
    } else {
        result = ImageDescriptor.getMissingImageDescriptor();
    }
    return result;
}

From source file:com.nokia.sdt.component.symbian.designerimages.DesignerImageAdapter.java

License:Open Source License

public ImageDescriptor getLargeIconDescriptor() {
    if (largeIconKey == null) {
        return ImageDescriptor.getMissingImageDescriptor();
    }// w  w w  . jav a2  s  .c om
    try {
        return ImageDescriptor.createFromURL(new URL("file", null, largeIconKey));
    } catch (MalformedURLException e) {
        return ImageDescriptor.getMissingImageDescriptor();
    }
}

From source file:com.nokia.sdt.component.symbian.designerimages.DesignerImageAdapter.java

License:Open Source License

public ImageDescriptor getSmallIconDescriptor() {
    if (smallIconKey == null) {
        return ImageDescriptor.getMissingImageDescriptor();
    }/*from   w  ww  . j a  v a  2s  .c  om*/
    try {
        return ImageDescriptor.createFromURL(new URL("file", null, smallIconKey));
    } catch (MalformedURLException e) {
        return ImageDescriptor.getMissingImageDescriptor();
    }
}

From source file:com.nokia.testfw.resultview.ResultViewPlugin.java

License:Open Source License

/**
 * retrieve an image based on its name (from the plug-in standard image folder)
 * @param imageName/*  ww  w .  ja  v  a  2 s  . c  o  m*/
 * @return <code>ImageDescriptor</code> of the image if found or the standard missing image descriptor
 */
public static final ImageDescriptor getImageDescriptor(Bundle bundle, String imageName) {
    URL url = getImageUrl(bundle, imageName);

    return (url != null) ? ImageDescriptor.createFromURL(url) : ImageDescriptor.getMissingImageDescriptor();
}

From source file:com.nokia.tools.media.utils.tooltip.DynamicTooltip.java

License:Open Source License

@SuppressWarnings("unchecked")
protected static void initializeData() {
    IConfigurationElement[] elements = Platform.getExtensionRegistry().getExtensionPoint(EXTENSION_POINT)
            .getConfigurationElements();
    for (IConfigurationElement element : elements) {
        if (ELEMENT_TOOLBAR_ITEM.equalsIgnoreCase(element.getName())) {
            ToolbarItemContribution def = new ToolbarItemContribution();

            String contributorName = element.getContributor().getName();

            String iconPath = element.getAttribute(ATTRIBUTE_ICON);
            if (iconPath != null) {
                URL url = FileLocator.find(Platform.getBundle(contributorName), new Path(iconPath), null);
                if (url != null) {
                    def.icon = ImageDescriptor.createFromURL(url);
                } else {
                    def.icon = ImageDescriptor.getMissingImageDescriptor();
                }/*w ww . j  ava  2 s. c  om*/
            }

            String disabledIconPath = element.getAttribute(ATTRIBUTE_DISABLED_ICON);
            if (disabledIconPath != null) {
                URL url = FileLocator.find(Platform.getBundle(contributorName), new Path(disabledIconPath),
                        null);
                if (url != null) {
                    def.disabledIcon = ImageDescriptor.createFromURL(url);
                }
            }

            String hoverIconPath = element.getAttribute(ATTRIBUTE_HOVER_ICON);
            if (hoverIconPath != null) {
                URL url = FileLocator.find(Platform.getBundle(contributorName), new Path(hoverIconPath), null);
                if (url != null) {
                    def.hoverIcon = ImageDescriptor.createFromURL(url);
                }
            }

            def.label = element.getAttribute(ATTRIBUTE_LABEL);

            String priority = element.getAttribute(ATTRIBUTE_PRIORITY);
            if (priority != null && priority.length() > 0) {
                try {
                    def.priority = new Integer(priority);
                } catch (NumberFormatException nfe) {
                    System.err.println("Invalid definition:\n" + element.toString());
                    System.err.println("Specified priority is not a number!");
                }
            }

            def.tooltip = element.getAttribute(ATTRIBUTE_TOOLTIP);

            def.tooltipStyle = element.getAttribute(ATTRIBUTE_TOOLTIP_STYLE);

            def.target = element.getAttribute(ATTRIBUTE_TARGET);

            Bundle contributor = Platform.getBundle(contributorName);

            def.actionId = element.getAttribute(ATTRIBUTE_ACTION);

            def.contributor = contributor;

            String actionProviderClassName = element.getAttribute(ATTRIBUTE_ACTION_PROVIDER);

            if (actionProviderClassName != null) {
                try {
                    Class actionProviderClass = contributor.loadClass(actionProviderClassName);

                    if (ITooltipActionProvider.class.isAssignableFrom(actionProviderClass)) {
                        def.actionProvider = (ITooltipActionProvider) actionProviderClass.newInstance();
                    } else {
                        System.err.println("Invalid definition:\n" + element.toString());
                        System.err.println("actionProvider class must implement interface "
                                + ITooltipActionProvider.class.getName());
                    }
                } catch (ClassNotFoundException cnfe) {
                    System.err.println("Invalid definition:\n" + element.toString());
                    System.err.println("actionProvider class not found: " + actionProviderClassName);
                } catch (Throwable t) {
                    System.err.println("Invalid definition:\n" + element.toString());
                    t.printStackTrace();
                }
            }

            def.enablements = parseEnablements(element);

            toolbarContributions.add(def);
        }

        if (ELEMENT_SECTION.equalsIgnoreCase(element.getName())) {
            SectionContribution def = new SectionContribution();

            String priority = element.getAttribute(ATTRIBUTE_PRIORITY);
            if (priority != null && priority.length() > 0) {
                try {
                    def.priority = new Integer(priority);
                } catch (NumberFormatException nfe) {
                    System.err.println("Invalid definition:\n" + element.toString());
                    System.err.println("Specified priority is not a number!");
                }
            }

            String uiClassName = element.getAttribute(ATTRIBUTE_UICLASS);
            Bundle contributor = Platform.getBundle(element.getContributor().getName());
            try {
                Class uiClass = contributor.loadClass(uiClassName);

                if (IDynamicTooltipUIContribution.class.isAssignableFrom(uiClass)) {
                    def.uiClass = (Class<IDynamicTooltipUIContribution>) uiClass;
                } else {
                    System.err.println("Invalid definition:\n" + element.toString());
                    System.err.println("UI class must implement interface "
                            + IDynamicTooltipUIContribution.class.getName());
                }
            } catch (ClassNotFoundException cnfe) {
                System.err.println("Invalid definition:\n" + element.toString());
                System.err.println("UI class not found: " + uiClassName);
            }

            def.enablements = parseEnablements(element);

            sectionContributions.add(def);
        }
    }
}