class JavaBean(object): def __init__(self): self._changeSupport = None def addPropertyChangeListener(self, *args): if not self._changeSupport: self._changeSupport = PropertyChangeSupport(self) self._changeSupport.addPropertyChangeListener(*args) def removePropertyChangeListener(self, *args): if self._changeSupport: self._changeSupport.removePropertyChangeListener(*args) def firePropertyChange(self, propertyName, oldValue, newValue): if self._changeSupport: event = PropertyChangeEvent(self, propertyName, oldValue, newValue) self._changeSupport.firePropertyChange(event) def getPropertyChangeListeners(self, *args): if self._changeSupport: return self._changeSupport.getPropertyChangeListeners(*args) return [] def hasListeners(self, *args): if self._changeSupport: return self._changeSupport.hasListeners(*args) return False
class JavaBeanSupport(object): """ Class that provides support for listening to property change events. This class does not provide a Java-compatible interface, so if you need that, inherit directly from :class:`java.beans.PropertyChangeSupport` instead. """ _changeSupport = None def addPropertyChangeListener(self, *args): if not self._changeSupport: self._changeSupport = PropertyChangeSupport(self) self._changeSupport.addPropertyChangeListener(*args) def removePropertyChangeListener(self, *args): if self._changeSupport: self._changeSupport.removePropertyChangeListener(*args) def firePropertyChange(self, propertyName, oldValue, newValue): if self._changeSupport: event = PropertyChangeEvent(self, propertyName, oldValue, newValue) self._changeSupport.firePropertyChange(event) def fireIndexedPropertyChange(self, propertyName, index, oldValue, newValue): if self._changeSupport: event = IndexedPropertyChangeEvent(self, propertyName, oldValue, newValue, index) self._changeSupport.firePropertyChange(event) def getPropertyChangeListeners(self, *args): if self._changeSupport: return self._changeSupport.getPropertyChangeListeners(*args) return [] def hasListeners(self, *args): if self._changeSupport: return self._changeSupport.hasListeners(*args) return False