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 | |
public class ContentBlockLayout extends VerticalFlowPanel{ |
10 | |
|
11 | 0 | private SectionTitle sectionTitle = SectionTitle.generateH1Title(""); |
12 | 0 | private FlowPanel titlePanel = new FlowPanel(); |
13 | |
|
14 | |
private FlowPanel currentRow; |
15 | 0 | private int rowSize = 0; |
16 | 0 | private int titleWidgetCount = 0; |
17 | |
|
18 | 0 | public ContentBlockLayout(String title){ |
19 | 0 | this.setContentTitle(title); |
20 | 0 | titlePanel.add(sectionTitle); |
21 | 0 | this.add(titlePanel); |
22 | |
|
23 | 0 | sectionTitle.addStyleName("blockLayout-title"); |
24 | 0 | titlePanel.addStyleName("blockLayout-titlePanel"); |
25 | |
|
26 | 0 | this.addStyleName("blockLayout"); |
27 | 0 | } |
28 | |
|
29 | |
public void setContentTitle(String title){ |
30 | 0 | sectionTitle.setText(title); |
31 | 0 | } |
32 | |
|
33 | |
public void addContentTitleWidget(Widget widget){ |
34 | |
|
35 | 0 | if(titleWidgetCount != 0){ |
36 | 0 | Label separator = new Label(" | "); |
37 | 0 | separator.addStyleName("titleWidget-separator"); |
38 | 0 | separator.addStyleName("blockLayout-title-widget"); |
39 | 0 | titlePanel.add(separator); |
40 | 0 | titlePanel.add(widget); |
41 | 0 | } |
42 | |
else{ |
43 | 0 | titlePanel.add(widget); |
44 | |
} |
45 | 0 | widget.addStyleName("blockLayout-title-widget"); |
46 | 0 | titleWidgetCount++; |
47 | 0 | } |
48 | |
|
49 | |
public void addContentBlock(ContentBlock block){ |
50 | 0 | if(rowSize == 0){ |
51 | 0 | FlowPanel row = new FlowPanel(); |
52 | 0 | this.add(row); |
53 | 0 | row.addStyleName("blockLayout-row"); |
54 | 0 | currentRow = row; |
55 | |
} |
56 | 0 | currentRow.add(block); |
57 | 0 | rowSize = rowSize + block.getBlockSize(); |
58 | 0 | if(rowSize == 3){ |
59 | 0 | rowSize = 0; |
60 | |
} |
61 | 0 | block.addStyleName("blockLayout-blockPadding"); |
62 | 0 | } |
63 | |
} |