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.clientcontroller.manager;
19 import org.eclipse.jface.resource.ImageDescriptor;
20 import org.eclipse.jface.resource.ImageRegistry;
21 import org.eclipse.swt.graphics.Image;
22 import org.osgi.framework.Bundle;
26 import oic.simulator.clientcontroller.Activator;
27 import oic.simulator.clientcontroller.utils.Constants;
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 // Log View related icons
54 r.put(Constants.DEBUG_LOG, ImageDescriptor.createFromURL(bundle
55 .getEntry("/icons/debug_log.gif")));
56 r.put(Constants.INFO_LOG, ImageDescriptor.createFromURL(bundle
57 .getEntry("/icons/info_log.gif")));
58 r.put(Constants.WARNING_LOG, ImageDescriptor.createFromURL(bundle
59 .getEntry("/icons/warning_log.gif")));
60 r.put(Constants.ERROR_LOG, ImageDescriptor.createFromURL(bundle
61 .getEntry("/icons/error_log.gif")));
62 r.put(Constants.UNKNOWN_LOG, ImageDescriptor.createFromURL(bundle
63 .getEntry("/icons/unknown_log.gif")));
66 public static Image getImage(String imagePath) {
67 if (null == imagePath || imagePath.length() < 1) {
70 URL imageURL = Activator.getDefault().getBundle().getEntry(imagePath);
71 ImageDescriptor descriptor = ImageDescriptor.createFromURL(imageURL);
72 return descriptor.createImage();