Coverage Report - org.kuali.student.common.ui.client.configurable.mvc.sections.ValidationMessagePanel
 
Classes in this File Line Coverage Branch Coverage Complexity
ValidationMessagePanel
0%
0/35
0%
0/10
1.5
 
 1  
 /**
 2  
  * Copyright 2010 The Kuali Foundation Licensed under the
 3  
  * Educational Community License, Version 2.0 (the "License"); you may
 4  
  * not use this file except in compliance with the License. You may
 5  
  * obtain a copy of the License at
 6  
  *
 7  
  * http://www.osedu.org/licenses/ECL-2.0
 8  
  *
 9  
  * Unless required by applicable law or agreed to in writing,
 10  
  * software distributed under the License is distributed on an "AS IS"
 11  
  * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 12  
  * or implied. See the License for the specific language governing
 13  
  * permissions and limitations under the License.
 14  
  */
 15  
 
 16  
 package org.kuali.student.common.ui.client.configurable.mvc.sections;
 17  
 
 18  
 import org.kuali.student.common.ui.client.widgets.KSLabel;
 19  
 import org.kuali.student.common.ui.client.widgets.layout.VerticalFlowPanel;
 20  
 import org.kuali.student.common.ui.client.widgets.menus.KSListPanel;
 21  
 
 22  
 import com.google.gwt.user.client.ui.Composite;
 23  
 import com.google.gwt.user.client.ui.Widget;
 24  
 
 25  
 /**
 26  
  * The validation message panel used for field elements, adds validation errors to a list and styles
 27  
  * them appropriately.
 28  
  * 
 29  
  * @author Kuali Student Team
 30  
  *
 31  
  */
 32  
 public class ValidationMessagePanel extends Composite{
 33  
         
 34  0
         private VerticalFlowPanel container = new VerticalFlowPanel();
 35  0
         private KSListPanel errorListPanel = new KSListPanel();
 36  0
         private KSListPanel warnListPanel = new KSListPanel();
 37  0
         private int warnCount = 0;
 38  0
         private int errorCount = 0;
 39  0
         private boolean topMargin = true;
 40  
         
 41  0
         public ValidationMessagePanel(){
 42  0
                 this.initWidget(container);
 43  0
                 container.add(errorListPanel);
 44  0
                 container.add(warnListPanel);
 45  0
                 errorListPanel.addStyleName("ks-form-module-validation-errors");
 46  0
                 warnListPanel.addStyleName("ks-form-module-validation-warnings");                
 47  0
         }
 48  
         
 49  0
         public ValidationMessagePanel(boolean topMargin){
 50  0
                 this.initWidget(errorListPanel);
 51  0
                 this.topMargin = topMargin;
 52  0
         }
 53  
         
 54  
         public void addErrorMessage(KSLabel message){
 55  0
                 if(getMessageCount() == 0 && topMargin){
 56  0
                         message.addStyleName("ks-form-module-single-line-margin");
 57  
                 }                
 58  0
                 errorListPanel.add(message);
 59  0
                 errorCount++;
 60  0
         }
 61  
         
 62  
         public void addWarnMessage(Widget message){
 63  0
                 if(getMessageCount() == 0 && topMargin){
 64  0
                         message.addStyleName("ks-form-module-single-line-margin");
 65  
                 }
 66  0
                 warnListPanel.add(message);
 67  0
                 warnCount++;                
 68  0
         }
 69  
         
 70  
         public boolean hasWarnings(){
 71  0
                 return (warnCount > 0);
 72  
         }
 73  
         
 74  
         public void clearErrors(){
 75  0
                 errorListPanel.clear();
 76  0
                 errorCount = 0;
 77  0
         }
 78  
         
 79  
         public void clearWarnings(){
 80  0
                 warnListPanel.clear();
 81  0
                 warnCount = 0;
 82  0
         }
 83  
         
 84  
         public int getMessageCount(){
 85  0
                 return errorCount + warnCount;
 86  
         }
 87  
 }