1 package org.simantics.tests.modelled.ui;
4 import java.util.ArrayList;
7 import org.eclipse.jface.resource.ImageDescriptor;
8 import org.eclipse.swt.graphics.Image;
9 import org.eclipse.swt.graphics.Resource;
10 import org.eclipse.ui.plugin.AbstractUIPlugin;
11 import org.osgi.framework.BundleContext;
14 * The activator class controls the plug-in life cycle
16 public class Activator extends AbstractUIPlugin {
19 public static final String PLUGIN_ID = "org.simantics.tests.modelled.ui"; //$NON-NLS-1$
21 // The shared instance
22 private static Activator plugin;
32 * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
34 public void start(BundleContext context) throws Exception {
41 * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
43 public void stop(BundleContext context) throws Exception {
45 imagesToDispose.forEach(Resource::dispose);
50 * Returns the shared instance
52 * @return the shared instance
54 public static Activator getDefault() {
58 public static ImageDescriptor getImageDescriptor(String relativePath) {
59 URL url = getDefault().getBundle().getEntry(relativePath);
60 return ImageDescriptor.createFromURL(url);
63 private static List<Image> imagesToDispose = new ArrayList<>();
65 public static Image createManagedImage(ImageDescriptor descriptor) {
66 Image image= descriptor.createImage();
68 image= ImageDescriptor.getMissingImageDescriptor().createImage();
70 imagesToDispose.add(image);