|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 package com.nokia.s60tools.hticonnection.resources; |
|
19 |
|
20 import java.io.File; |
|
21 |
|
22 import org.eclipse.jface.resource.ImageDescriptor; |
|
23 import org.eclipse.jface.resource.ImageRegistry; |
|
24 import org.eclipse.swt.graphics.Image; |
|
25 import org.eclipse.swt.widgets.Display; |
|
26 |
|
27 import com.nokia.s60tools.hticonnection.HtiApiActivator; |
|
28 |
|
29 /** |
|
30 * This class manages images that are used in HTI Connection project. |
|
31 */ |
|
32 public class ImageResourceManager { |
|
33 |
|
34 /** |
|
35 * Loads images to image registry. |
|
36 * @param imagesPath Path of image directory. |
|
37 */ |
|
38 public static void loadImages(String imagesPath){ |
|
39 |
|
40 Display disp = Display.getCurrent(); |
|
41 ImageRegistry imgReg = HtiApiActivator.getDefault().getImageRegistry(); |
|
42 |
|
43 // |
|
44 // Storing images to image registry. |
|
45 // |
|
46 // There are images that are under EPL license. |
|
47 // |
|
48 |
|
49 // Image for base action. |
|
50 Image img = new Image( disp, imagesPath + File.separator + "s60tools_action_icon.png" ); //$NON-NLS-1$ |
|
51 imgReg.put( ImageKeys.S60TOOLS_ACTION_ICON, img ); |
|
52 |
|
53 // HTI API specific images |
|
54 img = new Image( disp, imagesPath + File.separator + "hti_console.png" ); //$NON-NLS-1$ |
|
55 imgReg.put( ImageKeys.IMG_APP_ICON, img ); |
|
56 |
|
57 img = new Image( disp, imagesPath + File.separator + "preferences.png" ); //$NON-NLS-1$ |
|
58 imgReg.put( ImageKeys.IMG_PREFERENCES, img ); |
|
59 |
|
60 img = new Image( disp, imagesPath + File.separator + "start_datagateway.png" ); //$NON-NLS-1$ |
|
61 imgReg.put( ImageKeys.IMG_START_GATEWAY, img); |
|
62 |
|
63 img = new Image( disp, imagesPath + File.separator + "stop_datagateway.png" ); //$NON-NLS-1$ |
|
64 imgReg.put( ImageKeys.IMG_STOP_GATEWAY, img); |
|
65 |
|
66 /******************************************************************************* |
|
67 * The following pieces of the graphic are taken from from Eclipse 3.4 platform |
|
68 * and CDT project in Eclipse community, which are made available under |
|
69 * the terms of the Eclipse Public License v1.0. |
|
70 * A copy of the EPL is provided at http://www.eclipse.org/legal/epl-v10.html |
|
71 *******************************************************************************/ |
|
72 |
|
73 // Original location of the graphic: |
|
74 // eclipse-3.4\plugins\org.eclipse.ui.console\icons\full\clcl16\clear_co.gif |
|
75 img = new Image( disp, imagesPath + File.separator + "clear_co.gif" ); //$NON-NLS-1$ |
|
76 imgReg.put( ImageKeys.IMG_CLEAR_SCREEN, img); |
|
77 |
|
78 // Original location of the graphic: |
|
79 // eclipse-3.4\plugins\org.eclipse.ui.console\icons\full\clcl16\lock_co.gif |
|
80 img = new Image( disp, imagesPath + File.separator + "lock_co.gif" ); //$NON-NLS-1$ |
|
81 imgReg.put( ImageKeys.IMG_SCROLL_LOCK, img); |
|
82 |
|
83 } |
|
84 |
|
85 /** |
|
86 * Gets image descriptor for given key from plugin's image registry. |
|
87 * @param key Key for image. |
|
88 * @return ImageDescriptor for given image key. |
|
89 */ |
|
90 public static ImageDescriptor getImageDescriptor( String key ){ |
|
91 ImageRegistry imgReg = HtiApiActivator.getDefault().getImageRegistry(); |
|
92 return imgReg.getDescriptor( key ); |
|
93 } |
|
94 |
|
95 /** |
|
96 * Gets image for given key from plugin's image registry. |
|
97 * @param key Key for image. |
|
98 * @return Image for given key. |
|
99 */ |
|
100 public static Image getImage( String key ){ |
|
101 ImageRegistry imgReg = HtiApiActivator.getDefault().getImageRegistry(); |
|
102 return imgReg.get(key); |
|
103 } |
|
104 } |