Coverage Report - org.kuali.rice.kew.actionlist.web.ActionListDecorator
 
Classes in this File Line Coverage Branch Coverage Complexity
ActionListDecorator
0%
0/37
0%
0/6
2
 
 1  
 /**
 2  
  * Copyright 2005-2011 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.kew.actionlist.web;
 17  
 
 18  
 import org.displaytag.decorator.TableDecorator;
 19  
 import org.kuali.rice.kew.actionitem.ActionItemActionListExtension;
 20  
 import org.kuali.rice.kew.api.actionlist.DisplayParameters;
 21  
 import org.kuali.rice.kew.api.KewApiConstants;
 22  
 
 23  
 
 24  
 /**
 25  
  * Class used to decorate table rows generated by our table tag lib.
 26  
  *
 27  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 28  
  */
 29  0
 public class ActionListDecorator extends TableDecorator {
 30  0
     private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(ActionListDecorator.class);
 31  
     
 32  0
     private int rowCounter = 0;
 33  
     
 34  
     @Override
 35  
     public String startRow() {
 36  0
          return "";
 37  
     }
 38  
 
 39  
     @Override
 40  
     public String finishRow() {
 41  0
         ActionItemActionListExtension actionItem = (ActionItemActionListExtension) getCurrentRowObject();
 42  0
         String returnRow = "";
 43  
         try {
 44  0
                 DisplayParameters displayParameters = actionItem.getDisplayParameters();
 45  0
             if (displayParameters != null) {
 46  0
                 Integer index = actionItem.getActionItemIndex();
 47  0
                 Integer frameHeight = new Integer(290);
 48  
                 try {
 49  0
                     if (displayParameters.getFrameHeight() != null && displayParameters.getFrameHeight() > 0) {
 50  0
                         frameHeight = displayParameters.getFrameHeight();
 51  
                     }
 52  0
                 } catch (Exception ex) {
 53  0
                     LOG.error("Error getting custom action list frame height.", ex);
 54  0
                 }
 55  0
                 StringBuffer newRow = new StringBuffer();
 56  0
                 newRow.append("<tr id='G");
 57  0
                 newRow.append(index.toString());
 58  0
                 newRow.append("' style='display: none;'>");
 59  0
                 newRow.append("<td class='white' height='0' colspan='11' >");
 60  0
                 newRow.append("<iframe name='iframeAL_");
 61  0
                 newRow.append(index.toString());
 62  0
                 newRow.append("' scrolling='yes' width=100% height=");
 63  0
                 newRow.append(frameHeight.toString());
 64  0
                 newRow.append(" hspace=0 vspace=0 frameborder=0></iframe>");
 65  0
                 newRow.append("</td></tr>");
 66  0
                 returnRow += newRow.toString();
 67  
             }
 68  0
         } catch (Exception e) {
 69  0
             LOG.error("Error with custom action list attribute.", e);
 70  0
         }
 71  0
         return returnRow;
 72  
     }
 73  
     
 74  
     /**
 75  
      * Adds a CSS class to the current row based on the value of the row object's rowStyleClass attribute.
 76  
      * 
 77  
      * @see org.displaytag.decorator.TableDecorator#addRowClass()
 78  
      */
 79  
     @Override
 80  
     public String addRowClass() {
 81  0
             ActionItemActionListExtension actionItem = (ActionItemActionListExtension) getCurrentRowObject();
 82  0
             return "actionlist_" + KewApiConstants.ACTION_LIST_COLOR_NAMES.get(actionItem.getRowStyleClass());
 83  
     }
 84  
 
 85  
         /**
 86  
          * Adds a unique ID to this row that allows JavaScript to add mouse event listeners at run-time. This is necessary because the action list's
 87  
          * display:table tag does not allow event handlers to be specified for the row elements.
 88  
          * 
 89  
          * @see org.displaytag.decorator.TableDecorator#addRowId()
 90  
          */
 91  
         @Override
 92  
         public String addRowId() {
 93  0
                 return "actionlist_tr_" + rowCounter++;
 94  
         }
 95  
 
 96  
         /**
 97  
          * Resets the row index counter after all rows have been added to the table.
 98  
          * 
 99  
          * @see org.displaytag.decorator.TableDecorator#finish()
 100  
          */
 101  
         @Override
 102  
         public void finish() {
 103  0
                 super.finish();
 104  0
                 rowCounter = 0;
 105  0
         }
 106  
     
 107  
 }