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/25
0%
0/4
1.429
AbbrButton$1
0%
0/4
N/A
1.429
AbbrButton$2
0%
0/3
N/A
1.429
AbbrButton$3
0%
0/1
N/A
1.429
AbbrButton$AbbrButtonType
0%
0/1
N/A
1.429
 
 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  0
 public class AbbrButton extends Composite implements HasClickHandlers, HasMouseOverHandlers, HasMouseOutHandlers{
 35  
         
 36  0
         public enum AbbrButtonType{HELP, DELETE, VIEW};
 37  
         
 38  
         private AbbrPanel abbr;
 39  
         private KSButton button;
 40  0
         private PopupPanel hoverPopup = new PopupPanel();
 41  
         
 42  0
         public AbbrButton(AbbrButtonType type){
 43  
                 
 44  0
                 switch(type){
 45  
                         case HELP:
 46  0
                                 abbr = new AbbrPanel("Help", "ks-form-module-elements-help");
 47  0
                                 button = new KSButton("?", ButtonStyle.DEFAULT_ANCHOR);
 48  0
                                 abbr.add(button);
 49  0
                                 break;
 50  
                         case DELETE:
 51  0
                                 abbr = new AbbrPanel("Delete", "ks-form-module-elements-delete");
 52  0
                                 button = new KSButton("X", ButtonStyle.DEFAULT_ANCHOR);
 53  0
                                 abbr.add(button);
 54  0
                                 break;
 55  
                         case VIEW:
 56  0
                 abbr = new AbbrPanel("View", "ks-form-module-elements-delete");
 57  0
                 button = new KSButton("View", ButtonStyle.DEFAULT_ANCHOR);
 58  0
                 abbr.add(button);
 59  
                             break;
 60  
                 }
 61  0
                 this.initWidget(abbr);
 62  0
         }
 63  
         
 64  
         public void setHoverHTML(String html){
 65  0
                 hoverPopup.add(new HTMLPanel(html));
 66  0
                 hoverPopup.setStyleName("ks-help-popup");
 67  0
                 button.addMouseOverHandler(new MouseOverHandler(){
 68  
 
 69  
                         @Override
 70  
                         public void onMouseOver(MouseOverEvent event) {
 71  0
                                 hoverPopup.setPopupPosition(button.getAbsoluteLeft() + button.getOffsetWidth() + 5, 
 72  
                                                 button.getAbsoluteTop());
 73  0
                                 hoverPopup.show();
 74  0
                         }
 75  
                 });
 76  0
                 button.addMouseOutHandler(new MouseOutHandler(){
 77  
 
 78  
                         @Override
 79  
                         public void onMouseOut(MouseOutEvent event) {
 80  0
                                 hoverPopup.hide();
 81  0
                         }
 82  
                 });
 83  
                 
 84  0
         }
 85  
 
 86  
         @Override
 87  
         public HandlerRegistration addClickHandler(ClickHandler handler) {
 88  0
                 return button.addClickHandler(handler);
 89  
         }
 90  
 
 91  
         @Override
 92  
         public HandlerRegistration addMouseOverHandler(MouseOverHandler handler) {
 93  0
                 return button.addMouseOverHandler(handler);
 94  
         }
 95  
 
 96  
         @Override
 97  
         public HandlerRegistration addMouseOutHandler(MouseOutHandler handler) {
 98  0
                 return button.addMouseOutHandler(handler);
 99  
         }
 100  
 }