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