1 12 package org.eclipse.ant.internal.ui; 13 14 15 import java.net.URL ; 16 17 import org.eclipse.core.runtime.FileLocator; 18 import org.eclipse.core.runtime.Path; 19 import org.eclipse.core.runtime.Platform; 20 import org.eclipse.jface.resource.CompositeImageDescriptor; 21 import org.eclipse.jface.resource.ImageDescriptor; 22 import org.eclipse.jface.resource.ImageRegistry; 23 import org.eclipse.swt.graphics.Image; 24 import org.osgi.framework.Bundle; 25 26 29 public class AntUIImages { 30 31 34 private static ImageRegistry imageRegistry; 35 36 39 private static ImageDescriptorRegistry imageDescriptorRegistry; 40 41 private static String ICONS_PATH = "$nl$/icons/full/"; 43 private final static String LOCALTOOL= ICONS_PATH + "elcl16/"; private final static String OBJECT= ICONS_PATH + "obj16/"; private final static String OVR= ICONS_PATH + "ovr16/"; private final static String WIZ= ICONS_PATH + "wizban/"; private static final String T_ETOOL= ICONS_PATH + "etool16"; 50 53 private static void declareImages() { 54 declareRegistryImage(IAntUIConstants.IMG_PROPERTY, OBJECT + "property_obj.gif"); declareRegistryImage(IAntUIConstants.IMG_TASK_PROPOSAL, OBJECT + "task_obj.gif"); declareRegistryImage(IAntUIConstants.IMG_TEMPLATE_PROPOSAL, OBJECT + "template_obj.gif"); 59 declareRegistryImage(IAntUIConstants.IMG_SEGMENT_EDIT, T_ETOOL + "segment_edit.gif"); declareRegistryImage(IAntUIConstants.IMG_MARK_OCCURRENCES, T_ETOOL + "mark_occurrences.gif"); 62 declareRegistryImage(IAntUIConstants.IMG_ANT, OBJECT + "ant.gif"); declareRegistryImage(IAntUIConstants.IMG_REMOVE, LOCALTOOL + "remove_co.gif"); declareRegistryImage(IAntUIConstants.IMG_REMOVE_ALL, LOCALTOOL + "removeall_co.gif"); declareRegistryImage(IAntUIConstants.IMG_ADD, LOCALTOOL + "add_co.gif"); declareRegistryImage(IAntUIConstants.IMG_RUN, LOCALTOOL + "run_tool.gif"); declareRegistryImage(IAntUIConstants.IMG_SEARCH, LOCALTOOL + "search.gif"); 70 declareRegistryImage(IAntUIConstants.IMG_FILTER_INTERNAL_TARGETS, LOCALTOOL + "filter_internal_targets.gif"); declareRegistryImage(IAntUIConstants.IMG_FILTER_IMPORTED_ELEMENTS, LOCALTOOL + "filter_imported_elements.gif"); declareRegistryImage(IAntUIConstants.IMG_FILTER_PROPERTIES, LOCALTOOL + "filter_properties.gif"); declareRegistryImage(IAntUIConstants.IMG_FILTER_TOP_LEVEL, LOCALTOOL + "filter_top_level.gif"); declareRegistryImage(IAntUIConstants.IMG_LINK_WITH_EDITOR, LOCALTOOL + "synced.gif"); declareRegistryImage(IAntUIConstants.IMG_SORT_OUTLINE, LOCALTOOL + "alpha_mode.gif"); declareRegistryImage(IAntUIConstants.IMG_REFRESH, LOCALTOOL + "refresh.gif"); 78 declareRegistryImage(IAntUIConstants.IMG_ANT_PROJECT, OBJECT + "ant_buildfile.gif"); declareRegistryImage(IAntUIConstants.IMG_ANT_TARGET, OBJECT + "targetpublic_obj.gif"); declareRegistryImage(IAntUIConstants.IMG_ANT_TARGET_INTERNAL, OBJECT + "targetinternal_obj.gif"); declareRegistryImage(IAntUIConstants.IMG_ANT_DEFAULT_TARGET, OBJECT + "defaulttarget_obj.gif"); declareRegistryImage(IAntUIConstants.IMG_ANT_TARGET_ERROR, OBJECT + "ant_target_err.gif"); 85 declareRegistryImage(IAntUIConstants.IMG_TAB_CLASSPATH, OBJECT + "classpath.gif"); declareRegistryImage(IAntUIConstants.IMG_ANT_TYPE, OBJECT + "type.gif"); declareRegistryImage(IAntUIConstants.IMG_ANT_TASKDEF, OBJECT + "taskdef_obj.gif"); declareRegistryImage(IAntUIConstants.IMG_ANT_MACRODEF, OBJECT + "macrodef_obj.gif"); declareRegistryImage(IAntUIConstants.IMG_ANT_IMPORT, OBJECT + "import_obj.gif"); declareRegistryImage(IAntUIConstants.IMG_ANT_ECLIPSE_RUNTIME_OBJECT, OBJECT + "eclipse_obj.gif"); 93 declareRegistryImage(IAntUIConstants.IMG_WIZARD_BANNER, WIZ + "ant_wiz.png"); declareRegistryImage(IAntUIConstants.IMG_EXPORT_WIZARD_BANNER, WIZ + "export_ant_wiz.png"); declareRegistryImage(IAntUIConstants.IMG_TAB_ANT_TARGETS, LOCALTOOL + "ant_targets.gif"); declareRegistryImage(IAntUIConstants.IMG_ANT_BUILD_TAB, OBJECT + "build_tab.gif"); 98 declareRegistryImage(IAntUIConstants.IMG_OVR_ERROR, OVR + "error_co.gif"); declareRegistryImage(IAntUIConstants.IMG_OVR_WARNING, OVR + "warning_co.gif"); declareRegistryImage(IAntUIConstants.IMG_OVR_IMPORT, OVR + "import_co.gif"); } 103 104 110 private final static void declareRegistryImage(String key, String path) { 111 ImageDescriptor desc = ImageDescriptor.getMissingImageDescriptor(); 112 Bundle bundle = Platform.getBundle(AntUIPlugin.getUniqueIdentifier()); 113 URL url = null; 114 if (bundle != null) { 115 url = FileLocator.find(bundle, new Path(path), null); 116 desc = ImageDescriptor.createFromURL(url); 117 } 118 imageRegistry.put(key, desc); 119 } 120 121 124 public static ImageRegistry getImageRegistry() { 125 if (imageRegistry == null) { 126 initializeImageRegistry(); 127 } 128 return imageRegistry; 129 } 130 131 159 public static ImageRegistry initializeImageRegistry() { 160 imageRegistry= new ImageRegistry(AntUIPlugin.getStandardDisplay()); 161 declareImages(); 162 return imageRegistry; 163 } 164 165 169 public static Image getImage(String key) { 170 return getImageRegistry().get(key); 171 } 172 173 177 public static ImageDescriptor getImageDescriptor(String key) { 178 return getImageRegistry().getDescriptor(key); 179 } 180 181 184 public static Image getImage(CompositeImageDescriptor imageDescriptor) { 185 if (imageDescriptorRegistry == null) { 186 imageDescriptorRegistry = new ImageDescriptorRegistry(); 187 } 188 return imageDescriptorRegistry.get(imageDescriptor); 189 } 190 191 public static void disposeImageDescriptorRegistry() { 192 if (imageDescriptorRegistry != null) { 193 imageDescriptorRegistry.dispose(); 194 } 195 } 196 } 197 | Popular Tags |