Coverage Report - org.kuali.student.common.ui.client.widgets.buttongroups.ButtonGroup
 
Classes in this File Line Coverage Branch Coverage Complexity
ButtonGroup
0%
0/14
0%
0/2
1.167
 
 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.widgets.buttongroups;
 17  
 
 18  
 
 19  
 import java.util.ArrayList;
 20  
 import java.util.HashMap;
 21  
 import java.util.List;
 22  
 import java.util.Map;
 23  
 
 24  
 import org.kuali.student.common.ui.client.mvc.Callback;
 25  
 import org.kuali.student.common.ui.client.widgets.KSButton;
 26  
 import org.kuali.student.common.ui.client.widgets.buttongroups.ButtonEnumerations.ButtonEnum;
 27  
 import org.kuali.student.common.ui.client.widgets.buttonlayout.ButtonLayout;
 28  
 
 29  
 import com.google.gwt.user.client.ui.Composite;
 30  
 import com.google.gwt.user.client.ui.Widget;
 31  
 
 32  0
 public abstract class ButtonGroup<T extends ButtonEnum> extends Composite{
 33  0
     private List<Callback<T>> callbacks = new ArrayList<Callback<T>>();
 34  0
     protected Map<T, KSButton> buttonMap = new HashMap<T, KSButton>();
 35  
     protected ButtonLayout layout;
 36  
 
 37  
     public void addCallback(Callback<T> callback) {
 38  0
         callbacks.add(callback);
 39  0
     }
 40  
 
 41  
     public List<Callback<T>> getCallbacks() {
 42  0
         return callbacks;
 43  
     }
 44  
     
 45  
     protected void sendCallbacks(T type){
 46  0
         for(Callback<T> c: getCallbacks()){
 47  0
             c.exec(type);
 48  
         }
 49  0
     }
 50  
     
 51  
     public void setButtonText(T key, String text){
 52  0
         buttonMap.get(key).setText(text);
 53  0
     }
 54  
     
 55  
     public KSButton getButton(T key){
 56  0
         return buttonMap.get(key);
 57  
     }
 58  
     
 59  
     /**
 60  
      * This method is optional, the button panel can be contained inside of a parent panel which
 61  
      * will limit it's maximum size.
 62  
      * 
 63  
      * This method provides an alternative, the button panel will "wrap" the content and become the
 64  
      * proper size based on maximum size of the content. 
 65  
      * 
 66  
      * @param content - the content the button panel will align itself next to
 67  
      */
 68  
     public void setContent(Widget content){
 69  0
         layout.setContent(content);
 70  0
     }
 71  
 }