Coverage Report - org.kuali.student.common.ui.client.widgets.field.layout.layouts.TableFieldLayout
 
Classes in this File Line Coverage Branch Coverage Complexity
TableFieldLayout
0%
0/62
0%
0/8
1.364
 
 1  
 package org.kuali.student.common.ui.client.widgets.field.layout.layouts;
 2  
 
 3  
 import java.util.ArrayList;
 4  
 import java.util.List;
 5  
 
 6  
 import org.kuali.student.common.ui.client.configurable.mvc.SectionTitle;
 7  
 import org.kuali.student.common.ui.client.configurable.mvc.sections.ValidationMessagePanel;
 8  
 import org.kuali.student.common.ui.client.widgets.field.layout.button.ButtonLayout;
 9  
 import org.kuali.student.common.ui.client.widgets.field.layout.element.FieldElement;
 10  
 import org.kuali.student.common.ui.client.widgets.field.layout.element.SpanPanel;
 11  
 
 12  
 import com.google.gwt.user.client.ui.FlexTable;
 13  
 import com.google.gwt.user.client.ui.FlowPanel;
 14  
 import com.google.gwt.user.client.ui.Widget;
 15  
 
 16  
 public class TableFieldLayout extends FieldLayout{
 17  
         
 18  0
         private SpanPanel top = new SpanPanel();
 19  0
         private SpanPanel buttonPanel = new SpanPanel();
 20  0
         protected FlowPanel verticalLayout = new FlowPanel();
 21  0
         private FlexTable table = new FlexTable();
 22  0
         private int row = 0;
 23  
         
 24  0
         public List<Widget> tableIndex = new ArrayList<Widget>();
 25  
         
 26  0
         public TableFieldLayout(){
 27  0
                 this.hasValidation = true;
 28  0
                 init();
 29  0
         }
 30  
         
 31  0
         public TableFieldLayout(boolean hasValidation){
 32  0
                 this.hasValidation = hasValidation;
 33  0
                 init();
 34  0
         }
 35  
         
 36  0
         public TableFieldLayout(SectionTitle title, boolean hasValidation){
 37  0
                 this.hasValidation = hasValidation;
 38  0
                 this.setLayoutTitle(title);
 39  0
                 init();
 40  0
         }
 41  
         
 42  
         private void init(){
 43  0
                 instructions.setVisible(false);
 44  0
                 verticalLayout.add(instructions);
 45  0
                 verticalLayout.add(message);
 46  0
                 table.setWidth("100%");
 47  0
                 table.setStyleName("ks-table-plain");
 48  0
                 verticalLayout.add(table);
 49  0
                 this.add(verticalLayout);
 50  0
         }
 51  
         
 52  
         @Override
 53  
         public void addFieldToLayout(FieldElement field) {
 54  0
                 FlowPanel fieldPanel = field.getFieldWidgetAreaLayout();
 55  0
                 table.setWidget(row, 0, field.getFieldDetailsLayout());
 56  0
                 table.setWidget(row, 1, fieldPanel);
 57  0
                 if(this.hasValidation){
 58  0
                         ValidationMessagePanel validationPanel = new ValidationMessagePanel(false);
 59  0
                         table.setWidget(row, 2, validationPanel);
 60  0
                         field.setValidationPanel(validationPanel);
 61  0
                         field.setParentElement(table.getRowFormatter().getElement(row));
 62  0
                         table.getColumnFormatter().setStyleName(0, "ks-table-title-column-width");
 63  0
                         table.getColumnFormatter().setStyleName(1, "ks-table-field-column-width");
 64  0
                         validationPanel.setStyleName("ks-form-module-validation-inline");
 65  0
                 }
 66  
                 else{
 67  0
                         table.getColumnFormatter().setStyleName(0, "ks-table-title-column-width");
 68  
                 }
 69  0
                 row++;
 70  0
         }
 71  
 
 72  
         @Override
 73  
         public void addLayoutToLayout(FieldLayout layout) {
 74  0
                 verticalLayout.add(layout);
 75  0
         }
 76  
 
 77  
         @Override
 78  
         public void addWidgetToLayout(Widget widget) {
 79  0
                 verticalLayout.add(widget);
 80  0
         }
 81  
 
 82  
         @Override
 83  
         public void removeFieldLayoutComponentFromLayout(
 84  
                         FieldLayoutComponent component) {
 85  0
                 if(component instanceof FieldElement){
 86  0
                         int index = tableIndex.indexOf(component);
 87  0
                         table.removeRow(index);
 88  0
                 }
 89  0
                 else if(component instanceof FieldLayout){
 90  0
                         verticalLayout.remove((FieldLayout)component);
 91  
                 }
 92  
                 
 93  0
         }
 94  
 
 95  
         @Override
 96  
         public void removeWidgetFromLayout(Widget widget) {
 97  0
                 verticalLayout.remove(widget);
 98  0
         }
 99  
 
 100  
         @Override
 101  
         public void setLayoutTitle(SectionTitle layoutTitle) {
 102  0
                 if(this.layoutTitle != null){
 103  0
                         verticalLayout.remove(this.layoutTitle);
 104  
                 }
 105  0
                 this.layoutTitle = layoutTitle;
 106  0
                 verticalLayout.insert(layoutTitle, 0);
 107  0
                 layoutTitle.addStyleName("ks-layout-header");
 108  
                 
 109  0
         }
 110  
 
 111  
         @Override
 112  
         public void addButtonLayoutToLayout(ButtonLayout buttonLayout) {
 113  
                 // TODO Auto-generated method stub
 114  
                 
 115  0
         }
 116  
 
 117  
 }