View Javadoc

1   package org.kuali.student.common.ui.client.configurable.mvc.sections;
2   
3   import org.kuali.student.common.ui.client.theme.Theme;
4   
5   import com.google.gwt.user.client.ui.Composite;
6   import com.google.gwt.user.client.ui.FlowPanel;
7   import com.google.gwt.user.client.ui.Image;
8   import com.google.gwt.user.client.ui.Widget;
9   
10  /**
11   * An information message which can change its style to appear with a warning around the
12   * content and add additional information to its layout when it needs to warn the user about the contained
13   * information/widget functionality before they interact with it.
14   * @author Kuali Student Team
15   *
16   */
17  public class WarnContainer extends Composite{
18  	private Image icon = Theme.INSTANCE.getCommonImages().getWarningDiamondIcon();
19  	private FlowPanel layout = new FlowPanel();
20  	private FlowPanel normalLayout = new FlowPanel();
21  	private FlowPanel warnLayout = new FlowPanel();
22  	
23  	public WarnContainer(){
24  		icon.addStyleName("ks-message-static-image");
25  		normalLayout.addStyleName("ks-message-static-margin");
26  		layout.add(icon);
27  		layout.add(normalLayout);
28  		layout.add(warnLayout);
29  		this.initWidget(layout);
30  	}
31  	
32  	public WarnContainer(boolean shown){
33  		icon.addStyleName("ks-message-static-image");
34  		normalLayout.addStyleName("ks-message-static-margin");
35  		layout.add(icon);
36  		layout.add(normalLayout);
37  		layout.add(warnLayout);
38  		this.initWidget(layout);
39  		this.showWarningLayout(shown);
40  	}
41  	
42  	public void add(Widget w){
43  		normalLayout.add(w);
44  	}
45  	
46  	//Adds to same line
47  	public void addWarnWidget(Widget w){
48  		warnLayout.add(w);
49  		w.getElement().setAttribute("style", "display: inline");
50  	}
51  	
52  	//Adds to newline
53  	public void addWarnWidgetBlock(Widget w){	// KSLAB-1985
54  		warnLayout.add(w);
55  		w.getElement().setAttribute("style", "display: block");
56  	}
57  	
58  	public void clearWarnLayout(){	
59  		warnLayout.clear();
60  	}
61  	
62  	public void showWarningLayout(boolean show){
63  		icon.setVisible(show);
64  		warnLayout.setVisible(show);
65  		if(show){
66  			layout.addStyleName("ks-message-static");
67  		}
68  		else{
69  
70  			layout.removeStyleName("ks-message-static");
71  		}
72  	}
73  
74  }