Adding more phpdoc tags to String[] array so the code scanner will pick them up and...
[phpeclipse.git] / net.sourceforge.phpeclipse.xdebug.ui / src / net / sourceforge / phpeclipse / xdebug / ui / XDebugUIPluginImages.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2004 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  * 
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11 package net.sourceforge.phpeclipse.xdebug.ui;
12
13
14 import java.net.MalformedURLException;
15 import java.net.URL;
16
17 import org.eclipse.jface.resource.ImageDescriptor;
18 import org.eclipse.jface.resource.ImageRegistry;
19 import org.eclipse.swt.graphics.Image;
20
21 public class XDebugUIPluginImages {
22
23
24         /* Declare Common paths */
25         private static URL ICON_BASE_URL= null;
26
27         static {
28                 String pathSuffix = "icons/"; //$NON-NLS-1$
29                 ICON_BASE_URL= XDebugUIPlugin.getDefault().getBundle().getEntry(pathSuffix);
30         }
31         
32         // The plugin registry
33         private static ImageRegistry fgImageRegistry = null;
34         
35         /*
36          * Set of predefined Image Descriptors.
37          */
38         private static final String T_OBJ= "obj16/";            //$NON-NLS-1$
39 //      private static final String T_OVR= "ovr16/";            //$NON-NLS-1$
40         private static final String T_EVIEW= "eview16/";        //$NON-NLS-1$
41         private static final String T_LCL="elcl16/";
42
43         public static final String IMG_EVIEW_ARGUMENTS_TAB = "IMG_EVIEW_ARGUMENTS_TAB";
44         public static final String IMG_EVIEW_ENVIROMENT_TAB = "IMG_EVIEW_ENVIROMENT_TAB";
45
46         
47         public static final String IMG_PREV_EVENT="IMG_PREV_EVENT";
48         public static final String DESC_NEXT_EVENT="DESC_NEXT_EVENT";
49         public static final String IMG_ERROR_ST_OBJ="IMG_ERROR_ST_OBJ";
50         public static final String IMG_WARNING_ST_OBJ="IMG_WARNING_ST_OBJ";
51         public static final String IMG_INFO_ST_OBJ="IMG_INFO_ST_OBJ";
52         public static final String IMG_ERROR_STACK_OBJ="IMG_ERROR_STACK_OBJ";
53
54
55         public static final String IMG_PROPERTIES          = "IMG_PROPERTIES";
56 //      public static final String IMG_PROPERTIES_DISABLED = "IMG_PROPERTIES_DISABLED";
57         public static final String IMG_CLEAR               = "IMG_CLEAR";
58 //      public static final String IMG_CLEAR_DISABLED      = "IMG_CLEAR_DISABLED";
59         public static final String IMG_READ_LOG            = "IMG_READ_LOG";
60 //      public static final String IMG_READ_LOG_DISABLED   = "IMG_READ_LOG_DISABLED";
61         public static final String IMG_REMOVE_LOG          = "IMG_REMOVE_LOG";
62 //      public static final String IMG_REMOVE_LOG_DISABLED = "IMG_REMOVE_LOG_DISABLED";
63         public static final String IMG_FILTER              = "IMG_FILTER";
64 //      public static final String IMG_FILTER_DISABLED     = "IMG_FILTER_DISABLED";
65         public static final String IMG_EXPORT              = "IMG_EXPORT";
66 //      public static final String IMG_EXPORT_DISABLED     = "IMG_EXPORT_DISABLED";
67         public static final String IMG_IMPORT              = "IMG_IMPORT";
68 //      public static final String IMG_IMPORT_DISABLED     = "IMG_IMPORT_DISABLED";
69         public static final String IMG_OPEN_LOG                    = "IMG_OPEN_LOG";
70
71
72
73
74
75         /**
76          * Returns the image managed under the given key in this registry.
77          * 
78          * @param key the image's key
79          * @return the image managed under the given key
80          */ 
81         public static Image get(String key) {
82                 return getImageRegistry().get(key);
83         }
84         
85         /**
86          * Returns the <code>ImageDescriptor</code> identified by the given key,
87          * or <code>null</code> if it does not exist.
88          */
89         public static ImageDescriptor getImageDescriptor(String key) {
90                 return getImageRegistry().getDescriptor(key);
91         }       
92         
93         /*
94          * Helper method to access the image registry from the XDebugUIPlugin class.
95          */
96         public  static ImageRegistry getImageRegistry() {
97                 if (fgImageRegistry == null) {
98                         initializeImageRegistry();
99                 }
100                 return fgImageRegistry;
101         }
102         
103         public static void initializeImageRegistry() {
104                 fgImageRegistry= new ImageRegistry(XDebugUIPlugin.getStandardDisplay());
105                 declareImages();
106         }
107         
108         private static void declareImages() {
109                 declareRegistryImage(IMG_EVIEW_ARGUMENTS_TAB, T_EVIEW + "arguments_tab.gif"); //$NON-NLS-1$
110                 declareRegistryImage(IMG_EVIEW_ENVIROMENT_TAB, T_EVIEW + "environment_tab.gif"); //$NON-NLS-1$
111
112                 declareRegistryImage(IMG_ERROR_ST_OBJ,T_OBJ+"error_st_obj.gif"); 
113                 declareRegistryImage(IMG_WARNING_ST_OBJ,T_OBJ + "warning_st_obj.gif");
114                 declareRegistryImage(IMG_INFO_ST_OBJ,T_OBJ +"info_st_obj.gif");
115                 declareRegistryImage(IMG_ERROR_STACK_OBJ,T_OBJ +"error_stack.gif");
116
117                 declareRegistryImage(IMG_PROPERTIES,T_LCL + "properties.gif");
118 //              declareRegistryImage(IMG_PROPERTIES_DISABLED
119                 declareRegistryImage(IMG_CLEAR,T_LCL + "clear_log.gif");
120 //              declareRegistryImage(IMG_CLEAR_DISABLED
121                 declareRegistryImage(IMG_READ_LOG ,T_LCL + "restore_log.gif");
122 //              declareRegistryImage(IMG_READ_LOG_DISABLED
123                 declareRegistryImage(IMG_REMOVE_LOG,T_LCL + "remove_log.gif");
124 //              declareRegistryImage(IMG_REMOVE_LOG_DISABLED
125                 declareRegistryImage(IMG_FILTER,T_LCL + "filter_log.gif");
126 //              declareRegistryImage(IMG_FILTER_DISABLED
127                 declareRegistryImage(IMG_EXPORT,T_LCL + "export_log.gif");
128 //              declareRegistryImage(IMG_EXPORT_DISABLED
129                 declareRegistryImage(IMG_IMPORT,T_LCL + "import_log.gif");
130 //              declareRegistryImage(IMG_IMPORT_DISABLED
131                 declareRegistryImage(IMG_OPEN_LOG,T_LCL + "open_log.gif");
132                 
133         }       
134         
135         /**
136          * Declare an Image in the registry table.
137          * @param key   The key to use when registering the image
138          * @param path  The path where the image can be found. This path is relative to where
139          *                              this plugin class is found (i.e. typically the packages directory)
140          */
141         private final static void declareRegistryImage(String key, String path) {
142                 ImageDescriptor desc= ImageDescriptor.getMissingImageDescriptor();
143                 try {
144                         desc= ImageDescriptor.createFromURL(makeIconFileURL(path));
145                 } catch (MalformedURLException me) {
146                         XDebugUIPlugin.log(me);
147                 }
148                 fgImageRegistry.put(key, desc);
149         }       
150         
151         private static URL makeIconFileURL(String iconPath) throws MalformedURLException {
152                 if (ICON_BASE_URL == null) {
153                         throw new MalformedURLException();
154                 }
155                         
156                 return new URL(ICON_BASE_URL, iconPath);
157         }       
158
159
160
161
162 }