1 20 21 package org.apache.directory.ldapstudio.browser.ui; 22 23 24 import java.net.URL ; 25 26 import org.eclipse.core.runtime.Path; 27 import org.eclipse.jface.resource.ImageDescriptor; 28 import org.eclipse.swt.graphics.Image; 29 import org.eclipse.ui.plugin.AbstractUIPlugin; 30 import org.osgi.framework.BundleContext; 31 32 33 36 public class BrowserUIPlugin extends AbstractUIPlugin 37 { 38 39 40 public static final String PLUGIN_ID = "org.apache.directory.ldapstudio.browser.ui"; 41 42 43 private static BrowserUIPlugin plugin; 44 45 46 49 public BrowserUIPlugin() 50 { 51 plugin = this; 52 } 53 54 55 58 public void start( BundleContext context ) throws Exception  59 { 60 super.start( context ); 61 } 62 63 64 67 public void stop( BundleContext context ) throws Exception  68 { 69 super.stop( context ); 70 plugin = null; 71 } 72 73 74 77 public static BrowserUIPlugin getDefault() 78 { 79 return plugin; 80 } 81 82 83 96 97 105 public ImageDescriptor getImageDescriptor( String key ) 106 { 107 if ( key != null ) 108 { 109 URL url = this.find( new Path( key ) ); 110 if ( url != null ) 111 return ImageDescriptor.createFromURL( url ); 112 else 113 return null; 114 } 115 else 116 { 117 return null; 118 } 119 } 120 121 122 135 public Image getImage( String key ) 136 { 137 Image image = getImageRegistry().get( key ); 138 if ( image == null ) 139 { 140 ImageDescriptor id = this.getImageDescriptor( key ); 141 if ( id != null ) 142 { 143 image = id.createImage(); 144 getImageRegistry().put( key, image ); 145 } 146 } 147 return image; 148 } 149 150 } 151 | Popular Tags |