X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=org.argeo.suite.workbench.rap%2Fsrc%2Forg%2Fargeo%2Fsuite%2Fworkbench%2FAsUiPlugin.java;fp=org.argeo.suite.workbench.rap%2Fsrc%2Forg%2Fargeo%2Fsuite%2Fworkbench%2FAsUiPlugin.java;h=60663a6ea0fe65e051ba84b827580eb5a891dcef;hb=8bdde6aa832531285352b099ceecb5d890bd67a8;hp=0000000000000000000000000000000000000000;hpb=1c39de24767d857ea1f59f18b88ce807c39d3bce;p=gpl%2Fargeo-suite.git diff --git a/org.argeo.suite.workbench.rap/src/org/argeo/suite/workbench/AsUiPlugin.java b/org.argeo.suite.workbench.rap/src/org/argeo/suite/workbench/AsUiPlugin.java new file mode 100644 index 0000000..60663a6 --- /dev/null +++ b/org.argeo.suite.workbench.rap/src/org/argeo/suite/workbench/AsUiPlugin.java @@ -0,0 +1,73 @@ +package org.argeo.suite.workbench; + +import java.net.URL; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.resource.ImageRegistry; +import org.eclipse.swt.graphics.Image; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** The activator class controls the plug-in life cycle */ +public class AsUiPlugin extends AbstractUIPlugin { + + public static final String PLUGIN_ID = "org.argeo.suite.workbench"; + + // The shared instance + private static AsUiPlugin plugin; + + private BundleContext bundleContext; + + /** Default constructor */ + public AsUiPlugin() { + } + + public void start(BundleContext context) throws Exception { + super.start(context); + this.bundleContext = context; + plugin = this; + } + + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static AsUiPlugin getDefault() { + return plugin; + } + + /** Creates the image */ + public static Image img(String path) { + return getImageDescriptor(path).createImage(); + } + + /** + * Returns an image descriptor for the image file at the given plug-in + * relative path + * + * @param path + * the path + * @return the image descriptor + */ + public static ImageDescriptor getImageDescriptor(String path) { + return imageDescriptorFromPlugin(PLUGIN_ID, path); + } + + public URL imageUrl(String path) { + return bundleContext.getBundle().getResource(path); + } + + @Override + protected void initializeImageRegistry(ImageRegistry reg) { + } + + public BundleContext getBundleContext() { + return bundleContext; + } +}