Author: hoang_to
Date: 2009-11-17 03:26:49 -0500 (Tue, 17 Nov 2009)
New Revision: 623
Modified:
portal/trunk/web/eXoResources/src/main/webapp/javascript/eXo/portal/UIPortal.js
portal/trunk/web/portal/src/main/webapp/groovy/portal/webui/application/UIPortlet.gtmpl
portal/trunk/web/portal/src/main/webapp/groovy/portal/webui/container/UIContainer.gtmpl
portal/trunk/web/portal/src/main/webapp/groovy/portal/webui/container/UITableColumnContainer.gtmpl
portal/trunk/web/portal/src/main/webapp/groovy/portal/webui/container/UIToolbarContainer.gtmpl
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalComponentActionListener.java
Log:
GTNPORTAL-83: Update relevant Javascript and server-side action listeners
Modified: portal/trunk/web/eXoResources/src/main/webapp/javascript/eXo/portal/UIPortal.js
===================================================================
---
portal/trunk/web/eXoResources/src/main/webapp/javascript/eXo/portal/UIPortal.js 2009-11-17
05:20:43 UTC (rev 622)
+++
portal/trunk/web/eXoResources/src/main/webapp/javascript/eXo/portal/UIPortal.js 2009-11-17
08:26:49 UTC (rev 623)
@@ -515,9 +515,7 @@
window.location = url + '&action='+ action ;
} ;
-UIPortal.prototype.removeComponent = function(uri, componentId) {
- var result = ajaxAsyncGetRequest(uri, false) ;
- if(result == "OK") {
+UIPortal.prototype.removeComponent = function(componentId) {
var comp = document.getElementById(componentId);
var viewPage = eXo.core.DOMUtil.findAncestorByClass(comp, "VIEW-PAGE");
eXo.core.DOMUtil.removeElement(comp);
@@ -528,16 +526,15 @@
viewPage.style.paddingBottom = "50px";
viewPage.style.paddingLeft = "0px";
}
- }
};
+
UIPortal.prototype.changeComposerSaveButton = function() {
if(eXo.portal.hasEditted == false) {
var uiWorkingWS = document.getElementById("UIWorkingWorkspace");
var portalComposer = eXo.core.DOMUtil.findFirstDescendantByClass(uiWorkingWS,
"div", "UIPortalComposer");
var saveButton = eXo.core.DOMUtil.findFirstDescendantByClass(portalComposer,
"a", "SaveButton");
if(saveButton) eXo.core.DOMUtil.replaceClass(saveButton, "SaveButton",
"EdittedSaveButton");
- ajaxAsyncGetRequest(eXo.env.server.createPortalURL(portalComposer.id,
"ChangeEdittedState", true));
}
};
Modified:
portal/trunk/web/portal/src/main/webapp/groovy/portal/webui/application/UIPortlet.gtmpl
===================================================================
---
portal/trunk/web/portal/src/main/webapp/groovy/portal/webui/application/UIPortlet.gtmpl 2009-11-17
05:20:43 UTC (rev 622)
+++
portal/trunk/web/portal/src/main/webapp/groovy/portal/webui/application/UIPortlet.gtmpl 2009-11-17
08:26:49 UTC (rev 623)
@@ -16,13 +16,6 @@
String onControlOver = "eXo.webui.UIPortlet.onControlOver(this, true);";
String onControlOut = "eXo.webui.UIPortlet.onControlOver(this, false);";
-
- String deleteUri = uicomponent.url('DeleteComponent', uicomponent.id);
- String keyMark = "window.location=";
- String confirm = deleteUri.substring(0, deleteUri.indexOf(keyMark));
- String url = deleteUri.substring(deleteUri.indexOf(keyMark) + keyMark.length());
- url = url.substring(0, url.lastIndexOf(";"));
- deleteUri = confirm + " eXo.portal.UIPortal.removeComponent(" + url +
",'UIPortlet-" + uicomponent.id + "')";
WindowState windowState = uicomponent.getCurrentWindowState();
boolean isDesktop = "Window".equals(uicomponent.getPortletStyle());
@@ -321,10 +314,7 @@
%>
<div class="PortletIcon $portletIcon">$title</div>
<a
href="<%=uicomponent.event("EditPortlet","$uicomponent.id")%>;eXo.portal.UIPortal.changeComposerSaveButton()"
class="EditPortletPropertiesIcon"
title="<%=_ctx.appRes("UIPortlet.tooltip.editPortlet");%>"></a>
- <!--
<a
href="<%=uicomponent.event("DeleteComponent","$uicomponent.id")%>"
class="DeletePortletIcon"
title="<%=_ctx.appRes("UIPortlet.tooltip.deletePortlet");%>"></a>
- -->
- <a
href="$deleteUri;eXo.portal.UIPortal.changeComposerSaveButton()"
class="DeletePortletIcon"
title="<%=_ctx.appRes("UIPortlet.tooltip.deletePortlet");%>"></a>
</div>
<div
class="ClearLeft"><span></span></div>
</div>
Modified:
portal/trunk/web/portal/src/main/webapp/groovy/portal/webui/container/UIContainer.gtmpl
===================================================================
---
portal/trunk/web/portal/src/main/webapp/groovy/portal/webui/container/UIContainer.gtmpl 2009-11-17
05:20:43 UTC (rev 622)
+++
portal/trunk/web/portal/src/main/webapp/groovy/portal/webui/container/UIContainer.gtmpl 2009-11-17
08:26:49 UTC (rev 623)
@@ -17,13 +17,6 @@
if(uiComponentHeight != null) cssStyle += "height:
"+uiComponentHeight+";"
if(cssStyle.length() > 0) cssStyle += "\"";
- String deleteUri = uicomponent.url('DeleteComponent', uicomponent.id);
- String keyMark = "window.location=";
- String confirm = deleteUri.substring(0, deleteUri.indexOf(keyMark));
- String url = deleteUri.substring(deleteUri.indexOf(keyMark) + keyMark.length());
- url = url.substring(0, url.lastIndexOf(";"));
- deleteUri = confirm + " eXo.portal.UIPortal.removeComponent(" + url +
",'UIContainer-" + uicomponent.id + "')";
-
%>
<div class="UIContainer
<%=uiPortalApp.isEditting()?"EdittingContainer":""%>"
id="UIContainer-${uicomponent.id}" ${cssStyle}
onmouseover="eXo.portal.UIPortal.blockOnMouseOver(event, this, true);"
onmouseout="eXo.portal.UIPortal.blockOnMouseOver(event, this, false);">
@@ -72,10 +65,7 @@
<%=_ctx.appRes("UIContainer.title.Container")%>
<%}%>
</div>
- <!--
<a
href="<%=uicomponent.event("DeleteComponent","$uicomponent.id")%>"
class="DeleteContainerIcon"
title="<%=_ctx.appRes("UIContainer.tooltip.closeContainer")%>"><span></span></a>
- -->
- <a
href="$deleteUri;eXo.portal.UIPortal.changeComposerSaveButton()"
class="DeleteContainerIcon"
title="<%=_ctx.appRes("UIContainer.tooltip.closeContainer")%>"><span></span></a>
<a
href="<%=uicomponent.event("EditContainer","$uicomponent.id")%>;eXo.portal.UIPortal.changeComposerSaveButton()"
class="EditContainerIcon"
title="<%=_ctx.appRes("UIContainer.tooltip.editContainer")%>"><span></span></a>
<div
class="ClearBoth"><span></span></div>
</div>
Modified:
portal/trunk/web/portal/src/main/webapp/groovy/portal/webui/container/UITableColumnContainer.gtmpl
===================================================================
---
portal/trunk/web/portal/src/main/webapp/groovy/portal/webui/container/UITableColumnContainer.gtmpl 2009-11-17
05:20:43 UTC (rev 622)
+++
portal/trunk/web/portal/src/main/webapp/groovy/portal/webui/container/UITableColumnContainer.gtmpl 2009-11-17
08:26:49 UTC (rev 623)
@@ -8,12 +8,6 @@
UIPortalApplication uiPortalApp = rcontext.getUIApplication();
if(!uiPortalApp.isEditting() && !uicomponent.hasPermission()) return;
- String deleteUri = uicomponent.url('DeleteComponent', uicomponent.id);
- String keyMark = "window.location=";
- String confirm = deleteUri.substring(0, deleteUri.indexOf(keyMark));
- String url = deleteUri.substring(deleteUri.indexOf(keyMark) + keyMark.length());
- url = url.substring(0, url.lastIndexOf(";"));
- deleteUri = confirm + " eXo.portal.UIPortal.removeComponent(" + url +
",'UIContainer-" + uicomponent.id + "')";
%>
<div class="UIContainer
<%=uiPortalApp.isEditting()?"EdittingContainer":""%>"
id="UIContainer-${uicomponent.id}"
onmouseover="eXo.portal.UIPortal.blockOnMouseOver(event, this, true);"
onmouseout="eXo.portal.UIPortal.blockOnMouseOver(event, this, false);">
<div class="NormalContainerBlock">
@@ -76,7 +70,7 @@
<%}%>
</div>
- <a
href="$deleteUri;eXo.portal.UIPortal.changeComposerSaveButton()"
class="DeleteContainerIcon"
title="<%=_ctx.appRes("UIContainer.tooltip.closeContainer")%>"><span></span></a>
+ <a href="<%=uicomponent.event('DeleteComponent',
uicomponent.id); %>" class="DeleteContainerIcon"
title="<%=_ctx.appRes("UIContainer.tooltip.closeContainer")%>"><span></span></a>
<a
href="<%=uicomponent.event("EditContainer","$uicomponent.id")%>;eXo.portal.UIPortal.changeComposerSaveButton()"
class="EditContainerIcon"
title="<%=_ctx.appRes("UIContainer.tooltip.editContainer")%>"></a>
<div
class="ClearBoth"><span></span></div>
</div>
Modified:
portal/trunk/web/portal/src/main/webapp/groovy/portal/webui/container/UIToolbarContainer.gtmpl
===================================================================
---
portal/trunk/web/portal/src/main/webapp/groovy/portal/webui/container/UIToolbarContainer.gtmpl 2009-11-17
05:20:43 UTC (rev 622)
+++
portal/trunk/web/portal/src/main/webapp/groovy/portal/webui/container/UIToolbarContainer.gtmpl 2009-11-17
08:26:49 UTC (rev 623)
@@ -10,12 +10,6 @@
JavascriptManager jsmanager = rcontext.getJavascriptManager();
jsmanager.importJavascript('eXo.portal.PortalDragDrop');
- String deleteUri = uicomponent.url('DeleteComponent', uicomponent.id);
- String keyMark = "window.location=";
- String confirm = deleteUri.substring(0, deleteUri.indexOf(keyMark));
- String url = deleteUri.substring(deleteUri.indexOf(keyMark) + keyMark.length());
- url = url.substring(0, url.lastIndexOf(";"));
- deleteUri = confirm + " eXo.portal.UIPortal.removeComponent(" + url +
",'UIContainer-" + uicomponent.id + "')";
%>
<div class="UIContainer UIToolbarContainer
<%=uiPortalApp.isEditting()?"EdittingContainer":""%>"
id="UIContainer-${uicomponent.id}"
onmouseover="eXo.portal.UIPortal.blockOnMouseOver(event, this, true);"
onmouseout="eXo.portal.UIPortal.blockOnMouseOver(event, this, false);">
<div class="NormalContainerBlock">
@@ -78,7 +72,7 @@
<%}%>
</div>
- <a
href="$deleteUri;eXo.portal.UIPortal.changeComposerSaveButton()"
class="DeleteContainerIcon"
title="<%=_ctx.appRes("UIContainer.tooltip.closeContainer")%>"><span></span></a>
+ <a href="<%=uicomponent.event('DeleteComponent',
uicomponent.id);%>" class="DeleteContainerIcon"
title="<%=_ctx.appRes("UIContainer.tooltip.closeContainer")%>"><span></span></a>
<a
href="<%=uicomponent.event("EditContainer","$uicomponent.id")%>;eXo.portal.UIPortal.changeComposerSaveButton()"
class="EditContainerIcon"
title="<%=_ctx.appRes("UIContainer.tooltip.editContainer")%>"></a>
<div
class="ClearBoth"><span></span></div>
</div>
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalComponentActionListener.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalComponentActionListener.java 2009-11-17
05:20:43 UTC (rev 622)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalComponentActionListener.java 2009-11-17
08:26:49 UTC (rev 623)
@@ -55,6 +55,7 @@
import org.exoplatform.services.rss.parser.RSSDocument;
import org.exoplatform.services.rss.parser.RSSParser;
import org.exoplatform.web.application.ApplicationMessage;
+import org.exoplatform.web.application.JavascriptManager;
import org.exoplatform.webui.core.UIComponent;
import org.exoplatform.webui.core.UIContainer;
import org.exoplatform.webui.core.UITabPane;
@@ -94,42 +95,30 @@
}
}
- //
- // static public class RemoveJSApplicationToDesktopActionListener extends
- // EventListener<UIPortalComponent> {
- // public void execute(Event<UIPortalComponent> event) throws Exception {
- // UIPortal uiPortal = Util.getUIPortal();
- // UIPortalApplication uiApp =
- // uiPortal.getAncestorOfType(UIPortalApplication.class);
- // UIPage uiPage = uiApp.findFirstComponentOfType(UIPage.class);
- // String id =
event.getRequestContext().getRequestParameter("jsInstanceId");
- // uiPage.removeChildById(id);
- //
- // Page page = PortalDataMapper.toPageModel(uiPage);
- // UserPortalConfigService configService =
- // uiPortal.getApplicationComponent(UserPortalConfigService.class);
- // if(page.getChildren() == null) page.setChildren(new ArrayList<Object>());
- // configService.update(page);
- // }
- // }
-
static public class DeleteComponentActionListener extends
EventListener<UIComponent>
{
+ private final static String UI_CONTAINER = "UIContainer";
+
+ private final static String UI_PORTLET = "UIPortlet";
+
public void execute(Event<UIComponent> event) throws Exception
{
String id =
event.getRequestContext().getRequestParameter(UIComponent.OBJECTID);
UIComponent uiComponent = event.getSource();
UIPortalComponent uiParent = (UIPortalComponent)uiComponent.getParent();
UIComponent uiRemoveComponent = uiParent.findComponentById(id);
+ UIPortalApplication uiApp = Util.getUIPortalApplication();
if (uiRemoveComponent.findFirstComponentOfType(UIPageBody.class) != null)
{
- Util.getUIPortalApplication().addMessage(
- new ApplicationMessage("UIPortalApplication.msg.deletePageBody",
new Object[]{},
- ApplicationMessage.WARNING));
+ uiApp.addMessage(new
ApplicationMessage("UIPortalApplication.msg.deletePageBody", new Object[]{},
+ ApplicationMessage.WARNING));
return;
}
uiParent.removeChildById(id);
+ UIPortalComposer portalComposer =
uiApp.findFirstComponentOfType(UIPortalComposer.class);
+ portalComposer.setEditted(true);
+
UIPage uiPage = uiParent.getAncestorOfType(UIPage.class);
if (uiPage != null && uiPage.getMaximizedUIPortlet() != null)
{
@@ -162,11 +151,35 @@
}
Util.showComponentLayoutMode(uiRemoveComponent.getClass());
- PortalRequestContext pcontext =
(PortalRequestContext)event.getRequestContext();
- pcontext.setFullRender(false);
- pcontext.getWriter().write("OK");
- pcontext.setResponseComplete(true);
+ String componentType = null;
+ if (uiComponent instanceof UIPortlet)
+ {
+ componentType = UI_PORTLET;
+ }
+ else if (uiComponent instanceof UIContainer)
+ {
+ componentType = UI_CONTAINER;
+ }
+
+ if (componentType != null)
+ {
+ PortalRequestContext pcontext =
(PortalRequestContext)event.getRequestContext();
+ JavascriptManager jsManager = pcontext.getJavascriptManager();
+ jsManager.addJavascript(scriptRemovingComponent(id, componentType));
+
jsManager.addJavascript("eXo.portal.UIPortal.changeComposerSaveButton();");
+ }
}
+
+ private String scriptRemovingComponent(String componentId, String componentType)
+ {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("eXo.portal.UIPortal.removeComponent('");
+ buffer.append(componentType);
+ buffer.append("-");
+ buffer.append(componentId);
+ buffer.append("');");
+ return buffer.toString();
+ }
}
static public class MoveChildActionListener extends EventListener<UIContainer>
@@ -251,7 +264,7 @@
app = appList.getApplication(sourceId);
ApplicationType applicationType = app.getType();
- //TanPD: Hardcoded to fix bug GTNPORTAL-91
+ // TanPD: Hardcoded to fix bug GTNPORTAL-91
Application temp = null;
if (applicationType.equals(ApplicationType.GADGET))
{
@@ -289,7 +302,7 @@
//
uiPortlet.setState(new PortletState(state, applicationType));
- //TanPD: Fix bug GTNPORTAL-91
+ // TanPD: Fix bug GTNPORTAL-91
if (temp != null &&
applicationType.equals(ApplicationType.PORTLET))
{
Portlet pref = uiPortlet.getPreferences();
@@ -301,7 +314,7 @@
}
catch (Exception e)
{
- //Fix in case: RSS Reader Gadget
+ // Fix in case: RSS Reader Gadget
Preference aggIdPref =
pref.getPreference("aggregatorId");
String aggregatorId = null;
if (aggIdPref == null || aggIdPref.getValue() == null ||
aggIdPref.getValue().length() == 0)
@@ -310,7 +323,7 @@
aggregatorId = aggIdPref.getValue();
GadgetRegistryService gadgetSrv =
uiApp.getApplicationComponent(GadgetRegistryService.class);
org.exoplatform.application.gadget.Gadget gadget =
gadgetSrv.getGadget(aggregatorId);
- //TODO make sure it's an rss feed
+ // TODO make sure it's an rss feed
// TODO make sure that we did not add it already
UIGadget uiGadget = uiPortlet.createUIComponent(UIGadget.class,
null, null);
uiGadget.setState(new
TransientApplicationState<org.exoplatform.portal.pom.spi.gadget.Gadget>(