View Javadoc

1   /**
2    * Copyright 2005-2013 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
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.container.Group;
21  import org.kuali.rice.krad.uif.container.TreeGroup;
22  import org.kuali.rice.krad.uif.element.Message;
23  import org.kuali.rice.krad.uif.util.ObjectPropertyUtils;
24  import org.kuali.rice.krad.uif.view.View;
25  
26  /**
27   * @author Kuali Student Team
28   */
29  public class ViewTreeGroup extends TreeGroup {
30  
31      protected void buildTreeGroups(View view, Object model) {
32          // get Tree data property
33          Tree<Object, String> treeData = ObjectPropertyUtils.getPropertyValue(model, getBindingInfo().getBindingPath());
34  
35          if (treeData == null) {
36              return;
37          }
38  
39          // build component tree that corresponds with tree data
40          Tree<Group, Message> treeGroups = new Tree<Group, Message>();
41  
42          String bindingPrefix = getBindingInfo().getBindingPrefixForNested();
43          Node<Group, Message> rootNode = buildTreeNode(treeData.getRootElement(),
44                  bindingPrefix + ".rootElement", "root");
45          treeGroups.setRootElement(rootNode);
46  
47          setTreeGroups(treeGroups);
48      }
49  }