1 package freemarker.eclipse; 2 3 import java.net.MalformedURLException ; 4 import java.net.URL ; 5 6 import org.eclipse.jface.resource.ImageDescriptor; 7 import org.eclipse.swt.graphics.Image; 8 9 13 public class ImageManager { 14 15 public static final String IMG_MACRO = "icons/userdefined_directive_call.gif"; 16 public static final String IMG_IMPORT = "icons/import.gif"; 17 public static final String IMG_IMPORT_COLLECTION = "icons/import_collection.gif"; 18 public static final String IMG_FUNCTION = "icons/function.gif"; 19 20 21 public static Image getImage(String filename) { 22 ImageDescriptor temp = getImageDescriptor(filename); 23 if(null!=temp) { 24 return temp.createImage(); 25 } else { 26 return null; 27 } 28 } 29 30 public static ImageDescriptor getImageDescriptor(String filename) { 31 try { 32 URL url = new URL (FreemarkerPlugin.getInstance().getDescriptor().getInstallURL(), 33 filename); 34 return ImageDescriptor.createFromURL(url); 35 } catch (MalformedURLException mue) { 36 37 } 38 return null; 39 } 40 41 } 42 | Popular Tags |