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 =
38 NAME_PREFIX + "tsuite.gif";
39 public static final String IMG_RUN_TEST_SUITE = NAME_PREFIX + "start.gif";
40 public static final String IMG_TEST_ERROR = NAME_PREFIX + "testerr.gif";
41 public static final String IMG_TEST_FAILURE = NAME_PREFIX + "testfail.gif";
42 public static final String IMG_TEST_PASS = NAME_PREFIX + "testok.gif";
43 public static final String IMG_TEST_SUITE_ERROR = NAME_PREFIX + "tsuiteerror.gif";
44 public static final String IMG_TEST_SUITE_PASS = NAME_PREFIX + "tsuiteok.gif";
45 public static final String IMG_TEST_SUITE_FAILURE = NAME_PREFIX + "tsuitefail.gif";
50 public static final ImageDescriptor DESC_SELECT_TEST_SUITE = createManaged(IMG_SELECT_TEST_SUITE);
51 public static final ImageDescriptor DESC_RUN_TEST_SUITE =createManaged(IMG_RUN_TEST_SUITE);
52 public static final ImageDescriptor DESC_TEST_ERROR = createManaged(IMG_TEST_ERROR);
53 public static final ImageDescriptor DESC_TEST_FAILURE = createManaged(IMG_TEST_FAILURE);
54 public static final ImageDescriptor DESC_TEST_PASS = createManaged(IMG_TEST_PASS);
55 public static final ImageDescriptor DESC_TEST_SUITE_ERROR = createManaged(IMG_TEST_SUITE_ERROR);
56 public static final ImageDescriptor DESC_TEST_SUITE_PASS = createManaged(IMG_TEST_SUITE_PASS);
57 public static final ImageDescriptor DESC_TEST_SUITE_FAILURE = createManaged(IMG_TEST_SUITE_FAILURE);
60 * Returns the image managed under the given key in this registry.
62 * @param key the image's key
63 * @return the image managed under the given key
65 public static Image get(String key) {
66 return IMAGE_REGISTRY.get(key);
69 public static ImageRegistry getImageRegistry() {
70 return IMAGE_REGISTRY;
73 //---- Helper methods to access icons on the file system --------------------------------------
75 protected static ImageDescriptor createManaged(String name) {
77 ImageDescriptor result =
78 ImageDescriptor.createFromURL(
79 makeIconFileURL(name.substring(NAME_PREFIX_LENGTH)));
80 IMAGE_REGISTRY.put(name, result);
82 } catch (MalformedURLException e) {
83 return ImageDescriptor.getMissingImageDescriptor();
87 protected static URL makeIconFileURL(String name)
88 throws MalformedURLException {
89 if (iconBaseURL == null)
90 throw new MalformedURLException();
92 return new URL(iconBaseURL, name);