1 11 package org.eclipse.ui.internal.console; 12 13 14 import java.net.MalformedURLException ; 15 import java.net.URL ; 16 17 import org.eclipse.jface.resource.ImageDescriptor; 18 import org.eclipse.jface.resource.ImageRegistry; 19 import org.eclipse.swt.graphics.Image; 20 import org.eclipse.ui.console.ConsolePlugin; 21 import org.eclipse.ui.console.IConsoleConstants; 22 23 26 public class ConsolePluginImages { 27 28 31 private static ImageRegistry imageRegistry; 32 33 34 private static URL ICON_BASE_URL= null; 35 36 static { 37 String pathSuffix = "icons/full/"; ICON_BASE_URL= ConsolePlugin.getDefault().getBundle().getEntry(pathSuffix); 39 } 40 41 private final static String LOCALTOOL= "clcl16/"; private final static String DLCL= "dlcl16/"; private final static String ELCL= "elcl16/"; private final static String VIEW= "cview16/"; 47 50 private static void declareImages() { 51 53 declareRegistryImage(IConsoleConstants.IMG_LCL_CLEAR, LOCALTOOL + "clear_co.gif"); declareRegistryImage(IInternalConsoleConstants.IMG_LCL_PIN, LOCALTOOL + "pin.gif"); declareRegistryImage(IInternalConsoleConstants.IMG_LCL_LOCK, LOCALTOOL + "lock_co.gif"); 58 declareRegistryImage(IInternalConsoleConstants.IMG_DLCL_CLEAR, DLCL + "clear_co.gif"); declareRegistryImage(IInternalConsoleConstants.IMG_DLCL_PIN, DLCL + "pin.gif"); declareRegistryImage(IInternalConsoleConstants.IMG_DLCL_LOCK, DLCL + "lock_co.gif"); declareRegistryImage(IInternalConsoleConstants.IMG_DLCL_CLOSE, DLCL + "rem_co.gif"); 64 declareRegistryImage(IInternalConsoleConstants.IMG_ELCL_CLEAR, ELCL + "clear_co.gif"); declareRegistryImage(IInternalConsoleConstants.IMG_ELCL_PIN, ELCL + "pin.gif"); declareRegistryImage(IInternalConsoleConstants.IMG_ELCL_LOCK, ELCL + "lock_co.gif"); declareRegistryImage(IInternalConsoleConstants.IMG_ELCL_CLOSE, ELCL + "rem_co.gif"); declareRegistryImage(IInternalConsoleConstants.IMG_ELCL_NEW_CON, ELCL + "new_con.gif"); 71 declareRegistryImage(IConsoleConstants.IMG_VIEW_CONSOLE, VIEW + "console_view.gif"); } 74 75 81 private final static void declareRegistryImage(String key, String path) { 82 ImageDescriptor desc= ImageDescriptor.getMissingImageDescriptor(); 83 try { 84 desc= ImageDescriptor.createFromURL(makeIconFileURL(path)); 85 } catch (MalformedURLException me) { 86 ConsolePlugin.log(me); 87 } 88 imageRegistry.put(key, desc); 89 } 90 91 94 public static ImageRegistry getImageRegistry() { 95 if (imageRegistry == null) { 96 initializeImageRegistry(); 97 } 98 return imageRegistry; 99 } 100 101 129 public static ImageRegistry initializeImageRegistry() { 130 imageRegistry= new ImageRegistry(ConsolePlugin.getStandardDisplay()); 131 declareImages(); 132 return imageRegistry; 133 } 134 135 139 public static Image getImage(String key) { 140 return getImageRegistry().get(key); 141 } 142 143 147 public static ImageDescriptor getImageDescriptor(String key) { 148 return getImageRegistry().getDescriptor(key); 149 } 150 151 private static URL makeIconFileURL(String iconPath) throws MalformedURLException { 152 if (ICON_BASE_URL == null) { 153 throw new MalformedURLException (); 154 } 155 156 return new URL (ICON_BASE_URL, iconPath); 157 } 158 } 159 | Popular Tags |