1 package org.apache.directory.ldapstudio.valueeditors; 2 3 4 import java.net.URL ; 5 6 import org.eclipse.core.runtime.FileLocator; 7 import org.eclipse.core.runtime.Path; 8 import org.eclipse.jface.resource.ImageDescriptor; 9 import org.eclipse.swt.graphics.Image; 10 import org.eclipse.ui.plugin.AbstractUIPlugin; 11 import org.osgi.framework.BundleContext; 12 13 14 17 public class ValueEditorsActivator extends AbstractUIPlugin 18 { 19 20 21 public static final String PLUGIN_ID = "org.apache.directory.ldapstudio.valueeditors"; 22 23 24 private static ValueEditorsActivator plugin; 25 26 27 30 public ValueEditorsActivator() 31 { 32 plugin = this; 33 } 34 35 36 39 public void start( BundleContext context ) throws Exception  40 { 41 super.start( context ); 42 } 43 44 45 48 public void stop( BundleContext context ) throws Exception  49 { 50 plugin = null; 51 super.stop( context ); 52 } 53 54 55 60 public static ValueEditorsActivator getDefault() 61 { 62 return plugin; 63 } 64 65 66 74 public ImageDescriptor getImageDescriptor( String key ) 75 { 76 if ( key != null ) 77 { 78 URL url = FileLocator.find( getBundle(), new Path( key ), null ); 79 if ( url != null ) 80 return ImageDescriptor.createFromURL( url ); 81 else 82 return null; 83 } 84 else 85 { 86 return null; 87 } 88 } 89 90 91 104 public Image getImage( String key ) 105 { 106 Image image = getImageRegistry().get( key ); 107 if ( image == null ) 108 { 109 ImageDescriptor id = getImageDescriptor( key ); 110 if ( id != null ) 111 { 112 image = id.createImage(); 113 getImageRegistry().put( key, image ); 114 } 115 } 116 return image; 117 } 118 119 } 120 | Popular Tags |