1 11 package org.eclipse.team.internal.ui.registry; 12 13 import java.util.HashMap ; 14 import java.util.Map ; 15 16 import org.eclipse.core.runtime.*; 17 import org.eclipse.team.internal.ui.TeamUIPlugin; 18 import org.eclipse.team.ui.mapping.ITeamContentProviderDescriptor; 19 20 public class TeamDecoratorManager { 21 22 public static final String PT_TEAM_DECORATORS = "teamDecorators"; 24 private static TeamDecoratorManager instance; 25 26 Map descriptors; 27 28 public static TeamDecoratorManager getInstance() { 29 if (instance == null) 30 instance = new TeamDecoratorManager(); 31 return instance; 32 } 33 34 public ITeamContentProviderDescriptor[] getDescriptors() { 35 lazyInitialize(); 36 return (ITeamContentProviderDescriptor[]) descriptors.values().toArray(new ITeamContentProviderDescriptor[descriptors.size()]); 37 } 38 39 public TeamDecoratorDescription getDecoratorDescription(String providerId) { 40 lazyInitialize(); 41 return (TeamDecoratorDescription)descriptors.get(providerId); 42 } 43 44 protected void lazyInitialize() { 45 if (descriptors != null) 46 return; 47 IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(TeamUIPlugin.ID, PT_TEAM_DECORATORS); 48 IExtension[] extensions = point.getExtensions(); 49 descriptors = new HashMap (extensions.length * 2 + 1); 50 for (int i = 0, imax = extensions.length; i < imax; i++) { 51 TeamDecoratorDescription desc = null; 52 try { 53 desc = new TeamDecoratorDescription(extensions[i]); 54 } catch (CoreException e) { 55 TeamUIPlugin.log(e); 56 } 57 if (desc != null) 58 descriptors.put(desc.getRepositoryId(), desc); 59 } 60 } 61 } 62 | Popular Tags |