| 1 |  |   | 
  | 2 |  |   | 
  | 3 |  |   | 
  | 4 |  |   | 
  | 5 |  |   | 
  | 6 |  |   | 
  | 7 |  |   | 
  | 8 |  |   | 
  | 9 |  |   | 
  | 10 |  |   | 
  | 11 |  |   | 
  | 12 |  |   | 
  | 13 |  |   | 
  | 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 |  |   | 
  | 36 |  |   | 
  | 37 |  |   | 
  | 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 |  |  } |