|
2 | 2 |
|
3 | 3 | import org.eclipse.core.runtime.Platform;
|
4 | 4 | import org.eclipse.jface.resource.ImageDescriptor;
|
| 5 | +import org.eclipse.jface.resource.ImageRegistry; |
5 | 6 | import org.eclipse.ui.plugin.AbstractUIPlugin;
|
6 | 7 | import org.osgi.framework.BundleContext;
|
7 | 8 |
|
8 | 9 | /**
|
9 | 10 | * The activator class controls the plug-in life cycle
|
10 | 11 | */
|
11 | 12 | public class Activator extends AbstractUIPlugin {
|
12 |
| - // The plug-in ID |
13 |
| - public static final String PLUGIN_ID = "io.snyk.eclipse.plugin"; //$NON-NLS-1$ |
14 |
| - public static final String PLUGIN_VERSION = Platform.getBundle(Activator.PLUGIN_ID).getVersion().toString(); |
15 |
| - public static final String INTEGRATION_NAME = "ECLIPSE"; |
16 |
| - |
17 |
| - // The shared instance |
18 |
| - private static Activator plugin; |
19 |
| - |
20 |
| - @Override |
21 |
| - public void start(BundleContext context) throws Exception { |
22 |
| - super.start(context); |
23 |
| - plugin = this; |
24 |
| - } |
25 |
| - |
26 |
| - @Override |
27 |
| - public void stop(BundleContext context) throws Exception { |
28 |
| - plugin = null; |
29 |
| - super.stop(context); |
30 |
| - } |
31 |
| - |
32 |
| - /** |
33 |
| - * Returns the shared instance |
34 |
| - * |
35 |
| - * @return the shared instance |
36 |
| - */ |
37 |
| - public static Activator getDefault() { |
38 |
| - return plugin; |
39 |
| - } |
40 |
| - |
41 |
| - /** |
42 |
| - * Returns an image descriptor for the image file at the given plug-in relative |
43 |
| - * path |
44 |
| - * |
45 |
| - * @param path the path |
46 |
| - * @return the image descriptor |
47 |
| - */ |
48 |
| - public static ImageDescriptor getImageDescriptor(String path) { |
49 |
| - return imageDescriptorFromPlugin(PLUGIN_ID, path); |
50 |
| - } |
| 13 | + // The plug-in ID |
| 14 | + public static final String PLUGIN_ID = "io.snyk.eclipse.plugin"; //$NON-NLS-1$ |
| 15 | + public static final String PLUGIN_VERSION = Platform.getBundle(Activator.PLUGIN_ID).getVersion().toString(); |
| 16 | + public static final String INTEGRATION_NAME = "ECLIPSE"; |
| 17 | + |
| 18 | + // The shared instance |
| 19 | + private static Activator plugin; |
| 20 | + |
| 21 | + @Override |
| 22 | + public void start(BundleContext context) throws Exception { |
| 23 | + super.start(context); |
| 24 | + plugin = this; |
| 25 | + } |
| 26 | + |
| 27 | + @Override |
| 28 | + public void stop(BundleContext context) throws Exception { |
| 29 | + super.stop(context); |
| 30 | + } |
| 31 | + |
| 32 | + /** |
| 33 | + * Returns the shared instance |
| 34 | + * |
| 35 | + * @return the shared instance |
| 36 | + */ |
| 37 | + public static Activator getDefault() { |
| 38 | + return plugin; |
| 39 | + } |
| 40 | + |
| 41 | + /** |
| 42 | + * Returns an image descriptor for the image file at the given plug-in relative |
| 43 | + * path |
| 44 | + * |
| 45 | + * @param path the path |
| 46 | + * @return the image descriptor |
| 47 | + */ |
| 48 | + public static ImageDescriptor getImageDescriptor(String key) { |
| 49 | + return getDefault().getImageRegistry().getDescriptor(key); |
| 50 | + } |
| 51 | + |
| 52 | + @Override |
| 53 | + protected void initializeImageRegistry(ImageRegistry registry) { |
| 54 | + addImageToRegistry(registry, "CODE", "/icons/code.png"); |
| 55 | + addImageToRegistry(registry, "CODE_DISABLED", "/icons/code_disabled.png"); |
| 56 | + addImageToRegistry(registry, "OSS", "/icons/oss.png"); |
| 57 | + addImageToRegistry(registry, "OSS_DISABLED", "/icons/oss_disabled.png"); |
| 58 | + addImageToRegistry(registry, "IAC", "/icons/iac.png"); |
| 59 | + addImageToRegistry(registry, "IAC_DISABLED", "/icons/iac_disabled.png"); |
| 60 | + addImageToRegistry(registry, "SEVERITY_CRITICAL", "/icons/severity_critical.png"); |
| 61 | + addImageToRegistry(registry, "SEVERITY_HIGH", "/icons/severity_high.png"); |
| 62 | + addImageToRegistry(registry, "SEVERITY_MEDIUM", "/icons/severity_medium.png"); |
| 63 | + addImageToRegistry(registry, "SEVERITY_LOW", "/icons/severity_low.png"); |
| 64 | + addImageToRegistry(registry, "ENABLED", "/icons/enabled.png"); |
| 65 | + addImageToRegistry(registry, "DISABLED", "/icons/transparent.png"); |
| 66 | + } |
| 67 | + |
| 68 | + private void addImageToRegistry(ImageRegistry registry, String key, String path) { |
| 69 | + ImageDescriptor descriptor = imageDescriptorFromPlugin(PLUGIN_ID, path); |
| 70 | + registry.put(key, descriptor); |
| 71 | + |
| 72 | + } |
51 | 73 | }
|
0 commit comments