2 * Copyright 2015 Samsung Electronics All Rights Reserved.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package oic.simulator.serviceprovider.manager;
21 import oic.simulator.serviceprovider.Activator;
22 import oic.simulator.serviceprovider.utils.Constants;
24 import org.eclipse.jface.resource.ImageDescriptor;
25 import org.eclipse.jface.resource.ImageRegistry;
26 import org.eclipse.swt.graphics.Image;
27 import org.osgi.framework.Bundle;
30 * Class which loads the icons/images into the image registry, and has methods
31 * to handle the image related requests from other UI modules.
33 public class ImageManager {
35 private static ImageManager imageManager;
37 public static ImageManager getInstance() {
38 if (null == imageManager) {
39 imageManager = new ImageManager();
45 ImageRegistry r = Activator.getDefault().getImageRegistry();
46 Bundle bundle = Activator.getDefault().getBundle();
48 r.put(Constants.CHECKED, ImageDescriptor.createFromURL(bundle
49 .getEntry("icons/checked.gif")));
50 r.put(Constants.UNCHECKED, ImageDescriptor.createFromURL(bundle
51 .getEntry("icons/unchecked.gif")));
53 r.put(Constants.NOTIFY_BUTTON_UNSELECTED, ImageDescriptor
54 .createFromURL(bundle.getEntry("icons/button_free.PNG")));
55 r.put(Constants.NOTIFY_BUTTON_SELECTED, ImageDescriptor
56 .createFromURL(bundle.getEntry("icons/button_pressed.PNG")));
58 // Log View related icons
59 r.put(Constants.DEBUG_LOG, ImageDescriptor.createFromURL(bundle
60 .getEntry("/icons/debug_log.gif")));
61 r.put(Constants.INFO_LOG, ImageDescriptor.createFromURL(bundle
62 .getEntry("/icons/info_log.gif")));
63 r.put(Constants.WARNING_LOG, ImageDescriptor.createFromURL(bundle
64 .getEntry("/icons/warning_log.gif")));
65 r.put(Constants.ERROR_LOG, ImageDescriptor.createFromURL(bundle
66 .getEntry("/icons/error_log.gif")));
67 r.put(Constants.UNKNOWN_LOG, ImageDescriptor.createFromURL(bundle
68 .getEntry("/icons/unknown_log.gif")));
71 public static Image getImage(String imagePath) {
72 if (null == imagePath || imagePath.length() < 1) {
75 URL imageURL = Activator.getDefault().getBundle().getEntry(imagePath);
76 ImageDescriptor descriptor = ImageDescriptor.createFromURL(imageURL);
77 return descriptor.createImage();