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.splitfeed;
35
36 import java.util.Iterator;
37
38 import com.vaadin.ui.Component;
39 import com.vaadin.ui.CssLayout;
40 import com.vaadin.ui.HorizontalSplitPanel;
41 import com.vaadin.ui.NativeButton;
42 import com.vaadin.v7.ui.Label;
43 import com.vaadin.v7.ui.themes.BaseTheme;
44
45
46
47
48 public class SplitFeed extends HorizontalSplitPanel {
49
50 private final FeedSection leftContainer = new FeedSection();
51
52 private final FeedSection rightContainer = new FeedSection();
53
54 public SplitFeed() {
55 super();
56 addStyleName("v-split-feed");
57 setSizeFull();
58 setSplitPosition(50);
59 setLocked(true);
60 construct();
61 }
62
63 private void construct() {
64 leftContainer.setSizeFull();
65 rightContainer.setSizeFull();
66
67
68 setFirstComponent(leftContainer);
69 setSecondComponent(rightContainer);
70 }
71
72 public FeedSection getLeftContainer() {
73 return leftContainer;
74 }
75
76 public FeedSection getRightContainer() {
77 return rightContainer;
78 }
79
80
81
82
83 public static class FeedTitle extends Label {
84
85 public FeedTitle(final String caption) {
86 super();
87 addStyleName("v-feed-title");
88 setContentMode(Label.CONTENT_XHTML);
89 setValue(caption);
90 }
91 }
92
93
94
95
96 public static class FeedSection extends CssLayout {
97
98 private final NativeButton link = new NativeButton();
99
100 public FeedSection() {
101 super();
102 setSizeFull();
103 addStyleName("v-feed-section");
104 link.setStyleName(BaseTheme.BUTTON_LINK);
105 link.addStyleName("icon-rssfeed");
106 }
107
108 public void setTitleLinkEnabled(boolean enabled) {
109 if (!enabled) {
110 removeComponent(link);
111 } else {
112 addComponent(link);
113 }
114 }
115
116 @Override
117 public void addComponent(Component component) {
118 if (component instanceof FeedTitle) {
119 final Iterator<Component> it = getComponentIterator();
120 while (it.hasNext()) {
121 final Component c = it.next();
122 if (c instanceof FeedTitle) {
123 removeComponent(c);
124 break;
125 }
126 }
127 }
128 super.addComponent(component);
129 }
130
131 public void setTitle(final String caption) {
132 addComponentAsFirst(new FeedTitle(caption));
133 }
134 }
135 }