01: /*******************************************************************************
02: * Copyright (c) 2006, 2007 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.pde.internal.core;
11:
12: import java.util.ArrayList;
13: import java.util.Iterator;
14:
15: import org.eclipse.pde.core.IModelProviderEvent;
16: import org.eclipse.pde.core.IModelProviderListener;
17:
18: public abstract class AbstractModelManager {
19:
20: private ArrayList fListeners = new ArrayList();
21:
22: public synchronized void removeModelProviderListener(
23: IModelProviderListener listener) {
24: fListeners.remove(listener);
25: }
26:
27: public synchronized void addModelProviderListener(
28: IModelProviderListener listener) {
29: if (!fListeners.contains(listener))
30: fListeners.add(listener);
31: }
32:
33: public void fireModelProviderEvent(IModelProviderEvent event) {
34: for (Iterator iter = fListeners.iterator(); iter.hasNext();) {
35: ((IModelProviderListener) iter.next()).modelsChanged(event);
36: }
37: }
38:
39: public void shutdown() {
40: removeListeners();
41: }
42:
43: protected void removeListeners() {
44: if (fListeners.size() > 0) {
45: fListeners.clear();
46: }
47: }
48:
49: }
|