1 11 package org.eclipse.ui.internal.ide.registry; 12 13 import org.eclipse.core.runtime.IConfigurationElement; 14 import org.eclipse.core.runtime.IExtensionRegistry; 15 import org.eclipse.jface.resource.ImageDescriptor; 16 import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin; 17 import org.eclipse.ui.plugin.AbstractUIPlugin; 18 19 22 public class ProjectImageRegistryReader extends IDERegistryReader { 23 private static final String TAG_IMAGE = "image"; 25 private static final String ATT_ID = "id"; 27 private static final String ATT_NATURE_ID = "natureId"; 29 private static final String ATT_ICON = "icon"; 31 private ProjectImageRegistry registry; 32 33 36 protected boolean readElement(IConfigurationElement element) { 37 if (!element.getName().equals(TAG_IMAGE)) { 38 return false; 39 } 40 41 String id = element.getAttribute(ATT_ID); 42 if (id == null) { 43 logMissingAttribute(element, ATT_ID); 44 return true; 45 } 46 47 String natureId = element.getAttribute(ATT_NATURE_ID); 48 if (natureId == null) { 49 logMissingAttribute(element, ATT_NATURE_ID); 50 return true; 51 } 52 53 String icon = element.getAttribute(ATT_ICON); 54 if (icon == null) { 55 logMissingAttribute(element, ATT_ICON); 56 return true; 57 } 58 String extendingPluginId = element.getNamespace(); 59 ImageDescriptor image = AbstractUIPlugin.imageDescriptorFromPlugin( 60 extendingPluginId, icon); 61 62 if (image != null) { 63 registry.setNatureImage(natureId, image); 64 } 65 66 return true; 67 } 68 69 72 public void readProjectNatureImages(IExtensionRegistry in, 73 ProjectImageRegistry out) { 74 registry = out; 75 readRegistry(in, IDEWorkbenchPlugin.IDE_WORKBENCH, 76 IDEWorkbenchPlugin.PL_PROJECT_NATURE_IMAGES); 77 } 78 } 79 | Popular Tags |