Coverage Report - org.kuali.student.common.ui.client.mvc.DelegatingViewComposite
 
Classes in this File Line Coverage Branch Coverage Complexity
DelegatingViewComposite
0%
0/28
0%
0/8
1.417
 
 1  
 /**
 2  
  * Copyright 2010 The Kuali Foundation Licensed under the
 3  
  * Educational Community License, Version 2.0 (the "License"); you may
 4  
  * not use this file except in compliance with the License. You may
 5  
  * obtain a copy of the License at
 6  
  *
 7  
  * http://www.osedu.org/licenses/ECL-2.0
 8  
  *
 9  
  * Unless required by applicable law or agreed to in writing,
 10  
  * software distributed under the License is distributed on an "AS IS"
 11  
  * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 12  
  * or implied. See the License for the specific language governing
 13  
  * permissions and limitations under the License.
 14  
  */
 15  
 
 16  
 package org.kuali.student.common.ui.client.mvc;
 17  
 
 18  
 import java.util.List;
 19  
 
 20  
 import org.kuali.student.common.ui.client.security.AuthorizationCallback;
 21  
 import org.kuali.student.common.ui.client.security.RequiresAuthorization;
 22  
 import org.kuali.student.core.rice.authorization.PermissionType;
 23  
 
 24  
 
 25  
 /**
 26  
  * This is a simple view composite that delegates all view operations to nested
 27  
  * controller. Use of this view allows you to nest controllers in the view
 28  
  * hierarchy.
 29  
  * 
 30  
  * @author Kuali Student Team
 31  
  *
 32  
  */
 33  
 public class DelegatingViewComposite extends ViewComposite implements RequiresAuthorization {
 34  
     Controller childController;
 35  
     
 36  
     /**
 37  
      * @param controller
 38  
      * @param name
 39  
      */
 40  
     public DelegatingViewComposite(Controller parentController, Controller childController, Enum<?> viewType) {
 41  0
         super(parentController, "DelegatingViewComposite", viewType);
 42  0
         initWidget(childController);
 43  0
         this.childController = childController;
 44  0
     }
 45  
 
 46  
     /**
 47  
      * Delegates beforeHide to the nested controllers current view
 48  
      * 
 49  
      * @see org.kuali.student.common.ui.client.mvc.View#beforeHide()
 50  
      */
 51  
     @Override
 52  
     public boolean beforeHide() {
 53  0
         return childController.getCurrentView().beforeHide();
 54  
     }
 55  
 
 56  
     /**
 57  
      * @see org.kuali.student.common.ui.client.mvc.View#beforeShow()
 58  
      */
 59  
     @Override
 60  
     public void beforeShow(final Callback<Boolean> onReadyCallback) {
 61  0
         if (childController.getCurrentView() == null){
 62  0
             childController.showDefaultView(onReadyCallback);
 63  
         } else {
 64  0
             childController.getCurrentView().beforeShow(onReadyCallback);
 65  
         }
 66  0
     }
 67  
     
 68  
     public Controller getChildController(){
 69  0
         return childController;
 70  
     }
 71  
     
 72  
     public void setChildController(Controller controller){
 73  0
         this.childController = controller;
 74  0
     }
 75  
     
 76  
     @Override
 77  
         public String collectHistory(String historyStack) {
 78  0
                 return childController.collectHistory(historyStack);
 79  
         }
 80  
 
 81  
         @Override
 82  
         public void onHistoryEvent(String historyStack) {
 83  0
                 childController.onHistoryEvent(historyStack);
 84  0
         }
 85  
 
 86  
         @Override
 87  
     public void clear() {
 88  0
             childController.resetCurrentView();
 89  0
     }
 90  
 
 91  
         @Override
 92  
         public void checkAuthorization(PermissionType permissionType, AuthorizationCallback callback) {
 93  0
                 if (childController instanceof RequiresAuthorization){
 94  0
                         ((RequiresAuthorization)childController).checkAuthorization(permissionType, callback);
 95  
                 }                                
 96  0
         }
 97  
 
 98  
         @Override
 99  
         public boolean isAuthorizationRequired() {
 100  0
                 if (childController instanceof RequiresAuthorization){
 101  0
                         return ((RequiresAuthorization)childController).isAuthorizationRequired();
 102  
                 } else {
 103  0
                         return false;
 104  
                 }
 105  
         }
 106  
 
 107  
         @Override
 108  
         public void setAuthorizationRequired(boolean required) {
 109  0
                 if (childController instanceof RequiresAuthorization){
 110  0
                         ((RequiresAuthorization)childController).setAuthorizationRequired(required);
 111  
                 }                
 112  0
         }
 113  
 
 114  
         @Override
 115  
         public void collectBreadcrumbNames(List<String> names) {
 116  0
                 childController.collectBreadcrumbNames(names);
 117  
                 
 118  0
         }
 119  
 
 120  
 }