Search in sources :

Example 1 with Activator

use of org.eclipse.tracecompass.internal.tmf.ui.Activator in project tracecompass by tracecompass.

the class TmfAnalysisOutputElement method getIcon.

@Override
public Image getIcon() {
    if (fOutput instanceof TmfAnalysisViewOutput) {
        IViewDescriptor descr = PlatformUI.getWorkbench().getViewRegistry().find(((TmfAnalysisViewOutput) fOutput).getViewId());
        if (descr != null) {
            Activator bundle = Activator.getDefault();
            String key = descr.getId();
            Image icon = bundle.getImageRegistry().get(key);
            if (icon == null) {
                icon = descr.getImageDescriptor().createImage();
                bundle.getImageRegistry().put(key, icon);
            }
            if (icon != null) {
                return icon;
            }
        }
    }
    return TmfProjectModelIcons.DEFAULT_VIEW_ICON;
}
Also used : IViewDescriptor(org.eclipse.ui.views.IViewDescriptor) Activator(org.eclipse.tracecompass.internal.tmf.ui.Activator) Image(org.eclipse.swt.graphics.Image) TmfAnalysisViewOutput(org.eclipse.tracecompass.tmf.ui.analysis.TmfAnalysisViewOutput)

Example 2 with Activator

use of org.eclipse.tracecompass.internal.tmf.ui.Activator in project tracecompass by tracecompass.

the class TmfUITestPlugin method loadIcon.

/**
 * Loads icons into the bundle's image registry
 *
 * @param bundle
 *          the bundle
 * @param url
 *          the icon url
 * @return the image
 */
@Nullable
public static Image loadIcon(Bundle bundle, String url) {
    if (bundle == null) {
        return null;
    }
    Activator plugin = Activator.getDefault();
    // $NON-NLS-1$
    String key = bundle.getSymbolicName() + "/" + url;
    Image icon = plugin.getImageRegistry().get(key);
    if (icon == null) {
        URL imageURL = bundle.getResource(url);
        ImageDescriptor descriptor = ImageDescriptor.createFromURL(imageURL);
        if (descriptor != null) {
            icon = descriptor.createImage();
            plugin.getImageRegistry().put(key, icon);
        }
    }
    return icon;
}
Also used : Activator(org.eclipse.tracecompass.internal.tmf.ui.Activator) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) Image(org.eclipse.swt.graphics.Image) URL(java.net.URL) Nullable(org.eclipse.jdt.annotation.Nullable)

Example 3 with Activator

use of org.eclipse.tracecompass.internal.tmf.ui.Activator in project tracecompass by tracecompass.

the class TmfProjectModelIcons method loadIcon.

@Nullable
public static Image loadIcon(Bundle bundle, String url) {
    if (bundle == null) {
        return null;
    }
    Activator plugin = Activator.getDefault();
    // $NON-NLS-1$
    String key = bundle.getSymbolicName() + "/" + url;
    Image icon = plugin.getImageRegistry().get(key);
    if (icon == null) {
        URL imageURL = bundle.getResource(url);
        ImageDescriptor descriptor = ImageDescriptor.createFromURL(imageURL);
        if (descriptor != null) {
            icon = descriptor.createImage();
            plugin.getImageRegistry().put(key, icon);
        }
    }
    return icon;
}
Also used : Activator(org.eclipse.tracecompass.internal.tmf.ui.Activator) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) Image(org.eclipse.swt.graphics.Image) URL(java.net.URL) Nullable(org.eclipse.jdt.annotation.Nullable)

Aggregations

Image (org.eclipse.swt.graphics.Image)3 Activator (org.eclipse.tracecompass.internal.tmf.ui.Activator)3 URL (java.net.URL)2 Nullable (org.eclipse.jdt.annotation.Nullable)2 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)2 TmfAnalysisViewOutput (org.eclipse.tracecompass.tmf.ui.analysis.TmfAnalysisViewOutput)1 IViewDescriptor (org.eclipse.ui.views.IViewDescriptor)1