Refactory: remove unused classes, imports, fields and methods.
[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         public static final String IMG_FIELD_PUBLIC = "IMG_FIELD_PUBLIC";
55         public static final String IMG_FIELD_PROTECTED = "IMG_FIELD_PROTECTED";
56         public static final String IMG_FIELD_PRIVATE = "IMG_FIELD_PRIVATE";
57
58         public static final String IMG_PROPERTIES          = "IMG_PROPERTIES";
59 //      public static final String IMG_PROPERTIES_DISABLED = "IMG_PROPERTIES_DISABLED";
60         public static final String IMG_CLEAR               = "IMG_CLEAR";
61 //      public static final String IMG_CLEAR_DISABLED      = "IMG_CLEAR_DISABLED";
62         public static final String IMG_READ_LOG            = "IMG_READ_LOG";
63 //      public static final String IMG_READ_LOG_DISABLED   = "IMG_READ_LOG_DISABLED";
64         public static final String IMG_REMOVE_LOG          = "IMG_REMOVE_LOG";
65 //      public static final String IMG_REMOVE_LOG_DISABLED = "IMG_REMOVE_LOG_DISABLED";
66         public static final String IMG_FILTER              = "IMG_FILTER";
67 //      public static final String IMG_FILTER_DISABLED     = "IMG_FILTER_DISABLED";
68         public static final String IMG_EXPORT              = "IMG_EXPORT";
69 //      public static final String IMG_EXPORT_DISABLED     = "IMG_EXPORT_DISABLED";
70         public static final String IMG_IMPORT              = "IMG_IMPORT";
71 //      public static final String IMG_IMPORT_DISABLED     = "IMG_IMPORT_DISABLED";
72         public static final String IMG_OPEN_LOG                    = "IMG_OPEN_LOG";
73
74
75
76
77
78         /**
79          * Returns the image managed under the given key in this registry.
80          * 
81          * @param key the image's key
82          * @return the image managed under the given key
83          */ 
84         public static Image get(String key) {
85                 return getImageRegistry().get(key);
86         }
87         
88         /**
89          * Returns the <code>ImageDescriptor</code> identified by the given key,
90          * or <code>null</code> if it does not exist.
91          */
92         public static ImageDescriptor getImageDescriptor(String key) {
93                 return getImageRegistry().getDescriptor(key);
94         }       
95         
96         /*
97          * Helper method to access the image registry from the XDebugUIPlugin class.
98          */
99         public  static ImageRegistry getImageRegistry() {
100                 if (fgImageRegistry == null) {
101                         initializeImageRegistry();
102                 }
103                 return fgImageRegistry;
104         }
105         
106         public static void initializeImageRegistry() {
107                 fgImageRegistry= new ImageRegistry(XDebugUIPlugin.getStandardDisplay());
108                 declareImages();
109         }
110         
111         private static void declareImages() {
112                 declareRegistryImage(IMG_FIELD_PUBLIC, T_OBJ + "methpub_obj.gif");
113                 declareRegistryImage(IMG_FIELD_PROTECTED, T_OBJ + "methpro_obj.gif");
114                 declareRegistryImage(IMG_FIELD_PRIVATE, T_OBJ + "methpri_obj.gif");
115
116                 declareRegistryImage(IMG_EVIEW_ARGUMENTS_TAB, T_EVIEW + "arguments_tab.gif"); //$NON-NLS-1$
117                 declareRegistryImage(IMG_EVIEW_ENVIROMENT_TAB, T_EVIEW + "environment_tab.gif"); //$NON-NLS-1$
118
119                 declareRegistryImage(IMG_ERROR_ST_OBJ,T_OBJ+"error_st_obj.gif"); 
120                 declareRegistryImage(IMG_WARNING_ST_OBJ,T_OBJ + "warning_st_obj.gif");
121                 declareRegistryImage(IMG_INFO_ST_OBJ,T_OBJ +"info_st_obj.gif");
122                 declareRegistryImage(IMG_ERROR_STACK_OBJ,T_OBJ +"error_stack.gif");
123
124                 declareRegistryImage(IMG_PROPERTIES,T_LCL + "properties.gif");
125 //              declareRegistryImage(IMG_PROPERTIES_DISABLED
126                 declareRegistryImage(IMG_CLEAR,T_LCL + "clear_log.gif");
127 //              declareRegistryImage(IMG_CLEAR_DISABLED
128                 declareRegistryImage(IMG_READ_LOG ,T_LCL + "restore_log.gif");
129 //              declareRegistryImage(IMG_READ_LOG_DISABLED
130                 declareRegistryImage(IMG_REMOVE_LOG,T_LCL + "remove_log.gif");
131 //              declareRegistryImage(IMG_REMOVE_LOG_DISABLED
132                 declareRegistryImage(IMG_FILTER,T_LCL + "filter_log.gif");
133 //              declareRegistryImage(IMG_FILTER_DISABLED
134                 declareRegistryImage(IMG_EXPORT,T_LCL + "export_log.gif");
135 //              declareRegistryImage(IMG_EXPORT_DISABLED
136                 declareRegistryImage(IMG_IMPORT,T_LCL + "import_log.gif");
137 //              declareRegistryImage(IMG_IMPORT_DISABLED
138                 declareRegistryImage(IMG_OPEN_LOG,T_LCL + "open_log.gif");
139                 
140         }       
141         
142         /**
143          * Declare an Image in the registry table.
144          * @param key   The key to use when registering the image
145          * @param path  The path where the image can be found. This path is relative to where
146          *                              this plugin class is found (i.e. typically the packages directory)
147          */
148         private final static void declareRegistryImage(String key, String path) {
149                 ImageDescriptor desc= ImageDescriptor.getMissingImageDescriptor();
150                 try {
151                         desc= ImageDescriptor.createFromURL(makeIconFileURL(path));
152                 } catch (MalformedURLException me) {
153                         XDebugUIPlugin.log(me);
154                 }
155                 fgImageRegistry.put(key, desc);
156         }       
157         
158         private static URL makeIconFileURL(String iconPath) throws MalformedURLException {
159                 if (ICON_BASE_URL == null) {
160                         throw new MalformedURLException();
161                 }
162                         
163                 return new URL(ICON_BASE_URL, iconPath);
164         }       
165
166
167
168
169 }