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