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