/* * LICENSE: This program is being made available under the LGPL 3.0 license. * For more information on the license, please read the following: * http://www.gnu.org/licenses/lgpl-3.0.txt * * For additional information on the Model behind Mismatches, please refer to * the following publication(s): * Thorsten Reitz (2010): A Mismatch Description Language for Conceptual Schema * Mapping and Its Cartographic Representation, Geographic Information Science, * http://www.springerlink.com/content/um2082120r51232u/ */ package eu.xsdi.mdlui; 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; /** * TODO Add Type comment * * @author Thorsten Reitz * @partner 01 / Fraunhofer Institute for Computer Graphics Research * @version $Id$ * @since 0.1.0 */ public class MdlUiPlugin extends AbstractUIPlugin { //The shared instance. private static MdlUiPlugin plugin; // static identifiers of images for forms public static final String IMG_FORM_BG = "formBg"; //$NON-NLS-1$ public static final String IMG_HORIZONTAL = "horizontal"; //$NON-NLS-1$ public static final String IMG_VERTICAL = "vertical"; //$NON-NLS-1$ public static final String IMG_SAMPLE = "sample"; //$NON-NLS-1$ public static final String IMG_LINKTO_HELP = "linkto_help"; //$NON-NLS-1$ public static final String IMG_HELP_TOPIC = "help_topic"; //$NON-NLS-1$ public static final String IMG_CLOSE = "close"; //$NON-NLS-1$ /** * The constructor. */ public MdlUiPlugin() { super(); } /** * @see AbstractUIPlugin#start(BundleContext) */ @Override public void start(BundleContext context) throws Exception { super.start(context); plugin = this; } /** * @see AbstractUIPlugin#stop(BundleContext) */ @Override public void stop(BundleContext context) throws Exception { plugin = null; super.stop(context); } /** * Returns the shared instance. * @return this plugin. */ public static MdlUiPlugin getDefault() { return plugin; } /** * @param key * @return the image identified by the key. */ public Image getImage(String key) { return getImageRegistry().get(key); } /** * @param key * @return the {@link ImageDescriptor} defined by the given key. */ public ImageDescriptor getImageDescriptor(String key) { return getImageRegistry().getDescriptor(key); } protected void initializeImageRegistry(ImageRegistry registry) { registerImage(registry, IMG_FORM_BG, "form_banner.gif"); //$NON-NLS-1$ registerImage(registry, IMG_HORIZONTAL, "th_horizontal.gif"); //$NON-NLS-1$ registerImage(registry, IMG_VERTICAL, "th_vertical.gif"); //$NON-NLS-1$ registerImage(registry, IMG_SAMPLE, "sample.gif"); //$NON-NLS-1$ registerImage(registry, IMG_LINKTO_HELP, "linkto_help.gif"); //$NON-NLS-1$ registerImage(registry, IMG_HELP_TOPIC, "help_topic.gif"); //$NON-NLS-1$ registerImage(registry, IMG_CLOSE, "close_view.gif"); //$NON-NLS-1$ } private void registerImage(ImageRegistry registry, String key, String fileName) { try { URL url = MdlUiPlugin.class.getResource(fileName); if (url != null) { ImageDescriptor desc = ImageDescriptor.createFromURL(url); registry.put(key, desc); } } catch (Exception e) { throw new RuntimeException(e); } } }