1 11 12 package org.eclipse.team.internal.core; 13 14 import java.util.*; 15 16 import org.eclipse.core.runtime.*; 17 import org.eclipse.team.core.Team; 18 19 22 public class PluginStringMappings { 23 24 private final String fExtensionID; 25 private final String fAttributeName; 26 27 private SortedMap fMappings; 28 29 public PluginStringMappings(String extensionID, String stringAttributeName) { 30 fExtensionID= extensionID; 31 fAttributeName= stringAttributeName; 32 } 33 34 38 private SortedMap loadPluginPatterns() { 39 40 final SortedMap result= new TreeMap(); 41 42 final TeamPlugin plugin = TeamPlugin.getPlugin(); 43 if (plugin == null) 44 return result; 45 46 final IExtensionPoint extension = Platform.getExtensionRegistry().getExtensionPoint(TeamPlugin.ID, fExtensionID); if (extension == null) 48 return result; 49 50 final IExtension[] extensions = extension.getExtensions(); 51 52 for (int i = 0; i < extensions.length; i++) { 53 IConfigurationElement[] configElements = extensions[i].getConfigurationElements(); 54 55 for (int j = 0; j < configElements.length; j++) { 56 57 final String ext = configElements[j].getAttribute(fAttributeName); final String type = configElements[j].getAttribute("type"); if (ext == null || type == null) 60 continue; 61 62 if (type.equals("text")) { result.put(ext, new Integer (Team.TEXT)); 64 } else if (type.equals("binary")) { result.put(ext, new Integer (Team.BINARY)); 66 } 67 } 68 } 69 return result; 70 } 71 72 public Map referenceMap() { 73 if (fMappings == null) { 74 fMappings= loadPluginPatterns(); 75 } 76 return fMappings; 77 } 78 79 public int getType(String filename) { 80 final Map mappings= referenceMap(); 81 return mappings.containsKey(filename) ? ((Integer )mappings.get(filename)).intValue() : Team.UNKNOWN; 82 } 83 } 84 | Popular Tags |