use of com.revolsys.beans.PropertyChangeSupport in project com.revolsys.open by revolsys.
the class AbstractConnectionRegistry method removeConnection.
protected synchronized boolean removeConnection(final String name, final Connection connection) {
if (connection != null && name != null) {
final String lowerName = name.toLowerCase();
final C existingConnection = this.connections.get(lowerName);
if (existingConnection == connection) {
final int index = getConnectionIndex(name);
this.connectionNames.remove(lowerName);
this.connections.remove(lowerName);
if (connection instanceof PropertyChangeSupportProxy) {
final PropertyChangeSupportProxy proxy = (PropertyChangeSupportProxy) connection;
final PropertyChangeSupport propertyChangeSupport = proxy.getPropertyChangeSupport();
if (propertyChangeSupport != null) {
propertyChangeSupport.removePropertyChangeListener(this);
}
}
this.propertyChangeSupport.fireIndexedPropertyChange("connections", index, connection, null);
this.propertyChangeSupport.fireIndexedPropertyChange("children", index, connection, null);
if (this.directory != null && !this.readOnly) {
final Path file = existingConnection.getConnectionFile();
Paths.deleteDirectories(file);
}
return true;
}
}
return false;
}
use of com.revolsys.beans.PropertyChangeSupport in project com.revolsys.open by revolsys.
the class AbstractConnectionRegistry method addConnection.
protected synchronized void addConnection(final String name, final C connection) {
if (connection != null && name != null) {
final String lowerName = name.toLowerCase();
final C existingConnection = this.connections.get(lowerName);
removeConnection(existingConnection);
this.connectionNames.put(lowerName, name);
this.connections.put(lowerName, connection);
if (connection instanceof PropertyChangeSupportProxy) {
final PropertyChangeSupportProxy proxy = (PropertyChangeSupportProxy) connection;
final PropertyChangeSupport propertyChangeSupport = proxy.getPropertyChangeSupport();
if (propertyChangeSupport != null) {
propertyChangeSupport.addPropertyChangeListener(this);
}
}
final int index = getConnectionIndex(name);
this.propertyChangeSupport.fireIndexedPropertyChange("connections", index, null, connection);
this.propertyChangeSupport.fireIndexedPropertyChange("children", index, null, connection);
}
}
use of com.revolsys.beans.PropertyChangeSupport in project com.revolsys.open by revolsys.
the class PropertyChangeArrayList method removeListener.
protected void removeListener(final Object object) {
if (object instanceof PropertyChangeSupportProxy) {
final PropertyChangeSupportProxy proxy = (PropertyChangeSupportProxy) object;
final PropertyChangeSupport propertyChangeSupport = proxy.getPropertyChangeSupport();
if (propertyChangeSupport != null) {
propertyChangeSupport.removePropertyChangeListener(this);
}
}
}
use of com.revolsys.beans.PropertyChangeSupport in project com.revolsys.open by revolsys.
the class PropertyChangeArrayList method addListener.
protected void addListener(final Object object) {
if (object instanceof PropertyChangeSupportProxy) {
final PropertyChangeSupportProxy proxy = (PropertyChangeSupportProxy) object;
final PropertyChangeSupport propertyChangeSupport = proxy.getPropertyChangeSupport();
if (propertyChangeSupport != null) {
propertyChangeSupport.addPropertyChangeListener(this);
}
}
}
use of com.revolsys.beans.PropertyChangeSupport in project com.revolsys.open by revolsys.
the class Property method removeListener.
static boolean removeListener(final Object source, final Object listener) {
boolean removed = false;
if (source != null && listener instanceof PropertyChangeListener) {
final PropertyChangeListener propertyChangeListener = (PropertyChangeListener) listener;
final PropertyChangeSupport propertyChangeSupport = propertyChangeSupport(source);
if (propertyChangeSupport != null) {
for (final PropertyChangeListener otherListener : propertyChangeSupport.getPropertyChangeListeners()) {
boolean remove = false;
PropertyChangeListener compareListener;
if (otherListener instanceof PropertyChangeListenerProxy) {
final PropertyChangeListenerProxy proxy = (PropertyChangeListenerProxy) otherListener;
compareListener = proxy.getListener();
} else {
compareListener = otherListener;
}
if (compareListener == propertyChangeListener) {
remove = true;
} else if (compareListener instanceof ProxyPropertyChangeListener) {
final ProxyPropertyChangeListener proxiedListener = (ProxyPropertyChangeListener) compareListener;
final PropertyChangeListener listenerReference = proxiedListener.getPropertyChangeListener();
if (listenerReference == null || listenerReference == propertyChangeListener) {
remove = true;
}
}
if (remove) {
propertyChangeSupport.removePropertyChangeListener(otherListener);
removed = true;
}
}
}
if (source instanceof Component) {
final Component component = (Component) source;
for (final PropertyChangeListener otherListener : component.getPropertyChangeListeners()) {
if (otherListener.equals(propertyChangeListener)) {
component.removePropertyChangeListener(propertyChangeListener);
removed = true;
} else if (otherListener instanceof ProxyPropertyChangeListener) {
final ProxyPropertyChangeListener proxiedListener = (ProxyPropertyChangeListener) otherListener;
final PropertyChangeListener listenerReference = proxiedListener.getPropertyChangeListener();
if (listenerReference == null || listenerReference.equals(propertyChangeListener)) {
component.removePropertyChangeListener(otherListener);
removed = true;
}
}
}
}
}
return removed;
}
Aggregations