| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package org.kuali.student.common.ui.client.widgets.field.layout.layouts; |
| 17 | |
|
| 18 | |
import java.util.HashMap; |
| 19 | |
import java.util.Map; |
| 20 | |
|
| 21 | |
import org.kuali.student.common.ui.client.configurable.mvc.SectionTitle; |
| 22 | |
import org.kuali.student.common.ui.client.configurable.mvc.sections.ValidationMessagePanel; |
| 23 | |
import org.kuali.student.common.ui.client.widgets.field.layout.button.ButtonLayout; |
| 24 | |
import org.kuali.student.common.ui.client.widgets.field.layout.element.FieldElement; |
| 25 | |
import org.kuali.student.common.ui.client.widgets.field.layout.element.SpanPanel; |
| 26 | |
|
| 27 | |
import com.google.gwt.user.client.ui.FlowPanel; |
| 28 | |
import com.google.gwt.user.client.ui.Widget; |
| 29 | |
|
| 30 | |
|
| 31 | |
|
| 32 | |
|
| 33 | |
|
| 34 | |
|
| 35 | |
|
| 36 | |
|
| 37 | |
|
| 38 | |
public class VerticalFieldLayout extends FieldLayout { |
| 39 | 0 | private Map<String, FlowPanel> fieldContainers = new HashMap<String, FlowPanel>(); |
| 40 | |
|
| 41 | 0 | protected FlowPanel verticalLayout = new FlowPanel(); |
| 42 | 0 | private SpanPanel buttonArea = new SpanPanel(); |
| 43 | |
|
| 44 | |
public VerticalFieldLayout() { |
| 45 | 0 | super(); |
| 46 | 0 | hasValidation = true; |
| 47 | 0 | init(); |
| 48 | 0 | } |
| 49 | |
|
| 50 | |
public VerticalFieldLayout(boolean hasValidation) { |
| 51 | 0 | super(); |
| 52 | 0 | this.hasValidation = hasValidation; |
| 53 | 0 | init(); |
| 54 | 0 | } |
| 55 | |
|
| 56 | |
public VerticalFieldLayout(SectionTitle title) { |
| 57 | 0 | super(); |
| 58 | 0 | this.setLayoutTitle(title); |
| 59 | 0 | this.hasValidation = true; |
| 60 | 0 | init(); |
| 61 | 0 | } |
| 62 | |
|
| 63 | |
public VerticalFieldLayout(Widget titleWidget) { |
| 64 | 0 | super(); |
| 65 | 0 | this.setTitleWidget(titleWidget); |
| 66 | 0 | this.hasValidation = true; |
| 67 | 0 | init(); |
| 68 | 0 | } |
| 69 | |
|
| 70 | |
public VerticalFieldLayout(SectionTitle title, boolean hasValidation) { |
| 71 | 0 | super(); |
| 72 | 0 | this.setLayoutTitle(title); |
| 73 | 0 | this.hasValidation = hasValidation; |
| 74 | 0 | init(); |
| 75 | 0 | } |
| 76 | |
|
| 77 | |
private void init() { |
| 78 | 0 | instructions.setVisible(false); |
| 79 | 0 | this.add(verticalLayout); |
| 80 | 0 | verticalLayout.add(instructions); |
| 81 | 0 | verticalLayout.add(message); |
| 82 | 0 | this.add(buttonArea); |
| 83 | 0 | verticalLayout.setStyleName("ks-form-module"); |
| 84 | 0 | } |
| 85 | |
|
| 86 | |
|
| 87 | |
@Override |
| 88 | |
public void addFieldToLayout(FieldElement field) { |
| 89 | 0 | FlowPanel fieldContainer = new FlowPanel(); |
| 90 | 0 | FlowPanel fieldLayout = new FlowPanel(); |
| 91 | 0 | fieldContainer.add(field); |
| 92 | 0 | fieldLayout.add(fieldContainer); |
| 93 | 0 | if (hasValidation) { |
| 94 | 0 | ValidationMessagePanel validationPanel = new ValidationMessagePanel(); |
| 95 | 0 | fieldLayout.add(validationPanel); |
| 96 | 0 | field.setValidationPanel(validationPanel); |
| 97 | 0 | validationPanel.setStyleName("ks-form-module-validation-inline"); |
| 98 | |
} |
| 99 | 0 | field.setParentPanel(fieldLayout); |
| 100 | 0 | verticalLayout.add(fieldLayout); |
| 101 | 0 | fieldContainers.put(field.getKey(), fieldLayout); |
| 102 | 0 | fieldLayout.setStyleName("ks-form-module-group"); |
| 103 | 0 | fieldLayout.addStyleName("clearfix"); |
| 104 | |
|
| 105 | 0 | fieldContainer.setStyleName("ks-form-module-fields"); |
| 106 | 0 | } |
| 107 | |
|
| 108 | |
@Override |
| 109 | |
public void addLayoutToLayout(FieldLayout layout) { |
| 110 | 0 | verticalLayout.add(layout); |
| 111 | 0 | layout.setParentLayout(this); |
| 112 | 0 | } |
| 113 | |
|
| 114 | |
@Override |
| 115 | |
public void addWidgetToLayout(Widget widget) { |
| 116 | 0 | widget.addStyleName("ks-section-widget"); |
| 117 | 0 | verticalLayout.add(widget); |
| 118 | 0 | } |
| 119 | |
|
| 120 | |
@Override |
| 121 | |
public void removeWidgetFromLayout(Widget widget) { |
| 122 | 0 | verticalLayout.remove(widget); |
| 123 | 0 | } |
| 124 | |
|
| 125 | |
@Override |
| 126 | |
public void removeFieldLayoutComponentFromLayout(FieldLayoutComponent component) { |
| 127 | 0 | if (component instanceof FieldElement) { |
| 128 | 0 | FlowPanel panel = fieldContainers.get(component.getKey()); |
| 129 | 0 | verticalLayout.remove(panel); |
| 130 | 0 | fieldContainers.remove(component.getKey()); |
| 131 | 0 | } else if (component instanceof FieldLayout) { |
| 132 | 0 | verticalLayout.remove((FieldLayout) component); |
| 133 | |
} |
| 134 | 0 | } |
| 135 | |
|
| 136 | |
@Override |
| 137 | |
public void setLayoutTitle(SectionTitle layoutTitle) { |
| 138 | 0 | if (this.layoutTitle != null) { |
| 139 | 0 | verticalLayout.remove(this.layoutTitle); |
| 140 | |
} |
| 141 | 0 | if (layoutTitle != null) { |
| 142 | 0 | this.layoutTitle = layoutTitle; |
| 143 | 0 | verticalLayout.insert(layoutTitle, 0); |
| 144 | 0 | layoutTitle.addStyleName("ks-layout-header"); |
| 145 | |
} |
| 146 | 0 | } |
| 147 | |
|
| 148 | |
public void setTitleWidget(Widget layoutTitle) { |
| 149 | 0 | if (this.layoutTitle != null) { |
| 150 | 0 | verticalLayout.remove(this.layoutTitle); |
| 151 | |
} |
| 152 | 0 | verticalLayout.insert(layoutTitle, 0); |
| 153 | 0 | } |
| 154 | |
|
| 155 | |
@Override |
| 156 | |
public void addButtonLayoutToLayout(ButtonLayout buttonLayout) { |
| 157 | 0 | buttonArea.add(buttonLayout); |
| 158 | |
|
| 159 | 0 | } |
| 160 | |
|
| 161 | |
public Map<String, FlowPanel> getFieldContainers() { |
| 162 | 0 | return fieldContainers; |
| 163 | |
} |
| 164 | |
|
| 165 | |
} |