1 package org.simantics.tests.modelled.ui;
\r
4 import java.util.ArrayList;
\r
5 import java.util.List;
\r
7 import org.eclipse.jface.resource.ImageDescriptor;
\r
8 import org.eclipse.swt.graphics.Image;
\r
9 import org.eclipse.ui.plugin.AbstractUIPlugin;
\r
10 import org.osgi.framework.BundleContext;
\r
13 * The activator class controls the plug-in life cycle
\r
15 public class Activator extends AbstractUIPlugin {
\r
18 public static final String PLUGIN_ID = "org.simantics.tests.modelled.ui"; //$NON-NLS-1$
\r
20 // The shared instance
\r
21 private static Activator plugin;
\r
26 public Activator() {
\r
31 * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
\r
33 public void start(BundleContext context) throws Exception {
\r
34 super.start(context);
\r
40 * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
\r
42 public void stop(BundleContext context) throws Exception {
\r
44 for (Image image : imagesToDispose)
\r
46 super.stop(context);
\r
50 * Returns the shared instance
\r
52 * @return the shared instance
\r
54 public static Activator getDefault() {
\r
58 public static ImageDescriptor getImageDescriptor(String relativePath) {
\r
59 URL url = getDefault().getBundle().getEntry(relativePath);
\r
60 return ImageDescriptor.createFromURL(url);
\r
63 private static List<Image> imagesToDispose = new ArrayList<>();
\r
65 public static Image createManagedImage(ImageDescriptor descriptor) {
\r
66 Image image= descriptor.createImage();
\r
67 if (image == null) {
\r
68 image= ImageDescriptor.getMissingImageDescriptor().createImage();
\r
70 imagesToDispose.add(image);
\r