1 11 package org.eclipse.ui.internal.decorators; 12 13 import java.util.ArrayList ; 14 import java.util.Collection ; 15 import java.util.HashSet ; 16 17 import org.eclipse.core.runtime.IConfigurationElement; 18 import org.eclipse.core.runtime.IExtensionRegistry; 19 import org.eclipse.ui.PlatformUI; 20 import org.eclipse.ui.internal.registry.IWorkbenchRegistryConstants; 21 import org.eclipse.ui.internal.registry.RegistryReader; 22 23 27 public class DecoratorRegistryReader extends RegistryReader { 28 29 private Collection values = new ArrayList (); 31 32 private Collection ids = new HashSet (); 33 34 37 public DecoratorRegistryReader() { 38 super(); 39 } 40 41 44 public boolean readElement(IConfigurationElement element) { 45 46 DecoratorDefinition desc = getDecoratorDefinition(element); 47 48 if (desc == null) { 49 return false; 50 } 51 52 values.add(desc); 53 54 return true; 55 56 } 57 58 64 DecoratorDefinition getDecoratorDefinition(IConfigurationElement element){ 65 66 String id = element.getAttribute(IWorkbenchRegistryConstants.ATT_ID); 67 if (ids.contains(id)) { 68 logDuplicateId(element); 69 return null; 70 } 71 ids.add(id); 72 73 boolean noClass = element.getAttribute(DecoratorDefinition.ATT_CLASS) == null; 74 75 if (Boolean.valueOf(element.getAttribute(IWorkbenchRegistryConstants.ATT_LIGHTWEIGHT)).booleanValue() || noClass) { 77 78 String iconPath = element.getAttribute(LightweightDecoratorDefinition.ATT_ICON); 79 80 if (noClass && iconPath == null) { 81 logMissingElement(element, LightweightDecoratorDefinition.ATT_ICON); 82 return null; 83 } 84 85 return new LightweightDecoratorDefinition(id, element); 86 } 87 return new FullDecoratorDefinition(id, element); 88 89 } 90 91 95 Collection readRegistry(IExtensionRegistry in) { 96 values.clear(); 97 ids.clear(); 98 readRegistry(in, PlatformUI.PLUGIN_ID, 99 IWorkbenchRegistryConstants.PL_DECORATORS); 100 return values; 101 } 102 103 108 public Collection getValues() { 109 return values; 110 } 111 112 115 protected void logDuplicateId(IConfigurationElement element) { 116 logError(element, "Duplicate id found: " + element.getAttribute(IWorkbenchRegistryConstants.ATT_ID)); } 118 119 } 120 | Popular Tags |