Coverage Report - org.kuali.student.core.statement.ui.client.widgets.rules.AndOrButton
 
Classes in this File Line Coverage Branch Coverage Complexity
AndOrButton
0%
0/34
0%
0/4
1.222
AndOrButton$1
0%
0/3
N/A
1.222
AndOrButton$2
0%
0/3
N/A
1.222
 
 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.core.statement.ui.client.widgets.rules;
 17  
 
 18  
 import com.google.gwt.event.dom.client.ClickEvent;
 19  
 import com.google.gwt.event.dom.client.ClickHandler;
 20  
 import com.google.gwt.event.shared.HandlerRegistration;
 21  
 import com.google.gwt.user.client.ui.Button;
 22  
 import com.google.gwt.user.client.ui.HorizontalPanel;
 23  
 
 24  0
 public class AndOrButton extends HorizontalPanel {
 25  
 
 26  0
     Button andButton = new Button(" AND ");
 27  0
     Button orButton = new Button("OR");
 28  
     HandlerRegistration andHandlerRegi;
 29  
     HandlerRegistration orHandlerRegi;
 30  
     
 31  
     public final static int And = 1;
 32  
     public final static int Or = 2;
 33  0
     private int value = And;
 34  
 
 35  0
     public AndOrButton(){
 36  0
         super.add(andButton);
 37  
         //super.add(andLabel);
 38  
         //super.add(orLabel);
 39  0
         super.add(orButton);
 40  
         //andLabel.setStyleName("KS-Rules-Toggle-Label");
 41  0
         andButton.setStyleName("KS-Rules-Toggle-Button");
 42  
         //orLabel.setStyleName("KS-Rules-Toggle-Label");
 43  0
         orButton.setStyleName("KS-Rules-Toggle-Button");
 44  0
         update(AndOrButton.And);
 45  0
         andButton.addClickHandler(new ClickHandler(){
 46  
             @Override
 47  
             public void onClick(ClickEvent event) {
 48  0
               update(AndOrButton.Or);
 49  0
             }
 50  
         });
 51  0
         orButton.addClickHandler(new ClickHandler(){
 52  
             @Override
 53  
             public void onClick(ClickEvent event) {
 54  0
               update(AndOrButton.And);
 55  0
             }
 56  
         });       
 57  0
     }
 58  
 
 59  
     public int getValue(){
 60  0
         return value;
 61  
     }
 62  
 
 63  
     public void addClickHandler(ClickHandler clickHandler) {
 64  0
         andHandlerRegi = andButton.addClickHandler(clickHandler);
 65  0
         orHandlerRegi = orButton.addClickHandler(clickHandler);
 66  0
     }
 67  
 
 68  
     public void removeClickHandler() {
 69  0
         andHandlerRegi.removeHandler();
 70  0
         orHandlerRegi.removeHandler();
 71  0
     }
 72  
 
 73  
     public void setValue(int v){
 74  0
         this.value = v;
 75  0
         update(this.value);
 76  0
     }
 77  
 
 78  
     private void update(int value){
 79  0
         this.value = value;
 80  
         
 81  0
         if(value == And) {
 82  0
             andButton.setStyleName("KS-Rules-Toggle-Label");
 83  0
             orButton.setStyleName("KS-Rules-Toggle-Button");
 84  0
         } else if (value == Or){
 85  0
             orButton.setStyleName("KS-Rules-Toggle-Label"); 
 86  0
             andButton.setStyleName("KS-Rules-Toggle-Button");
 87  
         }
 88  0
     }
 89  
 
 90  
     public void setEnabled(boolean enabled) {
 91  0
         andButton.setEnabled(enabled);
 92  0
         orButton.setEnabled(enabled);
 93  0
     }
 94  
 }