Clover Coverage Report - Kuali Student 1.2-M4-SNAPSHOT (Aggregated)
Coverage timestamp: Wed Jul 20 2011 11:14:35 EDT
../../../../../../../../img/srcFileCovDistChart0.png 41% of files have more coverage
50   208   25   2.63
12   153   0.5   9.5
19     1.32  
2    
 
  KSDocumentHeader       Line # 28 50 0% 25 81 0% 0.0
  KSDocumentHeader.KSDocumentHeaderUiBinder       Line # 38 0 - 0 0 - -1.0
 
No Tests
 
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   
 
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   
 
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; // Widget to be printed.
56   
57    private boolean hasSeparator = true;
58   
 
59  0 toggle public KSDocumentHeader() {
60  0 initWidget(uiBinder.createAndBindUi(this));
61  0 setupPrint();
62  0 setupExportPrint();
63    }
64   
 
65  0 toggle 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    * returns the widget that will be printed
74    *
75    * @return
76    */
 
77  0 toggle public Widget getPrintContent(){
78  0 return this.printContent;
79    }
80   
81   
82    /**
83    * Takes a widget to be printed. This is useful when you want to
84    * print only a certain section of a page
85    *
86    * @param pContent
87    */
 
88  0 toggle public void setPrintContent(Widget pContent){
89  0 this.printContent = pContent;
90    }
91   
 
92  0 toggle private void setupPrint() {
93   
94    // Default to the old way of printing the entire page
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(){
 
102  0 toggle @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   
 
111  0 toggle @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   
 
119  0 toggle @Override
120    public void onClick(ClickEvent event) {
121  0 PrintUtils.print(getPrintContent());
122    }
123    });
124    }
125   
 
126  0 toggle 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(){
 
132  0 toggle @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   
 
141  0 toggle @Override
142    public void onMouseOut(MouseOutEvent event) {
143  0 hoverPopup1.hide();
144    }
145    });
146   
147  0 exportImage.addClickHandler(new ClickHandler() {
148   
 
149  0 toggle @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>() {
 
159  0 toggle @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   
 
171  0 toggle public void setTitle(String header) {
172  0 headerHTML.setHTML("<h2>" + header + "</h2>");
173    }
174   
 
175  0 toggle 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   
 
187  0 toggle public HTML getInfoLabel() {
188  0 return infoLabel;
189    }
190   
 
191  0 toggle public void showPrint(boolean show) {
192  0 printImage.setVisible(true);
193    }
194   
195    /**
196    * This method set the visibility of the export button to the value of the parameter
197    *
198    * @param show
199    */
 
200  0 toggle public void showExport(boolean show) {
201  0 exportImage.setVisible(show);
202   
203    }
204   
 
205  0 toggle public Image getExportImage() {
206  0 return exportImage;
207    }
208    }