1 | |
package org.kuali.student.lum.lu.ui.course.client.views; |
2 | |
|
3 | |
import org.kuali.student.common.rice.authorization.PermissionType; |
4 | |
import org.kuali.student.common.ui.client.application.Application; |
5 | |
import org.kuali.student.common.ui.client.configurable.mvc.SectionTitle; |
6 | |
import org.kuali.student.common.ui.client.mvc.Callback; |
7 | |
import org.kuali.student.common.ui.client.mvc.Controller; |
8 | |
import org.kuali.student.common.ui.client.mvc.ViewComposite; |
9 | |
import org.kuali.student.common.ui.client.security.AuthorizationCallback; |
10 | |
import org.kuali.student.common.ui.client.security.RequiresAuthorization; |
11 | |
import org.kuali.student.lum.common.client.lo.CategoryManagement; |
12 | |
import org.kuali.student.lum.common.client.lu.LUUIPermissions; |
13 | |
|
14 | |
import com.google.gwt.user.client.ui.FlowPanel; |
15 | |
|
16 | |
public class CategoryManagementView extends ViewComposite implements RequiresAuthorization{ |
17 | |
|
18 | 0 | private FlowPanel layout = new FlowPanel(); |
19 | |
|
20 | |
public CategoryManagementView(Controller controller, String name, |
21 | |
Enum<?> viewType) { |
22 | 0 | super(controller, name, viewType); |
23 | 0 | this.initWidget(layout); |
24 | 0 | layout.addStyleName("standard-content-padding"); |
25 | 0 | layout.add(SectionTitle.generateH1Title(name)); |
26 | |
|
27 | 0 | layout.add(new CategoryManagement(true, false)); |
28 | 0 | } |
29 | |
@Override |
30 | |
public boolean isAuthorizationRequired() { |
31 | 0 | return true; |
32 | |
} |
33 | |
|
34 | |
@Override |
35 | |
public void setAuthorizationRequired(boolean required) { |
36 | 0 | throw new UnsupportedOperationException(); |
37 | |
} |
38 | |
|
39 | |
@Override |
40 | |
public void checkAuthorization(final AuthorizationCallback authCallback) { |
41 | 0 | Application.getApplicationContext().getSecurityContext().checkScreenPermission(LUUIPermissions.USE_LO_CATEGORY_SCREEN, new Callback<Boolean>() { |
42 | |
@Override |
43 | |
public void exec(Boolean result) { |
44 | |
|
45 | 0 | final boolean isAuthorized = result; |
46 | |
|
47 | 0 | if(isAuthorized){ |
48 | 0 | authCallback.isAuthorized(); |
49 | |
} |
50 | |
else |
51 | 0 | authCallback.isNotAuthorized("User is not authorized: " + LUUIPermissions.USE_LO_CATEGORY_SCREEN); |
52 | 0 | } |
53 | |
}); |
54 | 0 | } |
55 | |
} |