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.framework.UiFrameworkView;
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, UiFrameworkView {
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.setWidth(100, PERCENTAGE);
98 footer.setHeight(75, PIXELS);
99 footer.addStyleName("content-footer");
100 addComponent(footer);
101
102 return this;
103 }
104
105 public void setContent(Component content) {
106 this.content = content;
107 }
108
109 public void setActionBar(Component actionBar) {
110 this.actionbar = actionBar;
111 }
112
113 @Override
114 public void setCaption(String caption) {
115 super.setCaption(caption);
116 title.setValue("<div class='heading-1'>" + caption + "</div>");
117 }
118
119 @Override
120 public void setIcon(Resource icon) {
121 super.setIcon(icon);
122 title.setIcon(icon);
123 }
124 }