1 package net.sourceforge.phpeclipse.phpunit;
3 import java.net.MalformedURLException;
6 import org.eclipse.jface.resource.ImageDescriptor;
7 import org.eclipse.jface.resource.ImageRegistry;
8 import org.eclipse.swt.graphics.Image;
10 public class PHPUnitImages {
12 protected static final String NAME_PREFIX =
13 "net.sourceforge.phpeclipse.phpunit";
14 protected static final int NAME_PREFIX_LENGTH = NAME_PREFIX.length();
16 protected static URL iconBaseURL;
19 String pathSuffix = "icons/";
23 PHPUnitPlugin.getDefault().getDescriptor().getInstallURL(),
25 } catch (MalformedURLException e) {
26 //PHPUnitPlugin.log(e);
31 protected static final ImageRegistry IMAGE_REGISTRY = new ImageRegistry();
34 * Available cached Images in the Java plugin image registry.
37 public static final String IMG_SELECT_TEST_SUITE = NAME_PREFIX + "tsuite.gif";
38 public static final String IMG_RUN_TEST_SUITE = NAME_PREFIX + "start.gif";
39 public static final String IMG_TEST_ERROR = NAME_PREFIX + "testerr.gif";
40 public static final String IMG_TEST_FAILURE = NAME_PREFIX + "testfail.gif";
41 public static final String IMG_TEST_PASS = NAME_PREFIX + "testok.gif";
42 public static final String IMG_TEST_SUITE_ERROR = NAME_PREFIX + "tsuiteerror.gif";
43 public static final String IMG_TEST_SUITE_PASS = NAME_PREFIX + "tsuiteok.gif";
44 public static final String IMG_TEST_SUITE_FAILURE = NAME_PREFIX + "tsuitefail.gif";
46 public static final String IMG_ERROR = NAME_PREFIX + "error.gif";
47 public static final String IMG_FAILURE = NAME_PREFIX + "failure.gif";
51 public static final ImageDescriptor DESC_SELECT_TEST_SUITE = createManaged(IMG_SELECT_TEST_SUITE);
52 public static final ImageDescriptor DESC_RUN_TEST_SUITE =createManaged(IMG_RUN_TEST_SUITE);
53 public static final ImageDescriptor DESC_TEST_ERROR = createManaged(IMG_TEST_ERROR);
54 public static final ImageDescriptor DESC_TEST_FAILURE = createManaged(IMG_TEST_FAILURE);
55 public static final ImageDescriptor DESC_TEST_PASS = createManaged(IMG_TEST_PASS);
56 public static final ImageDescriptor DESC_TEST_SUITE_ERROR = createManaged(IMG_TEST_SUITE_ERROR);
57 public static final ImageDescriptor DESC_TEST_SUITE_PASS = createManaged(IMG_TEST_SUITE_PASS);
58 public static final ImageDescriptor DESC_TEST_SUITE_FAILURE = createManaged(IMG_TEST_SUITE_FAILURE);
60 public static final ImageDescriptor DESC_ERROR = createManaged(IMG_ERROR);
61 public static final ImageDescriptor DESC_FAILURE = createManaged(IMG_FAILURE);
63 * Returns the image managed under the given key in this registry.
65 * @param key the image's key
66 * @return the image managed under the given key
68 public static Image get(String key) {
69 return IMAGE_REGISTRY.get(key);
72 public static ImageRegistry getImageRegistry() {
73 return IMAGE_REGISTRY;
76 //---- Helper methods to access icons on the file system --------------------------------------
78 protected static ImageDescriptor createManaged(String name) {
80 ImageDescriptor result =
81 ImageDescriptor.createFromURL(
82 makeIconFileURL(name.substring(NAME_PREFIX_LENGTH)));
83 IMAGE_REGISTRY.put(name, result);
85 } catch (MalformedURLException e) {
86 return ImageDescriptor.getMissingImageDescriptor();
90 protected static URL makeIconFileURL(String name)
91 throws MalformedURLException {
92 if (iconBaseURL == null)
93 throw new MalformedURLException();
95 return new URL(iconBaseURL, name);