| 1 11 package org.eclipse.team.core; 12 13 import java.util.*; 14 15 import org.eclipse.core.resources.IContainer; 16 import org.eclipse.core.resources.IProject; 17 import org.eclipse.core.runtime.*; 18 import org.eclipse.team.core.subscribers.Subscriber; 19 import org.eclipse.team.internal.core.DefaultProjectSetCapability; 20 import org.eclipse.team.internal.core.TeamPlugin; 21 22 56 57 public abstract class RepositoryProviderType extends PlatformObject { 58 private static Map allProviderTypes = new HashMap(); 59 60 private String id; 61 62 private String scheme; 63 64 public RepositoryProviderType() { 65 } 66 67 75 public static RepositoryProviderType getProviderType(String id) { 76 RepositoryProviderType type = (RepositoryProviderType) allProviderTypes.get(id); 77 78 if(type != null) 79 return type; 80 81 return newProviderType(id); 84 } 85 86 96 public static RepositoryProviderType getTypeForScheme(String scheme) { 97 for (Iterator iter = allProviderTypes.values().iterator(); iter.hasNext();) { 98 RepositoryProviderType type = (RepositoryProviderType) iter.next(); 99 if (type.getFileSystemScheme() != null && type.getFileSystemScheme().equals(scheme)) 100 return type; 101 } 102 return findProviderForScheme(scheme); 103 } 104 105 private static RepositoryProviderType findProviderForScheme(String scheme) { 106 IExtensionPoint extension = Platform.getExtensionRegistry().getExtensionPoint(TeamPlugin.ID, TeamPlugin.REPOSITORY_EXTENSION); 107 if (extension != null) { 108 IExtension[] extensions = extension.getExtensions(); 109 for (int i = 0; i < extensions.length; i++) { 110 IConfigurationElement [] configElements = extensions[i].getConfigurationElements(); 111 for (int j = 0; j < configElements.length; j++) { 112 String extensionId = configElements[j].getAttribute("id"); String typeScheme = configElements[j].getAttribute("fileSystemScheme"); if (typeScheme != null && typeScheme.equals(scheme) && extensionId != null) { 115 return newProviderType(extensionId); 116 } 117 } 118 } 119 } 120 return null; 121 } 122 123 private void setID(String id) { 124 this.id = id; 125 } 126 127 private static RepositoryProviderType newProviderType(String id) { 128 IExtensionPoint extension = Platform.getExtensionRegistry().getExtensionPoint(TeamPlugin.ID, TeamPlugin.REPOSITORY_EXTENSION); 129 if (extension != null) { 130 IExtension[] extensions = extension.getExtensions(); 131 for (int i = 0; i < extensions.length; i++) { 132 IConfigurationElement [] configElements = extensions[i].getConfigurationElements(); 133 for (int j = 0; j < configElements.length; j++) { 134 String extensionId = configElements[j].getAttribute("id"); 136 if (extensionId != null && extensionId.equals(id)) { 137 try { 138 RepositoryProviderType providerType; 139 if(configElements[j].getAttribute("typeClass") == null) { providerType = new DefaultRepositoryProviderType(); 142 } else { 143 providerType = (RepositoryProviderType) configElements[j].createExecutableExtension("typeClass"); } 145 146 providerType.setID(id); 147 allProviderTypes.put(id, providerType); 148 String scheme = configElements[j].getAttribute("fileSystemScheme"); providerType.setFileSystemScheme(scheme); 150 return providerType; 151 } catch (CoreException e) { 152 TeamPlugin.log(e); 153 } catch (ClassCastException e) { 154 String className = configElements[j].getAttribute("typeClass"); TeamPlugin.log(IStatus.ERROR, "Class " + className + " registered for repository provider type id " + id + " is not a subclass of RepositoryProviderType", e); } 157 return null; 158 } 159 } 160 } 161 } 162 return null; 163 } 164 165 private void setFileSystemScheme(String scheme) { 166 this.scheme = scheme; 167 } 168 169 175 public final String getID() { 176 return this.id; 177 } 178 179 201 public ProjectSetCapability getProjectSetCapability() { 202 IProjectSetSerializer oldSerializer = Team.getProjectSetSerializer(getID()); 204 if (oldSerializer != null) { 205 ProjectSetCapability capability = new DefaultProjectSetCapability(); 206 capability.setSerializer(oldSerializer); 207 return capability; 208 } 209 return null; 210 } 211 212 229 public void metaFilesDetected(IProject project, IContainer[] containers) { 230 } 232 233 241 public Subscriber getSubscriber() { 242 return null; 243 } 244 245 254 public final String getFileSystemScheme() { 255 return scheme; 256 } 257 } 258 | Popular Tags |