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.context.event.EventListener;
|
12
|
|
13
|
import com.vaadin.data.fieldgroup.BeanFieldGroup;
|
14
|
|
15
|
/**
|
16
|
* @author a.kohlbecker
|
17
|
* @since Apr 5, 2017
|
18
|
*
|
19
|
*/
|
20
|
public abstract class AbstractEditorPresenter<DTO extends Object> extends AbstractPresenter {
|
21
|
|
22
|
@SuppressWarnings("unchecked")
|
23
|
@EventListener
|
24
|
public void onEditorSaveEvent(EditorSaveEvent saveEvent){
|
25
|
// casting to BeanFieldGroup<DTO> must be possible here!
|
26
|
DTO bean = ((BeanFieldGroup<DTO>)saveEvent.getCommitEvent().getFieldBinder()).getItemDataSource().getBean();
|
27
|
saveBean(bean);
|
28
|
}
|
29
|
|
30
|
protected abstract void saveBean(DTO bean);
|
31
|
|
32
|
}
|