Project

General

Profile

Download (1.22 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2017 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.vaadin.mvp;
10

    
11
import org.springframework.beans.factory.annotation.Autowired;
12
import org.springframework.context.ApplicationEventPublisher;
13
import org.springframework.context.event.EventListener;
14

    
15
import com.vaadin.data.fieldgroup.BeanFieldGroup;
16

    
17
/**
18
 * @author a.kohlbecker
19
 * @since Apr 5, 2017
20
 *
21
 */
22
public abstract class AbstractEditorPresenter<DTO extends Object> extends AbstractPresenter {
23

    
24

    
25
    private static final long serialVersionUID = -6677074110764145236L;
26

    
27
    @Autowired
28
    protected ApplicationEventPublisher eventBus;
29

    
30
    @EventListener
31
    public void onEditorPreSaveEvent(EditorPreSaveEvent preSaveEvent){
32

    
33
    }
34

    
35
    /**
36
     *
37
     * @param saveEvent
38
     */
39
    @EventListener
40
    public void onEditorSaveEvent(EditorSaveEvent saveEvent){
41
        DTO bean = ((BeanFieldGroup<DTO>)saveEvent.getCommitEvent().getFieldBinder()).getItemDataSource().getBean();
42
        saveBean(bean);
43
    }
44

    
45
    protected abstract void saveBean(DTO bean);
46

    
47
}
(3-3/10)