Coverage Report - org.kuali.student.common.ui.client.configurable.mvc.binding.ListOfStringBinding
 
Classes in this File Line Coverage Branch Coverage Complexity
ListOfStringBinding
0%
0/18
0%
0/6
2.5
 
 1  
 package org.kuali.student.common.ui.client.configurable.mvc.binding;
 2  
 
 3  
 import java.util.ArrayList;
 4  
 import java.util.Iterator;
 5  
 
 6  
 import org.kuali.student.common.assembly.data.Data;
 7  
 import org.kuali.student.common.assembly.data.QueryPath;
 8  
 import org.kuali.student.common.assembly.data.Data.DataValue;
 9  
 import org.kuali.student.common.assembly.data.Data.Property;
 10  
 import org.kuali.student.common.ui.client.mvc.DataModel;
 11  
 import org.kuali.student.common.ui.client.widgets.ListOfStringWidget;
 12  
 
 13  
 /**
 14  
  * Model widget binding for list of strings.  This binding only works with data that is known
 15  
  * to be a list of strings.
 16  
  * 
 17  
  * @author Kuali Student Team
 18  
  *
 19  
  */
 20  0
 public class ListOfStringBinding implements ModelWidgetBinding<ListOfStringWidget> {
 21  
 
 22  
         @Override
 23  
         public void setModelValue(ListOfStringWidget widget, DataModel model, String path) {
 24  0
                 Data data = new Data();
 25  0
                 DataValue listData = new Data.DataValue(data);
 26  0
                 for(String value:widget.getStringValues()){
 27  0
                         data.add(value);
 28  
                 }
 29  0
                 model.set(QueryPath.parse(path), listData);
 30  0
         }
 31  
 
 32  
         @Override
 33  
         public void setWidgetValue(ListOfStringWidget widget, DataModel model, String path) {
 34  0
                 Data data = model.get(path);
 35  0
                 ArrayList<String> values = new ArrayList<String>();
 36  0
                 if(data!=null){
 37  0
                         Iterator<Property> iter = data.realPropertyIterator();
 38  0
                         while(iter.hasNext()){
 39  0
                                 Property prop = iter.next();
 40  0
                                 String value = prop.getValue();
 41  0
                                 values.add(value);
 42  0
                         }
 43  
                 }
 44  0
                 widget.setStringValues(values);
 45  0
         }
 46  
 
 47  
 }