1 11 package org.eclipse.ui.internal.navigator; 12 13 import java.net.MalformedURLException ; 14 import java.net.URL ; 15 import java.util.Collections ; 16 17 import org.eclipse.core.runtime.FileLocator; 18 import org.eclipse.core.runtime.Path; 19 import org.eclipse.jface.resource.ImageDescriptor; 20 import org.eclipse.jface.resource.ImageRegistry; 21 import org.eclipse.swt.graphics.Image; 22 23 28 public class NavigatorImages { 29 30 private final static ImageRegistry NAVIGATOR_PLUGIN_REGISTRY = NavigatorPlugin 32 .getDefault().getImageRegistry(); 33 34 private static URL ICONS_LOCATION; 35 static { 36 ICONS_LOCATION = FileLocator.find(NavigatorPlugin.getDefault() 37 .getBundle(), new Path("icons/full/"), Collections.EMPTY_MAP); } 39 40 47 public static Image get(String key) { 48 return NAVIGATOR_PLUGIN_REGISTRY.get(key); 49 } 50 51 61 public static ImageDescriptor createManaged(String prefix, String name) { 62 ImageDescriptor result = ImageDescriptor.createFromURL(makeIconFileURL( 63 prefix, name)); 64 NAVIGATOR_PLUGIN_REGISTRY.put(name, result); 65 return result; 66 } 67 68 77 private static URL makeIconFileURL(String prefix, String name) { 78 StringBuffer buffer = new StringBuffer (prefix); 79 buffer.append(name); 80 try { 81 return new URL (ICONS_LOCATION, buffer.toString()); 82 } catch (MalformedURLException ex) { 83 return null; 84 } 85 } 86 } 87 | Popular Tags |