1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.exoplatform.wcm.webui.fastcontentcreator;
18
19 import org.exoplatform.services.jcr.RepositoryService;
20 import org.exoplatform.wcm.webui.fastcontentcreator.config.UIFCCConfig;
21 import org.exoplatform.webui.application.WebuiApplication;
22 import org.exoplatform.webui.application.WebuiRequestContext;
23 import org.exoplatform.webui.application.portlet.PortletRequestContext;
24 import org.exoplatform.webui.config.annotation.ComponentConfig;
25 import org.exoplatform.webui.core.UIPopupContainer;
26 import org.exoplatform.webui.core.UIPortletApplication;
27 import org.exoplatform.webui.core.lifecycle.UIApplicationLifecycle;
28
29 import javax.portlet.PortletMode;
30 import javax.portlet.PortletPreferences;
31
32
33
34
35
36
37
38 @ComponentConfig(
39 lifecycle = UIApplicationLifecycle.class
40 )
41 public class UIFCCPortlet extends UIPortletApplication {
42
43
44
45
46
47
48 public UIFCCPortlet() throws Exception {
49 addChild(UIPopupContainer.class, null, null);
50 }
51
52
53
54
55
56
57
58
59 public void processRender(WebuiApplication app, WebuiRequestContext context) throws Exception {
60
61
62 context.getJavascriptManager().require("SHARED/ecm-utils", "ecmutil").
63 addScripts("ecmutil.ECMUtils.init('UIFastContentCreatorPortlet');");
64 PortletRequestContext portletRequestContext = (PortletRequestContext) context;
65 if (portletRequestContext.getApplicationMode() == PortletMode.VIEW) {
66 if (getChild(UIFCCConfig.class) != null) {
67 removeChild(UIFCCConfig.class);
68 }
69 if (getChild(UIFCCForm.class) == null) {
70 UIFCCForm fastContentCreatorForm = addChild(UIFCCForm.class, null, null);
71 PortletPreferences preferences = UIFCCUtils.getPortletPreferences();
72 fastContentCreatorForm.setTemplateNode(preferences.getValue(UIFCCConstant.PREFERENCE_TYPE,
73 ""));
74 fastContentCreatorForm.setWorkspace(preferences.getValue(UIFCCConstant.PREFERENCE_WORKSPACE,
75 ""));
76 fastContentCreatorForm.setStoredPath(preferences.getValue(UIFCCConstant.PREFERENCE_PATH, ""));
77 fastContentCreatorForm.setRepositoryName(getApplicationComponent(RepositoryService.class).getCurrentRepository()
78 .getConfiguration()
79 .getName());
80 }
81 } else if (portletRequestContext.getApplicationMode() == PortletMode.EDIT) {
82 if (getChild(UIFCCForm.class) != null) {
83 removeChild(UIFCCForm.class);
84 }
85 if (getChild(UIFCCConfig.class) == null) {
86 UIFCCConfig fastContentCreatorConfig = addChild(UIFCCConfig.class, null, null);
87 fastContentCreatorConfig.initEditMode();
88 }
89 }
90 super.processRender(app, context) ;
91 }
92 }