View Javadoc

1   package org.kuali.student.common.ui.client.widgets.layout;
2   
3   import org.kuali.student.common.ui.client.configurable.mvc.SectionTitle;
4   
5   import com.google.gwt.user.client.ui.FlowPanel;
6   import com.google.gwt.user.client.ui.Label;
7   import com.google.gwt.user.client.ui.Widget;
8   
9   /**
10   * A layout which contains content blocks, used for a layout which contains logical blocks of content.
11   * Each row contains a space of 3 blocks, and depending on size of blocks added will wrap to the next line.
12   * 
13   * @author Kuali Student Team
14   *
15   */
16  public class ContentBlockLayout extends VerticalFlowPanel{
17  	
18  	private SectionTitle sectionTitle = SectionTitle.generateH1Title("");
19  	private FlowPanel titlePanel = new FlowPanel();
20  	//private FlowPanel blockPanel = new FlowPanel();
21  	private FlowPanel currentRow;
22  	private int rowSize = 0;
23  	private int titleWidgetCount = 0;
24  	
25  	public ContentBlockLayout(String title){
26  		this.setContentTitle(title);
27  		titlePanel.add(sectionTitle);
28  		this.add(titlePanel);
29  		//this.add(blockPanel);
30  		sectionTitle.addStyleName("blockLayout-title");
31  		titlePanel.addStyleName("blockLayout-titlePanel");
32  		//blockPanel.addStyleName("blockLayout-content");
33  		this.addStyleName("blockLayout");
34  	}
35  	
36  	public void setContentTitle(String title){
37  		sectionTitle.setText(title);
38  	}
39  	
40  	public void addContentTitleWidget(Widget widget){
41  		
42  		if(titleWidgetCount != 0){
43  			Label separator = new Label(" | ");
44  			separator.addStyleName("titleWidget-separator");
45  			separator.addStyleName("blockLayout-title-widget");
46  			titlePanel.add(separator);
47  			titlePanel.add(widget);
48  		}
49  		else{
50  			titlePanel.add(widget);
51  		}
52  		widget.addStyleName("blockLayout-title-widget");
53  		titleWidgetCount++;
54  	}
55  	
56  	public void addContentBlock(ContentBlock block){
57  		if(rowSize == 0){
58  			FlowPanel row = new FlowPanel();
59  			this.add(row);
60  			row.addStyleName("blockLayout-row");
61  			currentRow = row;
62  		}
63  		currentRow.add(block);
64  		rowSize = rowSize + block.getBlockSize();
65  		if(rowSize == 3){
66  			rowSize = 0;
67  		}
68  		block.addStyleName("blockLayout-blockPadding");
69  	}
70  }