Project

General

Profile

Download (1.57 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2015 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.taxeditor.store;
10

    
11
import org.eclipse.swt.widgets.Display;
12

    
13
import eu.etaxonomy.cdm.api.application.CdmChangeEvent;
14
import eu.etaxonomy.cdm.api.application.CdmDataChangeService;
15
import eu.etaxonomy.cdm.api.application.ICdmChangeListener;
16

    
17
/**
18
 * @author cmathew
19
 * @date 18 Jun 2015
20
 *
21
 */
22
public class CdmUIDataChangeService extends CdmDataChangeService {
23

    
24
    /* (non-Javadoc)
25
     * @see eu.etaxonomy.taxeditor.store.ICdmDataChangeService#fireChangeEvent(eu.etaxonomy.cdm.api.application.CdmChangeEvent, boolean)
26
     */
27
    @Override
28
    public void fireChangeEvent(final CdmChangeEvent event, boolean async) {
29

    
30
        for(final ICdmChangeListener listener : listeners) {
31
            // Update the user interface asynchronously
32
            if(async) {
33
                Display.getDefault().asyncExec(new Runnable() {
34
                    @Override
35
                    public void run() {
36
                        listener.onChange(event);
37
                    }
38
                });
39
            } else {
40
                // Update the user interface synchronously
41
                Display.getDefault().syncExec(new Runnable() {
42
                    @Override
43
                    public void run() {
44
                        listener.onChange(event);
45
                    }
46
                });
47
            }
48
        }
49
    }
50

    
51
}
(5-5/14)