Author: hoang_to
Date: 2010-12-08 06:04:36 -0500 (Wed, 08 Dec 2010)
New Revision: 5504
Modified:
exo/portal/branches/webos-gatein-branch/portlet/exoadmin/src/main/webapp/groovy/admintoolbar/webui/component/UIAdminToolbarPortlet.gtmpl
exo/portal/branches/webos-gatein-branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPage.java
Log:
Update GateIn code to have edit-page event handling varies with type of page
Modified:
exo/portal/branches/webos-gatein-branch/portlet/exoadmin/src/main/webapp/groovy/admintoolbar/webui/component/UIAdminToolbarPortlet.gtmpl
===================================================================
---
exo/portal/branches/webos-gatein-branch/portlet/exoadmin/src/main/webapp/groovy/admintoolbar/webui/component/UIAdminToolbarPortlet.gtmpl 2010-12-08
09:42:38 UTC (rev 5503)
+++
exo/portal/branches/webos-gatein-branch/portlet/exoadmin/src/main/webapp/groovy/admintoolbar/webui/component/UIAdminToolbarPortlet.gtmpl 2010-12-08
11:04:36 UTC (rev 5504)
@@ -6,7 +6,10 @@
import org.exoplatform.services.security.ConversationState;
import org.exoplatform.web.CacheUserProfileFilter;
import org.exoplatform.webui.application.portlet.PortletRequestContext;
-
+ import org.exoplatform.portal.webui.util.Util;
+ import org.exoplatform.portal.webui.workspace.UIPortalApplication;
+ import org.exoplatform.portal.webui.page.UIPage;
+
def rcontext = (PortletRequestContext)_ctx.getRequestContext();
java.util.Map<String, String[]> publicRenderParams =
rcontext.getRequest().getPublicParameterMap();
@@ -51,9 +54,14 @@
</div>
<% } %>
- <% if(userCouldEditPage){ %>
+ <% if(userCouldEditPage){
+
+ UIPortalApplication portalApp = Util.getUIPortalApplication();
+ UIPage uiPage = portalApp.findFirstComponentOfType(UIPage.class);//TODO: Find a
better solution than this traversing
+ String editPageRequest =
"javascript:ajaxGet(eXo.env.server.createPortalURL('" + uiPage.getId() +
"', 'EditCurrentPage', true))";
+ %>
<div class="MenuItem">
- <a
href="javascript:ajaxGet(eXo.env.server.createPortalURL('UIWorkingWorkspace',
'EditCurrentPage', true))" title="" class="ItemIcon
EditPageIcon">$editPageLabel</a>
+ <a href="$editPageRequest" title="" class="ItemIcon
EditPageIcon">$editPageLabel</a>
</div>
<% } %>
Modified:
exo/portal/branches/webos-gatein-branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPage.java
===================================================================
---
exo/portal/branches/webos-gatein-branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPage.java 2010-12-08
09:42:38 UTC (rev 5503)
+++
exo/portal/branches/webos-gatein-branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPage.java 2010-12-08
11:04:36 UTC (rev 5504)
@@ -19,16 +19,29 @@
package org.exoplatform.portal.webui.page;
+import org.exoplatform.portal.config.UserACL;
+import org.exoplatform.portal.config.model.Page;
import org.exoplatform.portal.webui.application.UIPortlet;
import org.exoplatform.portal.webui.container.UIContainer;
+import org.exoplatform.portal.webui.portal.UIPortalComposer;
import
org.exoplatform.portal.webui.portal.UIPortalComponentActionListener.MoveChildActionListener;
+import org.exoplatform.portal.webui.util.PortalDataMapper;
+import org.exoplatform.portal.webui.util.Util;
+import org.exoplatform.portal.webui.workspace.UIEditInlineWorkspace;
+import org.exoplatform.portal.webui.workspace.UIPortalApplication;
+import org.exoplatform.portal.webui.workspace.UIPortalToolPanel;
+import org.exoplatform.portal.webui.workspace.UIWorkingWorkspace;
+import org.exoplatform.web.application.ApplicationMessage;
import org.exoplatform.webui.config.annotation.ComponentConfig;
import org.exoplatform.webui.config.annotation.EventConfig;
+import org.exoplatform.webui.event.Event;
+import org.exoplatform.webui.event.EventListener;
/**
* May 19, 2006
*/
-@ComponentConfig(lifecycle = UIPageLifecycle.class, template =
"system:/groovy/portal/webui/page/UIPage.gtmpl", events =
{@EventConfig(listeners = MoveChildActionListener.class)})
+@ComponentConfig(lifecycle = UIPageLifecycle.class, template =
"system:/groovy/portal/webui/page/UIPage.gtmpl", events =
{@EventConfig(listeners = MoveChildActionListener.class),
+ @EventConfig(name = "EditCurrentPage", listeners =
UIPage.EditCurrentPageActionListener.class)})
public class UIPage extends UIContainer
{
@@ -104,4 +117,61 @@
{
this.maximizedUIPortlet = maximizedUIPortlet;
}
+
+ public static class EditCurrentPageActionListener extends EventListener<UIPage>
+ {
+ @Override
+ public void execute(Event<UIPage> event) throws Exception {
+ UIPortalApplication uiApp = Util.getUIPortalApplication();
+ UIWorkingWorkspace uiWorkingWS = uiApp
+ .getChildById(UIPortalApplication.UI_WORKING_WS_ID);
+
+ // check edit permission for page
+ UIPageBody pageBody = uiWorkingWS
+ .findFirstComponentOfType(UIPageBody.class);
+ UIPage uiPage = (UIPage) pageBody.getUIComponent();
+ if (uiPage == null) {
+ uiApp.addMessage(new ApplicationMessage(
+ "UIPageBrowser.msg.PageNotExist", null));
+ return;
+ }
+ Page page = PortalDataMapper.toPageModel(uiPage);
+
+ UserACL userACL = uiApp.getApplicationComponent(UserACL.class);
+ if (!userACL.hasEditPermission(page)) {
+ uiApp.addMessage(new ApplicationMessage(
+ "UIPortalManagement.msg.Invalid-EditPage-Permission", null));
+ return;
+ }
+
+ uiWorkingWS.setRenderedChild(UIEditInlineWorkspace.class);
+
+ UIPortalComposer portalComposer = uiWorkingWS.findFirstComponentOfType(
+ UIPortalComposer.class).setRendered(true);
+ portalComposer.setComponentConfig(UIPortalComposer.class, "UIPageEditor");
+ portalComposer.setId("UIPageEditor");
+ portalComposer.setShowControl(true);
+ portalComposer.setEditted(false);
+ portalComposer.setCollapse(false);
+
+ UIPortalToolPanel uiToolPanel = uiWorkingWS
+ .findFirstComponentOfType(UIPortalToolPanel.class);
+ uiToolPanel.setShowMaskLayer(false);
+ uiApp.setModeState(UIPortalApplication.APP_BLOCK_EDIT_MODE);
+
+ // We clone the edited UIPage object, that is required for Abort action
+ Class<? extends UIPage> clazz = Class.forName(page.getFactoryId())
+ .asSubclass(UIPage.class);
+ UIPage newUIPage = uiWorkingWS.createUIComponent(clazz, null, null);
+ PortalDataMapper.toUIPage(newUIPage, page);
+ uiToolPanel.setWorkingComponent(newUIPage);
+
+ // Remove current UIPage from UIPageBody
+ pageBody.setUIComponent(null);
+
+ event.getRequestContext().addUIComponentToUpdateByAjax(uiWorkingWS);
+ Util.getPortalRequestContext().setFullRender(true);
+
+ }
+ }
}
\ No newline at end of file
Show replies by date