Project

General

Profile

Download (1.97 KB) Statistics
| Branch: | Tag: | Revision:
1
package eu.etaxonomy.vaadin.ui.view;
2

    
3
import org.springframework.beans.factory.annotation.Autowired;
4

    
5
import com.vaadin.navigator.View;
6
import com.vaadin.navigator.ViewDisplay;
7
import com.vaadin.spring.annotation.SpringComponent;
8
import com.vaadin.spring.annotation.UIScope;
9
import com.vaadin.ui.Component;
10
import com.vaadin.ui.CssLayout;
11
import com.vaadin.ui.HorizontalLayout;
12

    
13
import eu.etaxonomy.vaadin.ui.MainMenu;
14

    
15
/**
16
 * ViewAreaBean is the default implementation of ViewArea that is used to
17
 * position the fundamental UI elements on screen. ViewAreaBean supports dynamic
18
 * main menu assignment as well as allows easier handling of popup windows.
19
 *
20
 * @author Peter / Vaadin
21
 * @author Andreas Kohlbecker - ported to Spring
22
 */
23

    
24
@SpringComponent
25
@UIScope
26
class ViewAreaBean extends HorizontalLayout implements ViewDisplay {
27

    
28
    private static final long serialVersionUID = -3763800167385449693L;
29

    
30
	private MainMenu mainMenu;
31

    
32
	private CssLayout contentArea;
33

    
34
	public ViewAreaBean() {
35
		setSizeFull();
36

    
37
		contentArea = new CssLayout();
38
		contentArea.setPrimaryStyleName("valo-content");
39
		contentArea.addStyleName("v-scrollable");
40
		contentArea.setSizeFull();
41

    
42
		addComponent(contentArea);
43
		setExpandRatio(contentArea, 1);
44
	}
45

    
46
	@Autowired
47
	public void setMainMenu(MainMenu mainMenu) {
48
	    this.mainMenu = mainMenu;
49
	    addComponentAsFirst(this.mainMenu.asComponent());
50
	}
51

    
52
// TODO was this needed to avoid bean loading probelms? Otherwise remove it
53
//	private MainMenu mainMenuInstantiator;
54
//	@PostConstruct
55
//	protected void initialize() {
56
//		if (mainMenuInstantiator.isAmbiguous()) {
57
//			throw new RuntimeException("Ambiguous main menu implementations available, please refine your deployment");
58
//		}
59
//
60
//		if (!mainMenuInstantiator.isUnsatisfied()) {
61
//			mainMenu = mainMenuInstantiator.get();
62
//			addComponentAsFirst(mainMenu.asComponent());
63
//		}
64
//	}
65

    
66
	@Override
67
	public void showView(View view) {
68
		contentArea.removeAllComponents();
69
		contentArea.addComponent(Component.class.cast(view));
70
	}
71

    
72
}
(4-4/4)