diff options
author | Alex Blewitt | 2020-06-22 14:33:56 +0000 |
---|---|---|
committer | Alex Blewitt | 2020-10-20 16:15:58 +0000 |
commit | 5c202200d26fa8f0fb07c46d3f92f5e4338b2f32 (patch) | |
tree | 265a226945f0e3b69480e5fec45c29ef9a00db20 | |
parent | 84dda3f422859d49d2ef2394ad6efa2cc29b2602 (diff) | |
download | eclipse.platform.debug-5c202200d26fa8f0fb07c46d3f92f5e4338b2f32.tar.gz eclipse.platform.debug-5c202200d26fa8f0fb07c46d3f92f5e4338b2f32.tar.xz eclipse.platform.debug-5c202200d26fa8f0fb07c46d3f92f5e4338b2f32.zip |
Bug 564082 - Use deferred image APII20201021-0200I20201020-1800
Change-Id: I36d688b97daaacc21fe08fdf8a9db7eb3be53aca
3 files changed, 22 insertions, 28 deletions
diff --git a/org.eclipse.debug.ui/META-INF/MANIFEST.MF b/org.eclipse.debug.ui/META-INF/MANIFEST.MF index 1e44df9fb..e3894413b 100644 --- a/org.eclipse.debug.ui/META-INF/MANIFEST.MF +++ b/org.eclipse.debug.ui/META-INF/MANIFEST.MF @@ -83,6 +83,7 @@ Require-Bundle: org.eclipse.core.expressions;bundle-version="[3.4.0,4.0.0)", org.eclipse.ui.console;bundle-version="[3.5.300,4.0.0)", org.eclipse.help;bundle-version="[3.4.0,4.0.0)", org.eclipse.debug.core;bundle-version="[3.9.0,4.0.0)";visibility:=reexport, + org.eclipse.jface;bundle-version="[3.21.0,4.0.0)", org.eclipse.jface.text;bundle-version="[3.5.0,4.0.0)", org.eclipse.ui.workbench.texteditor;bundle-version="[3.5.0,4.0.0)", org.eclipse.ui.ide;bundle-version="[3.5.0,4.0.0)", diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugPluginImages.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugPluginImages.java index f90062145..a7ca3d11f 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugPluginImages.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugPluginImages.java @@ -20,8 +20,6 @@ package org.eclipse.debug.internal.ui; -import java.net.URL; - import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IExtensionPoint; @@ -33,6 +31,7 @@ import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.resource.ImageRegistry; import org.eclipse.swt.graphics.Image; import org.osgi.framework.Bundle; +import org.osgi.framework.FrameworkUtil; /** * The images provided by the debug plugin. @@ -292,16 +291,13 @@ public class DebugPluginImages { * this plugin class is found (i.e. typically the packages directory) */ private final static void declareRegistryImage(String key, String path) { - ImageDescriptor desc = ImageDescriptor.getMissingImageDescriptor(); - Bundle bundle = Platform.getBundle(DebugUIPlugin.getUniqueIdentifier()); - URL url = null; - if (bundle != null){ - url = FileLocator.find(bundle, new Path(path), null); - if(url != null) { - desc = ImageDescriptor.createFromURL(url); - } + Bundle bundle = FrameworkUtil.getBundle(DebugPluginImages.class); + if (bundle == null) { + imageRegistry.put(key, ImageDescriptor.getMissingImageDescriptor()); + } else { + imageRegistry.put(key, + ImageDescriptor.createFromURLSupplier(true, () -> FileLocator.find(bundle, new Path(path), null))); } - imageRegistry.put(key, desc); } /** diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java index 9dc8f62f3..d0ea7f219 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java @@ -1339,22 +1339,22 @@ public class DebugUIPlugin extends AbstractUIPlugin implements ILaunchListener, * @return image descriptor or <code>null</code> */ public static ImageDescriptor getImageDescriptor(IConfigurationElement element, String attr) { - Bundle bundle = Platform.getBundle(element.getContributor().getName()); String iconPath = element.getAttribute(attr); if (iconPath != null) { - URL iconURL = FileLocator.find(bundle , new Path(iconPath), null); - if (iconURL != null) { - return ImageDescriptor.createFromURL(iconURL); - } else { // try to search as a URL in case it is absolute path - try { - iconURL = FileLocator.find(new URL(iconPath)); - if (iconURL != null) { - return ImageDescriptor.createFromURL(iconURL); + Bundle bundle = Platform.getBundle(element.getContributor().getName()); + return ImageDescriptor.createFromURLSupplier(true, () -> { + URL iconURL = FileLocator.find(bundle, new Path(iconPath), null); + if (iconURL != null) { + return iconURL; + } else { // try to search as a URL in case it is absolute path + try { + return FileLocator.find(new URL(iconPath)); + } catch (MalformedURLException e) { + // return null } - } catch (MalformedURLException e) { - // return null } - } + return null; + }); } return null; } @@ -1369,12 +1369,9 @@ public class DebugUIPlugin extends AbstractUIPlugin implements ILaunchListener, * @since 3.3 */ public static ImageDescriptor getImageDescriptor(String bundleName, String path) { - Bundle bundle = Platform.getBundle(bundleName); if (path != null) { - URL iconURL = FileLocator.find(bundle , new Path(path), null); - if (iconURL != null) { - return ImageDescriptor.createFromURL(iconURL); - } + Bundle bundle = Platform.getBundle(bundleName); + return ImageDescriptor.createFromURLSupplier(true, () -> FileLocator.find(bundle, new Path(path), null)); } return null; } |