1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.demo.uif.components;
17
18 import org.kuali.rice.krad.uif.component.Component;
19 import org.kuali.rice.krad.uif.container.Group;
20 import org.kuali.rice.krad.uif.container.TabGroup;
21 import org.kuali.rice.krad.uif.element.ContentElementBase;
22 import org.kuali.rice.krad.uif.field.FieldGroup;
23 import org.kuali.rice.krad.uif.lifecycle.ViewLifecycle;
24 import org.kuali.rice.krad.uif.view.View;
25 import org.kuali.rice.krad.uif.widget.SyntaxHighlighter;
26
27 import java.util.ArrayList;
28 import java.util.List;
29
30
31
32
33
34
35
36 public class ComponentExhibit extends ContentElementBase {
37
38 private List<Group> demoGroups;
39 private List<String> demoSourceCode;
40 private List<String> additionalDemoSourceCode1 = new ArrayList<String>();
41 private List<String> additionalDemoSourceCode2 = new ArrayList<String>();
42 private SyntaxHighlighter sourceCodeViewer;
43 private SyntaxHighlighter additionalSourceCodeViewer1;
44 private SyntaxHighlighter additionalSourceCodeViewer2;
45 private FieldGroup docLinkFields;
46 private TabGroup tabGroup;
47
48
49
50
51
52
53 @Override
54 public void performInitialization(Object model) {
55
56 List<Component> tabItems = new ArrayList<Component>();
57 tabItems.addAll(tabGroup.getItems());
58 tabItems.addAll(demoGroups);
59 tabGroup.setItems(tabItems);
60
61
62 if(demoSourceCode != null && !demoSourceCode.isEmpty()){
63 sourceCodeViewer.setSourceCode(demoSourceCode.get(0));
64 }
65
66 if(additionalDemoSourceCode1 != null && !additionalDemoSourceCode1.isEmpty()
67 && additionalDemoSourceCode1.get(0) != null){
68 additionalSourceCodeViewer1.setSourceCode(additionalDemoSourceCode1.get(0));
69 }
70
71 if(additionalDemoSourceCode2 != null && !additionalDemoSourceCode2.isEmpty()
72 && additionalDemoSourceCode2.get(0) != null){
73 additionalSourceCodeViewer2.setSourceCode(additionalDemoSourceCode2.get(0));
74 }
75 }
76
77
78
79
80 @Override
81 public List<Component> getComponentsForLifecycle() {
82 List<Component> components = new ArrayList<Component>();
83
84 components.add(sourceCodeViewer);
85 components.add(additionalSourceCodeViewer1);
86 components.add(additionalSourceCodeViewer2);
87 components.add(tabGroup);
88
89 return components;
90 }
91
92
93
94
95
96
97 public List<Group> getDemoGroups() {
98 return demoGroups;
99 }
100
101
102
103
104
105
106 public void setDemoGroups(List<Group> demoGroups) {
107 this.demoGroups = demoGroups;
108 }
109
110
111
112
113
114
115 public List<String> getDemoSourceCode() {
116 return demoSourceCode;
117 }
118
119
120
121
122
123
124 public void setDemoSourceCode(List<String> demoSourceCode) {
125 this.demoSourceCode = demoSourceCode;
126 }
127
128
129
130
131
132
133 public SyntaxHighlighter getSourceCodeViewer() {
134 return sourceCodeViewer;
135 }
136
137
138
139
140
141
142 public void setSourceCodeViewer(SyntaxHighlighter sourceCodeViewer) {
143 this.sourceCodeViewer = sourceCodeViewer;
144 }
145
146
147
148
149
150
151 public FieldGroup getDocLinkFields() {
152 return docLinkFields;
153 }
154
155
156
157
158
159 public void setDocLinkFields(FieldGroup docLinkFields) {
160 this.docLinkFields = docLinkFields;
161 }
162
163
164
165
166
167
168 public TabGroup getTabGroup() {
169 return tabGroup;
170 }
171
172
173
174
175
176
177 public void setTabGroup(TabGroup tabGroup) {
178 this.tabGroup = tabGroup;
179 }
180
181 public List<String> getAdditionalDemoSourceCode1() {
182 return additionalDemoSourceCode1;
183 }
184
185 public void setAdditionalDemoSourceCode1(List<String> additionalDemoSourceCode1) {
186 this.additionalDemoSourceCode1 = additionalDemoSourceCode1;
187 }
188
189 public List<String> getAdditionalDemoSourceCode2() {
190 return additionalDemoSourceCode2;
191 }
192
193 public void setAdditionalDemoSourceCode2(List<String> additionalDemoSourceCode2) {
194 this.additionalDemoSourceCode2 = additionalDemoSourceCode2;
195 }
196
197 public SyntaxHighlighter getAdditionalSourceCodeViewer1() {
198 return additionalSourceCodeViewer1;
199 }
200
201 public void setAdditionalSourceCodeViewer1(SyntaxHighlighter additionalSourceCodeViewer1) {
202 this.additionalSourceCodeViewer1 = additionalSourceCodeViewer1;
203 }
204
205 public SyntaxHighlighter getAdditionalSourceCodeViewer2() {
206 return additionalSourceCodeViewer2;
207 }
208
209 public void setAdditionalSourceCodeViewer2(SyntaxHighlighter additionalSourceCodeViewer2) {
210 this.additionalSourceCodeViewer2 = additionalSourceCodeViewer2;
211 }
212
213
214
215
216 @Override
217 protected <T> void copyProperties(T component) {
218 super.copyProperties(component);
219
220 ComponentExhibit exhibitCopy = (ComponentExhibit) component;
221
222 if (this.demoGroups != null) {
223 List<Group> demoGroupsCopy = new ArrayList<Group>();
224
225 for (Group demoGroup : this.demoGroups) {
226 demoGroupsCopy.add((Group) demoGroup.copy());
227 }
228 exhibitCopy.setDemoGroups(demoGroupsCopy);
229 }
230
231 if (this.demoSourceCode != null) {
232 exhibitCopy.setDemoSourceCode(new ArrayList<String>(this.demoSourceCode));
233 }
234
235 if (this.additionalDemoSourceCode1 != null) {
236 exhibitCopy.setAdditionalDemoSourceCode1(new ArrayList<String>(this.additionalDemoSourceCode1));
237 }
238
239 if (this.additionalDemoSourceCode2 != null) {
240 exhibitCopy.setAdditionalDemoSourceCode2(new ArrayList<String>(this.additionalDemoSourceCode2));
241 }
242
243 if (this.sourceCodeViewer != null) {
244 exhibitCopy.setSourceCodeViewer((SyntaxHighlighter) this.sourceCodeViewer.copy());
245 }
246
247 if (this.additionalSourceCodeViewer1 != null) {
248 exhibitCopy.setAdditionalSourceCodeViewer1((SyntaxHighlighter) this.additionalSourceCodeViewer1.copy());
249 }
250
251 if (this.additionalSourceCodeViewer2 != null) {
252 exhibitCopy.setAdditionalSourceCodeViewer2((SyntaxHighlighter) this.additionalSourceCodeViewer2.copy());
253 }
254
255 if (this.docLinkFields != null) {
256 exhibitCopy.setDocLinkFields((FieldGroup) this.docLinkFields.copy());
257 }
258
259 if (this.tabGroup != null) {
260 exhibitCopy.setTabGroup((TabGroup) this.tabGroup.copy());
261 }
262 }
263 }