Project

General

Profile

Download (1.77 KB) Statistics
| Branch: | Tag: | Revision:
1
package eu.etaxonomy.vaadin.mvp;
2

    
3
import java.util.logging.Logger;
4

    
5
import org.springframework.beans.factory.annotation.Autowired;
6
import org.springframework.beans.factory.annotation.Qualifier;
7

    
8
import com.vaadin.spring.annotation.SpringComponent;
9
import com.vaadin.spring.annotation.ViewScope;
10

    
11
import eu.etaxonomy.cdm.api.application.CdmRepository;
12

    
13
/**
14
 * AbstractPresenter is the base class of all presenter components. Presenter's
15
 * role is to govern the view and control the complex UI logic based on
16
 * notifications presenter receives from its view.
17
 *
18
 * @author Peter / Vaadin
19
 *
20
 * @param <V>
21
 *            type of the view this presenter governs
22
 */
23
@SpringComponent
24
@ViewScope
25
public abstract class AbstractPresenter<V extends ApplicationView> {
26

    
27
	private V view;
28

    
29

    
30
	protected V getView() {
31
		return view;
32
	}
33

    
34
	@Autowired
35
	@Qualifier("cdmRepository")
36
	private CdmRepository repo;
37

    
38
	/**
39
	 * @return the repo
40
	 */
41
	public CdmRepository getRepo() {
42
	    return repo;
43
	}
44

    
45
	/**
46
	 * Notifies the presenter that its view is initialized so that presenter can
47
	 * start its own initialization if required.
48
	 *
49
	 * @param view
50
	 */
51
	protected final void init(V view) {
52
		Logger.getLogger(getClass().getName()).info("Presenter init");
53
		this.view = view;
54
		onPresenterReady();
55
	}
56

    
57
	/**
58
	 * Extending classes should overwrite this method in order to perform logic
59
	 * after presenter has finished initializing.
60
	 */
61
	protected void onPresenterReady() {
62
		Logger.getLogger(getClass().getName()).info("Presenter ready");
63
	}
64

    
65
	/**
66
	 * Extending classes should overwrite this method to react to the event when
67
	 * user has navigated into the view that this presenter governs.
68
	 */
69
	public void onViewEnter() {
70
		Logger.getLogger(getClass().getName()).info("View entered");
71
	}
72

    
73
	public void onViewExit() {
74

    
75
	}
76

    
77
}
(1-1/3)