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();
}
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);
}
Aggregations