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;
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
+ ControlPreferences.getInstance().init(getPreferenceStore());
}
/* (non-Javadoc)
*/
@Override
public void stop(BundleContext context) throws Exception {
+ ControlPreferences.getInstance().dispose();
plugin = null;
super.stop(context);
}
}
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;
+ }
}