Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
ControlCopy |
|
| 15.0;15 |
1 | package org.kuali.rice.core.api.uif; | |
2 | ||
3 | import java.util.ArrayList; | |
4 | import java.util.List; | |
5 | ||
6 | /** utility class for copying controls. */ | |
7 | final class ControlCopy { | |
8 | ||
9 | 0 | private ControlCopy() { |
10 | 0 | throw new IllegalArgumentException("do not call."); |
11 | } | |
12 | ||
13 | public static RemotableAbstractControl.Builder toBuilder(Control c) { | |
14 | 0 | if (c == null) { |
15 | 0 | throw new IllegalArgumentException("c is null"); |
16 | } | |
17 | ||
18 | 0 | if (c instanceof RemotableCheckboxGroup || c instanceof RemotableCheckboxGroup.Builder) return RemotableCheckboxGroup.Builder.create(((KeyLabeled)c).getKeyLabels()); |
19 | 0 | if (c instanceof RemotableHiddenInput || c instanceof RemotableHiddenInput.Builder) return RemotableHiddenInput.Builder.create(); |
20 | 0 | if (c instanceof RemotablePasswordInput || c instanceof RemotablePasswordInput.Builder){ |
21 | 0 | RemotablePasswordInput.Builder b = RemotablePasswordInput.Builder.create(); |
22 | 0 | b.setSize(((Sized) c).getSize()); |
23 | 0 | return b; |
24 | } | |
25 | 0 | if (c instanceof RemotableRadioButtonGroup || c instanceof RemotableRadioButtonGroup.Builder) return RemotableRadioButtonGroup.Builder.create(((KeyLabeled)c).getKeyLabels()); |
26 | 0 | if (c instanceof RemotableSelect) { |
27 | 0 | RemotableSelect sc = (RemotableSelect) c; |
28 | 0 | RemotableSelect.Builder b = RemotableSelect.Builder.create(sc.getKeyLabels()); |
29 | ||
30 | 0 | final List<RemotableSelectGroup.Builder> temp = new ArrayList<RemotableSelectGroup.Builder>(); |
31 | 0 | if (sc.getGroups() != null) { |
32 | 0 | for (RemotableSelectGroup attr : sc.getGroups()) { |
33 | 0 | temp.add(RemotableSelectGroup.Builder.create(attr.getKeyLabels(), attr.getLabel())); |
34 | } | |
35 | } | |
36 | ||
37 | 0 | b.setGroups(temp); |
38 | 0 | b.setSize(sc.getSize()); |
39 | 0 | b.setMultiple(sc.isMultiple()); |
40 | 0 | return b; |
41 | } | |
42 | 0 | if (c instanceof RemotableSelect.Builder) { |
43 | 0 | RemotableSelect.Builder sc = (RemotableSelect.Builder) c; |
44 | 0 | RemotableSelect.Builder b = RemotableSelect.Builder.create(sc.getKeyLabels()); |
45 | 0 | b.setGroups(sc.getGroups()); |
46 | 0 | b.setSize(sc.getSize()); |
47 | 0 | b.setMultiple(sc.isMultiple()); |
48 | 0 | return b; |
49 | } | |
50 | 0 | if(c instanceof RemotableTextarea || c instanceof RemotableTextarea.Builder) { |
51 | 0 | RemotableTextarea.Builder b = RemotableTextarea.Builder.create(); |
52 | 0 | b.setWatermark(((Watermarked) c).getWatermark()); |
53 | 0 | b.setCols(((RowsCols) c).getCols()); |
54 | 0 | b.setRows(((RowsCols) c).getRows()); |
55 | 0 | return b; |
56 | } | |
57 | 0 | if(c instanceof RemotableTextInput || c instanceof RemotableTextInput.Builder) { |
58 | 0 | RemotableTextInput.Builder b = RemotableTextInput.Builder.create(); |
59 | 0 | b.setWatermark(((Watermarked) c).getWatermark()); |
60 | 0 | b.setSize(((Sized) c).getSize()); |
61 | 0 | return b; |
62 | } | |
63 | 0 | throw new UnsupportedOperationException(c.getClass().getName() + " not supported"); |
64 | } | |
65 | } |