View Javadoc

1   /**
2    * Copyright 2010 The Kuali Foundation Licensed under the
3    * Educational Community License, Version 2.0 (the "License"); you may
4    * not use this file except in compliance with the License. You may
5    * obtain a copy of the License at
6    *
7    * http://www.osedu.org/licenses/ECL-2.0
8    *
9    * Unless required by applicable law or agreed to in writing,
10   * software distributed under the License is distributed on an "AS IS"
11   * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12   * or implied. See the License for the specific language governing
13   * permissions and limitations under the License.
14   */
15  
16  package org.kuali.student.common.ui.client.widgets.containers;
17  
18  import org.kuali.student.common.ui.client.theme.Theme;
19  import org.kuali.student.common.ui.client.widgets.KSLabel;
20  import org.kuali.student.common.ui.client.widgets.layout.HorizontalBlockFlowPanel;
21  import org.kuali.student.common.ui.client.widgets.layout.VerticalFlowPanel;
22  
23  import com.google.gwt.user.client.ui.Composite;
24  import com.google.gwt.user.client.ui.HasHorizontalAlignment;
25  import com.google.gwt.user.client.ui.HorizontalPanel;
26  import com.google.gwt.user.client.ui.SimplePanel;
27  import com.google.gwt.user.client.ui.VerticalPanel;
28  import com.google.gwt.user.client.ui.Widget;
29  
30  public class KSTitleContainerImpl extends Composite{
31  	private String title;
32  	private String status;
33  	private String linkText;
34  	private KSLabel titleLabel = new KSLabel();
35  	private KSLabel statusLabel = new KSLabel();
36  	private KSLabel linkLabel = new KSLabel();
37  	private SimplePanel parentContainer = new SimplePanel();
38  	private SimplePanel toolbar = new SimplePanel();
39  	private VerticalFlowPanel messagePanel = new VerticalFlowPanel();
40  	private SimplePanel content = new SimplePanel();
41  	private VerticalPanel layout = new VerticalPanel();
42  	private VerticalPanel rightContent = new VerticalPanel();
43  	private HorizontalPanel top = new HorizontalPanel();
44  	
45  	public KSTitleContainerImpl(){
46  		createLayout();
47  	}
48  	
49  	public KSTitleContainerImpl(String title, String status, String link){
50  		this.setTitle(title);
51  		this.setStatus(status);
52  		this.setLinkText(link);
53  		createLayout();
54  	}
55  	
56  	public KSTitleContainerImpl(String title, String status){
57  		this.setTitle(title);
58  		this.setStatus(status);
59  		createLayout();
60  	}
61  	
62  	public KSTitleContainerImpl(String title){
63  		this.setTitle(title);
64  		createLayout();
65  	}
66  	
67  	private void createLayout(){
68  		top.add(titleLabel);
69  		rightContent.add(statusLabel);
70  		rightContent.add(linkLabel);
71  		rightContent.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
72  		rightContent.setCellHorizontalAlignment(linkLabel, HasHorizontalAlignment.ALIGN_RIGHT);
73  		rightContent.setCellHorizontalAlignment(statusLabel, HasHorizontalAlignment.ALIGN_RIGHT);
74  		top.add(rightContent);
75  		layout.add(top);
76  		layout.add(toolbar);
77  		layout.add(messagePanel);
78  		layout.add(content);
79  		linkLabel.addStyleName("KS-TitleContainer-Link");
80  		statusLabel.addStyleName("KS-TitleContainer-Status");
81  		titleLabel.addStyleName("KS-TitleContainer-Title");
82  		top.addStyleName("KS-TitleContainer-Top-Row");
83  		toolbar.addStyleName("KS-TitleContainer-Toolbar");
84  		messagePanel.addStyleName("KS-TitleContainer-Messages");
85  		rightContent.addStyleName("KS-TitleContainer-Right-Panel");
86  		layout.addStyleName("KS-TitleContainer-Layout");
87  		parentContainer.addStyleName("KS-Drop-Shadow");
88  		parentContainer.addStyleName("KS-TitleContainer");
89  		parentContainer.setWidget(layout);
90  		this.initWidget(parentContainer);
91  	}
92  	
93  	public String getTitle() {
94  		return title;
95  	}
96  	
97  	public void setTitle(String title) {
98  		this.title = title;
99  		titleLabel.setText(title);
100 	}
101 	
102 	public String getStatus() {
103 		return status;
104 	}
105 	
106 	public void setStatus(String status) {
107 		this.status = status;
108 		statusLabel.setText(status);
109 	}
110 	
111 	public String getLinkText() {
112 		return linkText;
113 	}
114 
115 	public void setLinkText(String linkText) {
116 		this.linkText = linkText;
117 		linkLabel.setText(linkText);
118 	}
119 
120 	public void setContent(Widget contentWidget) {
121 		content.setWidget(contentWidget);		
122 	}
123 	
124 	public void setToolbar(Widget toolbarWidget) {
125 		toolbar.setWidget(toolbarWidget);
126 	}
127 	
128 	public void addMessage(String message){
129 		HorizontalBlockFlowPanel staticMessagePanel = new HorizontalBlockFlowPanel();
130 		staticMessagePanel.addStyleName("KS-Message-Static");
131 		staticMessagePanel.add(Theme.INSTANCE.getCommonImages().getWarningDiamondIcon());
132 		staticMessagePanel.add(new KSLabel(message));
133 		messagePanel.add(staticMessagePanel);		
134 	}
135 	
136 	public void clearMessages(){
137 		messagePanel.clear();
138 	}
139 }