1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.exoplatform.ecm.webui.component.explorer.popup.admin;
18
19 import java.util.List;
20
21 import javax.jcr.Node;
22 import javax.jcr.nodetype.PropertyDefinition;
23
24 import org.exoplatform.ecm.webui.component.explorer.UIJCRExplorer;
25 import org.exoplatform.ecm.webui.utils.Utils;
26 import org.exoplatform.webui.application.WebuiRequestContext;
27 import org.exoplatform.webui.config.annotation.ComponentConfig;
28 import org.exoplatform.webui.config.annotation.EventConfig;
29 import org.exoplatform.webui.core.UIComponent;
30 import org.exoplatform.webui.core.UIContainer;
31 import org.exoplatform.webui.core.UIPopupComponent;
32 import org.exoplatform.webui.event.Event;
33 import org.exoplatform.webui.event.EventListener;
34
35
36
37
38
39
40
41
42 @ComponentConfig(
43 template = "system:/groovy/webui/core/UITabPane_New.gtmpl",
44 events = {
45 @EventConfig(listeners = UIPropertiesManager.SelectTabActionListener.class)
46 }
47 )
48
49 public class UIPropertiesManager extends UIContainer implements UIPopupComponent {
50
51 private String selectedPath_ = null;
52 private String wsName_ = null;
53 private boolean isEditProperty = false;
54 private List<PropertyDefinition> properties = null;
55 private String selectedTabId = "";
56
57 public UIPropertiesManager() throws Exception {
58 addChild(UIPropertyTab.class, null, null);
59 addChild(UIPropertyForm.class, null, null);
60 setSelectedTab(1);
61 }
62
63 public String getSelectedTabId()
64 {
65 return selectedTabId;
66 }
67
68 public void setSelectedTab(String renderTabId)
69 {
70 selectedTabId = renderTabId;
71 }
72
73 public void setSelectedTab(int index)
74 {
75 selectedTabId = getChild(index - 1).getId();
76 }
77
78 public void processRender(WebuiRequestContext context) throws Exception {
79 Node currentNode = getCurrentNode();
80 properties = org.exoplatform.services.cms.impl.Utils.getProperties(currentNode);
81
82 if (!isEditProperty && currentNode != null && !currentNode.isNodeType(Utils.NT_UNSTRUCTURED)
83 && (properties == null || properties.size() == 0)) {
84 removeChild(UIPropertyForm.class);
85 }
86 super.processRender(context);
87 }
88
89 public Node getCurrentNode() throws Exception {
90 UIJCRExplorer uiExplorer = getAncestorOfType(UIJCRExplorer.class) ;
91 if(uiExplorer != null) {
92 if(selectedPath_ != null) {
93 return uiExplorer.getNodeByPath(selectedPath_, uiExplorer.getSessionByWorkspace(wsName_));
94 }
95 return uiExplorer.getCurrentNode();
96 } else return null;
97 }
98
99 public void setSelectedPath(String selectedPath, String wsName) {
100 selectedPath_ = selectedPath;
101 wsName_ = wsName;
102 }
103
104 public void activate() {
105 }
106
107 public void deActivate() {}
108 public void setLockForm(boolean isLockForm) {
109 getChild(UIPropertyForm.class).lockForm(isLockForm) ;
110 }
111
112 static public class SelectTabActionListener extends EventListener<UIPropertiesManager> {
113 public void execute(Event<UIPropertiesManager> event) throws Exception
114 {
115 WebuiRequestContext context = event.getRequestContext();
116 String renderTab = context.getRequestParameter(UIComponent.OBJECTID);
117 if (renderTab == null)
118 return;
119 event.getSource().setSelectedTab(renderTab);
120 WebuiRequestContext parentContext = (WebuiRequestContext)context.getParentAppRequestContext();
121 if (parentContext != null) {
122 parentContext.setResponseComplete(true);
123 }
124 else {
125 context.setResponseComplete(true);
126 }
127 }
128 }
129
130 public void setIsEditProperty(boolean isEdit) { this.isEditProperty = isEdit; }
131 }