Internalize API for trace control and move control to lttng2
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.ui / src / org / eclipse / linuxtools / internal / lttng2 / ui / Activator.java
index 3c161c9fea052d3217f190d457a8faf1fa1bc851..1b92b9844f67c308f6f91cee1e1af81e7429a433 100644 (file)
@@ -12,6 +12,8 @@
 
 package org.eclipse.linuxtools.internal.lttng2.ui;
 
+import java.net.URL;
+
 import org.eclipse.jface.resource.ImageDescriptor;
 import org.eclipse.jface.resource.ImageRegistry;
 import org.eclipse.swt.graphics.Image;
@@ -109,5 +111,22 @@ public class Activator extends AbstractUIPlugin {
         }
         return icon;
     }
+    
+    /**
+     * Loads the image in the plug-ins image registry (if necessary) and returns the image
+     * @param url - URL relative to the Bundle
+     * @return  the image
+     */
+    public Image loadIcon(String url) {
+        String key = plugin.getBundle().getSymbolicName() + "/" + url; //$NON-NLS-1$
+        Image icon = plugin.getImageRegistry().get(key);
+        if (icon == null) {
+            URL imageURL = plugin.getBundle().getResource(url);
+            ImageDescriptor descriptor = ImageDescriptor.createFromURL(imageURL);
+            icon = descriptor.createImage();
+            plugin.getImageRegistry().put(key, icon);
+        }
+        return icon;
+    }
 
 }
This page took 0.023732 seconds and 5 git commands to generate.