KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > ui > registry > TeamDecoratorManager


1 /*******************************************************************************
2  * Copyright (c) 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.team.internal.ui.registry;
12
13 import java.util.HashMap JavaDoc;
14 import java.util.Map JavaDoc;
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 JavaDoc PT_TEAM_DECORATORS = "teamDecorators"; //$NON-NLS-1$
23

24     private static TeamDecoratorManager instance;
25     
26     Map JavaDoc 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 JavaDoc 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 JavaDoc(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