1 26 27 package org.nightlabs.editor2d.viewer; 28 29 import java.util.MissingResourceException ; 30 import java.util.ResourceBundle ; 31 32 import org.eclipse.core.runtime.Platform; 33 import org.eclipse.jface.resource.ImageDescriptor; 34 import org.eclipse.ui.plugin.AbstractUIPlugin; 35 import org.osgi.framework.BundleContext; 36 37 40 public class ViewerPlugin 41 extends AbstractUIPlugin { 42 43 private static ViewerPlugin plugin; 45 46 49 public ViewerPlugin() { 50 plugin = this; 51 } 52 53 56 public void start(BundleContext context) throws Exception { 57 super.start(context); 58 resourceBundle = Platform.getResourceBundle(getBundle()); 59 } 60 61 64 public void stop(BundleContext context) throws Exception { 65 super.stop(context); 66 plugin = null; 67 resourceBundle = null; 68 } 69 70 73 public static ViewerPlugin getDefault() { 74 return plugin; 75 } 76 77 84 public static ImageDescriptor getImageDescriptor(String path) { 85 return AbstractUIPlugin.imageDescriptorFromPlugin("org.nightlabs.editor2d.viewer", path); 86 } 87 88 private static ResourceBundle resourceBundle; 89 90 97 public static String getResourceString(String key) { 98 try { 99 return resourceBundle.getString(key); 100 } catch (Exception e) { 101 return key; 102 } 103 } 104 105 111 public ResourceBundle getResourceBundle() { 112 return resourceBundle; 113 } 114 115 } 144 | Popular Tags |