use of com.revolsys.beans.PropertyChangeSupport in project com.revolsys.open by revolsys.
the class Property method addListener.
static void addListener(final Object source, final String propertyName, final Object listener) {
final PropertyChangeListener propertyChangeListener = getPropertyChangeListener(listener);
if (propertyChangeListener != null) {
if (source != null) {
final PropertyChangeSupport propertyChangeSupport = propertyChangeSupport(source);
if (propertyChangeSupport == null) {
if (source instanceof JComponent) {
final JComponent component = (JComponent) source;
component.addPropertyChangeListener(propertyName, propertyChangeListener);
}
} else {
propertyChangeSupport.addPropertyChangeListener(propertyName, propertyChangeListener);
}
}
}
}
use of com.revolsys.beans.PropertyChangeSupport in project com.revolsys.open by revolsys.
the class Property method addListener.
static void addListener(final Object source, final Object listener) {
if (source != null) {
final PropertyChangeListener propertyChangeListener = getPropertyChangeListener(listener);
if (propertyChangeListener != null) {
final PropertyChangeSupport propertyChangeSupport = propertyChangeSupport(source);
if (propertyChangeSupport == null) {
if (source instanceof JComponent) {
final JComponent component = (JComponent) source;
component.addPropertyChangeListener(propertyChangeListener);
}
} else {
propertyChangeSupport.addPropertyChangeListener(propertyChangeListener);
}
}
}
}
use of com.revolsys.beans.PropertyChangeSupport in project com.revolsys.open by revolsys.
the class AbstractLayer method delete.
@Override
public void delete() {
this.deleted = true;
setExists(false);
this.beanPropertyListener = null;
final ProjectFrame projectFrame = ProjectFrame.get(this);
if (projectFrame != null) {
projectFrame.removeBottomTab(this);
}
firePropertyChange("deleted", false, true);
final LayerGroup layerGroup = getLayerGroup();
if (layerGroup != null) {
layerGroup.removeLayer(this);
this.layerGroup = new EmptyReference<>();
}
this.eventsEnabled.closeable(false);
final PropertyChangeSupport propertyChangeSupport = this.propertyChangeSupport;
if (propertyChangeSupport != null) {
Property.removeAllListeners(propertyChangeSupport);
this.propertyChangeSupport = null;
}
if (this.renderer != null) {
this.renderer.setLayer(null);
}
}
use of com.revolsys.beans.PropertyChangeSupport in project com.revolsys.open by revolsys.
the class Property method removeListener.
static void removeListener(final Object source, final String propertyName, final Object listener) {
if (listener instanceof PropertyChangeListener) {
final PropertyChangeListener propertyChangeListener = (PropertyChangeListener) listener;
final PropertyChangeSupport propertyChangeSupport = propertyChangeSupport(source);
if (propertyChangeSupport != null) {
for (final PropertyChangeListener otherListener : propertyChangeSupport.getPropertyChangeListeners()) {
if (otherListener instanceof PropertyChangeListenerProxy) {
final PropertyChangeListenerProxy proxy = (PropertyChangeListenerProxy) otherListener;
final PropertyChangeListener proxyListener = proxy.getListener();
final String proxyPropertyName = proxy.getPropertyName();
if (proxyListener instanceof WeakPropertyChangeListener) {
final WeakPropertyChangeListener weakListener = (WeakPropertyChangeListener) proxyListener;
final PropertyChangeListener listenerReference = weakListener.getPropertyChangeListener();
if (listenerReference == null) {
propertyChangeSupport.removePropertyChangeListener(proxyPropertyName, weakListener);
} else if (proxyPropertyName.equals(propertyName)) {
if (listenerReference == propertyChangeListener) {
propertyChangeSupport.removePropertyChangeListener(propertyName, weakListener);
}
}
} else if (propertyChangeListener.equals(proxyListener)) {
if (proxyPropertyName.equals(propertyName)) {
propertyChangeSupport.removePropertyChangeListener(propertyName, propertyChangeListener);
}
}
} else if (otherListener instanceof WeakPropertyChangeListener) {
final WeakPropertyChangeListener weakListener = (WeakPropertyChangeListener) otherListener;
final PropertyChangeListener listenerReference = weakListener.getPropertyChangeListener();
if (listenerReference == null) {
propertyChangeSupport.removePropertyChangeListener(weakListener);
}
}
}
}
if (source instanceof Component) {
final Component component = (Component) source;
for (final PropertyChangeListener otherListener : component.getPropertyChangeListeners()) {
if (otherListener.equals(propertyChangeListener)) {
component.removePropertyChangeListener(propertyName, propertyChangeListener);
} else if (otherListener instanceof WeakPropertyChangeListener) {
final WeakPropertyChangeListener weakListener = (WeakPropertyChangeListener) otherListener;
final PropertyChangeListener listenerReference = weakListener.getPropertyChangeListener();
if (listenerReference == null || listenerReference.equals(propertyChangeListener)) {
component.removePropertyChangeListener(propertyName, propertyChangeListener);
}
}
}
}
}
}
use of com.revolsys.beans.PropertyChangeSupport in project com.revolsys.open by revolsys.
the class Property method removeAllListeners.
static void removeAllListeners(final Object object) {
if (object instanceof Component) {
final Component component = (Component) object;
removeAllListeners(component);
}
if (object instanceof PropertyChangeSupportProxy) {
final PropertyChangeSupportProxy proxy = (PropertyChangeSupportProxy) object;
final PropertyChangeSupport propertyChangeSupport = proxy.getPropertyChangeSupport();
for (final PropertyChangeListener listener : propertyChangeSupport.getPropertyChangeListeners()) {
if (listener instanceof PropertyChangeListenerProxy) {
final PropertyChangeListenerProxy listenerProxy = (PropertyChangeListenerProxy) listener;
final String propertyName = listenerProxy.getPropertyName();
propertyChangeSupport.removePropertyChangeListener(propertyName, listener);
}
propertyChangeSupport.removePropertyChangeListener(listener);
}
}
}
Aggregations