1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krms.util;
17
18 import org.kuali.rice.core.api.util.tree.Node;
19 import org.kuali.rice.core.api.util.tree.Tree;
20 import org.kuali.rice.krad.uif.component.Component;
21 import org.kuali.rice.krad.uif.container.Group;
22 import org.kuali.rice.krad.uif.container.TreeGroup;
23 import org.kuali.rice.krad.uif.element.Message;
24 import org.kuali.rice.krad.uif.util.ObjectPropertyUtils;
25 import org.kuali.rice.krad.uif.view.View;
26 import org.kuali.rice.krms.dto.PropositionEditor;
27 import org.kuali.rice.krms.tree.node.RuleEditorTreeNode;
28
29
30
31
32 public class EditTreeGroup extends TreeGroup {
33
34 protected void buildTreeGroups(View view, Object model) {
35
36 Tree<Object, String> treeData = ObjectPropertyUtils.getPropertyValue(model, getBindingInfo().getBindingPath());
37
38 if(treeData==null){
39 return;
40 }
41
42
43 Tree<Group, Message> treeGroups = new Tree<Group, Message>();
44
45 String bindingPrefix = getBindingInfo().getBindingPrefixForNested();
46 Node<Group, Message> rootNode = buildTreeNode(treeData.getRootElement(),
47 bindingPrefix + ".rootElement", "root");
48 treeGroups.setRootElement(rootNode);
49
50 setTreeGroups(treeGroups);
51 }
52
53 protected Node<Group, Message> buildTreeNode(Node<Object, String> nodeData, String bindingPrefix,
54 String parentNode) {
55 Node<Group, Message> node = super.buildTreeNode(nodeData, bindingPrefix, parentNode);
56
57
58 if(nodeData.getData() instanceof RuleEditorTreeNode){
59 PropositionEditor proposition = ((RuleEditorTreeNode) nodeData.getData()).getProposition();
60 proposition.setBindingPath(bindingPrefix + ".data");
61 }
62
63
64 if(node.getData().getId().startsWith("KRMS-PropositionEdit-BoxSection")){
65 node.getData().setId(node.getData().getBaseId());
66 for(Component component : node.getData().getItems()){
67 component.setId(component.getBaseId());
68 }
69 }
70
71 return node;
72 }
73 }