001package org.kuali.rice.krad.uif.layout.extension;
002
003import org.apache.commons.lang.StringUtils;
004import org.kuali.rice.krad.uif.container.Group;
005import org.kuali.rice.krad.uif.layout.StackedLayoutManagerBase;
006import org.kuali.rice.krad.uif.util.ObjectPropertyUtils;
007
008/**
009 * kmuthu Don't forget to add comment
010 * 
011 * @Author kmuthu Date: 2/14/13
012 */
013public class TabbedLayoutManager extends StackedLayoutManagerBase {
014
015        /*
016         * Builds the header text for the collection line
017         * 
018         * <p> Header text is built up by first the collection label, either
019         * specified on the collection definition or retrieved from the dictionary.
020         * Then for each summary field defined, the value from the model is
021         * retrieved and added to the header. If no summaryTitle exist, only summary
022         * field value is used as a header. </p>
023         * 
024         * <p> Note the {@link #getSummaryTitle()} field may have expressions
025         * defined, in which cause it will be copied to the property expressions map
026         * to set the title for the line group (which will have the item context
027         * variable set) </p>
028         * 
029         * @param line - Collection line containing data
030         * 
031         * @param lineGroup - Group instance for rendering the line and whose title
032         * should be built
033         * 
034         * @return String header text for line
035         */
036    @Override
037        protected String buildLineHeaderText(Object line, Group lineGroup) {
038                // check for expression on summary title
039                // TODO: KSAP-34 Rice 2.3 no longer includes expressionEvaluatorService
040                // if
041                // (KRADServiceLocatorWeb.getExpressionEvaluatorService().containsElPlaceholder(getSummaryTitle()))
042                // {
043                // lineGroup.getPropertyExpressions().put("title", getSummaryTitle());
044                // return null;
045                // }
046
047                // build up line summary from declared field values and fixed title
048        StringBuilder summaryFieldString = new StringBuilder("");
049                for (String summaryField : getSummaryFields()) {
050                        Object summaryFieldValue = ObjectPropertyUtils.getPropertyValue(
051                                        line, summaryField);
052                        if (StringUtils.isNotBlank(summaryFieldString.toString())) {
053                                summaryFieldString.append(" - ");
054                        }
055
056                        if (summaryFieldValue != null) {
057                                summaryFieldString.append(summaryFieldValue);
058                        } else {
059                                summaryFieldString.append("Null");
060                        }
061                }
062
063                String headerText = getSummaryTitle();
064                if (StringUtils.isNotBlank(headerText)
065                                && StringUtils.isNotBlank(summaryFieldString.toString())) {
066                        headerText += " ( " + summaryFieldString + " )";
067                } else if (StringUtils.isNotBlank(summaryFieldString.toString())) {
068                        headerText = summaryFieldString.toString();
069                }
070
071                return headerText;
072        }
073}