View Javadoc

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  	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  	private boolean hasSeparator = true;
38  	public KSDocumentHeader() {
39  		initWidget(uiBinder.createAndBindUi(this));
40  		setupPrint();
41  	}
42  	
43  	public KSDocumentHeader(boolean hasContentWidgetSeparator) {
44  		this.hasSeparator = hasContentWidgetSeparator;
45  		initWidget(uiBinder.createAndBindUi(this));
46  		setupPrint();
47  	}
48  	
49  	private void setupPrint(){
50  		printImage.setVisible(false);
51  		printImage.addClickHandler(new ClickHandler(){
52  
53  			@Override
54  			public void onClick(ClickEvent event) {
55  				PrintUtils.print(ApplicationPanel.get().getWidget(0));
56  			}
57  		});
58  	}
59  	
60  	public void setTitle(String header){
61  		headerHTML.setHTML("<h2>"+header+"</h2>");
62  	}
63      public void addWidget(Widget w){
64      	if(w != null){
65      		if(hasSeparator){
66  	    		if(widgetPanel.getElement().hasChildNodes()){
67  	    			widgetPanel.add(new HTML("<span style='float: left; margin-left: .7em; margin-right: .7em'>|</span>"));
68  	    		}
69      		}
70      		widgetPanel.add(w);
71      	}
72      	w.getElement().setAttribute("style", "float: left");
73      }
74      
75      public HTML getInfoLabel(){
76      	return infoLabel;
77      }
78      
79      public void showPrint(boolean show){
80      	printImage.setVisible(true);
81      }
82  }