Project

General

Profile

Download (1.53 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

    
7
import com.vaadin.spring.annotation.SpringComponent;
8

    
9
import eu.etaxonomy.cdm.api.application.CdmRepository;
10

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

    
24
	private V view;
25

    
26
	@Autowired
27
	private CdmRepository repo;
28

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

    
33
	/**
34
	 * Notifies the presenter that its view is initialized so that presenter can
35
	 * start its own initialization if required.
36
	 *
37
	 * @param view
38
	 */
39
	protected final void init(V view) {
40
		Logger.getLogger(getClass().getName()).info("Presenter init");
41
		this.view = view;
42
		onPresenterReady();
43
	}
44

    
45
	/**
46
	 * Extending classes should overwrite this method in order to perform logic
47
	 * after presenter has finished initializing.
48
	 */
49
	protected void onPresenterReady() {
50
		Logger.getLogger(getClass().getName()).info("Presenter ready");
51
	}
52

    
53
	/**
54
	 * Extending classes should overwrite this method to react to the event when
55
	 * user has navigated into the view that this presenter governs.
56
	 */
57
	public void onViewEnter() {
58
		Logger.getLogger(getClass().getName()).info("View entered");
59
	}
60

    
61
	public void onViewExit() {
62

    
63
	}
64
}
(1-1/3)