Coverage Report - org.kuali.student.lum.program.client.major.edit.SpecializationsEditConfiguration
 
Classes in this File Line Coverage Branch Coverage Complexity
SpecializationsEditConfiguration
0%
0/20
N/A
1
SpecializationsEditConfiguration$1
0%
0/3
N/A
1
 
 1  
 package org.kuali.student.lum.program.client.major.edit;
 2  
 
 3  
 import com.google.gwt.event.dom.client.ClickEvent;
 4  
 import com.google.gwt.event.dom.client.ClickHandler;
 5  
 import com.google.gwt.user.client.ui.FlexTable;
 6  
 
 7  
 import org.kuali.student.common.ui.client.configurable.mvc.Configurer;
 8  
 import org.kuali.student.common.ui.client.configurable.mvc.sections.VerticalSection;
 9  
 import org.kuali.student.common.ui.client.configurable.mvc.views.VerticalSectionView;
 10  
 import org.kuali.student.common.ui.client.mvc.DataModel;
 11  
 import org.kuali.student.common.ui.client.widgets.KSButton;
 12  
 import org.kuali.student.common.ui.client.widgets.KSButtonAbstract.ButtonStyle;
 13  
 import org.kuali.student.common.ui.client.widgets.KSCheckBox;
 14  
 import org.kuali.student.common.ui.client.widgets.field.layout.element.MessageKeyInfo;
 15  
 import org.kuali.student.lum.common.client.configuration.AbstractSectionConfiguration;
 16  
 import org.kuali.student.lum.common.client.widgets.AppLocations;
 17  
 import org.kuali.student.lum.program.client.ProgramConstants;
 18  
 import org.kuali.student.lum.program.client.ProgramMsgConstants;
 19  
 import org.kuali.student.lum.program.client.ProgramSections;
 20  
 import org.kuali.student.lum.program.client.events.AddSpecializationEvent;
 21  
 import org.kuali.student.lum.program.client.major.MajorManager;
 22  
 import org.kuali.student.lum.program.client.permissions.ModelPermissionType;
 23  
 import org.kuali.student.lum.program.client.variation.VariationsBinding;
 24  
 
 25  
 /**
 26  
  * @author Igor
 27  
  */
 28  
 public class SpecializationsEditConfiguration extends AbstractSectionConfiguration {
 29  
 
 30  
     private final KSButton addSpecializationButton;
 31  
 
 32  0
     public SpecializationsEditConfiguration(Configurer configurer) {
 33  0
         this.setConfigurer(configurer);
 34  0
         addSpecializationButton = new KSButton(getLabel(ProgramMsgConstants.VARIATIONINFORMATION_BUTTON_ADDSPECIALIZATION), ButtonStyle.SECONDARY);
 35  0
         rootSection = new VerticalSectionView(ProgramSections.SPECIALIZATIONS_EDIT, getLabel(ProgramMsgConstants.PROGRAM_MENU_SECTIONS_SPECIALIZATIONS), ProgramConstants.PROGRAM_MODEL_ID);
 36  0
         bind();
 37  0
     }
 38  
 
 39  
     private void bind() {
 40  0
         addSpecializationButton.addClickHandler(new ClickHandler() {
 41  
             @Override
 42  
             public void onClick(ClickEvent event) {
 43  0
                 MajorManager.getEventBus().fireEvent(new AddSpecializationEvent());
 44  0
             }
 45  
         });
 46  0
     }
 47  
 
 48  
     @Override
 49  
     protected void buildLayout() {
 50  0
         VerticalSection section = new VerticalSection();
 51  0
         KSCheckBox isVariationRequiredCheckBox = new KSCheckBox(getLabel(ProgramMsgConstants.PROGRAMSPECIALIZATION_INSTRUCTIONS));
 52  0
         configurer.addField(section, ProgramConstants.IS_VARIATION_REQUIRED, null, isVariationRequiredCheckBox);
 53  0
         configurer.addField(section, ProgramConstants.VARIATIONS, new MessageKeyInfo(""), new FlexTable()).setWidgetBinding(new VariationsBinding(AppLocations.Locations.EDIT_VARIATION.getLocation(), true, this));
 54  0
         section.addWidget(addSpecializationButton);
 55  0
         rootSection.addSection(section);
 56  0
     }
 57  
 
 58  
     @Override
 59  
     public boolean checkPermission(DataModel model) {
 60  0
         return ModelPermissionType.DRAFT_STATUS.check(model);
 61  
     }
 62  
 
 63  
     @Override
 64  
     public void applyRestrictions() {
 65  0
         addSpecializationButton.setEnabled(false);
 66  0
     }
 67  
 
 68  
     @Override
 69  
     public void removeRestrictions() {
 70  0
         addSpecializationButton.setEnabled(true);
 71  0
     }
 72  
 }