KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > core > AbstractModelManager


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.pde.internal.core;
12
13 import java.util.ArrayList JavaDoc;
14 import java.util.Iterator JavaDoc;
15
16 import org.eclipse.pde.core.IModelProviderEvent;
17 import org.eclipse.pde.core.IModelProviderListener;
18
19 public abstract class AbstractModelManager {
20     
21     private ArrayList JavaDoc fListeners = new ArrayList JavaDoc();
22     
23     public synchronized void removeModelProviderListener(IModelProviderListener listener) {
24         fListeners.remove(listener);
25     }
26
27     public synchronized void addModelProviderListener(IModelProviderListener listener) {
28         if (!fListeners.contains(listener))
29             fListeners.add(listener);
30     }
31     
32     public void fireModelProviderEvent(IModelProviderEvent event) {
33         for (Iterator JavaDoc iter = fListeners.iterator(); iter.hasNext();) {
34             ((IModelProviderListener) iter.next()).modelsChanged(event);
35         }
36     }
37
38     public void shutdown() {
39         removeListeners();
40     }
41
42     protected void removeListeners() {
43         if (fListeners.size() > 0) {
44             fListeners.clear();
45         }
46     }
47
48 }
49
Popular Tags