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
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package net.sourceforge.phpeclipse.xdebug.ui;
14 import java.net.MalformedURLException;
17 import org.eclipse.jface.resource.ImageDescriptor;
18 import org.eclipse.jface.resource.ImageRegistry;
19 import org.eclipse.swt.graphics.Image;
21 public class XDebugUIPluginImages {
24 /* Declare Common paths */
25 private static URL ICON_BASE_URL= null;
28 String pathSuffix = "icons/"; //$NON-NLS-1$
29 ICON_BASE_URL= XDebugUIPlugin.getDefault().getBundle().getEntry(pathSuffix);
32 // The plugin registry
33 private static ImageRegistry fgImageRegistry = null;
36 * Set of predefined Image Descriptors.
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/";
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";
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";
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";
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";
79 * Returns the image managed under the given key in this registry.
81 * @param key the image's key
82 * @return the image managed under the given key
84 public static Image get(String key) {
85 return getImageRegistry().get(key);
89 * Returns the <code>ImageDescriptor</code> identified by the given key,
90 * or <code>null</code> if it does not exist.
92 public static ImageDescriptor getImageDescriptor(String key) {
93 return getImageRegistry().getDescriptor(key);
97 * Helper method to access the image registry from the XDebugUIPlugin class.
99 public static ImageRegistry getImageRegistry() {
100 if (fgImageRegistry == null) {
101 initializeImageRegistry();
103 return fgImageRegistry;
106 public static void initializeImageRegistry() {
107 fgImageRegistry= new ImageRegistry(XDebugUIPlugin.getStandardDisplay());
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");
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$
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");
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");
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)
148 private final static void declareRegistryImage(String key, String path) {
149 ImageDescriptor desc= ImageDescriptor.getMissingImageDescriptor();
151 desc= ImageDescriptor.createFromURL(makeIconFileURL(path));
152 } catch (MalformedURLException me) {
153 XDebugUIPlugin.log(me);
155 fgImageRegistry.put(key, desc);
158 private static URL makeIconFileURL(String iconPath) throws MalformedURLException {
159 if (ICON_BASE_URL == null) {
160 throw new MalformedURLException();
163 return new URL(ICON_BASE_URL, iconPath);