Coverage Report - org.kuali.student.common.ui.client.widgets.field.layout.element.SpanPanel
 
Classes in this File Line Coverage Branch Coverage Complexity
SpanPanel
0%
0/29
0%
0/4
1.364
 
 1  
 /**
 2  
  * Copyright 2010 The Kuali Foundation Licensed under the Educational Community License, Version 2.0 (the "License"); you may
 3  
  * not use this file except in compliance with the License. You may obtain a copy of the License at
 4  
  * http://www.osedu.org/licenses/ECL-2.0 Unless required by applicable law or agreed to in writing, software distributed
 5  
  * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 6  
  * implied. See the License for the specific language governing permissions and limitations under the License.
 7  
  */
 8  
 
 9  
 package org.kuali.student.common.ui.client.widgets.field.layout.element;
 10  
 
 11  
 import java.util.List;
 12  
 
 13  
 import org.kuali.student.common.ui.client.reporting.ReportExportWidget;
 14  
 import org.kuali.student.common.ui.client.util.ExportElement;
 15  
 import org.kuali.student.common.ui.client.util.ExportUtils;
 16  
 
 17  
 import com.google.gwt.dom.client.Element;
 18  
 import com.google.gwt.user.client.DOM;
 19  
 import com.google.gwt.user.client.ui.ComplexPanel;
 20  
 import com.google.gwt.user.client.ui.Widget;
 21  
 
 22  
 public class SpanPanel extends ComplexPanel implements ReportExportWidget {
 23  
 
 24  0
     private boolean exportElement = true;
 25  
     private String reportText;
 26  
 
 27  0
     public SpanPanel() {
 28  0
         setElement(DOM.createSpan());
 29  0
     }
 30  
 
 31  0
     public SpanPanel(String text) {
 32  0
         Element span = DOM.createSpan();
 33  0
         span.setInnerText(text);
 34  0
         setElement(span);
 35  0
     }
 36  
 
 37  
     /**
 38  
      * Adds a new child widget to the panel.
 39  
      * 
 40  
      * @param w
 41  
      *            the widget to be added
 42  
      */
 43  
     @Override
 44  
     public void add(Widget w) {
 45  0
         add(w, getElement());
 46  0
     }
 47  
 
 48  
     /**
 49  
      * Inserts a widget before the specified index.
 50  
      * 
 51  
      * @param w
 52  
      *            the widget to be inserted
 53  
      * @param beforeIndex
 54  
      *            the index before which it will be inserted
 55  
      * @throws IndexOutOfBoundsException
 56  
      *             if <code>beforeIndex</code> is out of range
 57  
      */
 58  
     public void insert(Widget w, int beforeIndex) {
 59  0
         insert(w, getElement(), beforeIndex, true);
 60  0
     }
 61  
 
 62  
     public void setText(String text) {
 63  0
         this.getElement().setInnerText(text);
 64  0
         this.reportText = text;
 65  0
     }
 66  
 
 67  
     public void setHTML(String html) {
 68  0
         this.getElement().setInnerHTML(html);
 69  0
         this.reportText = html;
 70  0
     }
 71  
 
 72  
     public String getText() {
 73  0
         return this.getElement().getInnerText();
 74  
     }
 75  
 
 76  
     @Override
 77  
     public boolean isExportElement() {
 78  0
         return exportElement;
 79  
     }
 80  
 
 81  
     public void setExportElement(boolean export) {
 82  0
         this.exportElement = export;
 83  0
     }
 84  
 
 85  
     @Override
 86  
     public List<ExportElement> getExportElementSubset(ExportElement parent) {
 87  0
         return ExportUtils.getDetailsForWidget(this, parent.getViewName(), parent.getSectionName());
 88  
     }
 89  
 
 90  
     @Override
 91  
     public String getExportFieldValue() {
 92  0
         if (this.reportText != null){
 93  0
             return this.reportText;
 94  0
         } else if (this.getWidgetCount() == 0){
 95  0
             return this.getText();
 96  
         }
 97  0
         return "";
 98  
     }
 99  
 
 100  
 }