| 1 |
|
package org.kuali.student.common.ui.client.widgets.headers; |
| 2 |
|
|
| 3 |
|
import org.kuali.student.common.ui.client.configurable.mvc.LayoutController; |
| 4 |
|
import org.kuali.student.common.ui.client.mvc.Callback; |
| 5 |
|
import org.kuali.student.common.ui.client.mvc.Controller; |
| 6 |
|
import org.kuali.student.common.ui.client.util.ExportUtils; |
| 7 |
|
import org.kuali.student.common.ui.client.util.PrintUtils; |
| 8 |
|
import org.kuali.student.common.ui.client.widgets.ApplicationPanel; |
| 9 |
|
import org.kuali.student.common.ui.client.widgets.dialog.ReportExportDialog; |
| 10 |
|
import org.kuali.student.common.ui.client.widgets.field.layout.element.SpanPanel; |
| 11 |
|
|
| 12 |
|
import com.google.gwt.core.client.GWT; |
| 13 |
|
import com.google.gwt.event.dom.client.ClickEvent; |
| 14 |
|
import com.google.gwt.event.dom.client.ClickHandler; |
| 15 |
|
import com.google.gwt.event.dom.client.MouseOutEvent; |
| 16 |
|
import com.google.gwt.event.dom.client.MouseOutHandler; |
| 17 |
|
import com.google.gwt.event.dom.client.MouseOverEvent; |
| 18 |
|
import com.google.gwt.event.dom.client.MouseOverHandler; |
| 19 |
|
import com.google.gwt.uibinder.client.UiBinder; |
| 20 |
|
import com.google.gwt.uibinder.client.UiField; |
| 21 |
|
import com.google.gwt.user.client.ui.Composite; |
| 22 |
|
import com.google.gwt.user.client.ui.HTML; |
| 23 |
|
import com.google.gwt.user.client.ui.HTMLPanel; |
| 24 |
|
import com.google.gwt.user.client.ui.Image; |
| 25 |
|
import com.google.gwt.user.client.ui.PopupPanel; |
| 26 |
|
import com.google.gwt.user.client.ui.Widget; |
| 27 |
|
|
|
|
|
| 0% |
Uncovered Elements: 81 (81) |
Complexity: 25 |
Complexity Density: 0.5 |
|
| 28 |
|
public class KSDocumentHeader extends Composite { |
| 29 |
|
|
| 30 |
|
private static KSDocumentHeaderUiBinder uiBinder = GWT.create(KSDocumentHeaderUiBinder.class); |
| 31 |
|
|
| 32 |
|
private ReportExportDialog exportDialog = null; |
| 33 |
|
|
| 34 |
|
private PopupPanel hoverPopup = new PopupPanel(); |
| 35 |
|
|
| 36 |
|
private PopupPanel hoverPopup1 = new PopupPanel(); |
| 37 |
|
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 0 |
Complexity Density: - |
|
| 38 |
|
interface KSDocumentHeaderUiBinder extends UiBinder<Widget, KSDocumentHeader> {} |
| 39 |
|
|
| 40 |
|
@UiField |
| 41 |
|
HTML headerHTML; |
| 42 |
|
|
| 43 |
|
@UiField |
| 44 |
|
HTML infoLabel; |
| 45 |
|
|
| 46 |
|
@UiField |
| 47 |
|
SpanPanel widgetPanel; |
| 48 |
|
|
| 49 |
|
@UiField |
| 50 |
|
Image printImage; |
| 51 |
|
|
| 52 |
|
@UiField |
| 53 |
|
Image exportImage; |
| 54 |
|
|
| 55 |
|
private Widget printContent = null; |
| 56 |
|
|
| 57 |
|
private boolean hasSeparator = true; |
| 58 |
|
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 59 |
0
|
public KSDocumentHeader() {... |
| 60 |
0
|
initWidget(uiBinder.createAndBindUi(this)); |
| 61 |
0
|
setupPrint(); |
| 62 |
0
|
setupExportPrint(); |
| 63 |
|
} |
| 64 |
|
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 65 |
0
|
public KSDocumentHeader(boolean hasContentWidgetSeparator) {... |
| 66 |
0
|
this.hasSeparator = hasContentWidgetSeparator; |
| 67 |
0
|
initWidget(uiBinder.createAndBindUi(this)); |
| 68 |
0
|
setupPrint(); |
| 69 |
0
|
setupExportPrint(); |
| 70 |
|
} |
| 71 |
|
|
| 72 |
|
|
| 73 |
|
|
| 74 |
|
|
| 75 |
|
@return |
| 76 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 77 |
0
|
public Widget getPrintContent(){... |
| 78 |
0
|
return this.printContent; |
| 79 |
|
} |
| 80 |
|
|
| 81 |
|
|
| 82 |
|
|
| 83 |
|
|
| 84 |
|
|
| 85 |
|
|
| 86 |
|
@param |
| 87 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 88 |
0
|
public void setPrintContent(Widget pContent){... |
| 89 |
0
|
this.printContent = pContent; |
| 90 |
|
} |
| 91 |
|
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 2 |
Complexity Density: 0.25 |
|
| 92 |
0
|
private void setupPrint() {... |
| 93 |
|
|
| 94 |
|
|
| 95 |
0
|
if(this.printContent == null){ |
| 96 |
0
|
this.setPrintContent(ApplicationPanel.get().getWidget(0)); |
| 97 |
|
} |
| 98 |
0
|
hoverPopup.add(new HTMLPanel("Print Page")); |
| 99 |
0
|
hoverPopup.setStyleName("ks-help-popup"); |
| 100 |
|
|
| 101 |
0
|
printImage.addMouseOverHandler(new MouseOverHandler(){ |
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 102 |
0
|
@Override... |
| 103 |
|
public void onMouseOver(MouseOverEvent event) { |
| 104 |
0
|
hoverPopup.setPopupPosition(printImage.getAbsoluteLeft()-10 , |
| 105 |
|
printImage.getAbsoluteTop()-exportImage.getOffsetWidth()-15); |
| 106 |
0
|
hoverPopup.show(); |
| 107 |
|
} |
| 108 |
|
}); |
| 109 |
0
|
printImage.addMouseOutHandler(new MouseOutHandler(){ |
| 110 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 111 |
0
|
@Override... |
| 112 |
|
public void onMouseOut(MouseOutEvent event) { |
| 113 |
0
|
hoverPopup.hide(); |
| 114 |
|
} |
| 115 |
|
}); |
| 116 |
0
|
printImage.setVisible(false); |
| 117 |
0
|
printImage.addClickHandler(new ClickHandler() { |
| 118 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 119 |
0
|
@Override... |
| 120 |
|
public void onClick(ClickEvent event) { |
| 121 |
0
|
PrintUtils.print(getPrintContent()); |
| 122 |
|
} |
| 123 |
|
}); |
| 124 |
|
} |
| 125 |
|
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
|
| 126 |
0
|
private void setupExportPrint() {... |
| 127 |
0
|
exportDialog = new ReportExportDialog(); |
| 128 |
0
|
exportImage.setVisible(false); |
| 129 |
0
|
hoverPopup1.add(new HTMLPanel("Export Summary to File")); |
| 130 |
0
|
hoverPopup1.setStyleName("ks-help-popup"); |
| 131 |
0
|
exportImage.addMouseOverHandler(new MouseOverHandler(){ |
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 132 |
0
|
@Override... |
| 133 |
|
public void onMouseOver(MouseOverEvent event) { |
| 134 |
0
|
hoverPopup1.setPopupPosition(exportImage.getAbsoluteLeft()-55, |
| 135 |
|
exportImage.getAbsoluteTop()-exportImage.getOffsetWidth()-15); |
| 136 |
0
|
hoverPopup1.show(); |
| 137 |
|
} |
| 138 |
|
}); |
| 139 |
0
|
exportImage.addMouseOutHandler(new MouseOutHandler(){ |
| 140 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 141 |
0
|
@Override... |
| 142 |
|
public void onMouseOut(MouseOutEvent event) { |
| 143 |
0
|
hoverPopup1.hide(); |
| 144 |
|
} |
| 145 |
|
}); |
| 146 |
|
|
| 147 |
0
|
exportImage.addClickHandler(new ClickHandler() { |
| 148 |
|
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
| 149 |
0
|
@Override... |
| 150 |
|
public void onClick(ClickEvent event) { |
| 151 |
0
|
if (exportDialog != null) { |
| 152 |
0
|
exportDialog.show(); |
| 153 |
|
} |
| 154 |
|
|
| 155 |
|
} |
| 156 |
|
}); |
| 157 |
|
|
| 158 |
0
|
exportDialog.addSelectCompleteCallback(new Callback<String>() { |
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
| 159 |
0
|
@Override... |
| 160 |
|
public void exec(String format) { |
| 161 |
0
|
Controller currController = ExportUtils.getController(KSDocumentHeader.this); |
| 162 |
0
|
String title = null; |
| 163 |
0
|
if (currController instanceof LayoutController) { |
| 164 |
0
|
title = ((LayoutController) currController).getName(); |
| 165 |
|
} |
| 166 |
0
|
ExportUtils.handleExportClickEvent(currController, format, title); |
| 167 |
|
} |
| 168 |
|
}); |
| 169 |
|
} |
| 170 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 171 |
0
|
public void setTitle(String header) {... |
| 172 |
0
|
headerHTML.setHTML("<h2>" + header + "</h2>"); |
| 173 |
|
} |
| 174 |
|
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 4 |
Complexity Density: 0.67 |
|
| 175 |
0
|
public void addWidget(Widget w) {... |
| 176 |
0
|
if (w != null) { |
| 177 |
0
|
if (hasSeparator) { |
| 178 |
0
|
if (widgetPanel.getElement().hasChildNodes()) { |
| 179 |
0
|
widgetPanel.add(new HTML("<span style='float: left; margin-left: .7em; margin-right: .7em'>|</span>")); |
| 180 |
|
} |
| 181 |
|
} |
| 182 |
0
|
widgetPanel.add(w); |
| 183 |
|
} |
| 184 |
0
|
w.getElement().setAttribute("style", "float: left"); |
| 185 |
|
} |
| 186 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 187 |
0
|
public HTML getInfoLabel() {... |
| 188 |
0
|
return infoLabel; |
| 189 |
|
} |
| 190 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 191 |
0
|
public void showPrint(boolean show) {... |
| 192 |
0
|
printImage.setVisible(true); |
| 193 |
|
} |
| 194 |
|
|
| 195 |
|
|
| 196 |
|
|
| 197 |
|
|
| 198 |
|
@param |
| 199 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 200 |
0
|
public void showExport(boolean show) {... |
| 201 |
0
|
exportImage.setVisible(show); |
| 202 |
|
|
| 203 |
|
} |
| 204 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 205 |
0
|
public Image getExportImage() {... |
| 206 |
0
|
return exportImage; |
| 207 |
|
} |
| 208 |
|
} |