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;
13 import java.net.MalformedURLException;
16 import org.eclipse.jface.resource.ImageDescriptor;
17 import org.eclipse.jface.resource.ImageRegistry;
18 import org.eclipse.swt.graphics.Image;
20 public class XDebugUIPluginImages {
22 /* Declare Common paths */
23 private static URL ICON_BASE_URL = null;
26 String pathSuffix = "icons/"; //$NON-NLS-1$
27 ICON_BASE_URL = XDebugUIPlugin.getDefault().getBundle().getEntry(
31 // The plugin registry
32 private static ImageRegistry fgImageRegistry = null;
35 * Set of predefined Image Descriptors.
37 private static final String T_OBJ = "obj16/"; //$NON-NLS-1$
38 // private static final String T_OVR= "ovr16/"; //$NON-NLS-1$
40 private static final String T_EVIEW = "eview16/"; //$NON-NLS-1$
42 private static final String T_LCL = "elcl16/";
44 public static final String IMG_EVIEW_ARGUMENTS_TAB = "IMG_EVIEW_ARGUMENTS_TAB";
46 public static final String IMG_EVIEW_ENVIROMENT_TAB = "IMG_EVIEW_ENVIROMENT_TAB";
48 public static final String IMG_PREV_EVENT = "IMG_PREV_EVENT";
50 public static final String DESC_NEXT_EVENT = "DESC_NEXT_EVENT";
52 public static final String IMG_ERROR_ST_OBJ = "IMG_ERROR_ST_OBJ";
54 public static final String IMG_WARNING_ST_OBJ = "IMG_WARNING_ST_OBJ";
56 public static final String IMG_INFO_ST_OBJ = "IMG_INFO_ST_OBJ";
58 public static final String IMG_ERROR_STACK_OBJ = "IMG_ERROR_STACK_OBJ";
60 public static final String IMG_PROPERTIES = "IMG_PROPERTIES";
62 // public static final String IMG_PROPERTIES_DISABLED =
63 // "IMG_PROPERTIES_DISABLED";
64 public static final String IMG_CLEAR = "IMG_CLEAR";
66 // public static final String IMG_CLEAR_DISABLED = "IMG_CLEAR_DISABLED";
67 public static final String IMG_READ_LOG = "IMG_READ_LOG";
69 // public static final String IMG_READ_LOG_DISABLED =
70 // "IMG_READ_LOG_DISABLED";
71 public static final String IMG_REMOVE_LOG = "IMG_REMOVE_LOG";
73 // public static final String IMG_REMOVE_LOG_DISABLED =
74 // "IMG_REMOVE_LOG_DISABLED";
75 public static final String IMG_FILTER = "IMG_FILTER";
77 // public static final String IMG_FILTER_DISABLED = "IMG_FILTER_DISABLED";
78 public static final String IMG_EXPORT = "IMG_EXPORT";
80 // public static final String IMG_EXPORT_DISABLED = "IMG_EXPORT_DISABLED";
81 public static final String IMG_IMPORT = "IMG_IMPORT";
83 // public static final String IMG_IMPORT_DISABLED = "IMG_IMPORT_DISABLED";
84 public static final String IMG_OPEN_LOG = "IMG_OPEN_LOG";
87 * Returns the image managed under the given key in this registry.
91 * @return the image managed under the given key
93 public static Image get(String key) {
94 return getImageRegistry().get(key);
98 * Returns the <code>ImageDescriptor</code> identified by the given key,
99 * or <code>null</code> if it does not exist.
101 public static ImageDescriptor getImageDescriptor(String key) {
102 return getImageRegistry().getDescriptor(key);
106 * Helper method to access the image registry from the XDebugUIPlugin class.
108 public static ImageRegistry getImageRegistry() {
109 if (fgImageRegistry == null) {
110 initializeImageRegistry();
112 return fgImageRegistry;
115 public static void initializeImageRegistry() {
116 fgImageRegistry = new ImageRegistry(XDebugUIPlugin.getStandardDisplay());
120 private static void declareImages() {
121 declareRegistryImage(IMG_EVIEW_ARGUMENTS_TAB, T_EVIEW
122 + "arguments_tab.gif"); //$NON-NLS-1$
123 declareRegistryImage(IMG_EVIEW_ENVIROMENT_TAB, T_EVIEW
124 + "environment_tab.gif"); //$NON-NLS-1$
126 declareRegistryImage(IMG_ERROR_ST_OBJ, T_OBJ + "error_st_obj.gif");
127 declareRegistryImage(IMG_WARNING_ST_OBJ, T_OBJ + "warning_st_obj.gif");
128 declareRegistryImage(IMG_INFO_ST_OBJ, T_OBJ + "info_st_obj.gif");
129 declareRegistryImage(IMG_ERROR_STACK_OBJ, T_OBJ + "error_stack.gif");
131 declareRegistryImage(IMG_PROPERTIES, T_LCL + "properties.gif");
132 // declareRegistryImage(IMG_PROPERTIES_DISABLED
133 declareRegistryImage(IMG_CLEAR, T_LCL + "clear_log.gif");
134 // declareRegistryImage(IMG_CLEAR_DISABLED
135 declareRegistryImage(IMG_READ_LOG, T_LCL + "restore_log.gif");
136 // declareRegistryImage(IMG_READ_LOG_DISABLED
137 declareRegistryImage(IMG_REMOVE_LOG, T_LCL + "remove_log.gif");
138 // declareRegistryImage(IMG_REMOVE_LOG_DISABLED
139 declareRegistryImage(IMG_FILTER, T_LCL + "filter_log.gif");
140 // declareRegistryImage(IMG_FILTER_DISABLED
141 declareRegistryImage(IMG_EXPORT, T_LCL + "export_log.gif");
142 // declareRegistryImage(IMG_EXPORT_DISABLED
143 declareRegistryImage(IMG_IMPORT, T_LCL + "import_log.gif");
144 // declareRegistryImage(IMG_IMPORT_DISABLED
145 declareRegistryImage(IMG_OPEN_LOG, T_LCL + "open_log.gif");
150 * Declare an Image in the registry table.
153 * The key to use when registering the image
155 * The path where the image can be found. This path is relative
156 * to where this plugin class is found (i.e. typically the
157 * packages directory)
159 private final static void declareRegistryImage(String key, String path) {
160 ImageDescriptor desc = ImageDescriptor.getMissingImageDescriptor();
162 desc = ImageDescriptor.createFromURL(makeIconFileURL(path));
163 } catch (MalformedURLException me) {
164 XDebugUIPlugin.log(me);
166 fgImageRegistry.put(key, desc);
169 private static URL makeIconFileURL(String iconPath)
170 throws MalformedURLException {
171 if (ICON_BASE_URL == null) {
172 throw new MalformedURLException();
175 return new URL(ICON_BASE_URL, iconPath);