Coverage Report - org.kuali.student.common.ui.client.configurable.mvc.Configurer
 
Classes in this File Line Coverage Branch Coverage Complexity
Configurer
0%
0/36
0%
0/4
1.105
 
 1  
 package org.kuali.student.common.ui.client.configurable.mvc;
 2  
 
 3  
 import org.kuali.student.common.ui.client.application.Application;
 4  
 import org.kuali.student.common.ui.client.configurable.mvc.sections.Section;
 5  
 import org.kuali.student.common.ui.client.widgets.field.layout.element.MessageKeyInfo;
 6  
 import org.kuali.student.core.assembly.data.Metadata;
 7  
 import org.kuali.student.core.assembly.data.ModelDefinition;
 8  
 import org.kuali.student.core.assembly.data.QueryPath;
 9  
 
 10  
 import com.google.gwt.user.client.ui.Widget;
 11  
 
 12  0
 public abstract class Configurer {
 13  
     protected ModelDefinition modelDefinition;
 14  0
     protected String type = "";
 15  0
     protected String state = "";
 16  0
     protected String groupName = "";
 17  
 //    public abstract void configure(ConfigurableLayout layout);
 18  
     public void setModelDefinition(ModelDefinition modelDefinition){
 19  0
         this.modelDefinition = modelDefinition;
 20  0
     }
 21  
 
 22  
     public ModelDefinition getModelDefinition() {
 23  0
         return modelDefinition;
 24  
     }
 25  
 
 26  
     protected MessageKeyInfo generateMessageInfo(String labelKey) {
 27  0
         return new MessageKeyInfo(groupName, type, state, labelKey);
 28  
     }
 29  
     
 30  
     protected String getLabel(String labelKey) {
 31  0
         return Application.getApplicationContext().getUILabel(groupName, type, state, labelKey);
 32  
     }
 33  
 
 34  
     protected SectionTitle getH1Title(String labelKey) {
 35  0
         return SectionTitle.generateH1Title(getLabel(labelKey));
 36  
     }
 37  
 
 38  
     protected SectionTitle getH2Title(String labelKey) {
 39  0
         return SectionTitle.generateH2Title(getLabel(labelKey));
 40  
     }
 41  
 
 42  
     protected SectionTitle getH3Title(String labelKey) {
 43  0
         return SectionTitle.generateH3Title(getLabel(labelKey));
 44  
     }
 45  
 
 46  
     protected SectionTitle getH4Title(String labelKey) {
 47  0
         return SectionTitle.generateH4Title(getLabel(labelKey));
 48  
     }
 49  
 
 50  
     protected SectionTitle getH5Title(String labelKey) {
 51  0
         return SectionTitle.generateH5Title(getLabel(labelKey));
 52  
     }
 53  
 
 54  
     // TODO - when DOL is pushed farther down into LOBuilder,
 55  
     // revert these 5 methods to returning void again.
 56  
     public FieldDescriptor addField(Section section, String fieldKey) {
 57  0
         return addField(section, fieldKey, null, null, null);
 58  
     }    
 59  
     public FieldDescriptor addField(Section section, String fieldKey, MessageKeyInfo messageKey) {
 60  0
         return addField(section, fieldKey, messageKey, null, null);
 61  
     }
 62  
     public FieldDescriptor addField(Section section, String fieldKey, MessageKeyInfo messageKey, Widget widget) {
 63  0
         return addField(section, fieldKey, messageKey, widget, null);
 64  
     }
 65  
     public FieldDescriptor addField(Section section, String fieldKey, MessageKeyInfo messageKey, String parentPath) {
 66  0
         return addField(section, fieldKey, messageKey, null, parentPath);
 67  
     }
 68  
     
 69  
     public FieldDescriptor addField(Section section, String fieldKey, MessageKeyInfo messageKey, Widget widget, String parentPath) {
 70  0
         QueryPath path = QueryPath.concat(parentPath, fieldKey);
 71  0
         Metadata meta = modelDefinition.getMetadata(path);
 72  
 
 73  0
         FieldDescriptor fd = new FieldDescriptor(path.toString(), messageKey, meta);
 74  0
         if (widget != null) {
 75  0
             fd.setFieldWidget(widget);
 76  
         }
 77  0
         section.addField(fd);
 78  0
         return fd;
 79  
     }
 80  
     
 81  
     public FieldDescriptor addReadOnlyField(Section section, String fieldKey) {
 82  0
         return addReadOnlyField(section, fieldKey, null, null, null);
 83  
     }    
 84  
     public FieldDescriptor addReadOnlyField(Section section, String fieldKey, MessageKeyInfo messageKey) {
 85  0
         return addReadOnlyField(section, fieldKey, messageKey, null, null);
 86  
     }
 87  
     public FieldDescriptor addReadOnlyField(Section section, String fieldKey, MessageKeyInfo messageKey, Widget widget) {
 88  0
         return addReadOnlyField(section, fieldKey, messageKey, widget, null);
 89  
     }
 90  
     public FieldDescriptor addReadOnlyField(Section section, String fieldKey, MessageKeyInfo messageKey, String parentPath) {
 91  0
         return addReadOnlyField(section, fieldKey, messageKey, null, parentPath);
 92  
     }
 93  
     
 94  
     public FieldDescriptor addReadOnlyField(Section section, String fieldKey, MessageKeyInfo messageKey, Widget widget, String parentPath) {
 95  0
         QueryPath path = QueryPath.concat(parentPath, fieldKey);
 96  0
         Metadata meta = modelDefinition.getMetadata(path);
 97  
 
 98  0
         FieldDescriptor fd = new FieldDescriptorReadOnly(path.toString(), messageKey, meta);
 99  0
         if (widget != null) {                                               
 100  0
             fd.setFieldWidget(widget);
 101  
         }
 102  0
         section.addField(fd);
 103  0
         return fd;
 104  
     }
 105  
 }