Author: roy.russo(a)jboss.com
Date: 2006-11-27 12:06:21 -0500 (Mon, 27 Nov 2006)
New Revision: 5722
Modified:
trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/Configurator.java
trunk/core/src/resources/portal-core-war/WEB-INF/jsp/dashboard/editpage.jsp
Log:
JBPORTAL-993 - assign/remove windows functionality added to page editor.
Modified: trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/Configurator.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/Configurator.java 2006-11-26
02:55:41 UTC (rev 5721)
+++
trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/Configurator.java 2006-11-27
17:06:21 UTC (rev 5722)
@@ -29,10 +29,10 @@
import org.jboss.portal.core.model.portal.Window;
import org.jboss.portal.theme.ThemeConstants;
import org.jboss.portlet.JBossActionRequest;
+import org.jboss.portlet.JBossActionResponse;
import org.jboss.portlet.JBossPortlet;
import org.jboss.portlet.JBossRenderRequest;
import org.jboss.portlet.JBossRenderResponse;
-import org.jboss.portlet.JBossActionResponse;
import javax.portlet.PortletException;
import javax.portlet.PortletRequestDispatcher;
@@ -54,6 +54,9 @@
private PortalObjectContainer portalObjectContainer;
+ private static final int MOVE_UP = 0;
+ private static final int MOVE_DOWN = 1;
+
public void init()
throws PortletException
{
@@ -115,6 +118,104 @@
protected void processAction(JBossActionRequest actionRequest, JBossActionResponse
actionResponse)
{
- System.out.println("blah");
+ String op = actionRequest.getParameter("op");
+ if ("copy".equals(op))
+ {
+ String toRegion = actionRequest.getParameter("toRegion");
+ String[] copyInstance =
actionRequest.getParameterValues("available_instances");
+
+ Page page =
portalObjectContainer.getContext().getPortal("dashboard").getPage(actionRequest.getUser().getUserName());
+ try
+ {
+ for (int i = 0; i < copyInstance.length; i++)
+ {
+ String windowName = "" + doWindowNaming();
+ while (page.getWindow(windowName) != null)
+ {
+ windowName = "" + doWindowNaming();
+ }
+
+ Window window = page.createWindow(windowName);
+ window.setInstanceRef((String)copyInstance[i]);
+ window.setDeclaredProperty(ThemeConstants.PORTAL_PROP_REGION, toRegion);
+ window.setDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER, ""
+ Integer.MAX_VALUE);
+ }
+ }
+ catch (Exception e)
+ {
+ // todo
+ }
+ }
+ else if ("remove".equals(op))
+ {
+ String fromRegion = actionRequest.getParameter("fromRegion");
+ String[] removeInstances = null;
+ if ("left".equals(fromRegion))
+ {
+ removeInstances =
actionRequest.getParameterValues("left_instances");
+ }
+ else if ("center".equals(fromRegion))
+ {
+ removeInstances =
actionRequest.getParameterValues("center_instances");
+ }
+ else if ("right".equals(fromRegion))
+ {
+ removeInstances =
actionRequest.getParameterValues("right_instances");
+ }
+
+ Page page =
portalObjectContainer.getContext().getPortal("dashboard").getPage(actionRequest.getUser().getUserName());
+ List removeWindows = new ArrayList();
+ for (Iterator i = page.getChildren().iterator(); i.hasNext();)
+ {
+ PortalObject object = (PortalObject)i.next();
+ if (object.getType() == PortalObject.TYPE_WINDOW)
+ {
+ Window window = (Window)object;
+ String region = object.getProperty(ThemeConstants.PORTAL_PROP_REGION);
+ String instance = window.getInstanceRef();
+ for (int j = 0; j < removeInstances.length; j++)
+ {
+ if (instance.equalsIgnoreCase(removeInstances[j]) &&
fromRegion.equalsIgnoreCase(region))
+ {
+ removeWindows.add(window.getName());
+ }
+ }
+ }
+ }
+ try
+ {
+ for (int i = 0; i < removeWindows.size(); i++)
+ {
+ page.destroyChild((String)removeWindows.get(i));
+ }
+ }
+ catch (Exception e)
+ {
+ // todo
+ }
+ }
+ else if ("up".equals(op))
+ {
+ String sortRegion = actionRequest.getParameter("sortRegion");
+ String[] moveRegion = null;
+ if ("left".equals(sortRegion))
+ {
+ moveRegion = actionRequest.getParameterValues("left_instances");
+ }
+ else if ("center".equals(sortRegion))
+ {
+ moveRegion = actionRequest.getParameterValues("center_instances");
+ }
+ else if ("right".equals(sortRegion))
+ {
+ moveRegion = actionRequest.getParameterValues("right_instances");
+ }
+
+ }
}
+
+ private int doWindowNaming()
+ {
+ return (int)(100 * Math.random());
+ }
}
Modified: trunk/core/src/resources/portal-core-war/WEB-INF/jsp/dashboard/editpage.jsp
===================================================================
--- trunk/core/src/resources/portal-core-war/WEB-INF/jsp/dashboard/editpage.jsp 2006-11-26
02:55:41 UTC (rev 5721)
+++ trunk/core/src/resources/portal-core-war/WEB-INF/jsp/dashboard/editpage.jsp 2006-11-27
17:06:21 UTC (rev 5722)
@@ -35,7 +35,7 @@
function debug()
{
- alert("OP: '" + this.instancesForm.op.value + "' toRegion:
'" + this.instancesForm.toRegion.value + "' fromRegion: '" +
this.instancesForm.fromRegion.value + "' sortRegion: '" +
this.instancesForm.sortRegion.value + "'");
+ //alert("OP: '" + this.instancesForm.op.value + "' toRegion:
'" + this.instancesForm.toRegion.value + "' fromRegion: '" +
this.instancesForm.fromRegion.value + "' sortRegion: '" +
this.instancesForm.sortRegion.value + "'");
}
</script>
<table width="100%">
@@ -132,15 +132,15 @@
<tr>
<td>
<input type="submit" class="portlet-form-button"
name=">" value=">"
-
onclick="sortPortlet('copy','center');"/><br/><input
+
onclick="assignPortlet('copy','center');"/><br/><input
type="submit" class="portlet-form-button"
name="<" value="<"
-
onclick="sortPortlet('remove','center');"/></td>
+
onclick="unassignPortlet('remove','center');"/></td>
<td class="portlet-section-body"
valign="top"><b>Middle Column</b><br/>
<select name="center_instances" multiple="true"
size="6">
<%
- for (int i = 0; i < right_instances.size(); i++)
+ for (int i = 0; i < center_instances.size(); i++)
{
- String instance = (String)right_instances.get(i);
+ String instance = (String)center_instances.get(i);
%>
<option value="<%= instance %>"><%= instance%>
</option>
@@ -163,9 +163,9 @@
<td class="portlet-section-body"
valign="top"><b>Right Column</b><br/>
<select name="right_instances" multiple="true"
size="6">
<%
- for (int i = 0; i < center_instances.size(); i++)
+ for (int i = 0; i < right_instances.size(); i++)
{
- String instance = (String)center_instances.get(i);
+ String instance = (String)right_instances.get(i);
%>
<option value="<%= instance %>"><%= instance%>
</option>
@@ -185,12 +185,14 @@
</form>
</td>
</tr>
+<!--
<tr>
<td class="portlet-section-alternate" width="100%"
colspan="4" align="center">
<input type="submit" name="save" value="Save"
class="portlet-form-button"/>
<input type="submit" name="delete" value="Delete"
class="portlet-form-button"/>
</td>
</tr>
+-->
</table>
</td>
</tr>
Show replies by date