Search in sources :

Example 1 with PropertyChangeSupport

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);
            }
        });
    }
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) Server(com.nimbusbase.nimbusbase.Server) PropertyChangeListener(java.beans.PropertyChangeListener) PropertyChangeSupport(java.beans.PropertyChangeSupport)

Example 2 with PropertyChangeSupport

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);
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeSupport(java.beans.PropertyChangeSupport)

Example 3 with PropertyChangeSupport

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());
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) PropertyChangeSupport(java.beans.PropertyChangeSupport) PropertyChangeListenerProxy(java.beans.PropertyChangeListenerProxy)

Example 4 with PropertyChangeSupport

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);
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeSupport(java.beans.PropertyChangeSupport)

Example 5 with PropertyChangeSupport

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();
}
Also used : PropertyChangeSupport(java.beans.PropertyChangeSupport)

Aggregations

PropertyChangeSupport (java.beans.PropertyChangeSupport)22 PropertyChangeEvent (java.beans.PropertyChangeEvent)10 PropertyChangeListener (java.beans.PropertyChangeListener)6 PropertyChangeListenerProxy (java.beans.PropertyChangeListenerProxy)4 HttpResponse (com.microsoft.azure.hdinsight.sdk.common.HttpResponse)2 IOException (java.io.IOException)2 UISettings (com.intellij.ide.ui.UISettings)1 UISettingsListener (com.intellij.ide.ui.UISettingsListener)1 JBScrollPane (com.intellij.ui.components.JBScrollPane)1 Server (com.nimbusbase.nimbusbase.Server)1 SystemTray (java.awt.SystemTray)1 TrayIcon (java.awt.TrayIcon)1 Window (java.awt.Window)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 InvocationEvent (java.awt.event.InvocationEvent)1 VetoableChangeListener (java.beans.VetoableChangeListener)1 VetoableChangeSupport (java.beans.VetoableChangeSupport)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1