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.admincentral.apps.messages.view.detail;
35
36 import static com.vaadin.server.Sizeable.Unit.*;
37
38 import info.magnolia.ui.framework.UiFrameworkView;
39
40 import java.util.Optional;
41
42 import com.vaadin.server.Resource;
43 import com.vaadin.shared.ui.ContentMode;
44 import com.vaadin.ui.Component;
45 import com.vaadin.ui.CssLayout;
46 import com.vaadin.ui.HasComponents;
47 import com.vaadin.ui.HorizontalLayout;
48 import com.vaadin.ui.Label;
49 import com.vaadin.ui.VerticalLayout;
50
51
52
53
54 public class MessageFormView extends VerticalLayout implements HasComponents, UiFrameworkView {
55 private Component content;
56 private Component actionbar;
57 private Label title = new Label();
58
59 public MessageFormView() {
60 }
61
62 @Override
63 public Component asVaadinComponent() {
64
65 HorizontalLayout root = new HorizontalLayout();
66 root.setSpacing(false);
67 root.setMargin(false);
68 root.setSizeFull();
69
70 title.setContentMode(ContentMode.HTML);
71 title.setValue("<div class='heading-1'>" + getCaption() + "</div>");
72
73 VerticalLayout header = new VerticalLayout();
74 header.addStyleName("content-header");
75 header.setMargin(false);
76 header.setSpacing(false);
77 header.setWidth(100, PERCENTAGE);
78 header.addComponents(title);
79
80
81 CssLayout contentWraper = new CssLayout();
82 contentWraper.addStyleName("detailview");
83 contentWraper.setSizeFull();
84
85 VerticalLayout contentArea = new VerticalLayout(header, content);
86 contentArea.setMargin(false);
87 contentArea.setSizeFull();
88 contentArea.setExpandRatio(header, 0f);
89 contentArea.setExpandRatio(content, 1f);
90 content.addStyleName("content");
91
92 contentWraper.addComponent(contentArea);
93 root.addComponentsAndExpand(contentWraper);
94 root.addComponents(actionbar);
95
96 addComponentsAndExpand(root);
97
98 VerticalLayout footer = new VerticalLayout();
99 footer.setMargin(false);
100 footer.setSpacing(false);
101 footer.setWidth(100, PERCENTAGE);
102 footer.setHeight(75, PIXELS);
103 footer.addStyleName("content-footer");
104 addComponent(footer);
105
106 return this;
107 }
108
109 public void setContent(Component content) {
110 this.content = content;
111 }
112
113 public void setActionBar(Component actionBar) {
114 this.actionbar = actionBar;
115 }
116
117 @Override
118 public void setCaption(String caption) {
119 super.setCaption(caption);
120 Optional.ofNullable(title).ifPresent(t -> t.setValue("<div class='heading-1'>" + caption + "</div>"));
121 }
122
123 @Override
124 public void setIcon(Resource icon) {
125 super.setIcon(icon);
126 title.setIcon(icon);
127 }
128 }