1 | |
package org.kuali.student.common.ui.client.widgets.headers; |
2 | |
|
3 | |
import org.kuali.student.common.ui.client.util.PrintUtils; |
4 | |
import org.kuali.student.common.ui.client.widgets.ApplicationPanel; |
5 | |
import org.kuali.student.common.ui.client.widgets.field.layout.element.SpanPanel; |
6 | |
|
7 | |
import com.google.gwt.core.client.GWT; |
8 | |
import com.google.gwt.event.dom.client.ClickEvent; |
9 | |
import com.google.gwt.event.dom.client.ClickHandler; |
10 | |
import com.google.gwt.uibinder.client.UiBinder; |
11 | |
import com.google.gwt.uibinder.client.UiField; |
12 | |
import com.google.gwt.user.client.ui.Composite; |
13 | |
import com.google.gwt.user.client.ui.HTML; |
14 | |
import com.google.gwt.user.client.ui.Image; |
15 | |
import com.google.gwt.user.client.ui.Widget; |
16 | |
|
17 | |
public class KSDocumentHeader extends Composite { |
18 | |
|
19 | 0 | private static KSDocumentHeaderUiBinder uiBinder = GWT |
20 | |
.create(KSDocumentHeaderUiBinder.class); |
21 | |
|
22 | |
interface KSDocumentHeaderUiBinder extends |
23 | |
UiBinder<Widget, KSDocumentHeader> { |
24 | |
} |
25 | |
@UiField |
26 | |
HTML headerHTML; |
27 | |
|
28 | |
@UiField |
29 | |
HTML infoLabel; |
30 | |
|
31 | |
@UiField |
32 | |
SpanPanel widgetPanel; |
33 | |
|
34 | |
@UiField |
35 | |
Image printImage; |
36 | |
|
37 | 0 | private boolean hasSeparator = true; |
38 | 0 | public KSDocumentHeader() { |
39 | 0 | initWidget(uiBinder.createAndBindUi(this)); |
40 | 0 | setupPrint(); |
41 | 0 | } |
42 | |
|
43 | 0 | public KSDocumentHeader(boolean hasContentWidgetSeparator) { |
44 | 0 | this.hasSeparator = hasContentWidgetSeparator; |
45 | 0 | initWidget(uiBinder.createAndBindUi(this)); |
46 | 0 | setupPrint(); |
47 | 0 | } |
48 | |
|
49 | |
private void setupPrint(){ |
50 | 0 | printImage.setVisible(false); |
51 | 0 | printImage.addClickHandler(new ClickHandler(){ |
52 | |
|
53 | |
@Override |
54 | |
public void onClick(ClickEvent event) { |
55 | 0 | PrintUtils.print(ApplicationPanel.get().getWidget(0)); |
56 | 0 | } |
57 | |
}); |
58 | 0 | } |
59 | |
|
60 | |
public void setTitle(String header){ |
61 | 0 | headerHTML.setHTML("<h2>"+header+"</h2>"); |
62 | 0 | } |
63 | |
public void addWidget(Widget w){ |
64 | 0 | if(w != null){ |
65 | 0 | if(hasSeparator){ |
66 | 0 | if(widgetPanel.getElement().hasChildNodes()){ |
67 | 0 | widgetPanel.add(new HTML("<span style='float: left; margin-left: .7em; margin-right: .7em'>|</span>")); |
68 | |
} |
69 | |
} |
70 | 0 | widgetPanel.add(w); |
71 | |
} |
72 | 0 | w.getElement().setAttribute("style", "float: left"); |
73 | 0 | } |
74 | |
|
75 | |
public HTML getInfoLabel(){ |
76 | 0 | return infoLabel; |
77 | |
} |
78 | |
|
79 | |
public void showPrint(boolean show){ |
80 | 0 | printImage.setVisible(true); |
81 | 0 | } |
82 | |
} |