| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
package org.kuali.student.common.ui.client.widgets.notification; |
| 17 |
|
|
| 18 |
|
import com.google.gwt.dom.client.Element; |
| 19 |
|
import com.google.gwt.event.dom.client.ClickEvent; |
| 20 |
|
import com.google.gwt.event.dom.client.ClickHandler; |
| 21 |
|
import com.google.gwt.event.dom.client.MouseOutEvent; |
| 22 |
|
import com.google.gwt.event.dom.client.MouseOutHandler; |
| 23 |
|
import com.google.gwt.event.dom.client.MouseOverEvent; |
| 24 |
|
import com.google.gwt.event.dom.client.MouseOverHandler; |
| 25 |
|
import com.google.gwt.event.logical.shared.CloseEvent; |
| 26 |
|
import com.google.gwt.event.logical.shared.CloseHandler; |
| 27 |
|
import com.google.gwt.event.logical.shared.HasCloseHandlers; |
| 28 |
|
import com.google.gwt.event.shared.HandlerRegistration; |
| 29 |
|
import com.google.gwt.user.client.DOM; |
| 30 |
|
import com.google.gwt.user.client.Event; |
| 31 |
|
import com.google.gwt.user.client.ui.Composite; |
| 32 |
|
import com.google.gwt.user.client.ui.HTML; |
| 33 |
|
import com.google.gwt.user.client.ui.HTMLPanel; |
| 34 |
|
import com.google.gwt.user.client.ui.Widget; |
| 35 |
|
|
|
|
|
| 0% |
Uncovered Elements: 60 (60) |
Complexity: 17 |
Complexity Density: 0.44 |
|
| 36 |
|
public class KSNotification extends Composite implements HasCloseHandlers<KSNotification>{ |
| 37 |
|
private final int duration; |
| 38 |
|
public static final int DEFAULT_DURATION = 4000; |
| 39 |
|
private final String id = HTMLPanel.createUniqueId(); |
| 40 |
|
private final String contentId = HTMLPanel.createUniqueId(); |
| 41 |
|
private final String closeLinkId = HTMLPanel.createUniqueId(); |
| 42 |
|
private final HTMLPanel panel = new HTMLPanel("<p id='" + contentId + "'></p><a href='javascript:return false;' title='Close' class='ks-notification-close' style='visibility: hidden' id='" + closeLinkId + "'></a>"); |
| 43 |
|
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 2 |
Complexity Density: 0.25 |
|
| 44 |
0
|
public KSNotification(final String message, boolean isHtml, final int duration) {... |
| 45 |
0
|
this.duration = duration; |
| 46 |
0
|
panel.setStyleName("ks-notification-message"); |
| 47 |
0
|
panel.getElement().setId(id); |
| 48 |
|
|
| 49 |
0
|
if (isHtml) { |
| 50 |
0
|
panel.add(new HTML(message), contentId); |
| 51 |
|
} else { |
| 52 |
0
|
panel.getElementById(contentId).setInnerText(message); |
| 53 |
|
} |
| 54 |
|
|
| 55 |
0
|
initHandlers(); |
| 56 |
0
|
super.initWidget(panel); |
| 57 |
|
} |
| 58 |
|
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 59 |
0
|
public KSNotification(final String message, boolean isHtml, boolean isError, final int duration) {... |
| 60 |
0
|
this(message, isHtml, duration); |
| 61 |
0
|
if (isError){ |
| 62 |
0
|
panel.setStyleName("ks-notification-error"); |
| 63 |
|
} |
| 64 |
|
} |
| 65 |
|
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 2 |
Complexity Density: 0.25 |
|
| 66 |
0
|
public KSNotification(final String message, boolean isHtml) {... |
| 67 |
0
|
this.duration = DEFAULT_DURATION; |
| 68 |
0
|
panel.setStyleName("ks-notification-message"); |
| 69 |
0
|
panel.getElement().setId(id); |
| 70 |
|
|
| 71 |
0
|
if (isHtml) { |
| 72 |
0
|
panel.add(new HTML(message), contentId); |
| 73 |
|
} else { |
| 74 |
0
|
panel.getElementById(contentId).setInnerText(message); |
| 75 |
|
} |
| 76 |
|
|
| 77 |
0
|
initHandlers(); |
| 78 |
0
|
super.initWidget(panel); |
| 79 |
|
} |
| 80 |
|
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
| 81 |
0
|
public KSNotification(final Widget widget, final int duration) {... |
| 82 |
0
|
this.duration = duration; |
| 83 |
0
|
panel.setStyleName("ks-notification-message"); |
| 84 |
0
|
panel.getElement().setId(id); |
| 85 |
0
|
panel.add(widget, contentId); |
| 86 |
|
|
| 87 |
0
|
initHandlers(); |
| 88 |
0
|
super.initWidget(panel); |
| 89 |
|
} |
| 90 |
|
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 91 |
0
|
private void initHandlers() {... |
| 92 |
0
|
addDomHandler(new MouseOverHandler() { |
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 93 |
0
|
@Override... |
| 94 |
|
public void onMouseOver(MouseOverEvent event) { |
| 95 |
0
|
DOM.getElementById(closeLinkId).getStyle().setProperty("visibility", "visible"); |
| 96 |
|
} |
| 97 |
|
}, MouseOverEvent.getType()); |
| 98 |
|
|
| 99 |
0
|
addDomHandler(new MouseOutHandler() { |
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 100 |
0
|
@Override... |
| 101 |
|
public void onMouseOut(MouseOutEvent event) { |
| 102 |
0
|
DOM.getElementById(closeLinkId).getStyle().setProperty("visibility", "hidden"); |
| 103 |
|
} |
| 104 |
|
}, MouseOutEvent.getType()); |
| 105 |
|
|
| 106 |
0
|
DOM.sinkEvents(panel.getElementById(closeLinkId), Event.ONCLICK); |
| 107 |
0
|
addDomHandler(new ClickHandler() { |
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 108 |
0
|
@Override... |
| 109 |
|
public void onClick(ClickEvent event) { |
| 110 |
0
|
Element e = Element.as(event.getNativeEvent().getEventTarget()); |
| 111 |
0
|
if (e.equals(panel.getElementById(closeLinkId))) { |
| 112 |
0
|
CloseEvent.fire(KSNotification.this, KSNotification.this); |
| 113 |
|
} |
| 114 |
|
} |
| 115 |
|
}, ClickEvent.getType()); |
| 116 |
|
} |
| 117 |
|
|
| 118 |
|
|
| 119 |
|
@return |
| 120 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 121 |
0
|
public int getDuration() {... |
| 122 |
0
|
return duration; |
| 123 |
|
} |
| 124 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 125 |
0
|
public String getId() {... |
| 126 |
0
|
return id; |
| 127 |
|
} |
| 128 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 129 |
0
|
public String getContentId() {... |
| 130 |
0
|
return contentId; |
| 131 |
|
} |
| 132 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 133 |
0
|
public String getCloseLinkId() {... |
| 134 |
0
|
return closeLinkId; |
| 135 |
|
} |
| 136 |
|
|
| 137 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 138 |
0
|
@Override... |
| 139 |
|
public HandlerRegistration addCloseHandler( |
| 140 |
|
CloseHandler<KSNotification> handler) { |
| 141 |
0
|
return addHandler(handler, CloseEvent.getType()); |
| 142 |
|
} |
| 143 |
|
} |