Coverage Report - org.kuali.student.common.ui.client.configurable.mvc.sections.RemovableItemWithHeader
 
Classes in this File Line Coverage Branch Coverage Complexity
RemovableItemWithHeader
0%
0/43
0%
0/8
1.5
RemovableItemWithHeader$1
0%
0/3
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  
 
 16  
 package org.kuali.student.common.ui.client.configurable.mvc.sections;
 17  
 
 18  
 import org.kuali.student.common.ui.client.configurable.mvc.SectionTitle;
 19  
 import org.kuali.student.common.ui.client.configurable.mvc.multiplicity.MultiplicityItem;
 20  
 import org.kuali.student.common.ui.client.configurable.mvc.multiplicity.MultiplicityComposite.StyleType;
 21  
 
 22  
 import com.google.gwt.event.dom.client.ClickEvent;
 23  
 import com.google.gwt.event.dom.client.ClickHandler;
 24  
 import com.google.gwt.user.client.ui.FlowPanel;
 25  
 
 26  
 /**
 27  
  * @deprecated
 28  
  */
 29  
 public class RemovableItemWithHeader extends MultiplicityItem{
 30  
 
 31  
         private MultiplicityHeader header;
 32  0
         private FlowPanel layout = new FlowPanel();
 33  0
         private FlowPanel body = new FlowPanel();
 34  
         private StyleType style;
 35  
         private String itemLabel;
 36  0
     private boolean readOnly=false;
 37  0
         private boolean loaded = false;
 38  
         
 39  
         
 40  
     public void isReadOnly(boolean readOnly){
 41  0
         this.readOnly=readOnly;
 42  0
     }
 43  
 
 44  
         public void setReadOnly(boolean readOnly) {
 45  0
                 this.readOnly = readOnly;
 46  0
         }
 47  
         
 48  0
         public RemovableItemWithHeader(StyleType style){
 49  0
                 this.style = style;
 50  0
                 this.initWidget(layout);
 51  
                 
 52  0
         }
 53  
         
 54  0
         public RemovableItemWithHeader(StyleType style, boolean readOnly){
 55  0
                 this.style = style;
 56  0
                 this.readOnly = readOnly;
 57  0
                 this.initWidget(layout);
 58  
                 
 59  0
         }
 60  
         
 61  
         @Override
 62  
         public void clear() {
 63  0
         loaded = false;
 64  
                 
 65  0
         }
 66  
         
 67  
     public void setItemLabel(String itemLabel) {
 68  0
         this.itemLabel = itemLabel;
 69  0
     }
 70  
 
 71  
         @Override
 72  
         public void redraw() {
 73  0
                 if (!loaded){
 74  0
                         layout.clear();
 75  0
                     if(style == StyleType.TOP_LEVEL){
 76  0
                             SectionTitle title = SectionTitle.generateH4Title(itemLabel);
 77  0
                             title.addStyleName("ks-form-bordered-header-title");
 78  0
                             header = new MultiplicityHeader(title, readOnly);
 79  0
                             header.setStyleName("ks-form-bordered-header");
 80  0
                             layout.setStyleName("ks-form-bordered");
 81  0
                             body.setStyleName("ks-form-bordered-body");
 82  0
                     }
 83  0
                     else if(style == StyleType.SUB_LEVEL){
 84  0
                             SectionTitle title = SectionTitle.generateH5Title(itemLabel);
 85  0
                             title.addStyleName("ks-form-course-format-activity-header-title");
 86  0
                             header = new MultiplicityHeader(title, readOnly);
 87  0
                             header.setStyleName("ks-form-course-format-activity-header");
 88  0
                             layout.setStyleName("ks-form-course-format-activity");
 89  
                     }
 90  
                     
 91  
                     //This check is to disable delete of items in case of readonly mode.
 92  0
                     if(!readOnly){
 93  0
                         header.addDeleteHandler(new ClickHandler() {
 94  
                         public void onClick(ClickEvent event) {
 95  0
                             getRemoveCallback().exec(RemovableItemWithHeader.this);
 96  0
                         }
 97  
                     });
 98  
                     }
 99  
                     
 100  0
                     layout.add(header);
 101  0
                     body.add(this.getItemWidget());
 102  0
                     layout.add(body);
 103  
                 }
 104  
                 
 105  
 /*        if (this.getItemWidget() instanceof Section){
 106  
             ((Section)this.getItemWidget()).redraw();
 107  
         }*/
 108  
                 
 109  0
         }
 110  
 
 111  
 }