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 = "labelSeparatorModifier", 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 synchronized (label) {
75 label.getLibraryCssClasses().clear();
76 label.addStyleClass("displayWith-" + field.getId());
77 if (!field.isRender() && StringUtils.isBlank(field.getProgressiveRender())) {
78 label.setRender(false);
79 }
80 else if (!field.isRender() && StringUtils.isNotBlank(field.getProgressiveRender())) {
81 label.setRender(true);
82 String prefixStyle = "";
83 if (StringUtils.isNotBlank(label.getStyle())) {
84 prefixStyle = label.getStyle();
85 }
86 label.setStyle(prefixStyle + ";" + "display: none;");
87 }
88
89 groupFields.add(label);
90
91
92
93 field.setLabelRendered(true);
94 }
95 }
96
97 groupFields.add(item);
98 }
99
100
101 group.setItems(groupFields);
102 }
103
104
105
106
107 @Override
108 public Set<Class<? extends Component>> getSupportedComponents() {
109 Set<Class<? extends Component>> components = new HashSet<Class<? extends Component>>();
110 components.add(Group.class);
111
112 return components;
113 }
114
115 }