Clover Coverage Report - KS Common 1.2-M6-SNAPSHOT (Aggregated)
Coverage timestamp: Mon Sep 12 2011 05:50:56 EDT
../../../../../../../../img/srcFileCovDistChart0.png 30% of files have more coverage
53   213   25   2.79
12   156   0.47   9.5
19     1.32  
2    
 
  KSDocumentHeader       Line # 28 53 0% 25 84 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    //for firefox the roll over message was not being hidden when
153    //export was clicked
154  0 hoverPopup1.hide();
155  0 exportDialog.show();
156    }
157   
158    }
159    });
160   
161  0 exportDialog.addSelectCompleteCallback(new Callback<String>() {
 
162  0 toggle @Override
163    public void exec(String format) {
164  0 Controller currController = ExportUtils.getController(KSDocumentHeader.this);
165  0 String title = null;
166  0 if (currController instanceof LayoutController) {
167  0 title = ((LayoutController) currController).getName();
168    }
169  0 ExportUtils.handleExportClickEvent(currController, format, title);
170    }
171    });
172    }
173   
 
174  0 toggle public void setTitle(String header) {
175  0 headerHTML.setHTML("<h2>" + header + "</h2>");
176    }
177   
 
178  0 toggle public void addWidget(Widget w) {
179  0 if (w != null) {
180  0 if (hasSeparator) {
181  0 if (widgetPanel.getElement().hasChildNodes()) {
182  0 HTML separatorWrapper = new HTML("<span style='float: left; margin-left: .7em; margin-right: .7em'>|</span>");
183  0 separatorWrapper.addStyleName("ks-documentHeader-widgetPanel");
184  0 widgetPanel.add(separatorWrapper);
185    }
186    }
187  0 w.addStyleName("ks-documentHeader-widgetPanel");
188  0 widgetPanel.add(w);
189    }
190    }
191   
 
192  0 toggle public HTML getInfoLabel() {
193  0 return infoLabel;
194    }
195   
 
196  0 toggle public void showPrint(boolean show) {
197  0 printImage.setVisible(true);
198    }
199   
200    /**
201    * This method set the visibility of the export button to the value of the parameter
202    *
203    * @param show
204    */
 
205  0 toggle public void showExport(boolean show) {
206  0 exportImage.setVisible(show);
207   
208    }
209   
 
210  0 toggle public Image getExportImage() {
211  0 return exportImage;
212    }
213    }