KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ant > internal > ui > editor > outline > XMLCore


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

11 package org.eclipse.ant.internal.ui.editor.outline;
12
13 import java.util.ArrayList JavaDoc;
14 import java.util.Iterator JavaDoc;
15 import java.util.List JavaDoc;
16
17 /**
18  * XMLCore.java
19  */

20 public class XMLCore {
21     
22     private static XMLCore inst;
23     
24     public static XMLCore getDefault() {
25         if (inst == null) {
26             inst= new XMLCore();
27         }
28             
29         return inst;
30     }
31     
32     private List JavaDoc fModelChangeListeners= new ArrayList JavaDoc();
33     
34     private XMLCore() { }
35
36     public void addDocumentModelListener(IDocumentModelListener listener) {
37         synchronized (fModelChangeListeners) {
38             fModelChangeListeners.add(listener);
39         }
40     }
41     
42     public void removeDocumentModelListener(IDocumentModelListener listener) {
43         synchronized (fModelChangeListeners) {
44             fModelChangeListeners.remove(listener);
45         }
46     }
47     
48     public void notifyDocumentModelListeners(DocumentModelChangeEvent event) {
49         Iterator JavaDoc i;
50         synchronized (fModelChangeListeners) {
51             i= new ArrayList JavaDoc(fModelChangeListeners).iterator();
52         }
53         while (i.hasNext()) {
54             ((IDocumentModelListener)i.next()).documentModelChanged(event);
55         }
56     }
57 }
58
Popular Tags