1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.exoplatform.ecm.webui.component.admin.views;
18
19 import java.util.ResourceBundle;
20
21 import org.exoplatform.web.application.RequestContext;
22 import org.exoplatform.webui.config.annotation.ComponentConfig;
23 import org.exoplatform.webui.core.UIComponent;
24 import org.exoplatform.webui.core.UIContainer;
25 import org.exoplatform.webui.core.UIPopupWindow;
26 import org.exoplatform.webui.core.lifecycle.UIContainerLifecycle;
27
28
29
30
31
32
33
34
35 @ComponentConfig(lifecycle = UIContainerLifecycle.class)
36 public class UIViewContainer extends UIContainer {
37
38 public UIViewContainer() throws Exception {
39 addChild(UIViewList.class, null, null) ;
40 }
41
42 public void initPopup(String popupId, UIComponent uiComponent) throws Exception {
43 initPopup(popupId, uiComponent, 600, 300);
44 }
45
46 public void initPopup(String popupId, UIComponent uiComponent, int width, int height) throws Exception {
47 removeChildById(popupId) ;
48 UIPopupWindow uiPopup = addChild(UIPopupWindow.class, null, popupId) ;
49 uiPopup.setShowMask(true);
50 uiPopup.setShowMask(true);
51 uiPopup.setWindowSize(width, height) ;
52 uiPopup.setUIComponent(uiComponent);
53 uiPopup.setShow(true) ;
54 uiPopup.setResizable(true);
55 }
56
57 public void update() throws Exception {
58 UIViewList uiViewList = getChild(UIViewList.class);
59 uiViewList.refresh(uiViewList.getUIPageIterator().getCurrentPage());
60 }
61
62 public String getFriendlyPermission(String permission) throws Exception {
63 RequestContext context = RequestContext.getCurrentInstance();
64 ResourceBundle res = context.getApplicationResourceBundle();
65 String permissionLabel = res.getString(getId() + ".label.permission");
66 if(permission.indexOf(":") > -1) {
67 String[] arr = permission.split(":");
68 if(arr[0].equals("*")) {
69 permissionLabel = permissionLabel.replace("{0}", "Any");
70 } else {
71 permissionLabel = permissionLabel.replace("{0}", standardizeGroupName(arr[0]));
72 }
73 String groupName = arr[1];
74 groupName = groupName.substring(groupName.lastIndexOf("/")+1);
75 permissionLabel = permissionLabel.replace("{1}", standardizeGroupName(groupName));
76 } else {
77 permissionLabel = standardizeGroupName(permission);
78 }
79 return permissionLabel;
80 }
81
82 public String standardizeGroupName(String groupName) throws Exception {
83 groupName = groupName.replaceAll("-", " ");
84 char[] stringArray = groupName.toCharArray();
85 stringArray[0] = Character.toUpperCase(stringArray[0]);
86 groupName = new String(stringArray);
87 return groupName;
88 }
89
90 }