0a9d4451fd3a3a1b4dc5f4fed44f97d1759d5ac8
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / store / CdmUIDataChangeService.java
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 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 }
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 }