Clover Coverage Report - Kuali Student 1.2.1-SNAPSHOT (Aggregated)
Coverage timestamp: Wed Nov 2 2011 04:03:58 EST
../../../../../../../../../img/srcFileCovDistChart0.png 42% of files have more coverage
49   140   19   5.44
14   110   0.39   4.5
9     2.11  
2    
Warning
  • The source file used to generate this report was changed after Clover generated coverage information. The coverage reported may not match the source lines. You should regenerate the coverage information and the report to ensure the files are in sync.
 
  CourseRequirementsViewController       Line # 11 49 0% 19 72 0% 0.0
  CourseRequirementsViewController.CourseRequirementsViews       Line # 13 0 - 0 0 - -1.0
 
No Tests
 
1    package org.kuali.student.lum.lu.ui.course.client.requirements;
2   
3    import org.kuali.student.common.ui.client.configurable.mvc.layouts.BasicLayout;
4    import org.kuali.student.common.ui.client.configurable.mvc.views.SectionView;
5    import org.kuali.student.common.ui.client.mvc.Callback;
6    import org.kuali.student.common.ui.client.mvc.Controller;
7    import org.kuali.student.common.ui.client.mvc.DataModel;
8    import org.kuali.student.common.ui.client.mvc.ModelProvider;
9    import org.kuali.student.common.ui.client.mvc.ModelRequestCallback;
10    import org.kuali.student.common.ui.client.widgets.buttongroups.ButtonEnumerations;
 
11    import org.kuali.student.common.ui.client.widgets.dialog.ButtonMessageDialog;
12    import org.kuali.student.common.ui.client.widgets.field.layout.button.ButtonGroup;
 
13    import org.kuali.student.common.ui.client.widgets.field.layout.button.YesNoCancelGroup;
14   
15    import com.google.gwt.core.client.GWT;
16   
17    public class CourseRequirementsViewController extends BasicLayout {
18   
19    public enum CourseRequirementsViews {
20    PREVIEW,
21    MANAGE
22    }
 
23  0 toggle
24  0 public static final String COURSE_RULES_MODEL_ID = "courseRulesModelId";
25  0 public static final String COURSE_PROPOSAL_MODEL = "courseProposalModel";
26  0
27  0 private CourseRequirementsSummaryView preview;
28  0
29  0 public CourseRequirementsViewController(Controller controller, String name, Enum<?> viewType, boolean isReadOnly, boolean showSaveButtons) {
30    super(CourseRequirementsViewController.class.getName());
31  0 super.setController(controller);
32    super.setName(name);
33    super.setViewEnum(viewType);
34  0 super.setDefaultModelId(COURSE_RULES_MODEL_ID);
 
35  0 toggle super.setParentController(controller);
36   
37  0 this.setDefaultView(CourseRequirementsViews.PREVIEW);
38   
39    //not used
40    super.registerModel(COURSE_RULES_MODEL_ID, new ModelProvider<DataModel>() {
41    @Override
42  0 public void requestModel(final ModelRequestCallback<DataModel> callback) {
43    callback.onModelReady(new DataModel());
44    }
45  0 });
46   
47  0 //no name for the view so that breadcrumbs do not extra link
48    preview = GWT.create(CourseRequirementsSummaryView.class);
49    preview.init(
50  0 this,
51    CourseRequirementsViews.PREVIEW,
52  0 (isReadOnly ? "Course Requirements" : ""),
53  0 COURSE_PROPOSAL_MODEL,
54    (controller instanceof HasRequirements ? ((HasRequirements) controller).getReqDataModel()
55  0 : new CourseRequirementsDataModel(this)),
56    isReadOnly, showSaveButtons);
57    super.addView(preview);
58   
 
59  0 toggle if (!isReadOnly) {
60    CourseRequirementsManageView manageView = GWT.create(CourseRequirementsManageView.class);
61  0 manageView.init(this, CourseRequirementsViews.MANAGE, "Add and Combine Rules", COURSE_RULES_MODEL_ID);
62    super.addView(manageView);
63    }
 
64  0 toggle }
65   
66    @Override
67  0 public void updateModel() {
68  0 preview.updateModel();
69  0 }
70   
71    @Override
72  0 public void beforeViewChange(final Enum<?> viewChangingTo, final Callback<Boolean> okToChange) {
73   
 
74  0 toggle if (getCurrentView() == null) {
75    okToChange.exec(true);
76    return;
77    }
78  0
79  0 super.beforeViewChange(viewChangingTo, new Callback<Boolean>() {
80  0
81    @Override
82    public void exec(Boolean result) {
83   
84  0 //no dialog if user clicks on the 'Save' button on Manage Rule page
85    if (getCurrentView() instanceof CourseRequirementsManageView) {
86    okToChange.exec(true);
87  0 return;
88  0 }
89   
90    //no dialog if user is going to the Manage Rule page
91    if (viewChangingTo.name().equals(CourseRequirementsViewController.CourseRequirementsViews.MANAGE.name()))
92  0 {
93  0 //TODO show dialog if user clicks on a menu from Manage Rules page
94  0 okToChange.exec(true);
95    return;
96    }
97   
98  0 //user is moving to another course proposal section and no changes were made to the rules so allow it to happen
99  0 if (!((SectionView) getCurrentView()).isDirty()) {
100    okToChange.exec(true);
101  0 return;
102    }
 
103  0 toggle
104    //user is moving to another course proposal section and rules have been changed, user needs to either save rules or abondon changes before proceeding
105  0 ButtonGroup<ButtonEnumerations.YesNoCancelEnum> buttonGroup = new YesNoCancelGroup();
106  0 final ButtonMessageDialog<ButtonEnumerations.YesNoCancelEnum> dialog =
107  0 new ButtonMessageDialog<ButtonEnumerations.YesNoCancelEnum>("Warning", "You may have unsaved changes. Save changes?", buttonGroup);
108  0 buttonGroup.addCallback(new Callback<ButtonEnumerations.YesNoCancelEnum>() {
 
109  0 toggle
110    @Override
111  0 public void exec(ButtonEnumerations.YesNoCancelEnum result) {
112    switch (result) {
113    case YES:
114  0 dialog.hide();
115  0 preview.storeRules(true, new Callback<Boolean>() {
116  0 @Override
117  0 public void exec(Boolean result) {
118  0 okToChange.exec(result);
119  0 }
120  0 });
121  0 break;
122  0 case NO:
123  0 dialog.hide();
124    preview.revertRuleChanges();
125    okToChange.exec(true);
126    break;
127  0 case CANCEL:
128    okToChange.exec(false);
129    dialog.hide();
130    break;
131    }
 
132  0 toggle }
133    });
134  0 dialog.show();
135    }
136    });
 
137  0 toggle }
138  0
139    @Override
140    public void beforeShow(final Callback<Boolean> onReadyCallback){
141    showDefaultView(onReadyCallback);
142    }
143   
144    public void storeRules(Callback<Boolean> callback){
145    preview.storeRules(true, callback);
146    }
147    }