1 package oic.simulator.serviceprovider.manager;
5 import oic.simulator.serviceprovider.Activator;
6 import oic.simulator.serviceprovider.utils.Constants;
8 import org.eclipse.jface.resource.ImageDescriptor;
9 import org.eclipse.jface.resource.ImageRegistry;
10 import org.eclipse.swt.graphics.Image;
11 import org.osgi.framework.Bundle;
13 public class ImageManager {
15 private static ImageManager imageManager;
17 public static ImageManager getInstance() {
18 if (null == imageManager) {
19 imageManager = new ImageManager();
25 ImageRegistry r = Activator.getDefault().getImageRegistry();
26 Bundle bundle = Activator.getDefault().getBundle();
28 r.put(Constants.CHECKED, ImageDescriptor.createFromURL(bundle
29 .getEntry("icons/checked.gif")));
30 r.put(Constants.UNCHECKED, ImageDescriptor.createFromURL(bundle
31 .getEntry("icons/unchecked.gif")));
33 r.put(Constants.NOTIFY_BUTTON_UNSELECTED, ImageDescriptor
34 .createFromURL(bundle.getEntry("icons/button_free.PNG")));
35 r.put(Constants.NOTIFY_BUTTON_SELECTED, ImageDescriptor
36 .createFromURL(bundle.getEntry("icons/button_pressed.PNG")));
38 // Resource icons based on the resource type
39 r.put(Constants.OIC_LIGHT, ImageDescriptor.createFromURL(bundle
40 .getEntry("/icons/light_16x16.png")));
42 // Log View related icons
43 r.put(Constants.DEBUG_LOG, ImageDescriptor.createFromURL(bundle
44 .getEntry("/icons/debug_log.gif")));
45 r.put(Constants.INFO_LOG, ImageDescriptor.createFromURL(bundle
46 .getEntry("/icons/info_log.gif")));
47 r.put(Constants.WARNING_LOG, ImageDescriptor.createFromURL(bundle
48 .getEntry("/icons/warning_log.gif")));
49 r.put(Constants.ERROR_LOG, ImageDescriptor.createFromURL(bundle
50 .getEntry("/icons/error_log.gif")));
51 r.put(Constants.UNKNOWN_LOG, ImageDescriptor.createFromURL(bundle
52 .getEntry("/icons/unknown_log.gif")));
55 public static Image getImage(String imagePath) {
57 if (null == imagePath || imagePath.length() < 1) {
60 URL imageURL = Activator.getDefault().getBundle().getEntry(imagePath);
61 ImageDescriptor descriptor = ImageDescriptor.createFromURL(imageURL);
62 return descriptor.createImage();