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.datadictionary.parse.BeanTag;
20 import org.kuali.rice.krad.uif.container.Group;
21 import org.kuali.rice.krad.uif.view.View;
22 import org.kuali.rice.krad.uif.component.Component;
23 import org.kuali.rice.krad.uif.field.Field;
24
25 import java.util.ArrayList;
26 import java.util.HashSet;
27 import java.util.List;
28 import java.util.Set;
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
53 @Override
54 public void performModification(View view, Object model, Component component) {
55 if ((component != null) && !(component instanceof Group)) {
56 throw new IllegalArgumentException("Compare field initializer only support Group components, found type: "
57 + component.getClass());
58 }
59
60 if (component == null) {
61 return;
62 }
63
64
65 List<Component> groupFields = new ArrayList<Component>();
66
67 Group group = (Group) component;
68 for (Component item : group.getItems()) {
69 if (item instanceof Field) {
70 Field field = (Field) item;
71
72
73 if (field.getFieldLabel() != null && field.getFieldLabel().isRender()) {
74 field.getFieldLabel().addStyleClass("displayWith-" + field.getId());
75 if (!field.isRender() && StringUtils.isBlank(field.getProgressiveRender())) {
76 field.getFieldLabel().setRender(false);
77 }
78 else if(!field.isRender() && StringUtils.isNotBlank(field.getProgressiveRender())){
79 field.getFieldLabel().setRender(true);
80 String prefixStyle = "";
81 if(StringUtils.isNotBlank(field.getFieldLabel().getStyle())){
82 prefixStyle = field.getFieldLabel().getStyle();
83 }
84 field.getFieldLabel().setStyle(prefixStyle + ";" + "display: none;");
85 }
86
87 groupFields.add(field.getFieldLabel());
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 }