View Javadoc
1   package org.kuali.rice.krad.uif.layout.extension;
2   
3   import org.apache.commons.lang.StringUtils;
4   import org.kuali.rice.krad.uif.container.Group;
5   import org.kuali.rice.krad.uif.layout.StackedLayoutManagerBase;
6   import org.kuali.rice.krad.uif.util.ObjectPropertyUtils;
7   
8   /**
9    * kmuthu Don't forget to add comment
10   * 
11   * @Author kmuthu Date: 2/14/13
12   */
13  public class TabbedLayoutManager extends StackedLayoutManagerBase {
14  
15  	/*
16  	 * Builds the header text for the collection line
17  	 * 
18  	 * <p> Header text is built up by first the collection label, either
19  	 * specified on the collection definition or retrieved from the dictionary.
20  	 * Then for each summary field defined, the value from the model is
21  	 * retrieved and added to the header. If no summaryTitle exist, only summary
22  	 * field value is used as a header. </p>
23  	 * 
24  	 * <p> Note the {@link #getSummaryTitle()} field may have expressions
25  	 * defined, in which cause it will be copied to the property expressions map
26  	 * to set the title for the line group (which will have the item context
27  	 * variable set) </p>
28  	 * 
29  	 * @param line - Collection line containing data
30  	 * 
31  	 * @param lineGroup - Group instance for rendering the line and whose title
32  	 * should be built
33  	 * 
34  	 * @return String header text for line
35  	 */
36      @Override
37  	protected String buildLineHeaderText(Object line, Group lineGroup) {
38  		// check for expression on summary title
39  		// TODO: KSAP-34 Rice 2.3 no longer includes expressionEvaluatorService
40  		// if
41  		// (KRADServiceLocatorWeb.getExpressionEvaluatorService().containsElPlaceholder(getSummaryTitle()))
42  		// {
43  		// lineGroup.getPropertyExpressions().put("title", getSummaryTitle());
44  		// return null;
45  		// }
46  
47  		// build up line summary from declared field values and fixed title
48          StringBuilder summaryFieldString = new StringBuilder("");
49  		for (String summaryField : getSummaryFields()) {
50  			Object summaryFieldValue = ObjectPropertyUtils.getPropertyValue(
51  					line, summaryField);
52  			if (StringUtils.isNotBlank(summaryFieldString.toString())) {
53  				summaryFieldString.append(" - ");
54  			}
55  
56  			if (summaryFieldValue != null) {
57  				summaryFieldString.append(summaryFieldValue);
58  			} else {
59  				summaryFieldString.append("Null");
60  			}
61  		}
62  
63  		String headerText = getSummaryTitle();
64  		if (StringUtils.isNotBlank(headerText)
65  				&& StringUtils.isNotBlank(summaryFieldString.toString())) {
66  			headerText += " ( " + summaryFieldString + " )";
67  		} else if (StringUtils.isNotBlank(summaryFieldString.toString())) {
68  			headerText = summaryFieldString.toString();
69  		}
70  
71  		return headerText;
72  	}
73  }