KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > core > RepositoryProviderManager


1 /*******************************************************************************
2  * Copyright (c) 2006, 2007 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.core;
12
13 import org.eclipse.core.resources.IProject;
14 import org.eclipse.core.runtime.ListenerList;
15 import org.eclipse.team.core.RepositoryProvider;
16
17 public class RepositoryProviderManager implements IRepositoryProviderListener {
18
19     private static RepositoryProviderManager instance;
20     private ListenerList listeners = new ListenerList();
21     
22     public static synchronized RepositoryProviderManager getInstance() {
23         if (instance == null) {
24             instance = new RepositoryProviderManager();
25         }
26         return instance;
27     }
28
29     /* (non-Javadoc)
30      * @see org.eclipse.team.internal.core.IRepositoryProviderListener#providerMapped(org.eclipse.team.core.RepositoryProvider)
31      */

32     public void providerMapped(RepositoryProvider provider) {
33         Object JavaDoc[] allListeners = listeners.getListeners();
34         for (int i = 0; i < allListeners.length; i++) {
35             IRepositoryProviderListener listener = (IRepositoryProviderListener)allListeners[i];
36             listener.providerMapped(provider);
37         }
38     }
39
40     /* (non-Javadoc)
41      * @see org.eclipse.team.internal.core.IRepositoryProviderListener#providerUnmapped(org.eclipse.core.resources.IProject)
42      */

43     public void providerUnmapped(IProject project) {
44         Object JavaDoc[] allListeners = listeners.getListeners();
45         for (int i = 0; i < allListeners.length; i++) {
46             IRepositoryProviderListener listener = (IRepositoryProviderListener)allListeners[i];
47             listener.providerUnmapped(project);
48         }
49     }
50     
51     public void addListener(IRepositoryProviderListener listener) {
52         listeners.add(listener);
53     }
54     
55     public void removeListener(IRepositoryProviderListener listener) {
56         listeners.remove(listener);
57     }
58     
59     
60 }
61
Popular Tags