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-2008 The Kuali Foundation
 3  
  * 
 4  
  * 
 5  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 6  
  * you may not use this file except in compliance with the License.
 7  
  * You may obtain a copy of the License at
 8  
  * 
 9  
  * http://www.opensource.org/licenses/ecl2.php
 10  
  * 
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 package org.kuali.rice.kew.actionlist.web;
 18  
 
 19  
 import org.displaytag.decorator.TableDecorator;
 20  
 import org.kuali.rice.kew.actionitem.ActionItemActionListExtension;
 21  
 import org.kuali.rice.kew.actionlist.DisplayParameters;
 22  
 import org.kuali.rice.kew.util.KEWConstants;
 23  
 
 24  
 
 25  
 /**
 26  
  * Class used to decorate table rows generated by our table tag lib.
 27  
  *
 28  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 29  
  */
 30  0
 public class ActionListDecorator extends TableDecorator {
 31  0
     private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(ActionListDecorator.class);
 32  
     
 33  0
     private int rowCounter = 0;
 34  
     
 35  
     @Override
 36  
     public String startRow() {
 37  0
          return "";
 38  
     }
 39  
 
 40  
     @Override
 41  
     public String finishRow() {
 42  0
         ActionItemActionListExtension actionItem = (ActionItemActionListExtension) getCurrentRowObject();
 43  0
         String returnRow = "";
 44  
         try {
 45  0
                 DisplayParameters displayParameters = actionItem.getDisplayParameters();
 46  0
             if (displayParameters != null) {
 47  0
                 Integer index = actionItem.getActionItemIndex();
 48  0
                 Integer frameHeight = new Integer(290);
 49  
                 try {
 50  0
                     if (displayParameters.getFrameHeight() != null && displayParameters.getFrameHeight() > 0) {
 51  0
                         frameHeight = displayParameters.getFrameHeight();
 52  
                     }
 53  0
                 } catch (Exception ex) {
 54  0
                     LOG.error("Error getting custom action list frame height.", ex);
 55  0
                 }
 56  0
                 StringBuffer newRow = new StringBuffer();
 57  0
                 newRow.append("<tr id='G");
 58  0
                 newRow.append(index.toString());
 59  0
                 newRow.append("' style='display: none;'>");
 60  0
                 newRow.append("<td class='white' height='0' colspan='11' >");
 61  0
                 newRow.append("<iframe name='iframeAL_");
 62  0
                 newRow.append(index.toString());
 63  0
                 newRow.append("' scrolling='yes' width=100% height=");
 64  0
                 newRow.append(frameHeight.toString());
 65  0
                 newRow.append(" hspace=0 vspace=0 frameborder=0></iframe>");
 66  0
                 newRow.append("</td></tr>");
 67  0
                 returnRow += newRow.toString();
 68  
             }
 69  0
         } catch (Exception e) {
 70  0
             LOG.error("Error with custom action list attribute.", e);
 71  0
         }
 72  0
         return returnRow;
 73  
     }
 74  
     
 75  
     /**
 76  
      * Adds a CSS class to the current row based on the value of the row object's rowStyleClass attribute.
 77  
      * 
 78  
      * @see org.displaytag.decorator.TableDecorator#addRowClass()
 79  
      */
 80  
     @Override
 81  
     public String addRowClass() {
 82  0
             ActionItemActionListExtension actionItem = (ActionItemActionListExtension) getCurrentRowObject();
 83  0
             return "actionlist_" + KEWConstants.ACTION_LIST_COLOR_NAMES.get(actionItem.getRowStyleClass());
 84  
     }
 85  
 
 86  
         /**
 87  
          * 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
 88  
          * display:table tag does not allow event handlers to be specified for the row elements.
 89  
          * 
 90  
          * @see org.displaytag.decorator.TableDecorator#addRowId()
 91  
          */
 92  
         @Override
 93  
         public String addRowId() {
 94  0
                 return "actionlist_tr_" + rowCounter++;
 95  
         }
 96  
 
 97  
         /**
 98  
          * Resets the row index counter after all rows have been added to the table.
 99  
          * 
 100  
          * @see org.displaytag.decorator.TableDecorator#finish()
 101  
          */
 102  
         @Override
 103  
         public void finish() {
 104  0
                 super.finish();
 105  0
                 rowCounter = 0;
 106  0
         }
 107  
     
 108  
 }