Coverage Report - org.kuali.student.common.ui.client.widgets.field.layout.element.AbbrButton
 
Classes in this File Line Coverage Branch Coverage Complexity
AbbrButton
0%
0/32
0%
0/5
1.444
AbbrButton$1
0%
0/4
N/A
1.444
AbbrButton$2
0%
0/3
N/A
1.444
AbbrButton$3
0%
0/1
N/A
1.444
AbbrButton$AbbrButtonType
0%
0/1
N/A
1.444
 
 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.field.layout.element;
 17  
 
 18  
 import org.kuali.student.common.ui.client.widgets.KSButton;
 19  
 import org.kuali.student.common.ui.client.widgets.KSButtonAbstract.ButtonStyle;
 20  
 
 21  
 import com.google.gwt.event.dom.client.ClickHandler;
 22  
 import com.google.gwt.event.dom.client.HasClickHandlers;
 23  
 import com.google.gwt.event.dom.client.HasMouseOutHandlers;
 24  
 import com.google.gwt.event.dom.client.HasMouseOverHandlers;
 25  
 import com.google.gwt.event.dom.client.MouseOutEvent;
 26  
 import com.google.gwt.event.dom.client.MouseOutHandler;
 27  
 import com.google.gwt.event.dom.client.MouseOverEvent;
 28  
 import com.google.gwt.event.dom.client.MouseOverHandler;
 29  
 import com.google.gwt.event.shared.HandlerRegistration;
 30  
 import com.google.gwt.user.client.ui.Composite;
 31  
 import com.google.gwt.user.client.ui.HTMLPanel;
 32  
 import com.google.gwt.user.client.ui.PopupPanel;
 33  
 
 34  
 /**
 35  
  * A button wrapped in an abbr tag with a special hover mechanism for help text
 36  
  * 
 37  
  * @author Kuali Student Team
 38  
  *
 39  
  */
 40  0
 public class AbbrButton extends Composite implements HasClickHandlers, HasMouseOverHandlers, HasMouseOutHandlers{
 41  
         
 42  0
         public enum AbbrButtonType{HELP, DELETE, VIEW, EXAMPLES};
 43  
         
 44  
         private AbbrPanel abbr;
 45  
         private KSButton button;
 46  0
         private PopupPanel hoverPopup = new PopupPanel();
 47  
         
 48  0
         public AbbrButton(AbbrButtonType type){
 49  
                 
 50  0
                 switch(type){
 51  
                         case HELP:
 52  0
                                 abbr = new AbbrPanel("Help", "ks-form-module-elements-help");
 53  0
                                 button = new KSButton("?", ButtonStyle.DEFAULT_ANCHOR);
 54  0
                                 abbr.add(button);
 55  0
                                 break;
 56  
                         case DELETE:
 57  0
                                 abbr = new AbbrPanel("Delete", "ks-form-module-elements-delete");
 58  0
                                 button = new KSButton("X", ButtonStyle.DEFAULT_ANCHOR);
 59  0
                                 abbr.add(button);
 60  0
                                 break;
 61  
                         case VIEW:
 62  0
                 abbr = new AbbrPanel("View", "ks-form-module-elements-delete");
 63  0
                 button = new KSButton("View", ButtonStyle.DEFAULT_ANCHOR);
 64  0
                 abbr.add(button);
 65  0
                             break;
 66  
                         case EXAMPLES:
 67  0
                 abbr = new AbbrPanel("Examples", "ks-form-module-elements-help");
 68  0
                 button = new KSButton("See examples", ButtonStyle.DEFAULT_ANCHOR);
 69  0
                 abbr.add(button);
 70  
                             break;
 71  
                 }
 72  0
                 this.initWidget(abbr);
 73  0
         }
 74  
         
 75  
         public void setHoverHTML(String html){
 76  0
                 hoverPopup.add(new HTMLPanel(html));
 77  0
                 hoverPopup.setStyleName("ks-help-popup");
 78  0
                 button.addMouseOverHandler(new MouseOverHandler(){
 79  
 
 80  
                         @Override
 81  
                         public void onMouseOver(MouseOverEvent event) {
 82  0
                                 hoverPopup.setPopupPosition(button.getAbsoluteLeft() + button.getOffsetWidth() + 5, 
 83  
                                                 button.getAbsoluteTop());
 84  0
                                 hoverPopup.show();
 85  0
                         }
 86  
                 });
 87  0
                 button.addMouseOutHandler(new MouseOutHandler(){
 88  
 
 89  
                         @Override
 90  
                         public void onMouseOut(MouseOutEvent event) {
 91  0
                                 hoverPopup.hide();
 92  0
                         }
 93  
                 });
 94  
                 
 95  0
         }
 96  
 
 97  
         public PopupPanel getHoverPopup() {
 98  0
                 return hoverPopup;
 99  
         }
 100  
 
 101  
         public void setHoverPopup(PopupPanel hoverPopup) {
 102  0
                 this.hoverPopup = hoverPopup;
 103  0
         }
 104  
 
 105  
         @Override
 106  
         public HandlerRegistration addClickHandler(ClickHandler handler) {
 107  0
                 return button.addClickHandler(handler);
 108  
         }
 109  
 
 110  
         @Override
 111  
         public HandlerRegistration addMouseOverHandler(MouseOverHandler handler) {
 112  0
                 return button.addMouseOverHandler(handler);
 113  
         }
 114  
 
 115  
         @Override
 116  
         public HandlerRegistration addMouseOutHandler(MouseOutHandler handler) {
 117  0
                 return button.addMouseOutHandler(handler);
 118  
         }
 119  
 }