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 | 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 | |
} |