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.cdm.vaadin.view.registration;
|
10
|
|
11
|
import java.util.Collection;
|
12
|
|
13
|
import org.springframework.beans.factory.annotation.Autowired;
|
14
|
import org.springframework.beans.factory.annotation.Qualifier;
|
15
|
import org.springframework.context.event.EventListener;
|
16
|
import org.springframework.transaction.TransactionStatus;
|
17
|
|
18
|
import com.vaadin.spring.annotation.SpringComponent;
|
19
|
import com.vaadin.spring.annotation.ViewScope;
|
20
|
|
21
|
import eu.etaxonomy.cdm.mock.IRegistrationWorkingSetService;
|
22
|
import eu.etaxonomy.cdm.vaadin.event.ShowDetailsEvent;
|
23
|
import eu.etaxonomy.vaadin.mvp.AbstractPresenter;
|
24
|
|
25
|
/**
|
26
|
* @author a.kohlbecker
|
27
|
* @since Mar 3, 2017
|
28
|
*
|
29
|
*/
|
30
|
@SpringComponent
|
31
|
@ViewScope
|
32
|
public class ListPresenter extends AbstractPresenter<ListView> {
|
33
|
|
34
|
private static final long serialVersionUID = 5419947244621450665L;
|
35
|
|
36
|
@Autowired
|
37
|
@Qualifier(IRegistrationWorkingSetService.ACTIVE_IMPL)
|
38
|
private IRegistrationWorkingSetService workingSetService;
|
39
|
|
40
|
@Override
|
41
|
public void handleViewEntered() {
|
42
|
TransactionStatus tx = getRepo().startTransaction();
|
43
|
getView().populate(listRegistrations());
|
44
|
getRepo().commitTransaction(tx);
|
45
|
}
|
46
|
|
47
|
/**
|
48
|
* @return
|
49
|
*/
|
50
|
private Collection<RegistrationDTO> listRegistrations() {
|
51
|
Collection<RegistrationDTO> dtos = workingSetService.listDTOs();
|
52
|
return dtos;
|
53
|
}
|
54
|
|
55
|
@EventListener(classes=ShowDetailsEvent.class, condition = "#event.entityType == T(eu.etaxonomy.cdm.vaadin.view.registration.RegistrationDTO)")
|
56
|
public void onShowDetailsEvent(ShowDetailsEvent<?,?> event) { // WARNING don't use more specific generic type arguments
|
57
|
RegistrationDTO regDto = workingSetService.loadDtoById((Integer)event.getIdentifier());
|
58
|
if(event.getProperty().equals("messages")){
|
59
|
if(getView() != null){
|
60
|
getView().openDetailsPopup("Messages", regDto.getMessages());
|
61
|
}
|
62
|
}
|
63
|
}
|
64
|
|
65
|
}
|