001 /**
002 * Copyright 2010 The Kuali Foundation Licensed under the
003 * Educational Community License, Version 2.0 (the "License"); you may
004 * not use this file except in compliance with the License. You may
005 * obtain a copy of the License at
006 *
007 * http://www.osedu.org/licenses/ECL-2.0
008 *
009 * Unless required by applicable law or agreed to in writing,
010 * software distributed under the License is distributed on an "AS IS"
011 * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
012 * or implied. See the License for the specific language governing
013 * permissions and limitations under the License.
014 */
015
016 package org.kuali.student.common.ui.client.mvc;
017
018 import java.util.List;
019
020 import org.kuali.student.common.rice.authorization.PermissionType;
021 import org.kuali.student.common.ui.client.security.AuthorizationCallback;
022 import org.kuali.student.common.ui.client.security.RequiresAuthorization;
023
024
025 /**
026 * This is a simple view composite that delegates all view operations to nested
027 * controller. Use of this view allows you to nest controllers in the view
028 * hierarchy. This class is deprecated for all future development.
029 *
030 * @author Kuali Student Team
031 *
032 */
033 @Deprecated
034 public class DelegatingViewComposite extends ViewComposite implements RequiresAuthorization {
035 Controller childController;
036
037 /**
038 * @param controller
039 * @param name
040 */
041 public DelegatingViewComposite(Controller parentController, Controller childController, Enum<?> viewType) {
042 super(parentController, "DelegatingViewComposite", viewType);
043 initWidget(childController);
044 this.childController = childController;
045 }
046
047 /**
048 * Delegates beforeHide to the nested controllers current view
049 *
050 * @see org.kuali.student.common.ui.client.mvc.View#beforeHide()
051 */
052 @Override
053 public boolean beforeHide() {
054 return childController.getCurrentView().beforeHide();
055 }
056
057 /**
058 * @see org.kuali.student.common.ui.client.mvc.View#beforeShow()
059 */
060 @Override
061 public void beforeShow(final Callback<Boolean> onReadyCallback) {
062 if (childController.getCurrentView() == null){
063 childController.showDefaultView(onReadyCallback);
064 } else {
065 childController.getCurrentView().beforeShow(onReadyCallback);
066 }
067 }
068
069 public Controller getChildController(){
070 return childController;
071 }
072
073 public void setChildController(Controller controller){
074 this.childController = controller;
075 }
076
077 @Override
078 public String collectHistory(String historyStack) {
079 return childController.collectHistory(historyStack);
080 }
081
082 @Override
083 public void onHistoryEvent(String historyStack) {
084 childController.onHistoryEvent(historyStack);
085 }
086
087 @Override
088 public void clear() {
089 childController.resetCurrentView();
090 }
091
092 @Override
093 public void checkAuthorization(PermissionType permissionType, AuthorizationCallback callback) {
094 if (childController instanceof RequiresAuthorization){
095 ((RequiresAuthorization)childController).checkAuthorization(permissionType, callback);
096 }
097 }
098
099 @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 }