/*
* Gamers Own Instant Messenger
* Copyright (C) 2005-2006 Herbert Poul (kahless@sphene.net)
* http://goim.sphene.net
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
package net.sphene.goim.rcp.beans;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.Serializable;
import net.sphene.libs.SpheneEvent;
import net.sphene.libs.SpheneListener;
import net.sphene.libs.SpheneListenerList;
/**
* An abstract class which can be used to be extended by models which may be serialized
* and have changeListeners attached to them.
* @author kahless
*
*/
public abstract class GOIMAbstractItem implements Serializable {
private static final long serialVersionUID = -7391414345237660595L;
public transient SpheneListenerList<SpheneEvent,SpheneListener<SpheneEvent>> changeListenerList;
public GOIMAbstractItem() {
init();
}
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
stream.defaultReadObject();
init();
}
public void init() {
changeListenerList = new SpheneListenerList<SpheneEvent,SpheneListener<SpheneEvent>>();
}
public void fireChangeEvent() {
changeListenerList.fireEvent(new SpheneEvent(this));
}
public void addChangeListener(SpheneListener<SpheneEvent> listener) {
changeListenerList.addListener(listener);
}
public void removeChangeListener(SpheneListener<SpheneEvent> listener) {
changeListenerList.removeListener(listener);
}
}