1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2015 EDIT
|
4
|
* European Distributed Institute of Taxonomy
|
5
|
* http://www.e-taxonomy.eu
|
6
|
*
|
7
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
8
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
9
|
*/
|
10
|
package eu.etaxonomy.taxeditor.store;
|
11
|
|
12
|
import org.eclipse.swt.widgets.Display;
|
13
|
|
14
|
import eu.etaxonomy.cdm.api.application.CdmChangeEvent;
|
15
|
import eu.etaxonomy.cdm.api.application.CdmDataChangeService;
|
16
|
import eu.etaxonomy.cdm.api.application.ICdmChangeListener;
|
17
|
|
18
|
/**
|
19
|
* @author cmathew
|
20
|
* @date 18 Jun 2015
|
21
|
*
|
22
|
*/
|
23
|
public class CdmUIDataChangeService extends CdmDataChangeService {
|
24
|
|
25
|
/* (non-Javadoc)
|
26
|
* @see eu.etaxonomy.taxeditor.store.ICdmDataChangeService#fireChangeEvent(eu.etaxonomy.cdm.api.application.CdmChangeEvent, boolean)
|
27
|
*/
|
28
|
@Override
|
29
|
public void fireChangeEvent(final CdmChangeEvent event, boolean async) {
|
30
|
|
31
|
for(final ICdmChangeListener listener : listeners) {
|
32
|
// Update the user interface asynchronously
|
33
|
if(async) {
|
34
|
Display.getDefault().asyncExec(new Runnable() {
|
35
|
@Override
|
36
|
public void run() {
|
37
|
listener.onChange(event);
|
38
|
}
|
39
|
});
|
40
|
} else {
|
41
|
// Update the user interface synchronously
|
42
|
Display.getDefault().syncExec(new Runnable() {
|
43
|
@Override
|
44
|
public void run() {
|
45
|
listener.onChange(event);
|
46
|
}
|
47
|
});
|
48
|
}
|
49
|
}
|
50
|
}
|
51
|
|
52
|
}
|