Coverage Report - org.kuali.student.common.ui.client.configurable.mvc.multiplicity.MultiplicityGroupItem
 
Classes in this File Line Coverage Branch Coverage Complexity
MultiplicityGroupItem
0%
0/39
0%
0/11
1.5
MultiplicityGroupItem$1
0%
0/3
N/A
1.5
MultiplicityGroupItem$2
0%
0/1
N/A
1.5
 
 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  
  * Date: 14-Jul-2010
 16  
  * Time: 10:52:16 AM
 17  
  */
 18  
 
 19  
 package org.kuali.student.common.ui.client.configurable.mvc.multiplicity;
 20  
 
 21  
 import org.kuali.student.common.ui.client.configurable.mvc.multiplicity.MultiplicityConfiguration.StyleType;
 22  
 import org.kuali.student.common.ui.client.configurable.mvc.sections.BaseSection;
 23  
 import org.kuali.student.common.ui.client.mvc.Callback;
 24  
 import org.kuali.student.common.ui.client.widgets.field.layout.layouts.BorderedHeadedLayout;
 25  
 import org.kuali.student.common.ui.client.widgets.field.layout.layouts.HeadedLayout;
 26  
 import org.kuali.student.common.ui.client.widgets.field.layout.layouts.UnborderedHeadedLayout;
 27  
 
 28  
 import com.google.gwt.event.dom.client.ClickEvent;
 29  
 import com.google.gwt.event.dom.client.ClickHandler;
 30  
 import com.google.gwt.user.client.ui.Widget;
 31  
 
 32  
 public class MultiplicityGroupItem extends BaseSection {
 33  
         
 34  0
     private boolean updateable=false;
 35  
     private Integer itemKey;      
 36  
     private Widget itemWidget;
 37  
     private Callback<MultiplicityGroupItem> removeCallback;
 38  0
     private boolean created = true;
 39  0
     private boolean deleted = false;
 40  0
         private boolean loaded = false;
 41  
 
 42  
     private MultiplicityConfiguration.StyleType style;
 43  
 
 44  
         String itemLabel;
 45  
 
 46  
     /**
 47  
      *  Represents a single item within a MultiplicityGroup
 48  
      *
 49  
      * //TODO Should this be an inner class in MultiplicityGroup?
 50  
      *  
 51  
      * @param itemLabel
 52  
      * @param style
 53  
      * @param updateable
 54  
      */
 55  0
     public MultiplicityGroupItem(String itemLabel, StyleType style, boolean updateable){
 56  
 
 57  0
                 this.itemLabel = itemLabel;
 58  0
                 this.style = style;
 59  0
                 this.updateable = updateable;
 60  0
         }
 61  
 
 62  
     private void buildLayout() {
 63  
 
 64  0
         switch (style) {
 65  
             case TOP_LEVEL_GROUP:
 66  
             case BORDERED_TABLE:
 67  0
                 layout = new BorderedHeadedLayout(itemLabel, updateable);
 68  0
                 break;
 69  
             case SUB_LEVEL_GROUP:
 70  
             case BORDERLESS_TABLE:
 71  0
                 layout = new UnborderedHeadedLayout(itemLabel, updateable);
 72  
                 break;
 73  
         }
 74  0
         ((HeadedLayout)layout).setUpdateable(updateable);
 75  0
     }
 76  
 
 77  
         public void redraw() {
 78  0
                 if (!loaded){
 79  0
                         buildLayout(); 
 80  
 
 81  0
                         if(updateable){
 82  0
                         ((HeadedLayout)layout).addDeleteHandler(new ClickHandler() {
 83  
                         public void onClick(ClickEvent event) {
 84  0
                             getRemoveCallback().exec(MultiplicityGroupItem.this);
 85  0
                         }
 86  
                     });
 87  
                     }
 88  
                     
 89  0
                     layout.addWidget(this.getItemWidget());
 90  0
                     this.add(layout);
 91  
                 }                
 92  0
         }
 93  
         public Integer getItemKey() {
 94  0
         return itemKey;
 95  
     }
 96  
 
 97  
     public void setItemKey(Integer itemKey) {
 98  0
         this.itemKey = itemKey;
 99  0
     }
 100  
 
 101  
     public Widget getItemWidget() {
 102  0
         return itemWidget;
 103  
     }
 104  
 
 105  
     public void setItemWidget(Widget itemWidget) {
 106  0
         this.itemWidget = itemWidget;
 107  0
     }
 108  
 
 109  
     public void setRemoveCallback(Callback<MultiplicityGroupItem> callback){
 110  0
         removeCallback = callback;
 111  0
     }
 112  
 
 113  
     public Callback<MultiplicityGroupItem> getRemoveCallback(){
 114  0
         return removeCallback;
 115  
     }
 116  
 
 117  
     public boolean isCreated() {
 118  0
         return created;
 119  
     }
 120  
 
 121  
     public void setCreated(boolean created) {
 122  0
         this.created = created;
 123  0
     }
 124  
 
 125  
     public boolean isDeleted() {
 126  0
         return deleted;
 127  
     }
 128  
 
 129  
     public void setDeleted(boolean isDeleted) {
 130  0
         this.deleted = isDeleted;
 131  0
         if(isDeleted)
 132  0
             this.created = false;
 133  0
     }
 134  
 }