1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.exoplatform.ecm.webui.component.admin.templates.clv;
19
20 import org.exoplatform.ecm.webui.component.admin.UIECMAdminPortlet;
21 import org.exoplatform.webui.application.WebuiRequestContext;
22 import org.exoplatform.webui.config.annotation.ComponentConfig;
23 import org.exoplatform.webui.config.annotation.EventConfig;
24 import org.exoplatform.webui.core.UIComponent;
25 import org.exoplatform.webui.core.UIPopupContainer;
26 import org.exoplatform.webui.core.UIPopupWindow;
27 import org.exoplatform.webui.event.Event;
28 import org.exoplatform.webui.event.EventListener;
29 import org.exoplatform.webui.ext.manager.UIAbstractManager;
30
31
32
33
34
35
36
37
38 @ComponentConfig(template = "system:/groovy/webui/core/UITabPane_New.gtmpl",
39 events = { @EventConfig(listeners = UICLVTemplatesManager.SelectTabActionListener.class) })
40 public class UICLVTemplatesManager extends UIAbstractManager{
41
42 public static final String NEW_TEMPLATE = "CLVTemplatePopup" ;
43 public static final String EDIT_CLV_TEMPLATE = "EditCLVTemplatePopup" ;
44 public static final String CONTENT_TEMPLATE_ID = "ContentTemplateContainer";
45 public static final String CATE_TEMPLATE_ID = "CateTemplateContainer";
46 public static final String PAGE_TEMPLATE_ID = "PageTemplateContainer";
47 public static final String CATE_TEMPLATE_LIST_ID = "CateTemplateList";
48 public static final String PAGE_TEMPLATE_LIST_ID = "PageTemplateList";
49 public static final String CONTENT_TEMPLATE_TYPE = "contents";
50 public static final String CATEGORY_TEMPLATE_TYPE = "category";
51 public static final String PAGINATOR_TEMPLATE_TYPE = "paginators";
52
53 private String selectedTabId = "ContentTemplateContainer";
54
55 public UICLVTemplatesManager() throws Exception {
56 UICLVTemplateContainer uiContentTemp = addChild(UICLVTemplateContainer.class, null, CONTENT_TEMPLATE_ID) ;
57 uiContentTemp.getChild(UICLVTemplateList.class).setTemplateFilter(CONTENT_TEMPLATE_TYPE);
58
59 UICLVTemplateContainer uiCateTemp = addChild(UICLVTemplateContainer.class, null, CATE_TEMPLATE_ID) ;
60 uiCateTemp.getChild(UICLVTemplateList.class).setTemplateFilter(CATEGORY_TEMPLATE_TYPE);
61 uiCateTemp.getChild(UICLVTemplateList.class).setId(CATE_TEMPLATE_LIST_ID);
62
63 UICLVTemplateContainer uiPageTemp = addChild(UICLVTemplateContainer.class, null, PAGE_TEMPLATE_ID) ;
64 uiPageTemp.getChild(UICLVTemplateList.class).setTemplateFilter(PAGINATOR_TEMPLATE_TYPE);
65 uiPageTemp.getChild(UICLVTemplateList.class).setId(PAGE_TEMPLATE_LIST_ID);
66
67 setSelectedTab(CONTENT_TEMPLATE_ID);
68 }
69
70 @Override
71 public void refresh() throws Exception {
72 UICLVTemplateContainer templateContainer = ((UICLVTemplateContainer)getChildById(CONTENT_TEMPLATE_ID));
73 templateContainer.update();
74 templateContainer.getChild(UICLVTemplateList.class).getUIPageIterator().setId(CONTENT_TEMPLATE_ID + "PageIterator");
75 templateContainer.getChild(UICLVTemplateList.class).refresh(
76 templateContainer.getChild(UICLVTemplateList.class).getUIPageIterator().getCurrentPage());
77
78 UICLVTemplateContainer templateCateContainer = ((UICLVTemplateContainer)getChildById(CATE_TEMPLATE_ID));
79 templateCateContainer.update();
80 templateCateContainer.getChild(UICLVTemplateList.class).getUIPageIterator().setId(CATE_TEMPLATE_ID + "PageIterator");
81 templateCateContainer.getChild(UICLVTemplateList.class).refresh(
82 templateCateContainer.getChild(UICLVTemplateList.class).getUIPageIterator().getCurrentPage());
83
84 UICLVTemplateContainer templatePageContainer = ((UICLVTemplateContainer)getChildById(PAGE_TEMPLATE_ID));
85 templatePageContainer.update();
86 templatePageContainer.getChild(UICLVTemplateList.class).getUIPageIterator().setId(PAGE_TEMPLATE_ID + "PageIterator");
87 templatePageContainer.getChild(UICLVTemplateList.class).refresh(
88 templatePageContainer.getChild(UICLVTemplateList.class).getUIPageIterator().getCurrentPage());
89 }
90
91 public String getSelectedTabId()
92 {
93 return selectedTabId;
94 }
95
96 public void setSelectedTab(String renderTabId)
97 {
98 selectedTabId = renderTabId;
99 }
100
101 public void setSelectedTab(int index)
102 {
103 selectedTabId = getChild(index - 1).getId();
104 }
105
106 public boolean isEditingTemplate() {
107 UIECMAdminPortlet adminPortlet = this.getAncestorOfType(UIECMAdminPortlet.class);
108 UIPopupContainer popupContainer = adminPortlet.getChild(UIPopupContainer.class);
109 UIPopupWindow uiPopup = popupContainer.getChild(UIPopupWindow.class);
110 uiPopup.setId(EDIT_CLV_TEMPLATE);
111 return (uiPopup != null && uiPopup.isShow() && uiPopup.isRendered());
112 }
113
114 static public class SelectTabActionListener extends EventListener<UICLVTemplatesManager>
115 {
116 public void execute(Event<UICLVTemplatesManager> event) throws Exception
117 {
118 WebuiRequestContext context = event.getRequestContext();
119 String renderTab = context.getRequestParameter(UIComponent.OBJECTID);
120 if (renderTab == null)
121 return;
122 event.getSource().setSelectedTab(renderTab);
123 WebuiRequestContext parentContext = (WebuiRequestContext)context.getParentAppRequestContext();
124 if (parentContext != null)
125 {
126 parentContext.setResponseComplete(true);
127 }
128 else
129 {
130 context.setResponseComplete(true);
131 }
132 }
133 }
134
135 }