View Javadoc

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.rice.authorization.PermissionType;
21  import org.kuali.student.common.ui.client.security.AuthorizationCallback;
22  import org.kuali.student.common.ui.client.security.RequiresAuthorization;
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.  This class is deprecated for all future development.
29   * 
30   * @author Kuali Student Team
31   *
32   */
33  @Deprecated
34  public class DelegatingViewComposite extends ViewComposite implements RequiresAuthorization {
35      Controller childController;
36      
37      /**
38       * @param controller
39       * @param name
40       */
41      public DelegatingViewComposite(Controller parentController, Controller childController, Enum<?> viewType) {
42          super(parentController, "DelegatingViewComposite", viewType);
43          initWidget(childController);
44          this.childController = childController;
45      }
46  
47      /**
48       * Delegates beforeHide to the nested controllers current view
49       * 
50       * @see org.kuali.student.common.ui.client.mvc.View#beforeHide()
51       */
52      @Override
53      public boolean beforeHide() {
54          return childController.getCurrentView().beforeHide();
55      }
56  
57      /**
58       * @see org.kuali.student.common.ui.client.mvc.View#beforeShow()
59       */
60      @Override
61      public void beforeShow(final Callback<Boolean> onReadyCallback) {
62          if (childController.getCurrentView() == null){
63              childController.showDefaultView(onReadyCallback);
64          } else {
65              childController.getCurrentView().beforeShow(onReadyCallback);
66          }
67      }
68      
69      public Controller getChildController(){
70          return childController;
71      }
72      
73      public void setChildController(Controller controller){
74          this.childController = controller;
75      }
76      
77      @Override
78  	public String collectHistory(String historyStack) {
79  		return childController.collectHistory(historyStack);
80  	}
81  
82  	@Override
83  	public void onHistoryEvent(String historyStack) {
84  		childController.onHistoryEvent(historyStack);
85  	}
86  
87  	@Override
88      public void clear() {
89      	childController.resetCurrentView();
90      }
91  
92  	@Override
93  	public void checkAuthorization(PermissionType permissionType, AuthorizationCallback callback) {
94  		if (childController instanceof RequiresAuthorization){
95  			((RequiresAuthorization)childController).checkAuthorization(permissionType, callback);
96  		}				
97  	}
98  
99  	@Override
100 	public boolean isAuthorizationRequired() {
101 		if (childController instanceof RequiresAuthorization){
102 			return ((RequiresAuthorization)childController).isAuthorizationRequired();
103 		} else {
104 			return false;
105 		}
106 	}
107 
108 	@Override
109 	public void setAuthorizationRequired(boolean required) {
110 		if (childController instanceof RequiresAuthorization){
111 			((RequiresAuthorization)childController).setAuthorizationRequired(required);
112 		}		
113 	}
114 
115 	@Override
116 	public void collectBreadcrumbNames(List<String> names) {
117 		childController.collectBreadcrumbNames(names);
118 		
119 	}
120 
121 }