1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.uif.modifier;
17
18 import org.apache.commons.lang.StringUtils;
19 import org.kuali.rice.krad.uif.container.Group;
20 import org.kuali.rice.krad.uif.view.View;
21 import org.kuali.rice.krad.uif.component.Component;
22 import org.kuali.rice.krad.uif.field.Field;
23
24 import java.util.ArrayList;
25 import java.util.HashSet;
26 import java.util.List;
27 import java.util.Set;
28
29
30
31
32
33
34
35 public class LabelFieldSeparateModifier extends ComponentModifierBase {
36 private static final long serialVersionUID = -4304947796868636298L;
37
38 public LabelFieldSeparateModifier() {
39 super();
40 }
41
42
43
44
45
46
47
48
49
50
51 @Override
52 public void performModification(View view, Object model, Component component) {
53 if ((component != null) && !(component instanceof Group)) {
54 throw new IllegalArgumentException("Compare field initializer only support Group components, found type: "
55 + component.getClass());
56 }
57
58 if (component == null) {
59 return;
60 }
61
62
63 List<Component> groupFields = new ArrayList<Component>();
64
65 Group group = (Group) component;
66 for (Component item : group.getItems()) {
67 if (item instanceof Field) {
68 Field field = (Field) item;
69
70
71 if (field.getLabelField() != null && field.getLabelField().isRender()) {
72 field.getLabelField().addStyleClass("displayWith-" + field.getId());
73 if (!field.isRender() && StringUtils.isBlank(field.getProgressiveRender())) {
74 field.getLabelField().setRender(false);
75 }
76 else if(!field.isRender() && StringUtils.isNotBlank(field.getProgressiveRender())){
77 field.getLabelField().setRender(true);
78 String prefixStyle = "";
79 if(StringUtils.isNotBlank(field.getLabelField().getStyle())){
80 prefixStyle = field.getLabelField().getStyle();
81 }
82 field.getLabelField().setStyle(prefixStyle + ";" + "display: none;");
83 }
84
85 groupFields.add(field.getLabelField());
86
87
88
89 field.setLabelFieldRendered(true);
90 }
91 }
92
93 groupFields.add(item);
94 }
95
96
97 group.setItems(groupFields);
98 }
99
100
101
102
103 @Override
104 public Set<Class<? extends Component>> getSupportedComponents() {
105 Set<Class<? extends Component>> components = new HashSet<Class<? extends Component>>();
106 components.add(Group.class);
107
108 return components;
109 }
110
111 }