Update internal packages export in LTTng 2.0 control + update java doc
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.ui / src / org / eclipse / linuxtools / internal / lttng2 / ui / Activator.java
index 3c161c9fea052d3217f190d457a8faf1fa1bc851..800abc0f1dd4799048a35a00fe058bd7e9d91c56 100644 (file)
 
 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.linuxtools.internal.lttng2.ui.views.control.preferences.ControlPreferences;
 import org.eclipse.swt.graphics.Image;
 import org.eclipse.ui.plugin.AbstractUIPlugin;
 import org.osgi.framework.BundleContext;
@@ -71,6 +74,7 @@ public class Activator extends AbstractUIPlugin {
     public void start(BundleContext context) throws Exception {
         super.start(context);
         plugin = this;
+        ControlPreferences.getInstance().init(getPreferenceStore());
     }
 
     /* (non-Javadoc)
@@ -78,6 +82,7 @@ public class Activator extends AbstractUIPlugin {
      */
     @Override
     public void stop(BundleContext context) throws Exception {
+        ControlPreferences.getInstance().dispose();
         plugin = null;
         super.stop(context);
     }
@@ -109,5 +114,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.023736 seconds and 5 git commands to generate.