1 11 package org.eclipse.ui.internal.ide.registry; 12 13 import java.util.ArrayList ; 14 15 import org.eclipse.core.runtime.IConfigurationElement; 16 import org.eclipse.core.runtime.IExtensionRegistry; 17 import org.eclipse.core.runtime.Platform; 18 import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin; 19 20 24 public class MarkerHelpRegistryReader extends IDERegistryReader { 25 private MarkerHelpRegistry markerHelpRegistry; 26 27 private ArrayList currentAttributeNames; 28 29 private ArrayList currentAttributeValues; 30 31 private static final String TAG_HELP = "markerHelp"; 33 private static final String TAG_RESOLUTION_GENERATOR = "markerResolutionGenerator"; 35 private static final String TAG_ATTRIBUTE = "attribute"; 37 private static final String ATT_TYPE = "markerType"; 39 private static final String ATT_NAME = "name"; 41 private static final String ATT_VALUE = "value"; 43 54 public void addHelp(MarkerHelpRegistry registry) { 55 IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry(); 56 markerHelpRegistry = registry; 57 readRegistry(extensionRegistry, IDEWorkbenchPlugin.IDE_WORKBENCH, 58 IDEWorkbenchPlugin.PL_MARKER_HELP); 59 readRegistry(extensionRegistry, IDEWorkbenchPlugin.IDE_WORKBENCH, 60 IDEWorkbenchPlugin.PL_MARKER_RESOLUTION); 61 } 62 63 66 protected boolean readElement(IConfigurationElement element) { 67 if (element.getName().equals(TAG_HELP)) { 68 readHelpElement(element); 69 return true; 70 } 71 if (element.getName().equals(TAG_RESOLUTION_GENERATOR)) { 72 readResolutionElement(element); 73 return true; 74 } 75 if (element.getName().equals(TAG_ATTRIBUTE)) { 76 readAttributeElement(element); 77 return true; 78 } 79 return false; 80 } 81 82 85 private void readHelpElement(IConfigurationElement element) { 86 String type = element.getAttribute(ATT_TYPE); 88 89 currentAttributeNames = new ArrayList (); 91 currentAttributeValues = new ArrayList (); 92 readElementChildren(element); 93 String [] attributeNames = (String []) currentAttributeNames 94 .toArray(new String [currentAttributeNames.size()]); 95 String [] attributeValues = (String []) currentAttributeValues 96 .toArray(new String [currentAttributeValues.size()]); 97 98 MarkerQuery query = new MarkerQuery(type, attributeNames); 100 MarkerQueryResult result = new MarkerQueryResult(attributeValues); 101 markerHelpRegistry.addHelpQuery(query, result, element); 102 } 103 104 107 private void readResolutionElement(IConfigurationElement element) { 108 String type = element.getAttribute(ATT_TYPE); 110 111 currentAttributeNames = new ArrayList (); 113 currentAttributeValues = new ArrayList (); 114 readElementChildren(element); 115 String [] attributeNames = (String []) currentAttributeNames 116 .toArray(new String [currentAttributeNames.size()]); 117 String [] attributeValues = (String []) currentAttributeValues 118 .toArray(new String [currentAttributeValues.size()]); 119 120 MarkerQuery query = new MarkerQuery(type, attributeNames); 122 MarkerQueryResult result = new MarkerQueryResult(attributeValues); 123 markerHelpRegistry.addResolutionQuery(query, result, element); 124 } 125 126 129 private void readAttributeElement(IConfigurationElement element) { 130 String name = element.getAttribute(ATT_NAME); 131 String value = element.getAttribute(ATT_VALUE); 132 if (name != null && value != null) { 133 currentAttributeNames.add(name); 134 currentAttributeValues.add(value); 135 } 136 } 137 } 138 139 | Popular Tags |