1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.exoplatform.ecm.webui.component.admin;
18
19 import java.util.ArrayList;
20 import java.util.List;
21
22 import org.exoplatform.services.log.Log;
23 import org.exoplatform.services.log.ExoLogger;
24 import org.exoplatform.webui.config.annotation.ComponentConfig;
25 import org.exoplatform.webui.core.UIComponent;
26 import org.exoplatform.webui.core.UIContainer;
27 import org.exoplatform.webui.ext.UIExtension;
28 import org.exoplatform.webui.ext.UIExtensionManager;
29 import org.exoplatform.webui.ext.manager.UIAbstractManagerComponent;
30
31
32
33
34
35
36
37
38 @ComponentConfig(
39 template = "app:/groovy/webui/component/admin/UIECMAdminControlPanel.gtmpl"
40 )
41 public class UIECMAdminControlPanel extends UIContainer {
42
43
44
45
46 private static final Log LOG = ExoLogger.getLogger(UIECMAdminControlPanel.class.getName());
47
48 public static final String EXTENSION_TYPE = "org.exoplatform.ecm.dms.UIECMAdminControlPanel";
49
50 private List<UIAbstractManagerComponent> managers = new ArrayList<UIAbstractManagerComponent>();
51
52 public UIECMAdminControlPanel() throws Exception {}
53 public List<?> getEvents() { return getComponentConfig().getEvents() ; }
54
55 void initialize() throws Exception {
56 UIExtensionManager manager = getApplicationComponent(UIExtensionManager.class);
57 List<UIExtension> extensions = manager.getUIExtensions(EXTENSION_TYPE);
58 if (extensions == null) {
59 return;
60 }
61 for (UIExtension extension : extensions) {
62 UIComponent component = manager.addUIExtension(extension, null, this);
63 if (component instanceof UIAbstractManagerComponent) {
64
65 UIAbstractManagerComponent uiAbstractManagerComponent = (UIAbstractManagerComponent) component;
66 uiAbstractManagerComponent.setUIExtensionName(extension.getName());
67 uiAbstractManagerComponent.setUIExtensionCategory(extension.getCategory());
68 managers.add(uiAbstractManagerComponent);
69 } else if (component != null) {
70
71 if (LOG.isWarnEnabled()) {
72 LOG.warn("All the extension '" + extension.getName() + "' of type '" + EXTENSION_TYPE
73 + "' must be associated to a component of type " + UIAbstractManagerComponent.class);
74 }
75 removeChild(component.getClass());
76 }
77 }
78 }
79
80 List<UIAbstractManagerComponent> getManagers() {
81 return managers;
82 }
83
84 void unregister(UIAbstractManagerComponent component) {
85 managers.remove(component);
86 }
87
88
89
90
91
92
93
94
95
96 public boolean isSameCategoryWithCurrentRenderedManager (String currentCategory,
97 ArrayList<String> categories,
98 ArrayList<ArrayList<UIAbstractManagerComponent>> managersGroup) {
99 int i = 0;
100 UIECMAdminWorkingArea workingArea = this.getAncestorOfType(UIECMAdminPortlet.class).getChild(UIECMAdminWorkingArea.class);
101 String currentRenderId = workingArea.getRenderedCompId();
102 for(String category : categories) {
103 if (category.equals(currentCategory)) {
104 ArrayList<UIAbstractManagerComponent> groups = managersGroup.get(i);
105 for(UIAbstractManagerComponent group : groups) {
106 String extensionName = group.getUIExtensionName();
107 if (extensionName.equals(currentRenderId))
108 return true;
109 }
110 }
111 i++;
112 }
113 return false;
114 }
115 }