Coverage Report - org.kuali.rice.kns.uif.widget.TableTools
 
Classes in this File Line Coverage Branch Coverage Complexity
TableTools
0%
0/23
0%
0/6
1.375
 
 1  
 /*
 2  
  * Copyright 2007 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 1.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/ecl1.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.kns.uif.widget;
 17  
 
 18  
 import org.apache.commons.lang.StringUtils;
 19  
 
 20  
 import org.kuali.rice.kns.uif.UifConstants;
 21  
 import org.kuali.rice.kns.uif.container.View;
 22  
 import org.kuali.rice.kns.uif.core.Component;
 23  
 
 24  
 /**
 25  
  * Decorates a HTML Table client side with various tools
 26  
  * 
 27  
  * <p>
 28  
  * Decorations implemented depend on widget implementation. Examples are
 29  
  * sorting, paging and skinning.
 30  
  * </p>
 31  
  * 
 32  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 33  
  */
 34  
 public class TableTools extends WidgetBase {
 35  
         private static final long serialVersionUID = 4671589690877390070L;
 36  
 
 37  
         /**
 38  
          * A text to be displayed when the table is empty
 39  
          */
 40  
         private String emptyTableMessage;
 41  
         private boolean disableTableSort;
 42  
         
 43  
         /**
 44  
          * By default, show the search and export options
 45  
          */
 46  0
         private boolean showSearchAndExportOptions = true;
 47  
         
 48  
         public TableTools() {
 49  0
                 super();
 50  0
         }
 51  
 
 52  
         /**
 53  
          * The following initialization is performed:
 54  
          * 
 55  
          * <ul>
 56  
          * <li>Initializes component options for empty table message</li>
 57  
          * </ul>
 58  
          *
 59  
          */
 60  
         @Override
 61  
         public void performFinalize(View view, Object model, Component component) {
 62  0
                 super.performFinalize(view,model,component);
 63  
                 
 64  0
                 if (StringUtils.isNotBlank(getEmptyTableMessage())){
 65  0
                         getComponentOptions().put(UifConstants.TableToolsKeys.LANGUAGE, "{\"" + UifConstants.TableToolsKeys.EMPTY_TABLE + "\" : \"" + getEmptyTableMessage() + "\"}");
 66  
                 }
 67  
                 
 68  0
                 if (isDisableTableSort()){
 69  0
                         getComponentOptions().put(UifConstants.TableToolsKeys.TABLE_SORT,"false");
 70  
                 }
 71  
                 
 72  0
                 if (!isShowSearchAndExportOptions()){
 73  0
                         String sDomOption = getComponentOptions().get(UifConstants.TableToolsKeys.SDOM);
 74  0
                         sDomOption = StringUtils.remove(sDomOption, "T"); //Removes Export option         
 75  0
                         sDomOption = StringUtils.remove(sDomOption, "f"); //Removes search option
 76  0
                         getComponentOptions().put(UifConstants.TableToolsKeys.SDOM,sDomOption);
 77  
                 }
 78  0
         }
 79  
         
 80  
         /**
 81  
          * Returns the text which is used to display text when the table is empty
 82  
          * 
 83  
          *  @return empty table message
 84  
          */
 85  
         public String getEmptyTableMessage() {
 86  0
                 return emptyTableMessage;
 87  
         }
 88  
 
 89  
         /**
 90  
          * Setter for a text to be displayed when the table is empty
 91  
          * 
 92  
          * @param emptyTableMessage
 93  
          */
 94  
         public void setEmptyTableMessage(String emptyTableMessage) {
 95  0
                 this.emptyTableMessage = emptyTableMessage;
 96  0
         }
 97  
         
 98  
         /**
 99  
          * Returns true if sorting is disabled
 100  
          *  
 101  
          * @return the disableTableSort
 102  
          */
 103  
         public boolean isDisableTableSort() {
 104  0
                 return this.disableTableSort;
 105  
         }
 106  
 
 107  
         /**
 108  
          * Enables/disables the table sorting
 109  
          *  
 110  
          * @param disableTableSort the disableTableSort to set
 111  
          */
 112  
         public void setDisableTableSort(boolean disableTableSort) {
 113  0
                 this.disableTableSort = disableTableSort;
 114  0
         }
 115  
         
 116  
         /**
 117  
          * Returns true if search and export options are enabled
 118  
          * 
 119  
          * @return the showSearchAndExportOptions
 120  
          */
 121  
         public boolean isShowSearchAndExportOptions() {
 122  0
                 return this.showSearchAndExportOptions;
 123  
         }
 124  
 
 125  
         /**
 126  
          * Show/Hide the search and export options in tabletools
 127  
          * 
 128  
          * @param showSearchAndExportOptions the showSearchAndExportOptions to set
 129  
          */
 130  
         public void setShowSearchAndExportOptions(boolean showSearchAndExportOptions) {
 131  0
                 this.showSearchAndExportOptions = showSearchAndExportOptions;
 132  0
         }
 133  
 }