Coverage Report - org.kuali.student.lum.program.client.widgets.SideBarDialogManager
 
Classes in this File Line Coverage Branch Coverage Complexity
SideBarDialogManager
0%
0/31
0%
0/2
1.25
SideBarDialogManager$1
0%
0/6
0%
0/2
1.25
SideBarDialogManager$2
0%
0/3
N/A
1.25
SideBarDialogManager$3
0%
0/2
N/A
1.25
SideBarDialogManager$DialogView
0%
0/2
N/A
1.25
 
 1  
 package org.kuali.student.lum.program.client.widgets;
 2  
 
 3  
 import com.google.gwt.event.shared.HandlerManager;
 4  
 
 5  
 import org.kuali.student.common.assembly.data.ModelDefinition;
 6  
 import org.kuali.student.common.ui.client.application.Application;
 7  
 import org.kuali.student.common.ui.client.configurable.mvc.FieldDescriptor;
 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.Callback;
 11  
 import org.kuali.student.common.ui.client.widgets.KSLightBox;
 12  
 import org.kuali.student.common.ui.client.widgets.buttongroups.ButtonEnumerations;
 13  
 import org.kuali.student.common.ui.client.widgets.field.layout.button.ActionCancelGroup;
 14  
 import org.kuali.student.common.ui.client.widgets.field.layout.button.ButtonGroup;
 15  
 import org.kuali.student.common.ui.client.widgets.field.layout.element.MessageKeyInfo;
 16  
 import org.kuali.student.lum.program.client.ProgramConstants;
 17  
 import org.kuali.student.lum.program.client.ProgramController;
 18  
 import org.kuali.student.lum.program.client.ProgramMsgConstants;
 19  
 import org.kuali.student.lum.program.client.events.MetadataLoadedEvent;
 20  
 import org.kuali.student.lum.program.client.events.UpdateEvent;
 21  
 
 22  
 /**
 23  
  * @author Igor
 24  
  */
 25  0
 class SideBarDialogManager {
 26  
 
 27  
     private HandlerManager eventBus;
 28  
 
 29  
     private KSLightBox dialog;
 30  
 
 31  0
     private ButtonGroup<ButtonEnumerations.ButtonEnum> buttonGroup = new ActionCancelGroup(ButtonEnumerations.SaveCancelEnum.SAVE, ButtonEnumerations.SaveCancelEnum.CANCEL);
 32  
 
 33  0
     private VerticalSectionView dialogView = new VerticalSectionView(DialogView.MAIN, getLabel(ProgramMsgConstants.SIDEBAR_DIALOG_TITLE), ProgramConstants.PROGRAM_MODEL_ID, true);
 34  
 
 35  0
     private boolean viewConfigured = false;
 36  
 
 37  0
     public SideBarDialogManager(HandlerManager eventBus) {
 38  0
         this.eventBus = eventBus;
 39  0
         dialog = new KSLightBox();
 40  0
         dialog.setWidget(dialogView.asWidget());
 41  0
         dialog.addButtonGroup(buttonGroup);
 42  0
         dialog.setSize(300, 190);
 43  0
         dialog.setModal(false);
 44  0
         bind();
 45  0
     }
 46  
 
 47  
     private void bind() {
 48  0
         buttonGroup.addCallback(new Callback<ButtonEnumerations.ButtonEnum>() {
 49  
             @Override
 50  
             public void exec(ButtonEnumerations.ButtonEnum button) {
 51  0
                 if (button == ButtonEnumerations.SaveCancelEnum.SAVE) {
 52  0
                     dialogView.updateModel();
 53  0
                     eventBus.fireEvent(new UpdateEvent());
 54  
                 }
 55  0
                 dialog.hide();
 56  
 
 57  0
             }
 58  
         });
 59  0
         eventBus.addHandler(MetadataLoadedEvent.TYPE, new MetadataLoadedEvent.Handler() {
 60  
             @Override
 61  
             public void onEvent(MetadataLoadedEvent event) {
 62  0
                 configureView(event.getModelDefinition(), event.getController());
 63  0
             }
 64  
         });
 65  0
     }
 66  
 
 67  
     public void configureView(ModelDefinition modelDefinition, ProgramController controller) {
 68  0
         if (!viewConfigured) {
 69  0
             VerticalSection verticalSection = new VerticalSection();
 70  0
             verticalSection.addField(new FieldDescriptor(ProgramConstants.SCHEDULED_REVIEW_DATE, new MessageKeyInfo(ProgramMsgConstants.SIDEBAR_FORM_SCHEDULEDREVIEWDATE), modelDefinition.getMetadata(ProgramConstants.SCHEDULED_REVIEW_DATE)));
 71  0
             FieldDescriptor reviewDateDescriptor = new FieldDescriptor(ProgramConstants.LAST_REVIEW_DATE, new MessageKeyInfo(ProgramMsgConstants.SIDEBAR_FORM_LASTREVIEWDATE), modelDefinition.getMetadata(ProgramConstants.LAST_REVIEW_DATE));
 72  0
             reviewDateDescriptor.setWidgetBinding(new DateBinding());
 73  0
             verticalSection.addField(reviewDateDescriptor);
 74  0
             dialogView.setLayoutController(controller);
 75  0
             dialogView.addSection(verticalSection);
 76  0
             viewConfigured = true;
 77  
         }
 78  0
     }
 79  
 
 80  
     public void show() {
 81  0
         dialogView.beforeShow(new Callback<Boolean>() {
 82  
             @Override
 83  
             public void exec(Boolean result) {
 84  0
             }
 85  
         });
 86  0
         dialogView.updateModel();
 87  0
         dialog.show();
 88  0
     }
 89  
 
 90  0
     private static enum DialogView {
 91  0
         MAIN
 92  
     }
 93  
     
 94  
     private String getLabel(String messageKey) {
 95  0
         return Application.getApplicationContext().getUILabel(ProgramMsgConstants.PROGRAM_MSG_GROUP, messageKey);
 96  
     }
 97  
 }