]> git.argeo.org Git - gpl/argeo-suite.git/blob - org.argeo.suite.workbench.rap/src/org/argeo/suite/workbench/AsUiPlugin.java
Fix MANIFEST generation
[gpl/argeo-suite.git] / org.argeo.suite.workbench.rap / src / org / argeo / suite / workbench / AsUiPlugin.java
1 package org.argeo.suite.workbench;
2
3 import java.net.URL;
4
5 import org.eclipse.jface.resource.ImageDescriptor;
6 import org.eclipse.jface.resource.ImageRegistry;
7 import org.eclipse.swt.graphics.Image;
8 import org.eclipse.ui.plugin.AbstractUIPlugin;
9 import org.osgi.framework.BundleContext;
10
11 /** The activator class controls the plug-in life cycle */
12 public class AsUiPlugin extends AbstractUIPlugin {
13
14 public static final String PLUGIN_ID = "org.argeo.suite.workbench.rap";
15
16 // The shared instance
17 private static AsUiPlugin plugin;
18
19 private BundleContext bundleContext;
20
21 /** Default constructor */
22 public AsUiPlugin() {
23 }
24
25 public void start(BundleContext context) throws Exception {
26 super.start(context);
27 this.bundleContext = context;
28 plugin = this;
29 }
30
31 public void stop(BundleContext context) throws Exception {
32 plugin = null;
33 super.stop(context);
34 }
35
36 /**
37 * Returns the shared instance
38 *
39 * @return the shared instance
40 */
41 public static AsUiPlugin getDefault() {
42 return plugin;
43 }
44
45 /** Creates the image */
46 public static Image img(String path) {
47 return getImageDescriptor(path).createImage();
48 }
49
50 /**
51 * Returns an image descriptor for the image file at the given plug-in
52 * relative path
53 *
54 * @param path
55 * the path
56 * @return the image descriptor
57 */
58 public static ImageDescriptor getImageDescriptor(String path) {
59 return imageDescriptorFromPlugin(PLUGIN_ID, path);
60 }
61
62 public URL imageUrl(String path) {
63 return bundleContext.getBundle().getResource(path);
64 }
65
66 @Override
67 protected void initializeImageRegistry(ImageRegistry reg) {
68 }
69
70 public BundleContext getBundleContext() {
71 return bundleContext;
72 }
73 }