1 package org.hibernate.eclipse.mapper; 2 3 import java.util.MissingResourceException ; 4 import java.util.ResourceBundle ; 5 6 import org.eclipse.ui.plugin.AbstractUIPlugin; 7 import org.hibernate.eclipse.EclipseLogger; 8 import org.osgi.framework.BundleContext; 9 10 13 public class MapperPlugin extends AbstractUIPlugin { 14 15 final public static String ID = MapperPlugin.class.getName(); 16 17 private static MapperPlugin plugin; 19 private ResourceBundle resourceBundle; 21 22 private final EclipseLogger logger = new EclipseLogger(ID); 23 24 27 public MapperPlugin() { 28 super(); 29 plugin = this; 30 } 31 32 35 public void start(BundleContext context) throws Exception { 36 super.start(context); 37 } 38 39 42 public void stop(BundleContext context) throws Exception { 43 super.stop(context); 44 plugin = null; 45 resourceBundle = null; 46 } 47 48 51 public static MapperPlugin getDefault() { 52 return plugin; 53 } 54 55 public EclipseLogger getLogger() { 56 return logger; 57 } 58 59 63 public static String getResourceString(String key) { 64 ResourceBundle bundle = MapperPlugin.getDefault().getResourceBundle(); 65 try { 66 return (bundle != null) ? bundle.getString(key) : key; 67 } catch (MissingResourceException e) { 68 return key; 69 } 70 } 71 72 75 public ResourceBundle getResourceBundle() { 76 try { 77 if (resourceBundle == null) 78 resourceBundle = ResourceBundle.getBundle("org.hibernate.eclipse.mapper.MapperPluginResources"); 79 } catch (MissingResourceException x) { 80 resourceBundle = null; 81 } 82 return resourceBundle; 83 } 84 85 public void logException(Throwable exception) { 86 getLogger().logException(exception); 87 } 88 } 89 | Popular Tags |