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.shared.ui.MarginInfo;
|
8
|
import com.vaadin.spring.annotation.SpringComponent;
|
9
|
import com.vaadin.spring.annotation.UIScope;
|
10
|
import com.vaadin.ui.Component;
|
11
|
import com.vaadin.ui.HorizontalLayout;
|
12
|
import com.vaadin.ui.VerticalLayout;
|
13
|
|
14
|
import eu.etaxonomy.cdm.vaadin.toolbar.Toolbar;
|
15
|
import eu.etaxonomy.vaadin.ui.MainMenu;
|
16
|
|
17
|
/**
|
18
|
* ViewAreaBean is the default implementation of ViewArea that is used to
|
19
|
* position the fundamental UI elements on screen. ViewAreaBean supports dynamic
|
20
|
* main menu assignment as well as allows easier handling of popup windows.
|
21
|
*
|
22
|
* @author Peter / Vaadin
|
23
|
* @author Andreas Kohlbecker - ported to Spring
|
24
|
*/
|
25
|
|
26
|
@SpringComponent("viewAreaBean")
|
27
|
@UIScope
|
28
|
class ViewAreaBean extends HorizontalLayout implements ViewDisplay, ToolbarDisplay {
|
29
|
|
30
|
private static final long serialVersionUID = -3763800167385449693L;
|
31
|
|
32
|
private MainMenu mainMenu;
|
33
|
|
34
|
private Component toolbar = null;
|
35
|
|
36
|
// private VerticalLayout contentArea;
|
37
|
|
38
|
private VerticalLayout mainArea;
|
39
|
|
40
|
private Component currentViewComponent = null;
|
41
|
|
42
|
public ViewAreaBean() {
|
43
|
|
44
|
setSizeFull();
|
45
|
|
46
|
mainArea = new VerticalLayout();
|
47
|
mainArea.setPrimaryStyleName("valo-toolbar");
|
48
|
mainArea.setSizeFull();
|
49
|
mainArea.setMargin(new MarginInfo(false, false, true, false));
|
50
|
|
51
|
addComponent(mainArea);
|
52
|
setExpandRatio(mainArea, 1);
|
53
|
}
|
54
|
|
55
|
@Autowired
|
56
|
public void setMainMenu(MainMenu mainMenu) {
|
57
|
this.mainMenu = mainMenu;
|
58
|
addComponentAsFirst(this.mainMenu.asComponent());
|
59
|
}
|
60
|
|
61
|
|
62
|
@Override
|
63
|
public void setToolbar(Toolbar toolbar) {
|
64
|
toolbar.initialize();
|
65
|
this.toolbar = toolbar.asComponent();
|
66
|
this.toolbar.setPrimaryStyleName("valo-navigation-bar");
|
67
|
mainArea.addComponentAsFirst(this.toolbar);
|
68
|
}
|
69
|
|
70
|
@Override
|
71
|
public void showView(View view) {
|
72
|
if(currentViewComponent != null){
|
73
|
mainArea.removeComponent(currentViewComponent);
|
74
|
}
|
75
|
currentViewComponent = Component.class.cast(view);
|
76
|
mainArea.addComponent(currentViewComponent);
|
77
|
mainArea.setExpandRatio(Component.class.cast(view), 1);
|
78
|
}
|
79
|
|
80
|
}
|