KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > emf > importer > rose > parser > RoseComponent


1 /**
2  * <copyright>
3  *
4  * Copyright (c) 2002-2004 IBM Corporation and others.
5  * All rights reserved. This program and the accompanying materials
6  * are made available under the terms of the Eclipse Public License v1.0
7  * which accompanies this distribution, and is available at
8  * http://www.eclipse.org/legal/epl-v10.html
9  *
10  * Contributors:
11  * IBM - Initial API and implementation
12  *
13  * </copyright>
14  *
15  * $Id: RoseComponent.java,v 1.2 2005/06/08 06:20:36 nickb Exp $
16  */

17 package org.eclipse.emf.importer.rose.parser;
18
19 import java.beans.PropertyChangeEvent JavaDoc;
20 import java.beans.PropertyChangeListener JavaDoc;
21 import java.util.ArrayList JavaDoc;
22 import java.util.Iterator JavaDoc;
23 import java.util.List JavaDoc;
24
25
26 /**
27  * A common class for property change event producers.
28  */

29 public class RoseComponent
30 {
31   protected List JavaDoc listeners = new ArrayList JavaDoc();
32
33   public void addPropertyChangeListener(PropertyChangeListener JavaDoc l)
34   {
35     listeners.add(l);
36   }
37
38   public void firePropertyChange(String JavaDoc propertyName, int oldValue, int newValue)
39   {
40     for (Iterator JavaDoc i = listeners.iterator(); i.hasNext();)
41     {
42       PropertyChangeListener JavaDoc propertyChangeListener = (PropertyChangeListener JavaDoc)i.next();
43       Integer JavaDoc oldInt = new Integer JavaDoc(oldValue);
44       Integer JavaDoc newInt = new Integer JavaDoc(newValue);
45       PropertyChangeEvent JavaDoc propertyChangeEvent = new PropertyChangeEvent JavaDoc(this, propertyName, oldInt, newInt);
46       propertyChangeListener.propertyChange(propertyChangeEvent);
47     }
48   }
49 }
50
Popular Tags