From portal-commits at lists.jboss.org Tue Nov 13 11:55:45 2007 Content-Type: multipart/mixed; boundary="===============4435196144771497992==" MIME-Version: 1.0 From: portal-commits at lists.jboss.org To: portal-commits at lists.jboss.org Subject: [portal-commits] JBoss Portal SVN: r8905 - in branches/UIServer: uiserver/src/main/org/jboss/portal and 2 other directories. Date: Tue, 13 Nov 2007 11:55:45 -0500 Message-ID: --===============4435196144771497992== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: sohil.shah(a)jboss.com Date: 2007-11-13 11:55:45 -0500 (Tue, 13 Nov 2007) New Revision: 8905 Added: branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/test/l= ayout/ branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/test/l= ayout/TestFlexibleGrid.java branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/test/l= ayout/TestRegionLayoutManager.java Removed: branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/test/l= ayout/TestFlexibleGrid.java branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/test/l= ayout/TestRegionLayoutManager.java branches/UIServer/uiserver/src/main/org/jboss/portal/test/ Modified: branches/UIServer/core/src/main/org/jboss/portal/core/presentation/serve= r/MainProcessor.java branches/UIServer/core/src/main/org/jboss/portal/core/presentation/serve= r/PortalObjectReaderImpl.java Log: refactoring Modified: branches/UIServer/core/src/main/org/jboss/portal/core/presentatio= n/server/MainProcessor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- branches/UIServer/core/src/main/org/jboss/portal/core/presentation/serv= er/MainProcessor.java 2007-11-13 16:51:35 UTC (rev 8904) +++ branches/UIServer/core/src/main/org/jboss/portal/core/presentation/serv= er/MainProcessor.java 2007-11-13 16:55:45 UTC (rev 8905) @@ -46,11 +46,11 @@ import org.jboss.portal.theme.page.WindowResult; = import org.jboss.portal.presentation.RequestContext; +import org.jboss.portal.presentation.model.Page; +import org.jboss.portal.presentation.model.Window; import org.jboss.portal.presentation.server.Processor; import org.jboss.portal.presentation.server.ProcessorRequest; import org.jboss.portal.presentation.server.ProcessorResponse; -import org.jboss.portal.uiserver.protocol.Page; -import org.jboss.portal.uiserver.protocol.Window; = /** * @author Sohil Shah Modified: branches/UIServer/core/src/main/org/jboss/portal/core/presentatio= n/server/PortalObjectReaderImpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- branches/UIServer/core/src/main/org/jboss/portal/core/presentation/serv= er/PortalObjectReaderImpl.java 2007-11-13 16:51:35 UTC (rev 8904) +++ branches/UIServer/core/src/main/org/jboss/portal/core/presentation/serv= er/PortalObjectReaderImpl.java 2007-11-13 16:55:45 UTC (rev 8905) @@ -31,10 +31,10 @@ import org.jboss.portal.core.model.portal.PortalObjectContainer; import org.jboss.portal.core.model.portal.PortalContainer; = -import org.jboss.portal.uiserver.protocol.Portal; -import org.jboss.portal.uiserver.protocol.PortalObject; -import org.jboss.portal.uiserver.protocol.Page; -import org.jboss.portal.uiserver.protocol.Window; +import org.jboss.portal.presentation.model.Page; +import org.jboss.portal.presentation.model.Portal; +import org.jboss.portal.presentation.model.PortalObject; +import org.jboss.portal.presentation.model.Window; import org.jboss.portal.presentation.server.PortalObjectReader; = /** Copied: branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/t= est/layout (from rev 8903, branches/UIServer/uiserver/src/main/org/jboss/po= rtal/test/uiserver/layout) Deleted: branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/= test/layout/TestFlexibleGrid.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- branches/UIServer/uiserver/src/main/org/jboss/portal/test/uiserver/layo= ut/TestFlexibleGrid.java 2007-11-13 16:25:06 UTC (rev 8903) +++ branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/test/= layout/TestFlexibleGrid.java 2007-11-13 16:55:45 UTC (rev 8905) @@ -1,205 +0,0 @@ -/*************************************************************************= ***** - * 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.protocol.Container; -import org.jboss.portal.uiserver.protocol.Window; -import org.jboss.portal.uiserver.protocol.Page; -import org.jboss.portal.uiserver.layout.classic.FlexibleGrid; -import org.jboss.portal.uiserver.layout.classic.FlexibleGridConstraints; -import org.jboss.portal.uiserver.layout.classic.FlexibleGridLayoutManager; - -/** - * @author Sohil Shah - * = - */ -public class TestFlexibleGrid extends TestCase -{ - /** - * = - */ - private static Logger log =3D Logger.getLogger(TestFlexibleGrid.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 specif= ic - String htmlContent =3D this.getHtmlContent(); - Page page =3D new Page(); - Container container =3D new Container("container-1"); - Window window1 =3D new Window("window-1", htmlContent); - Window window2 =3D new Window("window-2", htmlContent); - container.addComponent(window1); - container.addComponent(window2); - page.addContainer(container); - = - Container container2 =3D new Container("container-2"); = - container2.addComponent(window1); - container2.addComponent(window2); - page.addContainer(container2); - = - - // Setup a Flexible Grid for laying out a container of portlet windo= ws - FlexibleGrid grid1 =3D this.getGrid("container-1", 1, 2); - FlexibleGridConstraints constraints =3D this.getConstraints("window-= 1", "50", 0, 0, 25, 0, 0, 0); - FlexibleGridConstraints constraints2 =3D this.getConstraints("window= -1", "50", 0, 0, 25, 0, 0, 1); - FlexibleGridConstraints[] firstGridConstraints =3D { constraints, co= nstraints2 }; - grid1.setConstraints(firstGridConstraints); - = - = - //Setup another Grid to be added right next to the previous grid - FlexibleGrid grid2 =3D this.getGrid("container-2", 1, 2); - constraints =3D this.getConstraints("window-1", "50", 0, 0, 25, 0, 0= , 0); - constraints2 =3D this.getConstraints("window-1", "50", 0, 0, 25, 0, = 0, 1); - FlexibleGridConstraints[] secondGridConstraints =3D { constraints, c= onstraints2 }; - grid2.setConstraints(secondGridConstraints); - = - - // Setup the FlexibleGridLayoutManager for doing a layout and apply = it - // to the Page - FlexibleGrid[] row1 =3D { grid1 }; - FlexibleGrid[] row2 =3D { grid2 }; - FlexibleGridLayoutManager layoutManager =3D new FlexibleGridLayoutMa= nager(); - layoutManager.addRowOfGrids(row1); - layoutManager.addRowOfGrids(row2); - - // Perform the actual layout of the Page using the - // FlexibleGridLayoutManager - String output =3D layoutManager.doLayout(page); - - log.info("--------------------------------------"); - log.info(output); - log.info("--------------------------------------"); - - // Write this output to local file to test in a browser - FileOutputStream fos =3D new FileOutputStream( - "/home/soshah/html/layout/flexibleGrid.html"); - - StringBuffer buffer =3D new StringBuffer(); - - buffer - .append("CSS Layout Strategies\n"); - buffer.append(output); - buffer.append("\n"); - - fos.write(buffer.toString().getBytes()); - fos.flush(); - fos.close(); - } - - /** - * = - * @return - */ - private String getHtmlContent() - { - String markup =3D null; - - try - { - java.io.FileInputStream fis =3D new java.io.FileInputStream( - "/home/soshah/html/layout/greetings.html"); - - StringBuffer buffer =3D new StringBuffer(); - int read =3D 0; - byte[] data =3D new byte[1000]; - while ((read =3D fis.read(data)) !=3D -1) - { - byte[] bufferData =3D new byte[read]; - System.arraycopy(data, 0, bufferData, 0, read); - buffer.append(new String(bufferData)); - } - - markup =3D buffer.toString(); - fis.close(); - } - catch (Exception e) - { - - } - - return markup; - } - = - /** - * = - * @param containerId - * @param rows - * @param columns - * @return - */ - private FlexibleGrid getGrid(String containerId,int rows, int columns) - { - FlexibleGrid grid =3D 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, Stri= ng widthPercentage, int top, int bottom, int left, int right, int row, int = column) - { - FlexibleGridConstraints constraints =3D 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; - } -} Copied: branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/t= est/layout/TestFlexibleGrid.java (from rev 8904, branches/UIServer/uiserver= /src/main/org/jboss/portal/test/uiserver/layout/TestFlexibleGrid.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/test/= layout/TestFlexibleGrid.java (rev 0) +++ branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/test/= layout/TestFlexibleGrid.java 2007-11-13 16:55:45 UTC (rev 8905) @@ -0,0 +1,205 @@ +/*************************************************************************= ***** + * 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.presentation.test.layout; + +import junit.framework.TestCase; + +import org.apache.log4j.Logger; + +import java.io.FileOutputStream; + +import org.jboss.portal.presentation.model.Container; +import org.jboss.portal.presentation.model.Page; +import org.jboss.portal.presentation.model.Window; +import org.jboss.portal.uiserver.layout.classic.FlexibleGrid; +import org.jboss.portal.uiserver.layout.classic.FlexibleGridConstraints; +import org.jboss.portal.uiserver.layout.classic.FlexibleGridLayoutManager; + +/** + * @author Sohil Shah + * = + */ +public class TestFlexibleGrid extends TestCase +{ + /** + * = + */ + private static Logger log =3D Logger.getLogger(TestFlexibleGrid.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 specif= ic + String htmlContent =3D this.getHtmlContent(); + Page page =3D new Page(); + Container container =3D new Container("container-1"); + Window window1 =3D new Window("window-1", htmlContent); + Window window2 =3D new Window("window-2", htmlContent); + container.addComponent(window1); + container.addComponent(window2); + page.addContainer(container); + = + Container container2 =3D new Container("container-2"); = + container2.addComponent(window1); + container2.addComponent(window2); + page.addContainer(container2); + = + + // Setup a Flexible Grid for laying out a container of portlet windo= ws + FlexibleGrid grid1 =3D this.getGrid("container-1", 1, 2); + FlexibleGridConstraints constraints =3D this.getConstraints("window-= 1", "50", 0, 0, 25, 0, 0, 0); + FlexibleGridConstraints constraints2 =3D this.getConstraints("window= -1", "50", 0, 0, 25, 0, 0, 1); + FlexibleGridConstraints[] firstGridConstraints =3D { constraints, co= nstraints2 }; + grid1.setConstraints(firstGridConstraints); + = + = + //Setup another Grid to be added right next to the previous grid + FlexibleGrid grid2 =3D this.getGrid("container-2", 1, 2); + constraints =3D this.getConstraints("window-1", "50", 0, 0, 25, 0, 0= , 0); + constraints2 =3D this.getConstraints("window-1", "50", 0, 0, 25, 0, = 0, 1); + FlexibleGridConstraints[] secondGridConstraints =3D { constraints, c= onstraints2 }; + grid2.setConstraints(secondGridConstraints); + = + + // Setup the FlexibleGridLayoutManager for doing a layout and apply = it + // to the Page + FlexibleGrid[] row1 =3D { grid1 }; + FlexibleGrid[] row2 =3D { grid2 }; + FlexibleGridLayoutManager layoutManager =3D new FlexibleGridLayoutMa= nager(); + layoutManager.addRowOfGrids(row1); + layoutManager.addRowOfGrids(row2); + + // Perform the actual layout of the Page using the + // FlexibleGridLayoutManager + String output =3D layoutManager.doLayout(page); + + log.info("--------------------------------------"); + log.info(output); + log.info("--------------------------------------"); + + // Write this output to local file to test in a browser + FileOutputStream fos =3D new FileOutputStream( + "/home/soshah/html/layout/flexibleGrid.html"); + + StringBuffer buffer =3D new StringBuffer(); + + buffer + .append("CSS Layout Strategies\n"); + buffer.append(output); + buffer.append("\n"); + + fos.write(buffer.toString().getBytes()); + fos.flush(); + fos.close(); + } + + /** + * = + * @return + */ + private String getHtmlContent() + { + String markup =3D null; + + try + { + java.io.FileInputStream fis =3D new java.io.FileInputStream( + "/home/soshah/html/layout/greetings.html"); + + StringBuffer buffer =3D new StringBuffer(); + int read =3D 0; + byte[] data =3D new byte[1000]; + while ((read =3D fis.read(data)) !=3D -1) + { + byte[] bufferData =3D new byte[read]; + System.arraycopy(data, 0, bufferData, 0, read); + buffer.append(new String(bufferData)); + } + + markup =3D buffer.toString(); + fis.close(); + } + catch (Exception e) + { + + } + + return markup; + } + = + /** + * = + * @param containerId + * @param rows + * @param columns + * @return + */ + private FlexibleGrid getGrid(String containerId,int rows, int columns) + { + FlexibleGrid grid =3D 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, Stri= ng widthPercentage, int top, int bottom, int left, int right, int row, int = column) + { + FlexibleGridConstraints constraints =3D 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; + } +} Deleted: branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/= test/layout/TestRegionLayoutManager.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- branches/UIServer/uiserver/src/main/org/jboss/portal/test/uiserver/layo= ut/TestRegionLayoutManager.java 2007-11-13 16:25:06 UTC (rev 8903) +++ branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/test/= layout/TestRegionLayoutManager.java 2007-11-13 16:55:45 UTC (rev 8905) @@ -1,151 +0,0 @@ -/*************************************************************************= ***** - * 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.protocol.Container; -import org.jboss.portal.uiserver.protocol.Window; -import org.jboss.portal.uiserver.protocol.Page; -import org.jboss.portal.uiserver.layout.classic.RegionConstraints; -import org.jboss.portal.uiserver.layout.classic.RegionLayoutManager; - -/** - * @author Sohil Shah - * = - */ -public class TestRegionLayoutManager extends TestCase -{ - /** - * = - */ - private static Logger log =3D 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 specif= ic - String htmlContent =3D this.getHtmlContent(); - Page page =3D new Page(); - Container container =3D new Container("container-1"); - Window window1 =3D new Window("window-1", htmlContent); - Window window2 =3D new Window("window-2", htmlContent); - container.addComponent(window1); - container.addComponent(window2); - page.addContainer(container); - = - Container container2 =3D new Container("container-2"); = - Window window3 =3D new Window("window-3", htmlContent); - Window window4 =3D new Window("window-4", htmlContent); - container2.addComponent(window3); - container2.addComponent(window4); - page.addContainer(container2); - = - - // Setup a two RegionConstraints for laying out using RegionLayoutMa= nager - RegionConstraints leftRegion =3D new RegionConstraints("container-1"= ,RegionConstraints.LEFT); - RegionConstraints centerRegion =3D new RegionConstraints("container-= 2",RegionConstraints.CENTER); - RegionLayoutManager layoutManager =3D new RegionLayoutManager(); - layoutManager.addRegionConstraints(leftRegion); - layoutManager.addRegionConstraints(centerRegion); - - // Perform the actual layout of the Page using the - // RegionLayoutManager - String output =3D layoutManager.doLayout(page); - - log.info("--------------------------------------"); - log.info(output); - log.info("--------------------------------------"); - - // Write this output to local file to test in a browser - FileOutputStream fos =3D new FileOutputStream( - "/home/soshah/html/layout/regionLayout.html"); - - StringBuffer buffer =3D new StringBuffer(); - - buffer - .append("CSS Layout Strategies\n"); - buffer.append(output); - buffer.append("\n"); - - fos.write(buffer.toString().getBytes()); - fos.flush(); - fos.close(); - } - - /** - * = - * @return - */ - private String getHtmlContent() - { - String markup =3D null; - - try - { - java.io.FileInputStream fis =3D new java.io.FileInputStream( - "/home/soshah/html/layout/greetings2.html"); - - StringBuffer buffer =3D new StringBuffer(); - int read =3D 0; - byte[] data =3D new byte[1000]; - while ((read =3D fis.read(data)) !=3D -1) - { - byte[] bufferData =3D new byte[read]; - System.arraycopy(data, 0, bufferData, 0, read); - buffer.append(new String(bufferData)); - } - - markup =3D buffer.toString(); - fis.close(); - } - catch (Exception e) - { - - } - - return markup; - } = -} Copied: branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/t= est/layout/TestRegionLayoutManager.java (from rev 8904, branches/UIServer/u= iserver/src/main/org/jboss/portal/test/uiserver/layout/TestRegionLayoutMana= ger.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/test/= layout/TestRegionLayoutManager.java (rev 0) +++ branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/test/= layout/TestRegionLayoutManager.java 2007-11-13 16:55:45 UTC (rev 8905) @@ -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.presentation.test.layout; + +import junit.framework.TestCase; + +import org.apache.log4j.Logger; + +import java.io.FileOutputStream; + +import org.jboss.portal.presentation.model.Container; +import org.jboss.portal.presentation.model.Page; +import org.jboss.portal.presentation.model.Window; +import org.jboss.portal.uiserver.layout.classic.RegionConstraints; +import org.jboss.portal.uiserver.layout.classic.RegionLayoutManager; + +/** + * @author Sohil Shah + * = + */ +public class TestRegionLayoutManager extends TestCase +{ + /** + * = + */ + private static Logger log =3D 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 specif= ic + String htmlContent =3D this.getHtmlContent(); + Page page =3D new Page(); + Container container =3D new Container("container-1"); + Window window1 =3D new Window("window-1", htmlContent); + Window window2 =3D new Window("window-2", htmlContent); + container.addComponent(window1); + container.addComponent(window2); + page.addContainer(container); + = + Container container2 =3D new Container("container-2"); = + Window window3 =3D new Window("window-3", htmlContent); + Window window4 =3D new Window("window-4", htmlContent); + container2.addComponent(window3); + container2.addComponent(window4); + page.addContainer(container2); + = + + // Setup a two RegionConstraints for laying out using RegionLayoutMa= nager + RegionConstraints leftRegion =3D new RegionConstraints("container-1"= ,RegionConstraints.LEFT); + RegionConstraints centerRegion =3D new RegionConstraints("container-= 2",RegionConstraints.CENTER); + RegionLayoutManager layoutManager =3D new RegionLayoutManager(); + layoutManager.addRegionConstraints(leftRegion); + layoutManager.addRegionConstraints(centerRegion); + + // Perform the actual layout of the Page using the + // RegionLayoutManager + String output =3D layoutManager.doLayout(page); + + log.info("--------------------------------------"); + log.info(output); + log.info("--------------------------------------"); + + // Write this output to local file to test in a browser + FileOutputStream fos =3D new FileOutputStream( + "/home/soshah/html/layout/regionLayout.html"); + + StringBuffer buffer =3D new StringBuffer(); + + buffer + .append("CSS Layout Strategies\n"); + buffer.append(output); + buffer.append("\n"); + + fos.write(buffer.toString().getBytes()); + fos.flush(); + fos.close(); + } + + /** + * = + * @return + */ + private String getHtmlContent() + { + String markup =3D null; + + try + { + java.io.FileInputStream fis =3D new java.io.FileInputStream( + "/home/soshah/html/layout/greetings2.html"); + + StringBuffer buffer =3D new StringBuffer(); + int read =3D 0; + byte[] data =3D new byte[1000]; + while ((read =3D fis.read(data)) !=3D -1) + { + byte[] bufferData =3D new byte[read]; + System.arraycopy(data, 0, bufferData, 0, read); + buffer.append(new String(bufferData)); + } + + markup =3D buffer.toString(); + fis.close(); + } + catch (Exception e) + { + + } + + return markup; + } = +} --===============4435196144771497992==--