Coverage Report - org.kuali.student.lum.lu.ui.tools.client.widgets.itemlist.ItemListFieldBinding
 
Classes in this File Line Coverage Branch Coverage Complexity
ItemListFieldBinding
0%
0/20
0%
0/6
1.75
 
 1  
 /**
 2  
  * Copyright 2010 The Kuali Foundation Licensed under the
 3  
  * Educational Community License, Version 2.0 (the "License"); you may
 4  
  * not use this file except in compliance with the License. You may
 5  
  * obtain a copy of the License at
 6  
  *
 7  
  * http://www.osedu.org/licenses/ECL-2.0
 8  
  *
 9  
  * Unless required by applicable law or agreed to in writing,
 10  
  * software distributed under the License is distributed on an "AS IS"
 11  
  * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 12  
  * or implied. See the License for the specific language governing
 13  
  * permissions and limitations under the License.
 14  
  */
 15  
 
 16  
 package org.kuali.student.lum.lu.ui.tools.client.widgets.itemlist;
 17  
 
 18  
 import java.util.List;
 19  
 
 20  
 import org.kuali.student.common.assembly.data.Data;
 21  
 import org.kuali.student.common.assembly.data.QueryPath;
 22  
 import org.kuali.student.common.ui.client.configurable.mvc.binding.ModelWidgetBindingSupport;
 23  
 import org.kuali.student.common.ui.client.mvc.DataModel;
 24  
 
 25  0
 public abstract class ItemListFieldBinding<V extends ItemValue<V>> extends ModelWidgetBindingSupport<ItemList<V>> {
 26  
 
 27  
     @Override
 28  
     public void setModelValue(ItemList<V> widget, DataModel model, String path) {
 29  0
         QueryPath qPath = QueryPath.parse(path);
 30  0
         List<V> values = widget.getValue();
 31  0
         Data valuesData = new Data();
 32  0
         if (values != null) {
 33  0
             for (V val : values) {
 34  0
                 Data valueData = new Data();
 35  0
                 setItemData(val, valueData);
 36  0
                 valuesData.add(valueData);
 37  0
             }
 38  
         }
 39  0
         model.set(qPath, valuesData);
 40  0
     }
 41  
 
 42  
     @Override
 43  
     public void setWidgetValue(ItemList<V> widget, DataModel model, String path) {
 44  0
         QueryPath qPath = QueryPath.parse(path);
 45  0
         Data valueData = model.get(qPath);
 46  0
         List<V> values = null;
 47  
         
 48  0
         if (valueData != null) {
 49  0
             values = getItemList(valueData);
 50  0
             widget.setValue(values);
 51  
         } else {
 52  0
             widget.setValue(null);
 53  
         }
 54  0
     }
 55  
     
 56  
     /**
 57  
      * Used by setModelValue to set values specific to the type of Item
 58  
      * @param val
 59  
      * @param data
 60  
      */
 61  
     public abstract void setItemData(V val, Data data);
 62  
     
 63  
     public abstract List<V> getItemList(Data data);
 64  
     
 65  
 }