Search in sources :

Example 6 with DataChangeListener

use of org.eclipse.scout.rt.client.ui.DataChangeListener in project scout.rt by eclipse.

the class AbstractClientSession method setDesktop.

@Override
public void setDesktop(IDesktop desktop) {
    if (desktop == null) {
        throw new IllegalArgumentException("argument must not be null");
    }
    if (m_desktop != null) {
        throw new IllegalStateException("desktop is active");
    }
    m_desktop = desktop;
    if (m_virtualDesktop != null) {
        for (DesktopListener listener : m_virtualDesktop.getDesktopListeners()) {
            m_desktop.addDesktopListener(listener);
        }
        for (Map.Entry<String, EventListenerList> e : m_virtualDesktop.getPropertyChangeListenerMap().entrySet()) {
            String propName = e.getKey();
            EventListenerList list = e.getValue();
            if (propName == null) {
                for (PropertyChangeListener listener : list.getListeners(PropertyChangeListener.class)) {
                    m_desktop.addPropertyChangeListener(listener);
                }
            } else {
                for (PropertyChangeListener listener : list.getListeners(PropertyChangeListener.class)) {
                    m_desktop.addPropertyChangeListener(propName, listener);
                }
            }
        }
        for (Map.Entry<Object, EventListenerList> e : m_virtualDesktop.getDataChangeListenerMap().entrySet()) {
            Object dataType = e.getKey();
            EventListenerList list = e.getValue();
            if (dataType == null) {
                for (DataChangeListener listener : list.getListeners(DataChangeListener.class)) {
                    m_desktop.addDataChangeListener(listener);
                }
            } else {
                for (DataChangeListener listener : list.getListeners(DataChangeListener.class)) {
                    m_desktop.addDataChangeListener(listener, dataType);
                }
            }
        }
        m_virtualDesktop = null;
    }
    m_desktop.initDesktop();
}
Also used : PropertyChangeListener(java.beans.PropertyChangeListener) DesktopListener(org.eclipse.scout.rt.client.ui.desktop.DesktopListener) EventListenerList(org.eclipse.scout.rt.platform.util.EventListenerList) DataChangeListener(org.eclipse.scout.rt.client.ui.DataChangeListener) IExtensibleObject(org.eclipse.scout.rt.shared.extension.IExtensibleObject) Map(java.util.Map) PropertyMap(org.eclipse.scout.rt.platform.context.PropertyMap) SharedVariableMap(org.eclipse.scout.rt.shared.services.common.context.SharedVariableMap)

Example 7 with DataChangeListener

use of org.eclipse.scout.rt.client.ui.DataChangeListener in project scout.rt by eclipse.

the class AbstractDesktopTest method testDataChangedChanging.

@Test
public void testDataChangedChanging() {
    TestEnvironmentDesktop desktop = (TestEnvironmentDesktop) IDesktop.CURRENT.get();
    final Holder<Object[]> resultHolder = new Holder<Object[]>(Object[].class);
    desktop.addDataChangeListener(new DataChangeListener() {

        @Override
        public void dataChanged(Object... dataTypes) {
            resultHolder.setValue(dataTypes);
        }
    }, TEST_DATA_TYPE_1, TEST_DATA_TYPE_2);
    desktop.setDataChanging(true);
    desktop.dataChanged(TEST_DATA_TYPE_1);
    desktop.dataChanged(TEST_DATA_TYPE_1, TEST_DATA_TYPE_1, TEST_DATA_TYPE_1);
    desktop.dataChanged(TEST_DATA_TYPE_2, TEST_DATA_TYPE_2);
    desktop.dataChanged(TEST_DATA_TYPE_1, TEST_DATA_TYPE_2);
    desktop.dataChanged(TEST_DATA_TYPE_1);
    desktop.dataChanged(TEST_DATA_TYPE_2);
    desktop.setDataChanging(false);
    verifyDataChanged(resultHolder);
}
Also used : Holder(org.eclipse.scout.rt.platform.holders.Holder) DataChangeListener(org.eclipse.scout.rt.client.ui.DataChangeListener) TestEnvironmentDesktop(org.eclipse.scout.rt.client.testenvironment.ui.desktop.TestEnvironmentDesktop) Test(org.junit.Test)

Aggregations

DataChangeListener (org.eclipse.scout.rt.client.ui.DataChangeListener)7 IExtensibleObject (org.eclipse.scout.rt.shared.extension.IExtensibleObject)4 Map (java.util.Map)2 TestEnvironmentDesktop (org.eclipse.scout.rt.client.testenvironment.ui.desktop.TestEnvironmentDesktop)2 PropertyMap (org.eclipse.scout.rt.platform.context.PropertyMap)2 Holder (org.eclipse.scout.rt.platform.holders.Holder)2 EventListenerList (org.eclipse.scout.rt.platform.util.EventListenerList)2 Test (org.junit.Test)2 PropertyChangeListener (java.beans.PropertyChangeListener)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 LinkedHashMap (java.util.LinkedHashMap)1 LinkedHashSet (java.util.LinkedHashSet)1 Set (java.util.Set)1 DesktopListener (org.eclipse.scout.rt.client.ui.desktop.DesktopListener)1 SimpleEventListenerList (org.eclipse.scout.rt.platform.util.event.SimpleEventListenerList)1 SharedVariableMap (org.eclipse.scout.rt.shared.services.common.context.SharedVariableMap)1