Project

General

Profile

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

    
3
import java.util.logging.Logger;
4

    
5
import com.vaadin.spring.annotation.SpringComponent;
6

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

    
20
	private V view;
21

    
22
	protected V getView() {
23
		return view;
24
	}
25

    
26
	/**
27
	 * Notifies the presenter that its view is initialized so that presenter can
28
	 * start its own initialization if required.
29
	 *
30
	 * @param view
31
	 */
32
	protected final void init(V view) {
33
		Logger.getLogger(getClass().getName()).info("Presenter init");
34
		this.view = view;
35
		onPresenterReady();
36
	}
37

    
38
	/**
39
	 * Extending classes should overwrite this method in order to perform logic
40
	 * after presenter has finished initializing.
41
	 */
42
	protected void onPresenterReady() {
43
		Logger.getLogger(getClass().getName()).info("Presenter ready");
44
	}
45

    
46
	/**
47
	 * Extending classes should overwrite this method to react to the event when
48
	 * user has navigated into the view that this presenter governs.
49
	 */
50
	public void onViewEnter() {
51
		Logger.getLogger(getClass().getName()).info("View entered");
52
	}
53

    
54
	public void onViewExit() {
55

    
56
	}
57
}
(1-1/3)