Author: sohil.shah(a)jboss.com
Date: 2007-08-28 11:53:58 -0400 (Tue, 28 Aug 2007)
New Revision: 8069
Added:
branches/UIServer/uiserver/src/main/org/jboss/portal/test/uiserver/layout/TestRegionLayoutManager.java
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/layout/classic/RegionConstraints.java
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/layout/classic/RegionLayoutManager.java
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/protocol/
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/protocol/PageResult.java
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/protocol/WindowResult.java
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/service/
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/service/UIServer.java
Modified:
branches/UIServer/core/src/main/org/jboss/portal/core/theme/PageRendition.java
branches/UIServer/uiserver/
branches/UIServer/uiserver/build.xml
branches/UIServer/uiserver/src/main/org/jboss/portal/test/uiserver/layout/TestFlexibleGrid.java
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/layout/Component.java
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/layout/LayoutService.java
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/layout/Page.java
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/layout/Window.java
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/layout/classic/FlexibleGrid.java
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/layout/classic/FlexibleGridLayoutManager.java
Log:
Prototype for the LayoutManagement service of UIServer
Modified: branches/UIServer/core/src/main/org/jboss/portal/core/theme/PageRendition.java
===================================================================
---
branches/UIServer/core/src/main/org/jboss/portal/core/theme/PageRendition.java 2007-08-28
13:44:21 UTC (rev 8068)
+++
branches/UIServer/core/src/main/org/jboss/portal/core/theme/PageRendition.java 2007-08-28
15:53:58 UTC (rev 8069)
@@ -30,12 +30,21 @@
import org.jboss.portal.theme.PortalTheme;
import org.jboss.portal.theme.page.PageResult;
import org.jboss.portal.common.util.MarkupInfo;
+import org.jboss.portal.theme.page.WindowContext;
+import org.jboss.portal.theme.page.WindowResult;
import org.jboss.portal.web.ServletContextDispatcher;
import org.jboss.portal.core.controller.ControllerResponse;
import javax.servlet.ServletException;
+import java.io.PrintWriter;
import java.io.IOException;
+import java.util.Map;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ArrayList;
+import org.jboss.portal.uiserver.service.UIServer;
+
/**
* Should not be a controller response, but it comes from legacy design.
*
@@ -72,8 +81,9 @@
/** Performs the page rendition. */
public void render(MarkupInfo markupInfo, ServletContextDispatcher dispatcher) throws
IOException, ServletException
{
+ /*
// Compute correct content type response header
-// String contentType = rendererContext.getContentType() + "; charset=" +
rendererContext.getCharset();
+ //String contentType = rendererContext.getContentType() + "; charset=" +
rendererContext.getCharset();
String contentType = markupInfo.getContentType() + "; charset=" +
markupInfo.getCharset();
// Set charset and content type on the response
@@ -86,8 +96,9 @@
//
RendererContext rendererContext = layout.getRenderContext(themeContext, markupInfo,
dispatcher);
-
+
//
+ //This is the non-uiserver based rendering
try
{
rendererContext.render(pageResult);
@@ -96,10 +107,35 @@
{
e.printStackTrace();
}
+ */
+
+ //Prototyping with the new ui server delegated rendering
+ UIServer uiServer = new UIServer(); //This will actually be a jmx service...instead
of instantiating the UiServer here
+
+ //Setup the Windows for the UIServer
+ List uiWindows = new ArrayList();
+ Map windowContexts = pageResult.getWindowContextMap();
+ for(Iterator itr=windowContexts.values().iterator();itr.hasNext();)
+ {
+ WindowContext wc = (WindowContext)itr.next();
+ WindowResult result = wc.getResult();
+
+ org.jboss.portal.uiserver.protocol.WindowResult uiWindow = new
org.jboss.portal.uiserver.protocol.WindowResult(wc.getId(),
+ result.getTitle(), result.getContent(), result.getHeaderContent(),
result.getWindowState(), result.getMode()
+ );
+
+ uiWindows.add(uiWindow);
+ }
+
+ //Setup the Page for the UIServer
+ org.jboss.portal.uiserver.protocol.PageResult uiPageResult = new
org.jboss.portal.uiserver.protocol.PageResult(this.pageResult.getPageName(), uiWindows);
+
+ //Delegate Rendering to the UIServer
+ uiServer.render(new PrintWriter(dispatcher.getResponse().getOutputStream()),
uiPageResult);
}
public PageResult getPageResult()
{
return pageResult;
- }
+ }
}
Property changes on: branches/UIServer/uiserver
___________________________________________________________________
Name: svn:ignore
+ output
src-backup
Modified: branches/UIServer/uiserver/build.xml
===================================================================
--- branches/UIServer/uiserver/build.xml 2007-08-28 13:44:21 UTC (rev 8068)
+++ branches/UIServer/uiserver/build.xml 2007-08-28 15:53:58 UTC (rev 8069)
@@ -96,6 +96,7 @@
<!-- Configure modules -->
<call target="configure-modules"/>
<path id="dependentmodule.classpath">
+ <path refid="jboss.portlet-api.classpath"/>
<path refid="jboss.portal-common.classpath"/>
<path refid="jboss.portal-jems.classpath"/>
<path refid="jboss.portal-server.classpath"/>
Modified:
branches/UIServer/uiserver/src/main/org/jboss/portal/test/uiserver/layout/TestFlexibleGrid.java
===================================================================
---
branches/UIServer/uiserver/src/main/org/jboss/portal/test/uiserver/layout/TestFlexibleGrid.java 2007-08-28
13:44:21 UTC (rev 8068)
+++
branches/UIServer/uiserver/src/main/org/jboss/portal/test/uiserver/layout/TestFlexibleGrid.java 2007-08-28
15:53:58 UTC (rev 8069)
@@ -75,12 +75,12 @@
Window window2 = new Window("window-2", htmlContent);
container.addComponent(window1);
container.addComponent(window2);
- page.getContainers().add(container);
+ page.addContainer(container);
Container container2 = new Container("container-2");
container2.addComponent(window1);
container2.addComponent(window2);
- page.getContainers().add(container2);
+ page.addContainer(container2);
// Setup a Flexible Grid for laying out a container of portlet windows
@@ -196,6 +196,10 @@
constraints.setWidthPercentage(widthPercentage);
constraints.setRow(row);
constraints.setColumn(column);
+ constraints.setTop(top);
+ constraints.setBottom(bottom);
+ constraints.setLeft(left);
+ constraints.setRight(right);
return constraints;
}
}
Added:
branches/UIServer/uiserver/src/main/org/jboss/portal/test/uiserver/layout/TestRegionLayoutManager.java
===================================================================
---
branches/UIServer/uiserver/src/main/org/jboss/portal/test/uiserver/layout/TestRegionLayoutManager.java
(rev 0)
+++
branches/UIServer/uiserver/src/main/org/jboss/portal/test/uiserver/layout/TestRegionLayoutManager.java 2007-08-28
15:53:58 UTC (rev 8069)
@@ -0,0 +1,151 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.uiserver.layout;
+
+import junit.framework.TestCase;
+
+import org.apache.log4j.Logger;
+
+import java.io.FileOutputStream;
+
+import org.jboss.portal.uiserver.layout.Container;
+import org.jboss.portal.uiserver.layout.Window;
+import org.jboss.portal.uiserver.layout.Page;
+import org.jboss.portal.uiserver.layout.classic.RegionConstraints;
+import org.jboss.portal.uiserver.layout.classic.RegionLayoutManager;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class TestRegionLayoutManager extends TestCase
+{
+ /**
+ *
+ */
+ private static Logger log = Logger.getLogger(TestRegionLayoutManager.class);
+
+ /**
+ *
+ */
+ protected void setUp() throws Exception
+ {
+ }
+
+ /**
+ *
+ */
+ protected void tearDown() throws Exception
+ {
+ }
+
+ /**
+ *
+ * @throws Exception
+ */
+ public void testDoLayout() throws Exception
+ {
+ // Setup a Page and a container with two portlet windows...
+ // This part is generic with no decoupling to anything layout specific
+ String htmlContent = this.getHtmlContent();
+ Page page = new Page();
+ Container container = new Container("container-1");
+ Window window1 = new Window("window-1", htmlContent);
+ Window window2 = new Window("window-2", htmlContent);
+ container.addComponent(window1);
+ container.addComponent(window2);
+ page.addContainer(container);
+
+ Container container2 = new Container("container-2");
+ Window window3 = new Window("window-3", htmlContent);
+ Window window4 = new Window("window-4", htmlContent);
+ container2.addComponent(window3);
+ container2.addComponent(window4);
+ page.addContainer(container2);
+
+
+ // Setup a two RegionConstraints for laying out using RegionLayoutManager
+ RegionConstraints leftRegion = new
RegionConstraints("container-1",RegionConstraints.LEFT);
+ RegionConstraints centerRegion = new
RegionConstraints("container-2",RegionConstraints.CENTER);
+ RegionLayoutManager layoutManager = new RegionLayoutManager();
+ layoutManager.addRegionConstraints(leftRegion);
+ layoutManager.addRegionConstraints(centerRegion);
+
+ // Perform the actual layout of the Page using the
+ // RegionLayoutManager
+ String output = layoutManager.doLayout(page);
+
+ log.info("--------------------------------------");
+ log.info(output);
+ log.info("--------------------------------------");
+
+ // Write this output to local file to test in a browser
+ FileOutputStream fos = new FileOutputStream(
+ "/home/soshah/html/layout/regionLayout.html");
+
+ StringBuffer buffer = new StringBuffer();
+
+ buffer
+ .append("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0
Transitional//EN\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitiona...
xmlns=\"http://www.w3.org/1999/xhtml\"><head><base
href=\"http://localhost/\"/><title>CSS Layout
Strategies</title><link rel=\"stylesheet\" type=\"text/css\"
href=\"file:///home/soshah/html/layout/unitTest.css\"/></head><body
id=\"body\">\n");
+ buffer.append(output);
+ buffer.append("</body></html>\n");
+
+ fos.write(buffer.toString().getBytes());
+ fos.flush();
+ fos.close();
+ }
+
+ /**
+ *
+ * @return
+ */
+ private String getHtmlContent()
+ {
+ String markup = null;
+
+ try
+ {
+ java.io.FileInputStream fis = new java.io.FileInputStream(
+ "/home/soshah/html/layout/greetings2.html");
+
+ StringBuffer buffer = new StringBuffer();
+ int read = 0;
+ byte[] data = new byte[1000];
+ while ((read = fis.read(data)) != -1)
+ {
+ byte[] bufferData = new byte[read];
+ System.arraycopy(data, 0, bufferData, 0, read);
+ buffer.append(new String(bufferData));
+ }
+
+ markup = buffer.toString();
+ fis.close();
+ }
+ catch (Exception e)
+ {
+
+ }
+
+ return markup;
+ }
+}
Modified:
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/layout/Component.java
===================================================================
---
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/layout/Component.java 2007-08-28
13:44:21 UTC (rev 8068)
+++
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/layout/Component.java 2007-08-28
15:53:58 UTC (rev 8069)
@@ -69,5 +69,5 @@
*
* @return
*/
- public abstract String render();
+ public abstract String getMarkup();
}
Modified:
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/layout/LayoutService.java
===================================================================
---
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/layout/LayoutService.java 2007-08-28
13:44:21 UTC (rev 8068)
+++
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/layout/LayoutService.java 2007-08-28
15:53:58 UTC (rev 8069)
@@ -33,8 +33,7 @@
*
*/
public LayoutService()
- {
-
+ {
}
/**
Modified: branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/layout/Page.java
===================================================================
---
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/layout/Page.java 2007-08-28
13:44:21 UTC (rev 8068)
+++
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/layout/Page.java 2007-08-28
15:53:58 UTC (rev 8069)
@@ -71,4 +71,13 @@
{
this.containers = containers;
}
+
+ /**
+ *
+ * @param container
+ */
+ public void addContainer(Container container)
+ {
+ this.getContainers().add(container);
+ }
}
Modified:
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/layout/Window.java
===================================================================
---
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/layout/Window.java 2007-08-28
13:44:21 UTC (rev 8068)
+++
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/layout/Window.java 2007-08-28
15:53:58 UTC (rev 8069)
@@ -54,16 +54,34 @@
this(id);
this.content = content;
}
+
+ /**
+ *
+ * @return
+ */
+ public String getContent()
+ {
+ return content;
+ }
/**
*
+ * @param content
*/
- public String render()
+ public void setContent(String content)
{
+ this.content = content;
+ }
+
+ /**
+ *
+ */
+ public String getMarkup()
+ {
String markup = "";
markup = this.content;
return markup;
- }
+ }
}
Modified:
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/layout/classic/FlexibleGrid.java
===================================================================
---
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/layout/classic/FlexibleGrid.java 2007-08-28
13:44:21 UTC (rev 8068)
+++
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/layout/classic/FlexibleGrid.java 2007-08-28
15:53:58 UTC (rev 8069)
@@ -226,12 +226,99 @@
return output;
}
+
/**
*
+ * @param container
+ * @return
+ */
+ String generateInlineStyle(Container container)
+ {
+ String style = null;
+
+ StringBuffer buffer = new StringBuffer();
+
+ for(int row=0;row<this.rows;row++)
+ {
+ for(int column=0;column<this.columns;column++)
+ {
+ String cellStyle = this.getCellStyle(row, column);
+ if(cellStyle != null && cellStyle.trim().length()>0)
+ {
+ buffer.append(cellStyle);
+ }
+ }
+ }
+
+ style = buffer.toString();
+
+ return style;
+ }
+
+ /**
+ *
* @param row
* @param column
* @return
*/
+ String getCellStyle(int row, int column)
+ {
+ String style = null;
+
+ if(this.constraints != null)
+ {
+ for(int i=0;i<this.constraints.length;i++)
+ {
+ FlexibleGridConstraints constraint = this.constraints[i];
+ if(constraint.getRow() == row && constraint.getColumn() == column)
+ {
+ StringBuffer buffer = new StringBuffer();
+
+ //Generate the layout style to be used for this cell
+
buffer.append("#grid-"+this.containerId+"-"+row+"-"+column+"{float:
left; margin: 0px; padding: 0px; width: "+constraint.getWidthPercentage()+"%;
position: relative;");
+
+ if(constraint.getTop() > 0)
+ {
+ buffer.append(" top:
"+String.valueOf(constraint.getTop())+"%;");
+ }
+
+ if(constraint.getBottom() > 0)
+ {
+ buffer.append(" bottom:
"+String.valueOf(constraint.getBottom())+"%;");
+ }
+
+ if(constraint.getLeft() > 0)
+ {
+ buffer.append(" left:
"+String.valueOf(constraint.getLeft())+"%;");
+ }
+
+ if(constraint.getRight() > 0)
+ {
+ buffer.append(" right:
"+String.valueOf(constraint.getRight())+"%;");
+ }
+
+ buffer.append("}\n");
+
+ style = buffer.toString();
+
+ return style;
+ }
+ }
+
+ //If we get here....need to use a spacer for this cell
+ int minWidth = 770/this.columns;
+ style =
"#grid-"+this.containerId+"-"+row+"-"+column+"{float:
left; line-height: 0px; font-size: 0px; min-width: "+minWidth+"px; height:
"+minWidth+"px;}\n";
+ }
+
+ return style;
+ }
+
+ /**
+ *
+ * @param row
+ * @param column
+ * @return
+ */
private String getPortletMarkup(Container container,int row,int column)
{
String markup = "";
@@ -246,7 +333,7 @@
{
String componentId = constraint.getComponentId();
Window window = (Window)container.getComponent(componentId);
- markup = window.render();
+ markup = window.getMarkup();
}
}
Modified:
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/layout/classic/FlexibleGridLayoutManager.java
===================================================================
---
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/layout/classic/FlexibleGridLayoutManager.java 2007-08-28
13:44:21 UTC (rev 8068)
+++
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/layout/classic/FlexibleGridLayoutManager.java 2007-08-28
15:53:58 UTC (rev 8069)
@@ -91,7 +91,7 @@
FlexibleGrid grid = grids[gridCounter];
Container container = containers[gridCounter];
- buffer.append(this.generateMarkup(grid, container));
+ buffer.append(grid.doLayout(container));
}
}
@@ -173,7 +173,7 @@
//Now generate the styles for each individual cell of the grid which will hold
//the components of this container
- buffer.append(this.generateInlineStyle(grid, container));
+ buffer.append(grid.generateInlineStyle(container));
}
buffer.append("</style>\n");
@@ -181,109 +181,5 @@
inlineStyle = buffer.toString();
return inlineStyle;
- }
-
- /**
- *
- * @param container
- * @return
- */
- private String generateInlineStyle(FlexibleGrid grid, Container container)
- {
- String style = null;
-
- StringBuffer buffer = new StringBuffer();
-
- int rows = grid.getRows();
- int columns = grid.getColumns();
- for(int row=0;row<rows;row++)
- {
- for(int column=0;column<columns;column++)
- {
- String cellStyle = this.getCellStyle(grid, row, column);
- if(cellStyle != null && cellStyle.trim().length()>0)
- {
- buffer.append(cellStyle);
- }
- }
- }
-
- style = buffer.toString();
-
- return style;
- }
-
- /**
- *
- * @param row
- * @param column
- * @return
- */
- private String getCellStyle(FlexibleGrid grid,int row, int column)
- {
- String style = null;
-
- FlexibleGridConstraints[] constraints = grid.getConstraints();
- if(constraints != null)
- {
- for(int i=0;i<constraints.length;i++)
- {
- FlexibleGridConstraints constraint = constraints[i];
- if(constraint.getRow() == row && constraint.getColumn() == column)
- {
- StringBuffer buffer = new StringBuffer();
-
- //Generate the layout style to be used for this cell
-
buffer.append("#grid-"+grid.getContainerId()+"-"+row+"-"+column+"{float:
left; margin: 0px; padding: 0px; width: "+constraint.getWidthPercentage()+"%;
position: relative;");
-
- if(constraint.getTop() > 0)
- {
- buffer.append(" top:
"+String.valueOf(constraint.getTop())+"%;");
- }
-
- if(constraint.getBottom() > 0)
- {
- buffer.append(" bottom:
"+String.valueOf(constraint.getBottom())+"%;");
- }
-
- if(constraint.getLeft() > 0)
- {
- buffer.append(" left:
"+String.valueOf(constraint.getLeft())+"%;");
- }
-
- if(constraint.getRight() > 0)
- {
- buffer.append(" right:
"+String.valueOf(constraint.getRight())+"%;");
- }
-
- buffer.append("}\n");
-
- style = buffer.toString();
-
- return style;
- }
- }
-
- //If we get here....need to use a spacer for this cell
- int minWidth = 770/grid.getColumns();
- style =
"#grid-"+grid.getContainerId()+"-"+row+"-"+column+"{float:
left; line-height: 0px; font-size: 0px; min-width: "+minWidth+"px; height:
"+minWidth+"px;}\n";
- }
-
- return style;
- }
-
- /**
- *
- * @param grid
- * @param container
- * @return
- */
- private String generateMarkup(FlexibleGrid grid, Container container)
- {
- String markup = null;
-
- markup = grid.doLayout(container);
-
- return markup;
- }
+ }
}
Added:
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/layout/classic/RegionConstraints.java
===================================================================
---
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/layout/classic/RegionConstraints.java
(rev 0)
+++
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/layout/classic/RegionConstraints.java 2007-08-28
15:53:58 UTC (rev 8069)
@@ -0,0 +1,101 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.uiserver.layout.classic;
+
+import java.io.Serializable;
+
+/**
+ * The RegionConstraints class specifies constraints for containers that are laid out
using the Region based layout manager.
+ *
+ * These constraints apply to an instance of a Container and its placement as its laid
out within a specified region on the Page
+ *
+ * When the Container is placed, all its Components (which are Windows) are laid out
vertically inside the Region
+ *
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class RegionConstraints implements Serializable
+{
+ public static final int LEFT = 1;
+ public static final int CENTER = 2;
+ public static final int RIGHT = 3;
+
+ /**
+ * Unique Id of the container that these constraints should be applied to
+ */
+ private String containerId = null;
+
+ /**
+ * Type of region where the component should be added
+ *
+ * makes it belong to LEFT region by default
+ */
+ private int type = 1;
+
+ /**
+ *
+ * @param containerId
+ * @param type
+ */
+ public RegionConstraints(String containerId, int type)
+ {
+ this.containerId = containerId;
+ this.type = type;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public String getContainerId()
+ {
+ return containerId;
+ }
+
+ /**
+ *
+ * @param containerId
+ */
+ public void setContainerId(String containerId)
+ {
+ this.containerId = containerId;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public int getType()
+ {
+ return type;
+ }
+
+ /**
+ *
+ * @param type
+ */
+ public void setType(int type)
+ {
+ this.type = type;
+ }
+}
Added:
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/layout/classic/RegionLayoutManager.java
===================================================================
---
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/layout/classic/RegionLayoutManager.java
(rev 0)
+++
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/layout/classic/RegionLayoutManager.java 2007-08-28
15:53:58 UTC (rev 8069)
@@ -0,0 +1,183 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.uiserver.layout.classic;
+
+import java.util.List;
+import java.util.ArrayList;
+
+import org.jboss.portal.uiserver.layout.LayoutManager;
+import org.jboss.portal.uiserver.layout.Page;
+import org.jboss.portal.uiserver.layout.Container;
+import org.jboss.portal.uiserver.layout.Window;
+
+/**
+ * This layout manager splits the page up into Regions. Containers which contain the
Portlet Windows
+ * are then laid out vertically inside each Region.
+ *
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class RegionLayoutManager implements LayoutManager
+{
+ /**
+ *
+ */
+ private List regionConstraints = null;
+
+ /**
+ *
+ *
+ */
+ public RegionLayoutManager()
+ {
+ this.regionConstraints = new ArrayList();
+ }
+
+ /**
+ *
+ * @param constraints
+ */
+ public void addRegionConstraints(RegionConstraints constraints)
+ {
+ this.regionConstraints.add(constraints);
+ }
+
+ /**
+ *
+ */
+ public String doLayout(Page page)
+ {
+ String output = null;
+
+ StringBuffer buffer = new StringBuffer();
+
+ buffer.append("<div id=\"portal-container\">\n");
+
+ //Perform layout of the containers on this page
+ Container leftContainer = this.findContainerByRegion(RegionConstraints.LEFT,
page);
+ Container centerContainer = this.findContainerByRegion(RegionConstraints.CENTER,
page);
+ Container rightContainer = this.findContainerByRegion(RegionConstraints.RIGHT,
page);
+
+ if(leftContainer != null)
+ {
+ buffer.append(this.layoutRegion(RegionConstraints.LEFT, leftContainer));
+ }
+
+ if(centerContainer != null)
+ {
+ buffer.append(this.layoutRegion(RegionConstraints.CENTER, centerContainer));
+ }
+
+ if(rightContainer != null)
+ {
+ buffer.append(this.layoutRegion(RegionConstraints.RIGHT, rightContainer));
+ }
+
+ buffer.append("</div>\n");
+
+ output = buffer.toString();
+
+ return output;
+ }
+
+ /**
+ *
+ * @param regionType
+ * @param page
+ * @return
+ */
+ private Container findContainerByRegion(int regionType, Page page)
+ {
+ Container container = null;
+
+ for(int containerCtr=0; containerCtr<page.getContainers().size();
containerCtr++)
+ {
+ Container cour = (Container)page.getContainers().get(containerCtr);
+
+ for(int constraintCtr=0; constraintCtr<this.regionConstraints.size();
constraintCtr++)
+ {
+ RegionConstraints constraints =
(RegionConstraints)this.regionConstraints.get(constraintCtr);
+
+ if(constraints.getContainerId() == cour.getId() &&
constraints.getType() == regionType)
+ {
+ container = cour;
+ break;
+ }
+ }
+
+ if(container != null)
+ {
+ break;
+ }
+ }
+
+ return container;
+ }
+
+ /**
+ *
+ * @param regionType
+ * @param container
+ */
+ private String layoutRegion(int regionType, Container container)
+ {
+ String output = null;
+
+ StringBuffer buffer = new StringBuffer();
+
+ switch(regionType)
+ {
+ case RegionConstraints.LEFT:
+ buffer.append("<div id=\"regionA\">\n");
+ break;
+
+ case RegionConstraints.CENTER:
+ buffer.append("<div id=\"regionB\">\n");
+ break;
+
+ case RegionConstraints.RIGHT:
+ buffer.append("<div id=\"regionC\">\n");
+ break;
+
+ default:
+ buffer.append("<div id=\"regionA\">\n");
+ break;
+ }
+
+ for(int i=0; i<container.getComponents().size(); i++)
+ {
+ Window window = (Window)container.getComponents().get(i);
+
+ buffer.append("<div class=\"portlet-container\"><table
width=\"100%\" border=\"0\" cellpadding=\"0\"
cellspacing=\"0\"><tr><td
class=\"portlet-titlebar-left\"></td><td
class=\"portlet-titlebar-center\"><div
class=\"portlet-titlebar-decoration\"></div><span
class=\"portlet-titlebar-title\"></span><div
class=\"portlet-mode-container\"><span
title=\"minimized\"><a class=\"portlet-mode-minimized\"
href=\"\"> </a></span><span
title=\"maximized\"><a class=\"portlet-mode-maximized\"
href=\"\"> </a></span></div></td><td
class=\"portlet-titlebar-right\"></td></tr><tr><td
class=\"portlet-content-left\"></td><td
class=\"portlet-body\"><div
class=\"portlet-content-center\">\n");
+
+ buffer.append(window.getMarkup());
+
+ buffer.append("</div></td><td
class=\"portlet-content-right\"></td></tr><tr><td
class=\"portlet-footer-left\"></td><td
class=\"portlet-footer-center\"></td><td
class=\"portlet-footer-right\"></td></tr></table></div>\n\n\n\n");
+ }
+
+ buffer.append("</div>\n\n\n\n");
+ output = buffer.toString();
+
+ return output;
+ }
+}
Added:
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/protocol/PageResult.java
===================================================================
---
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/protocol/PageResult.java
(rev 0)
+++
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/protocol/PageResult.java 2007-08-28
15:53:58 UTC (rev 8069)
@@ -0,0 +1,85 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.uiserver.protocol;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * PageResult represents data associated with the Page to be rendered on the client.
+ *
+ * Its part of the protocol package since this is the object that is exposed to the core
portal layer for communication with the UIServer
+ *
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class PageResult implements Serializable
+{
+ /**
+ * A list of WindowResult objects signifying the Windows to be rendered on this Page
+ */
+ private final List windows;
+
+ /**
+ * The name of this page
+ */
+ private String pageName;
+
+ /**
+ *
+ * @param pageName
+ * @param windows
+ */
+ public PageResult(String pageName, List windows)
+ {
+ this.pageName = pageName;
+ this.windows = windows;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public String getPageName()
+ {
+ return pageName;
+ }
+
+ /**
+ *
+ * @param pageName
+ */
+ public void setPageName(String pageName)
+ {
+ this.pageName = pageName;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public List getWindows()
+ {
+ return windows;
+ }
+}
Added:
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/protocol/WindowResult.java
===================================================================
---
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/protocol/WindowResult.java
(rev 0)
+++
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/protocol/WindowResult.java 2007-08-28
15:53:58 UTC (rev 8069)
@@ -0,0 +1,155 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.uiserver.protocol;
+
+import java.io.Serializable;
+
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+
+/**
+ * WindowResult represents data associated with a Window to be rendered on a Page.
+ *
+ * Its part of the protocol package since this is the object that is exposed to the core
portal layer for communication with the UIServer
+ *
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class WindowResult implements Serializable
+{
+ /**
+ * Unique WIndowId of this Window to be rendered on the Page
+ */
+ private String id = null;
+
+ /**
+ * Title for this Window
+ */
+ private String title = null;
+
+ /**
+ * Content/Markup to be displayed inside this Window
+ */
+ private String content = null;
+
+ /**
+ * Content/Markup related to the header of this Window
+ */
+ private final String headerContent;
+
+ /**
+ * The State of this Window such as Normal, Maximized, Minimized etc
+ */
+ private final WindowState windowState;
+
+ /**
+ * The Mode of this Window such as View, Edit, Help etc
+ */
+ private final Mode mode;
+
+ /**
+ *
+ *
+ */
+ public WindowResult(String id,String title, String content, String headerContent,
WindowState windowState, Mode mode)
+ {
+ this.id = id;
+ this.title = title;
+ this.content = content;
+ this.headerContent = headerContent;
+ this.windowState = windowState;
+ this.mode = mode;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public String getId()
+ {
+ return this.id;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public String getContent()
+ {
+ return content;
+ }
+
+ /**
+ *
+ * @param content
+ */
+ public void setContent(String content)
+ {
+ this.content = content;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public String getTitle()
+ {
+ return title;
+ }
+
+ /**
+ *
+ * @param title
+ */
+ public void setTitle(String title)
+ {
+ this.title = title;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public String getHeaderContent()
+ {
+ return headerContent;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public Mode getMode()
+ {
+ return mode;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public WindowState getWindowState()
+ {
+ return windowState;
+ }
+}
Added:
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/service/UIServer.java
===================================================================
--- branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/service/UIServer.java
(rev 0)
+++
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/service/UIServer.java 2007-08-28
15:53:58 UTC (rev 8069)
@@ -0,0 +1,294 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.uiserver.service;
+
+import java.io.PrintWriter;
+import java.util.Iterator;
+import java.util.List;
+
+
+import org.jboss.portal.uiserver.layout.Container;
+import org.jboss.portal.uiserver.layout.Page;
+import org.jboss.portal.uiserver.layout.Window;
+import org.jboss.portal.uiserver.layout.LayoutManager;
+import org.jboss.portal.uiserver.layout.classic.FlexibleGrid;
+import org.jboss.portal.uiserver.layout.classic.FlexibleGridConstraints;
+import org.jboss.portal.uiserver.layout.classic.FlexibleGridLayoutManager;
+import org.jboss.portal.uiserver.layout.classic.RegionLayoutManager;
+import org.jboss.portal.uiserver.layout.classic.RegionConstraints;
+import org.jboss.portal.uiserver.protocol.PageResult;
+import org.jboss.portal.uiserver.protocol.WindowResult;
+
+/**
+ * The UIServer is responsible for generating the output that is sent back to the client
based on the Portal state of a particular Portal Request
+ *
+ * The UIServer provides various UI level services like Page Aggregation, Page Layout,
Web 2.0 client interactions etc.
+ *
+ * Typically the Core component of the Portal delegates all UI specific functions to this
component
+ *
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class UIServer
+{
+ /**
+ *
+ *
+ */
+ public UIServer()
+ {
+ }
+
+ /**
+ *
+ * @param clientConnection
+ * @param page
+ */
+ public void render(PrintWriter clientConnection, PageResult pageResult)
+ {
+ /**
+ * Special Note: Currently this prototype code and layout configuration including
page result creation is hard coded for the purpose
+ * of getting the architecture right
+ *
+ * In the real implementation, LayoutState would be fetched dynamically based on
the Page State/Configuration being rendered
+ * Even type of Client considerations would be handled here
+ *
+ * Basically the UIServer would delegate functions to its various components and
then send back the result to the client
+ *
+ */
+
+
+ /**
+ * Some flexible grid layout testing code
+ */
+ //Object[] gridData = this.getFlexibleGridLayoutManager(pageResult);
+ //Page page = (Page)gridData[0];
+ //LayoutManager layoutManager = (LayoutManager)gridData[1];
+
+ /**
+ * Some region layout testing code
+ */
+ Object[] regionData = this.getRegionBasedLayoutManager(pageResult);
+ Page page = (Page)regionData[0];
+ LayoutManager layoutManager = (LayoutManager)regionData[1];
+
+ //Peform Page Layout
+ String output = layoutManager.doLayout(page);
+
+
+ //Create the final output...Also hardcoded without any preprocessing/postprocessing
etc
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0
Transitional//EN\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitiona...
xmlns=\"http://www.w3.org/1999/xhtml\"><head><title... Portal
UIServer</title><link rel=\"stylesheet\" id=\"dyna_css\"
href=\"/portal-ajax/dyna/style.css\" type=\"text/css\"/><link
rel=\"stylesheet\" type=\"text/css\" id=\"main_css\"
href=\"/portal-core/themes/renaissance/portal_style.css\"/><link
rel=\"shortcut icon\"
href=\"/portal-core/themes/renaissance/images/favicon.ico\" /><link
rel=\"icon\" type=\"image/gif\"
href=\"/portal-core/themes/renaissance/images/animated_favicon1.gif\"
/></head><body id=\"body\">\n");
+ buffer.append(output);
+ buffer.append("</body></html>\n");
+
+
+ //Sending the results back to the Client
+ clientConnection.write(buffer.toString());
+ clientConnection.flush();
+ }
+
+
+ //---------All these are just helper methods for the
prototype-----------------------------------------------------------------------------------------------
+ //----It containts mostly hard coded logic for the
prototype-------------------------------------------------------------------------------------------------
+ /**
+ *
+ */
+ private Object[] getFlexibleGridLayoutManager(PageResult pageResult)
+ {
+ /**
+ * Hard coding the FlexibleGridLayout Management here
+ */
+ Page page = new Page();
+ Container header = new Container("header");
+ Container leftPanel = new Container("leftPanel");
+ Container mainPanel = new Container("mainPanel");
+ Window headerTabsWindow = new Window("header-tabs-window");
+ Window menuWindow = new Window("menu-window");
+ Window leftPanelWindow1 = new Window("left-panel-window1");
+ Window leftPanelWindow2 = new Window("left-panel-window2");
+ Window mainPanelWindow = new Window("main-panel-window");
+ header.addComponent(headerTabsWindow);
+ header.addComponent(menuWindow);
+ leftPanel.addComponent(leftPanelWindow1);
+ leftPanel.addComponent(leftPanelWindow2);
+ mainPanel.addComponent(mainPanelWindow);
+
+ //Setup the Grid for headerTabs container
+ page.addContainer(header);
+ FlexibleGrid headerGrid = this.getGrid("header", 1, 2);
+ FlexibleGridConstraints[] headerTabConstraints = {
this.getConstraints("header-tabs-window", "100", 0, 0, 10, 0, 0, 0),
+ this.getConstraints("menu-window", "100", 0, 0, 0, 0, 0, 1) };
+ headerGrid.setConstraints(headerTabConstraints);
+
+ //Setup the Grid for left panel container
+ page.addContainer(leftPanel);
+ FlexibleGrid leftPanelGrid = this.getGrid("leftPanel", 2, 1);
+ FlexibleGridConstraints[] leftPanelConstraints = {
this.getConstraints("left-panel-window1", "75", 0, 0, 0, 0, 0, 0),
+ this.getConstraints("left-panel-window2", "75", 0, 0, 0, 0, 1,
0) };
+ leftPanelGrid.setConstraints(leftPanelConstraints);
+
+ //Setup the Grid for main panel container
+ page.addContainer(mainPanel);
+ FlexibleGrid mainPanelGrid = this.getGrid("mainPanel", 1, 1);
+ FlexibleGridConstraints[] mainPanelConstraints = {
this.getConstraints("main-panel-window", "100", 0, 0, 0, 0, 0, 0) };
+ mainPanelGrid.setConstraints(mainPanelConstraints);
+
+ //Setup the FlexibleGrid Layout Manager with the different grids
+ FlexibleGrid[] row1 = { headerGrid };
+ FlexibleGrid[] row2 = { leftPanelGrid, mainPanelGrid };
+ FlexibleGridLayoutManager layoutManager = new FlexibleGridLayoutManager();
+ layoutManager.addRowOfGrids(row1);
+ layoutManager.addRowOfGrids(row2);
+
+ //Populate the grid windows with proper content
+ List windows = pageResult.getWindows();
+ int counter = 0;
+ for(Iterator itr=windows.iterator();itr.hasNext();)
+ {
+ WindowResult result = (WindowResult)itr.next();
+
+ switch(counter)
+ {
+ case 0:
+ leftPanelWindow1.setContent(result.getContent());
+ break;
+
+ case 1:
+ leftPanelWindow2.setContent(result.getContent());
+ break;
+
+ case 2:
+ mainPanelWindow.setContent(result.getContent());
+ break;
+
+ case 3:
+ menuWindow.setContent(result.getContent());
+ break;
+
+ case 4:
+ headerTabsWindow.setContent(result.getContent());
+ break;
+ }
+
+ counter++;
+ }
+
+ return new Object[]{page, layoutManager};
+ }
+
+
+ /**
+ *
+ * @param containerId
+ * @param rows
+ * @param columns
+ * @return
+ */
+ private FlexibleGrid getGrid(String containerId,int rows, int columns)
+ {
+ FlexibleGrid grid = new FlexibleGrid(containerId);
+ grid.setRows(rows);
+ grid.setColumns(columns);
+ return grid;
+ }
+
+ /**
+ *
+ * @param componentId
+ * @param widthPercentage
+ * @param top
+ * @param bottom
+ * @param left
+ * @param right
+ */
+ private FlexibleGridConstraints getConstraints(String componentId, String
widthPercentage, int top, int bottom, int left, int right, int row, int column)
+ {
+ FlexibleGridConstraints constraints = new FlexibleGridConstraints();
+ constraints.setComponentId(componentId);
+ constraints.setWidthPercentage(widthPercentage);
+ constraints.setRow(row);
+ constraints.setColumn(column);
+ constraints.setTop(top);
+ constraints.setBottom(bottom);
+ constraints.setLeft(left);
+ constraints.setRight(right);
+ return constraints;
+ }
+
+ /**
+ *
+ * @param pageResult
+ * @return
+ */
+ private Object[] getRegionBasedLayoutManager(PageResult pageResult)
+ {
+ Page page = new Page();
+ Container left = new Container("left");
+ Container center = new Container("center");
+ page.addContainer(left);
+ page.addContainer(center);
+
+ //Populate the grid windows with proper content
+ List windows = pageResult.getWindows();
+ int counter = 0;
+ for(Iterator itr=windows.iterator();itr.hasNext();)
+ {
+ WindowResult result = (WindowResult)itr.next();
+ Window uiWindow = new Window(result.getId());
+ uiWindow.setContent(result.getContent());
+ switch(counter)
+ {
+ case 0:
+ left.addComponent(uiWindow);
+ break;
+
+ case 1:
+ left.addComponent(uiWindow);
+ break;
+
+ case 2:
+ center.addComponent(uiWindow);
+ break;
+
+ case 3:
+ center.addComponent(uiWindow);
+ break;
+
+ case 4:
+ left.addComponent(uiWindow);
+ break;
+ }
+
+ counter++;
+ }
+
+ RegionLayoutManager layoutManager = new RegionLayoutManager();
+ RegionConstraints leftConstraints = new RegionConstraints("left",
RegionConstraints.LEFT);
+ RegionConstraints centerConstraints = new RegionConstraints("center",
RegionConstraints.CENTER);
+ layoutManager.addRegionConstraints(leftConstraints);
+ layoutManager.addRegionConstraints(centerConstraints);
+
+ return new Object[]{page, layoutManager};
+ }
+}