1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package info.magnolia.task.app.view.detail;
35
36 import static com.vaadin.server.Sizeable.Unit.*;
37
38 import info.magnolia.ui.UIComponent;
39
40 import com.vaadin.server.Resource;
41 import com.vaadin.shared.ui.ContentMode;
42 import com.vaadin.ui.Component;
43 import com.vaadin.ui.CssLayout;
44 import com.vaadin.ui.HasComponents;
45 import com.vaadin.ui.HorizontalLayout;
46 import com.vaadin.ui.Label;
47 import com.vaadin.ui.VerticalLayout;
48
49
50
51
52 public class TaskFormView extends VerticalLayout implements HasComponents, UIComponent {
53
54 private Component content;
55 private Component actionbar;
56 private final Label title = new Label();
57
58 @Override
59 public Component asVaadinComponent() {
60
61 HorizontalLayout root = new HorizontalLayout();
62 root.setSpacing(false);
63 root.setMargin(false);
64 root.setSizeFull();
65
66 title.setContentMode(ContentMode.HTML);
67 title.setValue("<div class='heading-1'>" + getCaption() + "</div>");
68
69 HorizontalLayout header = new HorizontalLayout();
70 header.addStyleName("content-header");
71 header.setMargin(false);
72 header.setSpacing(false);
73 header.setWidth(100, PERCENTAGE);
74 header.addComponents(title);
75 header.setExpandRatio(title, 1f);
76
77 CssLayout contentWraper = new CssLayout();
78 contentWraper.addStyleName("detailview");
79 contentWraper.setSizeFull();
80
81 VerticalLayout contentArea = new VerticalLayout(header, content);
82 contentArea.setMargin(false);
83 contentArea.setSizeFull();
84 contentArea.setExpandRatio(header, 0f);
85 contentArea.setExpandRatio(content, 1f);
86 content.addStyleName("content");
87
88 contentWraper.addComponent(contentArea);
89 root.addComponentsAndExpand(contentWraper);
90 root.addComponents(actionbar);
91
92 addComponentsAndExpand(root);
93
94 VerticalLayout footer = new VerticalLayout();
95 footer.setMargin(false);
96 footer.setSpacing(false);
97 footer.addStyleName("content-footer");
98 addComponent(footer);
99
100 return this;
101 }
102
103 public void setContent(Component content) {
104 this.content = content;
105 }
106
107 public void setActionBar(Component actionBar) {
108 this.actionbar = actionBar;
109 }
110
111 @Override
112 public void setCaption(String caption) {
113 super.setCaption(caption);
114 title.setValue("<div class='heading-1'>" + caption + "</div>");
115 }
116
117 @Override
118 public void setIcon(Resource icon) {
119 super.setIcon(icon);
120 title.setIcon(icon);
121 }
122 }