use of java.beans.PropertyChangeSupport in project NimbusBase_Android_Tutorial by NimbusBase.
the class IndexFragment method bindEvents.
protected void bindEvents(Base base) {
final Server[] servers = base.getServers();
for (int index = 0; index < servers.length; index++) {
final Server server = servers[index];
final PropertyChangeSupport support = server.propertyChangeSupport;
final int innerIndex = index;
support.addPropertyChangeListener(Server.Property.authState, new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
final Server innerServer = (Server) event.getSource();
onServerStateChange(innerServer, innerIndex);
}
});
support.addPropertyChangeListener(Server.Property.isInitialized, new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
final Server innerServer = (Server) event.getSource();
onServerStateChange(innerServer, innerIndex);
}
});
}
}
use of java.beans.PropertyChangeSupport in project robovm by robovm.
the class PropertyChangeSupportTest method testOldAndNewAreBothNull.
public void testOldAndNewAreBothNull() {
Object bean = new Object();
PropertyChangeSupport support = new PropertyChangeSupport(bean);
EventLog listener = new EventLog();
support.addPropertyChangeListener(listener);
PropertyChangeEvent nullToNull = new PropertyChangeEvent(bean, "a", null, null);
support.firePropertyChange(nullToNull);
assertEquals(Arrays.<PropertyChangeEvent>asList(nullToNull), listener.log);
}
use of java.beans.PropertyChangeSupport in project robovm by robovm.
the class PropertyChangeSupportTest method testAddingAListenerActuallyAddsAProxy.
public void testAddingAListenerActuallyAddsAProxy() {
Object bean = new Object();
PropertyChangeSupport support = new PropertyChangeSupport(bean);
PropertyChangeListener listener = new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
}
};
support.addPropertyChangeListener("a", listener);
PropertyChangeListenerProxy p1 = (PropertyChangeListenerProxy) support.getPropertyChangeListeners()[0];
assertEquals(PropertyChangeListenerProxy.class, p1.getClass());
// weird but consistent with the RI
assertTrue(p1 != listener);
assertEquals("a", p1.getPropertyName());
assertEquals(listener, p1.getListener());
}
use of java.beans.PropertyChangeSupport in project robovm by robovm.
the class PropertyChangeSupportTest method testOldAndNewAreTheSame.
public void testOldAndNewAreTheSame() {
Object bean = new Object();
PropertyChangeSupport support = new PropertyChangeSupport(bean);
EventLog listener = new EventLog();
support.addPropertyChangeListener(listener);
PropertyChangeEvent xToX = new PropertyChangeEvent(bean, "a", "x", new String("x"));
support.firePropertyChange(xToX);
assertEquals(Arrays.<PropertyChangeEvent>asList(), listener.log);
}
use of java.beans.PropertyChangeSupport in project robovm by robovm.
the class PropertyChangeSupportTest method testSerialize.
public void testSerialize() {
String s = "aced0005737200206a6176612e6265616e732e50726f70657274794368616e67" + "65537570706f727458d5d264574860bb03000349002a70726f706572747943686" + "16e6765537570706f727453657269616c697a65644461746156657273696f6e4c" + "00086368696c6472656e7400154c6a6176612f7574696c2f486173687461626c6" + "53b4c0006736f757263657400124c6a6176612f6c616e672f4f626a6563743b78" + "7000000002737200136a6176612e7574696c2e486173687461626c6513bb0f252" + "14ae4b803000246000a6c6f6164466163746f724900097468726573686f6c6478" + "703f4000000000000877080000000b00000001740001617371007e00000000000" + "2707400046265616e7372003a6c6962636f72652e6a6176612e7574696c2e6265" + "616e732e50726f70657274794368616e6765537570706f7274546573742445766" + "56e744c6f67b92667637d0b6f450200024c00036c6f677400104c6a6176612f75" + "74696c2f4c6973743b4c00046e616d657400124c6a6176612f6c616e672f53747" + "2696e673b7870737200136a6176612e7574696c2e41727261794c6973747881d2" + "1d99c7619d03000149000473697a6578700000000077040000000a7874000b6c6" + "97374656e6572546f4171007e000c70787871007e00087371007e00097371007e" + "000d0000000077040000000a7874000d6c697374656e6572546f416c6c7078";
Object bean = "bean";
PropertyChangeSupport support = new PropertyChangeSupport(bean);
EventLog listenerToAll = new EventLog();
listenerToAll.name = "listenerToAll";
EventLog listenerToA = new EventLog();
listenerToA.name = "listenerToA";
support.addPropertyChangeListener(listenerToAll);
support.addPropertyChangeListener("a", listenerToA);
support.addPropertyChangeListener("a", listenerToA);
new SerializationTester<PropertyChangeSupport>(support, s) {
@Override
protected boolean equals(PropertyChangeSupport a, PropertyChangeSupport b) {
return describe(a.getPropertyChangeListeners()).equals(describe(b.getPropertyChangeListeners()));
}
@Override
protected void verify(PropertyChangeSupport deserialized) {
assertEquals("[a to listenerToA, a to listenerToA, listenerToAll]", describe(deserialized.getPropertyChangeListeners()));
}
}.test();
}
Aggregations