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 | 0 | super(parentController, "DelegatingViewComposite", viewType); |
42 | 0 | initWidget(childController); |
43 | 0 | this.childController = childController; |
44 | 0 | } |
45 | |
|
46 | |
|
47 | |
|
48 | |
|
49 | |
|
50 | |
|
51 | |
@Override |
52 | |
public boolean beforeHide() { |
53 | 0 | return childController.getCurrentView().beforeHide(); |
54 | |
} |
55 | |
|
56 | |
|
57 | |
|
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 | |
} |