1
2
3
4
5
6
7
8
9
10
11
12
13
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
27
28
29
30
31
32
33 public class DelegatingViewComposite extends ViewComposite implements RequiresAuthorization {
34 Controller childController;
35
36
37
38
39
40 public DelegatingViewComposite(Controller parentController, Controller childController, Enum<?> viewType) {
41 super(parentController, "DelegatingViewComposite", viewType);
42 initWidget(childController);
43 this.childController = childController;
44 }
45
46
47
48
49
50
51 @Override
52 public boolean beforeHide() {
53 return childController.getCurrentView().beforeHide();
54 }
55
56
57
58
59 @Override
60 public void beforeShow(final Callback<Boolean> onReadyCallback) {
61 if (childController.getCurrentView() == null){
62 childController.showDefaultView(onReadyCallback);
63 } else {
64 childController.getCurrentView().beforeShow(onReadyCallback);
65 }
66 }
67
68 public Controller getChildController(){
69 return childController;
70 }
71
72 public void setChildController(Controller controller){
73 this.childController = controller;
74 }
75
76 @Override
77 public String collectHistory(String historyStack) {
78 return childController.collectHistory(historyStack);
79 }
80
81 @Override
82 public void onHistoryEvent(String historyStack) {
83 childController.onHistoryEvent(historyStack);
84 }
85
86 @Override
87 public void clear() {
88 childController.resetCurrentView();
89 }
90
91 @Override
92 public void checkAuthorization(PermissionType permissionType, AuthorizationCallback callback) {
93 if (childController instanceof RequiresAuthorization){
94 ((RequiresAuthorization)childController).checkAuthorization(permissionType, callback);
95 }
96 }
97
98 @Override
99 public boolean isAuthorizationRequired() {
100 if (childController instanceof RequiresAuthorization){
101 return ((RequiresAuthorization)childController).isAuthorizationRequired();
102 } else {
103 return false;
104 }
105 }
106
107 @Override
108 public void setAuthorizationRequired(boolean required) {
109 if (childController instanceof RequiresAuthorization){
110 ((RequiresAuthorization)childController).setAuthorizationRequired(required);
111 }
112 }
113
114 @Override
115 public void collectBreadcrumbNames(List<String> names) {
116 childController.collectBreadcrumbNames(names);
117
118 }
119
120 }