01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: * Joe Bowbeer (jozart@blarg.net) - removed dependency on runtime compatibility layer (bug 74526)
11: *******************************************************************************/package org.eclipse.ui.examples.readmetool;
12:
13: import java.net.MalformedURLException;
14: import java.net.URL;
15:
16: import org.eclipse.jface.resource.ImageDescriptor;
17:
18: /**
19: * Convenience class for storing references to image descriptors
20: * used by the readme tool.
21: */
22: public class ReadmeImages {
23: static final URL BASE_URL = ReadmePlugin.getDefault().getBundle()
24: .getEntry("/"); //$NON-NLS-1$
25:
26: static final ImageDescriptor EDITOR_ACTION1_IMAGE;
27:
28: static final ImageDescriptor EDITOR_ACTION2_IMAGE;
29:
30: static final ImageDescriptor EDITOR_ACTION3_IMAGE;
31:
32: static final ImageDescriptor EDITOR_ACTION1_IMAGE_DISABLE;
33:
34: static final ImageDescriptor EDITOR_ACTION2_IMAGE_DISABLE;
35:
36: static final ImageDescriptor EDITOR_ACTION3_IMAGE_DISABLE;
37:
38: static final ImageDescriptor EDITOR_ACTION1_IMAGE_ENABLE;
39:
40: static final ImageDescriptor EDITOR_ACTION2_IMAGE_ENABLE;
41:
42: static final ImageDescriptor EDITOR_ACTION3_IMAGE_ENABLE;
43:
44: static final ImageDescriptor README_WIZARD_BANNER;
45:
46: static {
47: String iconPath = "icons/"; //$NON-NLS-1$
48:
49: String prefix = iconPath + "ctool16/"; //$NON-NLS-1$
50: EDITOR_ACTION1_IMAGE = createImageDescriptor(prefix
51: + "action1.gif"); //$NON-NLS-1$
52: EDITOR_ACTION2_IMAGE = createImageDescriptor(prefix
53: + "action2.gif"); //$NON-NLS-1$
54: EDITOR_ACTION3_IMAGE = createImageDescriptor(prefix
55: + "action3.gif"); //$NON-NLS-1$
56:
57: prefix = iconPath + "dtool16/"; //$NON-NLS-1$
58: EDITOR_ACTION1_IMAGE_DISABLE = createImageDescriptor(prefix
59: + "action1.gif"); //$NON-NLS-1$
60: EDITOR_ACTION2_IMAGE_DISABLE = createImageDescriptor(prefix
61: + "action2.gif"); //$NON-NLS-1$
62: EDITOR_ACTION3_IMAGE_DISABLE = createImageDescriptor(prefix
63: + "action3.gif"); //$NON-NLS-1$
64:
65: prefix = iconPath + "etool16/"; //$NON-NLS-1$
66: EDITOR_ACTION1_IMAGE_ENABLE = createImageDescriptor(prefix
67: + "action1.gif"); //$NON-NLS-1$
68: EDITOR_ACTION2_IMAGE_ENABLE = createImageDescriptor(prefix
69: + "action2.gif"); //$NON-NLS-1$
70: EDITOR_ACTION3_IMAGE_ENABLE = createImageDescriptor(prefix
71: + "action3.gif"); //$NON-NLS-1$
72:
73: prefix = iconPath + "wizban/"; //$NON-NLS-1$
74: README_WIZARD_BANNER = createImageDescriptor(prefix
75: + "newreadme_wiz.gif"); //$NON-NLS-1$
76: }
77:
78: /**
79: * Utility method to create an <code>ImageDescriptor</code>
80: * from a path to a file.
81: */
82: private static ImageDescriptor createImageDescriptor(String path) {
83: try {
84: URL url = new URL(BASE_URL, path);
85: return ImageDescriptor.createFromURL(url);
86: } catch (MalformedURLException e) {
87: // do nothing
88: }
89: return ImageDescriptor.getMissingImageDescriptor();
90: }
91: }
|