Coverage Report - org.kuali.student.core.statement.ui.client.widgets.rules.RuleManageWidget
 
Classes in this File Line Coverage Branch Coverage Complexity
RuleManageWidget
0%
0/46
0%
0/6
1.231
RuleManageWidget$1
0%
0/3
N/A
1.231
RuleManageWidget$2
0%
0/3
N/A
1.231
RuleManageWidget$3
0%
0/3
N/A
1.231
 
 1  
 package org.kuali.student.core.statement.ui.client.widgets.rules;
 2  
 
 3  
 import java.util.HashMap;
 4  
 import java.util.Map;
 5  
 
 6  
 import org.kuali.student.common.ui.client.mvc.Callback;
 7  
 import org.kuali.student.common.ui.client.widgets.tabs.KSTabPanel;
 8  
 import org.kuali.student.core.statement.dto.ReqComponentInfo;
 9  
 import org.kuali.student.core.statement.dto.StatementTreeViewInfo;
 10  
 
 11  
 import com.google.gwt.user.client.ui.FlowPanel;
 12  
 import com.google.gwt.user.client.ui.Widget;
 13  
 
 14  0
 public class RuleManageWidget extends FlowPanel {
 15  
 
 16  0
     private RuleTableManipulationWidget editObject = new RuleTableManipulationWidget();
 17  0
     private RuleExpressionEditor editLogic = new RuleExpressionEditor(this);
 18  0
     private SubrulePreviewWidget preview = new SubrulePreviewWidget(null, true, null);
 19  0
     private KSTabPanel panel = new KSTabPanel(KSTabPanel.TabPanelStyle.SMALL);
 20  
 
 21  
     //widget's data
 22  0
     private StatementTreeViewInfo rule = null;
 23  
     private static final String objectView = "Edit with Object";
 24  
     private static final String logicView = "Edit with Logic";
 25  
     private static final String previewView = "Preview";
 26  
 
 27  
     //TODO use application context for all labels
 28  
    
 29  
     public RuleManageWidget() {
 30  0
         super();
 31  
 
 32  0
         Map<String, Widget> tabLayoutMap = new HashMap<String, Widget>();
 33  
 
 34  0
         tabLayoutMap.put(objectView, editObject);
 35  0
         panel.addTab(objectView, objectView, editObject);
 36  0
         panel.addTabCustomCallback(objectView, new Callback<String>() {
 37  
             @Override
 38  
             public void exec(String result) {
 39  
                 //updateObjectView(false, null);
 40  0
                 editObject.redraw();
 41  0
             }
 42  
         });
 43  
 
 44  0
         tabLayoutMap.put(logicView, editLogic);
 45  0
         panel.addTab(logicView, logicView, editLogic);
 46  0
         panel.addTabCustomCallback(logicView, new Callback<String>() {
 47  
             @Override
 48  
             public void exec(String result) {
 49  0
                 updateLogicView();
 50  0
             }
 51  
         });
 52  
         
 53  0
         tabLayoutMap.put(previewView, preview);
 54  0
         panel.addTab(previewView, previewView, preview);
 55  0
         panel.addTabCustomCallback(previewView, new Callback<String>() {
 56  
             @Override
 57  
             public void exec(String result) {
 58  0
                 updatePreview();
 59  0
             }
 60  
         });
 61  
 
 62  0
         panel.selectTab(objectView);
 63  0
         add(panel);
 64  0
     }
 65  
 
 66  
     public void redraw(StatementTreeViewInfo rule, Boolean ruleChanged) {
 67  0
         this.rule = rule;
 68  0
         updateObjectView(ruleChanged);    //update object view first as other views depend on it
 69  0
         updateLogicView();
 70  
         //if we are coming from summary view then make sure object view is the default view
 71  0
         if (!ruleChanged) {
 72  0
             panel.selectTab(objectView);        
 73  
         }
 74  0
     }
 75  
 
 76  
     private void updateObjectView(Boolean ruleChanged) {
 77  0
         if (rule != null) {
 78  0
             editObject.redraw(rule, true, ruleChanged);
 79  
         }
 80  0
     }
 81  
 
 82  
     private void updateLogicView() {
 83  0
         if (rule != null) {
 84  0
             editLogic.setRule(editObject.getRule());
 85  
         }
 86  0
     }
 87  
 
 88  
     private void updatePreview() {
 89  0
         preview.showSubrule(getStatementTreeViewInfo());
 90  0
     }
 91  
 
 92  
     //called when user clicks 'update' or 'undo' on rule in rule expression editor
 93  
     protected void updateObjectRule(RuleInfo rule) {
 94  
         //this.rule = rule.getStatementVO().getStatementTreeViewInfo();
 95  0
         editObject.setRule(rule);
 96  0
     }
 97  
 
 98  
     public void setReqCompEditButtonClickCallback(Callback<ReqComponentInfo> callback) {
 99  0
         editObject.addReqCompEditButtonClickCallback(callback);
 100  0
         editLogic.addReqCompEditButtonClickCallback(callback);
 101  0
     }
 102  
 
 103  
     public void setRuleChangedButtonClickCallback(Callback<Boolean> callback) {
 104  0
         editObject.addRuleChangedButtonClickCallback(callback);
 105  0
         editLogic.addRuleChangedButtonClickCallback(callback);
 106  0
     }
 107  
 
 108  
     public StatementTreeViewInfo getStatementTreeViewInfo() {
 109  0
         return editObject.getRule().getStatementVO().getStatementTreeViewInfo();
 110  
     }
 111  
 
 112  
     public void setEnabled(boolean enabled) {
 113  0
         editObject.setEnabledView(enabled);
 114  0
         editLogic.setEnabledView(enabled);
 115  0
     }
 116  
 }