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