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  
 /**
 17  
  * A layout which adds fields as rows in a table.  All child layouts appear after these fields.
 18  
  * @author Kuali Student Team
 19  
  *
 20  
  */
 21  
 public class TableFieldLayout extends FieldLayout{
 22  
         
 23  0
         private SpanPanel top = new SpanPanel();
 24  0
         private SpanPanel buttonPanel = new SpanPanel();
 25  0
         protected FlowPanel verticalLayout = new FlowPanel();
 26  0
         private FlexTable table = new FlexTable();
 27  0
         private int row = 0;
 28  
         
 29  0
         public List<Widget> tableIndex = new ArrayList<Widget>();
 30  
         
 31  0
         public TableFieldLayout(){
 32  0
                 this.hasValidation = true;
 33  0
                 init();
 34  0
         }
 35  
         
 36  0
         public TableFieldLayout(boolean hasValidation){
 37  0
                 this.hasValidation = hasValidation;
 38  0
                 init();
 39  0
         }
 40  
         
 41  0
         public TableFieldLayout(SectionTitle title, boolean hasValidation){
 42  0
                 this.hasValidation = hasValidation;
 43  0
                 this.setLayoutTitle(title);
 44  0
                 init();
 45  0
         }
 46  
         
 47  
         private void init(){
 48  0
                 instructions.setVisible(false);
 49  0
                 verticalLayout.add(instructions);
 50  0
                 verticalLayout.add(message);
 51  0
                 table.setWidth("100%");
 52  0
                 table.setStyleName("ks-table-plain");
 53  0
                 verticalLayout.add(table);
 54  0
                 this.add(verticalLayout);
 55  0
         }
 56  
         
 57  
         @Override
 58  
         public void addFieldToLayout(FieldElement field) {
 59  0
                 FlowPanel fieldPanel = field.getFieldWidgetAreaLayout();
 60  0
                 table.setWidget(row, 0, field.getFieldDetailsLayout());
 61  0
                 table.setWidget(row, 1, fieldPanel);
 62  0
                 if(this.hasValidation){
 63  0
                         ValidationMessagePanel validationPanel = new ValidationMessagePanel(false);
 64  0
                         table.setWidget(row, 2, validationPanel);
 65  0
                         field.setValidationPanel(validationPanel);
 66  0
                         field.setParentElement(table.getRowFormatter().getElement(row));
 67  0
                         table.getColumnFormatter().setStyleName(0, "ks-table-title-column-width");
 68  0
                         table.getColumnFormatter().setStyleName(1, "ks-table-field-column-width");
 69  0
                         validationPanel.setStyleName("ks-form-module-validation-inline");
 70  0
                 }
 71  
                 else{
 72  0
                         table.getColumnFormatter().setStyleName(0, "ks-table-title-column-width");
 73  
                 }
 74  0
                 row++;
 75  0
         }
 76  
 
 77  
         @Override
 78  
         public void addLayoutToLayout(FieldLayout layout) {
 79  0
                 verticalLayout.add(layout);
 80  0
         }
 81  
 
 82  
         @Override
 83  
         public void addWidgetToLayout(Widget widget) {
 84  0
                 verticalLayout.add(widget);
 85  0
         }
 86  
 
 87  
         @Override
 88  
         public void removeFieldLayoutComponentFromLayout(
 89  
                         FieldLayoutComponent component) {
 90  0
                 if(component instanceof FieldElement){
 91  0
                         int index = tableIndex.indexOf(component);
 92  0
                         table.removeRow(index);
 93  0
                 }
 94  0
                 else if(component instanceof FieldLayout){
 95  0
                         verticalLayout.remove((FieldLayout)component);
 96  
                 }
 97  
                 
 98  0
         }
 99  
 
 100  
         @Override
 101  
         public void removeWidgetFromLayout(Widget widget) {
 102  0
                 verticalLayout.remove(widget);
 103  0
         }
 104  
 
 105  
         @Override
 106  
         public void setLayoutTitle(SectionTitle layoutTitle) {
 107  0
                 if(this.layoutTitle != null){
 108  0
                         verticalLayout.remove(this.layoutTitle);
 109  
                 }
 110  0
                 this.layoutTitle = layoutTitle;
 111  0
                 verticalLayout.insert(layoutTitle, 0);
 112  0
                 layoutTitle.addStyleName("ks-layout-header");
 113  
                 
 114  0
         }
 115  
 
 116  
         @Override
 117  
         public void addButtonLayoutToLayout(ButtonLayout buttonLayout) {
 118  
                 // TODO Auto-generated method stub
 119  
                 
 120  0
         }
 121  
 
 122  
 }