1 11 package org.eclipse.team.internal.core; 12 13 import java.net.URI ; 14 15 import org.eclipse.core.resources.*; 16 import org.eclipse.core.resources.team.ResourceRuleFactory; 17 import org.eclipse.core.resources.team.TeamHook; 18 import org.eclipse.core.runtime.IPath; 19 import org.eclipse.core.runtime.IStatus; 20 import org.eclipse.team.core.RepositoryProvider; 21 22 25 public class TeamHookDispatcher extends TeamHook { 26 27 private static final ResourceRuleFactory defaultFactory = new ResourceRuleFactory() {}; 28 private static TeamHookDispatcher instance; 29 30 public static void setProviderRuleFactory(IProject project, IResourceRuleFactory factory) { 31 if (instance != null) { 32 if (factory == null) { 33 factory = defaultFactory; 34 } 35 instance.setRuleFactory(project, factory); 36 } 37 } 38 39 public TeamHookDispatcher() { 40 instance = this; 41 } 42 43 46 public IStatus validateCreateLink(IFile file, int updateFlags, IPath location) { 47 RepositoryProvider provider = getProvider(file); 48 if (provider == null) { 49 return super.validateCreateLink(file, updateFlags, location); 50 } else { 51 return provider.validateCreateLink(file, updateFlags, location); 52 } 53 } 54 55 58 public IStatus validateCreateLink(IFile file, int updateFlags, URI location) { 59 RepositoryProvider provider = getProvider(file); 60 if (provider == null) { 61 return super.validateCreateLink(file, updateFlags, location); 62 } else { 63 return provider.validateCreateLink(file, updateFlags, location); 64 } 65 } 66 67 70 public IStatus validateCreateLink(IFolder folder, int updateFlags, IPath location) { 71 RepositoryProvider provider = getProvider(folder); 72 if (provider == null) { 73 return super.validateCreateLink(folder, updateFlags, location); 74 } else { 75 return provider.validateCreateLink(folder, updateFlags, location); 76 } 77 } 78 79 82 public IStatus validateCreateLink(IFolder folder, int updateFlags, URI location) { 83 RepositoryProvider provider = getProvider(folder); 84 if (provider == null) { 85 return super.validateCreateLink(folder, updateFlags, location); 86 } else { 87 return provider.validateCreateLink(folder, updateFlags, location); 88 } 89 } 90 91 96 private RepositoryProvider getProvider(IResource resource) { 97 return RepositoryProvider.getProvider(resource.getProject()); 98 } 99 100 103 public IResourceRuleFactory getRuleFactory(IProject project) { 104 if (RepositoryProvider.isShared(project)) { 105 RepositoryProvider provider = getProvider(project); 106 if (provider != null) { 108 return provider.getRuleFactory(); 109 } 110 } 111 return super.getRuleFactory(project); 113 } 114 115 } 116 | Popular Tags |