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.ui.vaadin.editor.pagebar;
35
36 import info.magnolia.ui.api.view.View;
37
38 import com.vaadin.ui.Component;
39 import com.vaadin.ui.CssLayout;
40 import com.vaadin.ui.CustomComponent;
41 import com.vaadin.ui.Label;
42
43
44
45
46
47
48 public class PageBarViewImpl<L extends PageBarView.Listener> extends CustomComponent implements PageBarView<L> {
49
50 private CssLayout layout = new CssLayout();
51
52 private Label pageNameLabel = new Label();
53
54 protected L listener;
55
56 public PageBarViewImpl() {
57 super();
58 setCompositionRoot(layout);
59 construct();
60 }
61
62 private void construct() {
63 layout.addStyleName("pagebar");
64
65 this.pageNameLabel.setSizeUndefined();
66 this.pageNameLabel.addStyleName("title");
67
68 layout.addComponent(pageNameLabel);
69 }
70
71 @Override
72 public void setPageName(String PageName) {
73 this.pageNameLabel.setValue(PageName);
74 }
75
76 @Override
77 public void setListener(L listener) {
78 this.listener = listener;
79 }
80
81 @Override
82 public void togglePreviewMode(boolean isPreview) {
83 if (isPreview) {
84 layout.addStyleName("preview");
85 } else {
86 layout.removeStyleName("preview");
87 }
88 }
89
90 @Override
91 public void addPageBarComponent(View component) {
92 layout.addComponent(component.asVaadinComponent());
93 }
94
95 @Override
96 public Component asVaadinComponent() {
97 return this;
98 }
99
100 }