Coverage Report - org.kuali.student.lum.lu.ui.course.client.requirements.CourseRequirementsSummaryView
 
Classes in this File Line Coverage Branch Coverage Complexity
CourseRequirementsSummaryView
0%
0/144
0%
0/60
2.387
CourseRequirementsSummaryView$1
0%
0/5
0%
0/2
2.387
CourseRequirementsSummaryView$2
0%
0/12
0%
0/4
2.387
CourseRequirementsSummaryView$3
0%
0/3
N/A
2.387
CourseRequirementsSummaryView$3$1
0%
0/10
0%
0/2
2.387
CourseRequirementsSummaryView$3$1$1
0%
0/5
N/A
2.387
CourseRequirementsSummaryView$4
0%
0/3
N/A
2.387
CourseRequirementsSummaryView$4$1
0%
0/4
N/A
2.387
CourseRequirementsSummaryView$5
0%
0/6
N/A
2.387
CourseRequirementsSummaryView$6
0%
0/7
0%
0/4
2.387
CourseRequirementsSummaryView$6$1
0%
0/6
0%
0/2
2.387
CourseRequirementsSummaryView$7
0%
0/17
0%
0/4
2.387
CourseRequirementsSummaryView$7$1
0%
0/3
N/A
2.387
CourseRequirementsSummaryView$7$2
0%
0/5
0%
0/2
2.387
 
 1  
 package org.kuali.student.lum.lu.ui.course.client.requirements;
 2  
 
 3  
 import java.util.HashMap;
 4  
 import java.util.HashSet;
 5  
 import java.util.LinkedHashMap;
 6  
 import java.util.List;
 7  
 import java.util.Map;
 8  
 import java.util.Set;
 9  
 
 10  
 import org.kuali.student.common.dto.RichTextInfo;
 11  
 import org.kuali.student.common.ui.client.application.Application;
 12  
 import org.kuali.student.common.ui.client.configurable.mvc.SectionTitle;
 13  
 import org.kuali.student.common.ui.client.configurable.mvc.views.SectionView;
 14  
 import org.kuali.student.common.ui.client.configurable.mvc.views.VerticalSectionView;
 15  
 import org.kuali.student.common.ui.client.mvc.Callback;
 16  
 import org.kuali.student.common.ui.client.mvc.Controller;
 17  
 import org.kuali.student.common.ui.client.mvc.DataModel;
 18  
 import org.kuali.student.common.ui.client.mvc.Model;
 19  
 import org.kuali.student.common.ui.client.mvc.ModelRequestCallback;
 20  
 import org.kuali.student.common.ui.client.mvc.View;
 21  
 import org.kuali.student.common.ui.client.widgets.KSButton;
 22  
 import org.kuali.student.common.ui.client.widgets.KSButtonAbstract;
 23  
 import org.kuali.student.common.ui.client.widgets.buttongroups.ButtonEnumerations;
 24  
 import org.kuali.student.common.ui.client.widgets.dialog.ConfirmationDialog;
 25  
 import org.kuali.student.common.ui.client.widgets.field.layout.button.ActionCancelGroup;
 26  
 import org.kuali.student.common.ui.client.widgets.field.layout.element.AbbrButton;
 27  
 import org.kuali.student.common.ui.client.widgets.field.layout.element.AbbrButton.AbbrButtonType;
 28  
 import org.kuali.student.common.ui.client.widgets.field.layout.element.LabelPanel;
 29  
 import org.kuali.student.common.ui.client.widgets.field.layout.element.SpanPanel;
 30  
 import org.kuali.student.core.statement.dto.ReqCompFieldInfo;
 31  
 import org.kuali.student.core.statement.dto.ReqComponentInfo;
 32  
 import org.kuali.student.core.statement.dto.StatementTreeViewInfo;
 33  
 import org.kuali.student.core.statement.dto.StatementTypeInfo;
 34  
 import org.kuali.student.core.statement.ui.client.widgets.rules.RulesUtil;
 35  
 import org.kuali.student.core.statement.ui.client.widgets.rules.SubrulePreviewWidget;
 36  
 import org.kuali.student.lum.common.client.widgets.AppLocations;
 37  
 import org.kuali.student.lum.common.client.widgets.CluSetDetailsWidget;
 38  
 import org.kuali.student.lum.common.client.widgets.CluSetRetriever;
 39  
 import org.kuali.student.lum.common.client.widgets.CluSetRetrieverImpl;
 40  
 import org.kuali.student.lum.lu.ui.course.client.configuration.AbstractCourseConfigurer;
 41  
 import org.kuali.student.lum.lu.ui.course.client.configuration.CourseProposalConfigurer;
 42  
 import org.kuali.student.lum.lu.ui.course.client.controllers.CourseProposalController;
 43  
 
 44  
 import com.google.gwt.core.client.GWT;
 45  
 import com.google.gwt.event.dom.client.ClickEvent;
 46  
 import com.google.gwt.event.dom.client.ClickHandler;
 47  
 import com.google.gwt.user.client.Window;
 48  
 import com.google.gwt.user.client.ui.FlowPanel;
 49  
 import com.google.gwt.user.client.ui.HorizontalPanel;
 50  
 import com.google.gwt.user.client.ui.VerticalPanel;
 51  
 import com.google.gwt.user.client.ui.Widget;
 52  
 
 53  0
 public class CourseRequirementsSummaryView extends VerticalSectionView {
 54  
 
 55  0
     private static CluSetRetriever cluSetRetriever = new CluSetRetrieverImpl();
 56  
 
 57  
     //view's widgets
 58  0
     protected FlowPanel layout = new FlowPanel();
 59  0
     protected ActionCancelGroup actionCancelButtons = new ActionCancelGroup(
 60  
             ButtonEnumerations.SaveContinueCancelEnum.SAVE_CONTINUE, ButtonEnumerations.SaveContinueCancelEnum.CANCEL);
 61  0
     protected Map<String, Widget> addButtonsList = new HashMap<String, Widget>();
 62  
 
 63  
     //view's data
 64  
     protected CourseRequirementsViewController parentController;
 65  
     protected CourseRequirementsDataModel rules;
 66  
     protected boolean isReadOnly;
 67  
     protected boolean showSaveButtons;
 68  0
     private static int tempProgReqInfoID = 9999;
 69  
     public static final String NEW_STMT_TREE_ID = "NEWSTMTTREE";
 70  
     public static final String NEW_REQ_COMP_ID = "NEWREQCOMP";    
 71  
 
 72  0
     protected Map<String, SpanPanel> perCourseRequisiteTypePanel = new LinkedHashMap<String, SpanPanel>();
 73  
 
 74  
     public CourseRequirementsSummaryView() {
 75  0
         super();
 76  0
     }
 77  
 
 78  
     public CourseRequirementsSummaryView(final CourseRequirementsViewController parentController, Enum<?> viewEnum, String name,
 79  
                                                             String modelId, CourseRequirementsDataModel rulesData, boolean isReadOnly, boolean showSaveButtons) {
 80  0
         super(viewEnum, name, modelId);
 81  0
         this.parentController = parentController;
 82  0
         rules = rulesData;
 83  0
         rules.setInitialized(false);
 84  0
         this.isReadOnly = isReadOnly;
 85  0
         this.showSaveButtons = showSaveButtons;
 86  0
         if (!isReadOnly && showSaveButtons) {
 87  0
             setupSaveCancelButtons();
 88  
         }
 89  0
     }
 90  
 
 91  
     public void init(final CourseRequirementsViewController parentController, Enum<?> viewEnum, String name,
 92  
             String modelId, CourseRequirementsDataModel rulesData, boolean isReadOnly, boolean showSaveButtons) {
 93  0
         super.init(viewEnum, name, modelId, true);
 94  0
         this.parentController = parentController;
 95  0
         rules = rulesData;
 96  0
         rules.setInitialized(false);
 97  0
         this.isReadOnly = isReadOnly;
 98  0
         this.showSaveButtons = showSaveButtons;
 99  0
         if (!isReadOnly && showSaveButtons) {
 100  0
             setupSaveCancelButtons();
 101  
         }
 102  0
     }
 103  
 
 104  
     @Override
 105  
     public boolean isDirty() {
 106  0
         return rules.isDirty();
 107  
     }
 108  
 
 109  
     @Override
 110  
     public void beforeShow(final Callback<Boolean> onReadyCallback) {
 111  
 
 112  
         //only when user wants to see rules then load requirements from database if they haven't been loaded yet
 113  0
         if (!rules.isInitialized()) {
 114  0
             rules.retrieveCourseRequirements(AbstractCourseConfigurer.COURSE_PROPOSAL_MODEL, new Callback<Boolean>() {
 115  
                 @Override
 116  
                 public void exec(Boolean result) {
 117  0
                     if (result) {
 118  0
                         displayRules();
 119  
                     }
 120  0
                     onReadyCallback.exec(result);
 121  0
                 }
 122  
             });
 123  0
             return;
 124  
         }
 125  
 
 126  
         //for read-only view, we don't need to worry about rules being added or modified
 127  0
         if (isReadOnly) {
 128  0
             displayRules();            
 129  0
             onReadyCallback.exec(true);
 130  0
             return;
 131  
         }
 132  
 
 133  
         //see if we need to update a rule if user is returning from rule manage screen
 134  0
         parentController.getView(CourseRequirementsViewController.CourseRequirementsViews.MANAGE, new Callback<View>(){
 135  
                         @Override
 136  
                         public void exec(View result) {
 137  0
                                 CourseRequirementsManageView manageView = (CourseRequirementsManageView) result;
 138  
                 
 139  
                                 //return if user did not added or updated a rule
 140  0
                 if (!manageView.isDirty() || !manageView.isUserClickedSaveButton()) {
 141  0
                     rules.removeEmptyRules();
 142  0
                     onReadyCallback.exec(true);
 143  0
                     return;
 144  
                 }
 145  
 
 146  
                 //update the rule because user added or edited the rule
 147  0
                 ((SectionView)parentController.getCurrentView()).setIsDirty(false);
 148  0
                 manageView.setUserClickedSaveButton(false);
 149  
 
 150  
                 //if rule storage updated successfully, update the display as well
 151  0
                 StatementTreeViewInfo affectedRule = rules.updateRules(manageView.getRuleTree(), manageView.getInternalCourseReqID(), manageView.isNewRule());
 152  0
                 updateRequirementWidgets(affectedRule);
 153  
                 
 154  0
                         onReadyCallback.exec(true);
 155  0
                         }
 156  
                 });        
 157  0
     }
 158  
 
 159  
     public void revertRuleChanges() {
 160  0
         rules.revertRuleChanges();
 161  0
         displayRules();
 162  0
     }
 163  
 
 164  
     private void updateRequirementWidgets(StatementTreeViewInfo rule) {
 165  0
         if (rule != null) {
 166  0
             StatementTypeInfo affectedStatementTypeInfo = rules.getStmtTypeInfo(rule.getType());
 167  0
             SpanPanel reqPanel = perCourseRequisiteTypePanel.get(affectedStatementTypeInfo.getId());
 168  
 
 169  
             //don't show 'add rule' button if we have one rule already
 170  0
             addButtonsList.get(rule.getType()).setVisible(false);
 171  
 
 172  
             //if this is a new rule then add it to the panel
 173  0
             if (reqPanel.getWidgetCount() == 0) {
 174  0
                 SubrulePreviewWidget newRulePreviewWidget = addCourseRequisite(reqPanel, rule);
 175  0
                 reqPanel.add(newRulePreviewWidget);
 176  0
                 return;
 177  
             }
 178  
 
 179  0
             for (int i = 0; i < reqPanel.getWidgetCount(); i++) {
 180  0
                 SubrulePreviewWidget subrulePreviewWidget = (SubrulePreviewWidget)reqPanel.getWidget(i);
 181  0
                 SubrulePreviewWidget newRulePreviewWidget = addCourseRequisite(reqPanel, rule);
 182  0
                 reqPanel.insert(newRulePreviewWidget, i);
 183  0
                 reqPanel.remove(subrulePreviewWidget);
 184  0
                 break; //there should be only one rule per requisite type
 185  
             }
 186  
         }
 187  0
     }    
 188  
 
 189  
     public void displayRules() {       
 190  0
         remove(layout);
 191  0
         layout.clear();
 192  
 
 193  
         //display 'Course Requirements' page title (don't add if read only because the section itself will display the title)
 194  0
         if (!isReadOnly) {
 195  0
             SectionTitle pageTitle = SectionTitle.generateH2Title("Course Requisites");
 196  0
             pageTitle.addStyleName("ks-layout-header");  //make the header orange
 197  0
             layout.add(pageTitle);
 198  
         }
 199  
 
 200  
         //iterate and display rules for each Course Requirement type e.g. Pre-Requisites, Co-Requisites, Anti-Requisites
 201  0
         boolean firstSubHeader = true;
 202  0
         for (StatementTypeInfo stmtTypeInfo : rules.getStmtTypes()) {
 203  
 
 204  
             //Show only headers for top statement types
 205  0
             if (isTopStatement(stmtTypeInfo)) {
 206  0
                 SectionTitle title = SectionTitle.generateH3Title(stmtTypeInfo.getName());
 207  0
                 title.addStyleName("KS-Course-Requisites-Top-Stmt-Header");
 208  0
                 layout.add(title);
 209  0
                 firstSubHeader = true;
 210  0
                 continue;
 211  
             }
 212  
 
 213  
             //create and display one type of Course Requisites section
 214  0
             SpanPanel requirementsPanel = new SpanPanel();
 215  0
             perCourseRequisiteTypePanel.put(stmtTypeInfo.getId(), requirementsPanel);
 216  0
             displayRequirementSectionForGivenType(requirementsPanel, stmtTypeInfo, firstSubHeader);
 217  0
             firstSubHeader = false;
 218  
 
 219  
             //now display each requirement for this Course Requisites type; should be only one for courses
 220  0
             for (StatementTreeViewInfo ruleInfo : rules.getCourseReqInfo(stmtTypeInfo.getId())) {
 221  0
                 SubrulePreviewWidget subrulePreviewWidget = addCourseRequisite(requirementsPanel, ruleInfo);
 222  0
                 requirementsPanel.add(subrulePreviewWidget);
 223  0
             }
 224  0
         }
 225  
 
 226  
         //save and cancel buttons
 227  0
         if (!isReadOnly && showSaveButtons) {
 228  0
             layout.add(actionCancelButtons);
 229  
         }
 230  
 
 231  0
         addWidget(layout);
 232  0
     }
 233  
 
 234  
     protected void displayRequirementSectionForGivenType(final SpanPanel requirementsPanel,
 235  
             final StatementTypeInfo stmtTypeInfo, boolean firstSubHeader) {
 236  
 
 237  
         //display header for this Course Requisites type e.g. Enrollment Eligibility
 238  0
         SectionTitle title = SectionTitle.generateH3Title(stmtTypeInfo.getName());
 239  0
         title.setStyleName((firstSubHeader ? "KS-Course-Requisites-Preview-Rule-Type-First-Header" : "KS-Course-Requisites-Preview-Rule-Type-Header"));
 240  0
         layout.add(title);
 241  
 
 242  0
         LabelPanel labelExamples = new LabelPanel(stmtTypeInfo.getDescr());
 243  0
         labelExamples.getElement().setAttribute("style", "font-weight: normal; width: 80%;");
 244  
         
 245  0
         String examplesHtml = Application.getApplicationContext().getMessage(stmtTypeInfo.getId());
 246  
         
 247  0
         if (examplesHtml != null && !examplesHtml.equals("")) {
 248  0
                 AbbrButton examples = new AbbrButton(AbbrButtonType.EXAMPLES);
 249  0
                 examples.setVisible(true);
 250  0
                 examples.setHoverHTML(examplesHtml);
 251  0
                 examples.getHoverPopup().addStyleName("ks-example-popup");
 252  0
                 labelExamples.add(examples);
 253  
         }
 254  
         
 255  0
         HorizontalPanel spacer0 = new HorizontalPanel();
 256  0
         spacer0.addStyleName("KS-Course-Requisites-Button-Spacer");
 257  0
         labelExamples.add(spacer0);
 258  
  
 259  0
         layout.add(labelExamples);
 260  
         
 261  
         //display "Add Rule" button if user is in 'edit' mode OR a rule is already defined
 262  0
         final String stmtId = stmtTypeInfo.getId();
 263  0
         if (!isReadOnly) { // && rules.getCourseReqInfo(stmtId).isEmpty()) {
 264  0
             KSButton addCourseReqButton = new KSButton("Add " + stmtTypeInfo.getName(), KSButtonAbstract.ButtonStyle.FORM_SMALL);
 265  0
             addCourseReqButton.addClickHandler(new ClickHandler(){
 266  
                 public void onClick(ClickEvent event) {
 267  
 
 268  0
                     storeRules(false, new Callback<Boolean>() {
 269  
                         @Override
 270  
                         public void exec(Boolean courseExists) {
 271  0
                             if (courseExists) {
 272  0
                                 final StatementTreeViewInfo newRule = new StatementTreeViewInfo();
 273  0
                                 newRule.setId(generateStatementTreeId());
 274  0
                                 newRule.setType(stmtId);
 275  0
                                 RichTextInfo text = new RichTextInfo();
 276  0
                                 text.setPlain("");
 277  0
                                 newRule.setDesc(text);
 278  0
                                 parentController.getView(
 279  
                                         CourseRequirementsViewController.CourseRequirementsViews.MANAGE,
 280  0
                                         new Callback<View>() {
 281  
                                     @Override
 282  
                                     public void exec(View result) {
 283  0
                                         rules.addRule(newRule);
 284  0
                                         ((CourseRequirementsManageView) result).setRuleTree(newRule, true, rules.getInternalCourseReqID(newRule));
 285  0
                                         parentController.showView(CourseRequirementsViewController.CourseRequirementsViews.MANAGE);
 286  0
                                     }
 287  
                                 });
 288  
                             }
 289  0
                         }
 290  
                     });
 291  0
                 };
 292  
             });
 293  0
             addCourseReqButton.setVisible(rules.getCourseReqInfo(stmtId).isEmpty());
 294  0
             addButtonsList.put(stmtId, addCourseReqButton);
 295  0
             layout.add(addCourseReqButton);
 296  0
             VerticalPanel spacer = new VerticalPanel();
 297  0
             spacer.addStyleName("KS-Course-Requisites-Button-Spacer");            
 298  0
             layout.add(spacer);
 299  
         }
 300  
 
 301  0
         layout.add(requirementsPanel);
 302  0
     }
 303  
 
 304  
     protected SubrulePreviewWidget addCourseRequisite(final SpanPanel requirementsPanel,
 305  
             final StatementTreeViewInfo rule) {
 306  
 
 307  0
         Integer internalProgReqID =  rules.getInternalCourseReqID(rule);
 308  0
         String stmtTypeId = rule.getType();
 309  
         
 310  0
         final SubrulePreviewWidget rulePreviewWidget = new SubrulePreviewWidget(rule, isReadOnly, getCluSetWidgetList(rule));
 311  
 
 312  0
         addRulePreviewWidgetHandlers(requirementsPanel, rulePreviewWidget, stmtTypeId, internalProgReqID);
 313  0
         return rulePreviewWidget;
 314  
     }
 315  
 
 316  
     private void addRulePreviewWidgetHandlers(final SpanPanel requirementsPanel, final SubrulePreviewWidget subRuleWidget, final String stmtTypeId, final Integer internalProgReqID) {
 317  
 
 318  0
         subRuleWidget.addEditButtonClickHandler(new ClickHandler() {
 319  
             public void onClick(ClickEvent event) {
 320  0
                 parentController.getView(CourseRequirementsViewController.CourseRequirementsViews.MANAGE, new Callback<View>(){
 321  
                     @Override
 322  
                     public void exec(View result) {
 323  0
                         ((CourseRequirementsManageView) result).setRuleTree(rules.getRule(internalProgReqID), false, internalProgReqID);
 324  0
                         parentController.showView(CourseRequirementsViewController.CourseRequirementsViews.MANAGE);
 325  0
                     }
 326  
                 });                
 327  0
             }
 328  
         });
 329  
                 
 330  0
         subRuleWidget.addDeleteButtonClickHandler(new ClickHandler() {
 331  
             public void onClick(ClickEvent event) {
 332  
                 //deleting subrule does not delete the requirement (rule) itself
 333  0
                 rules.markRuleAsEdited(internalProgReqID);
 334  
                 //remove rule from display and storage
 335  0
                 rules.deleteRule(internalProgReqID);
 336  0
                 requirementsPanel.remove(subRuleWidget);
 337  0
                 addButtonsList.get(stmtTypeId).setVisible(true);
 338  0
             }
 339  
         });                   
 340  0
     }
 341  
 
 342  
     static public boolean isTopStatement(StatementTypeInfo stmtInfo) {
 343  0
         return ((stmtInfo.getAllowedStatementTypes() != null) && !stmtInfo.getAllowedStatementTypes().isEmpty());
 344  
     }
 345  
 
 346  
     static public Map<String, Widget> getCluSetWidgetList(StatementTreeViewInfo rule) {
 347  0
         Map<String, Widget> widgetList = new HashMap<String, Widget>();
 348  0
         Set<String> cluSetIds = new HashSet<String>();
 349  0
         findCluSetIds(rule, cluSetIds);
 350  0
         for (String clusetId : cluSetIds) {
 351  0
             widgetList.put(clusetId, new CluSetDetailsWidget(clusetId, cluSetRetriever));
 352  
         }
 353  
 
 354  0
         return widgetList;
 355  
     }
 356  
 
 357  
     static private void findCluSetIds(StatementTreeViewInfo rule, Set<String> list) {
 358  
 
 359  0
         List<StatementTreeViewInfo> statements = rule.getStatements();
 360  0
         List<ReqComponentInfo> reqComponentInfos = rule.getReqComponents();
 361  
 
 362  0
         if ((statements != null) && (statements.size() > 0)) {
 363  
             // retrieve all statements
 364  0
             for (StatementTreeViewInfo statement : statements) {
 365  0
                 findCluSetIds(statement, list); // inside set the children of this statementTreeViewInfo
 366  
             }
 367  0
         } else if ((reqComponentInfos != null) && (reqComponentInfos.size() > 0)) {
 368  
             // retrieve all req. component LEAFS
 369  0
             for (ReqComponentInfo reqComponent : reqComponentInfos) {
 370  0
                 List<ReqCompFieldInfo> fieldInfos = reqComponent.getReqCompFields();
 371  0
                 for (ReqCompFieldInfo fieldInfo : fieldInfos) {
 372  0
                     if (RulesUtil.isCluSetWidget(fieldInfo.getType())) {
 373  0
                         list.add(fieldInfo.getValue());
 374  
                     }
 375  
                 }
 376  0
             }
 377  
         }
 378  0
     }
 379  
 
 380  
     private void setupSaveCancelButtons() {
 381  0
         actionCancelButtons.addStyleName("KS-Course-Requisites-Save-Button");
 382  0
         actionCancelButtons.addCallback(new Callback<ButtonEnumerations.ButtonEnum>(){
 383  
              @Override
 384  
             public void exec(ButtonEnumerations.ButtonEnum result) {
 385  0
                 if (result == ButtonEnumerations.SaveContinueCancelEnum.SAVE_CONTINUE) {
 386  0
                     storeRules(true, new Callback<Boolean>() {
 387  
                         @Override
 388  
                         public void exec(Boolean result) {
 389  0
                             if (result) {
 390  0
                                 CourseProposalController courseController = ((CourseProposalController) parentController.getParentController());
 391  0
                                 courseController.showNextViewOnMenu();
 392  0
                                 courseController.getReqDataModel().retrieveStatementTypes(courseController.getCourseId(), Controller.NO_OP_CALLBACK);
 393  
                             }
 394  0
                         }
 395  
                     });                    
 396  
                 } else {
 397  0
                     if(! ((CourseProposalController)parentController.getController()).isNew()){
 398  0
                         (parentController.getController()).showView(CourseProposalConfigurer.CourseSections.SUMMARY);
 399  
                     }
 400  
                     else{
 401  0
                         Application.navigate(AppLocations.Locations.CURRICULUM_MANAGEMENT.getLocation());
 402  
                     }
 403  
                 }
 404  0
             }
 405  
         });
 406  0
     }
 407  
 
 408  
     public void storeRules(final boolean storeRules, final Callback<Boolean> callback) {
 409  0
         parentController.requestModel(CourseRequirementsViewController.COURSE_PROPOSAL_MODEL, new ModelRequestCallback() {
 410  
             @Override
 411  
             public void onRequestFail(Throwable cause) {
 412  0
                 Window.alert(cause.getMessage());
 413  0
                 GWT.log("Unable to retrieve model for course requirements view", cause);
 414  0
                 callback.exec(false);
 415  0
             }
 416  
             @Override
 417  
             public void onModelReady(Model model) {
 418  0
                 String courseId = ((DataModel)model).getRoot().get("id");
 419  0
                 String courseState = ((DataModel)model).getRoot().get("state");
 420  0
                 if (courseId == null) {
 421  0
                     final ConfirmationDialog dialog = new ConfirmationDialog("Submit Course Title", "Before saving rules please submit course proposal title");
 422  0
                     dialog.getConfirmButton().addClickHandler(new ClickHandler(){
 423  
                         @Override
 424  
                         public void onClick(ClickEvent event) {
 425  0
                             dialog.hide();
 426  0
                         }
 427  
                     });
 428  0
                     dialog.show();
 429  0
                     callback.exec(false);
 430  0
                 } else {
 431  0
                     if (storeRules) {
 432  0
                         rules.updateCourseRequisites(courseId, courseState, new Callback<List<StatementTreeViewInfo>>() {
 433  
                             @Override
 434  
                             public void exec(List<StatementTreeViewInfo> rules) {
 435  0
                                 for (StatementTreeViewInfo rule : rules) {
 436  0
                                     updateRequirementWidgets(rule);
 437  
                                 }
 438  0
                                 callback.exec(true);                                
 439  0
                             }
 440  
                         });
 441  
                     } else {
 442  0
                         callback.exec(true);                         
 443  
                     }
 444  
                 }
 445  0
             }
 446  
         });
 447  0
     }
 448  
     
 449  
     static public String generateStatementTreeId() {
 450  0
         return (NEW_STMT_TREE_ID + Integer.toString(tempProgReqInfoID++));
 451  
     }
 452  
 }