Author: sohil.shah(a)jboss.com
Date: 2007-11-13 12:19:15 -0500 (Tue, 13 Nov 2007)
New Revision: 8907
Added:
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/ajax/
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/classic/
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/classic/layout/
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/classic/layout/FlexibleGrid.java
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/classic/layout/FlexibleGridConstraints.java
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/classic/layout/FlexibleGridLayoutManager.java
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/classic/layout/RegionConstraints.java
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/classic/layout/RegionLayoutManager.java
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/layout/
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/layout/LayoutManager.java
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/layout/LayoutService.java
Removed:
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/layout/
Modified:
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/test/layout/TestFlexibleGrid.java
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/test/layout/TestRegionLayoutManager.java
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/service/PortalEntryPoint.java
Log:
refactoring
Added:
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/classic/layout/FlexibleGrid.java
===================================================================
---
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/classic/layout/FlexibleGrid.java
(rev 0)
+++
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/classic/layout/FlexibleGrid.java 2007-11-13
17:19:15 UTC (rev 8907)
@@ -0,0 +1,344 @@
+/******************************************************************************
+ * 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.impl.classic.layout;
+
+import org.apache.log4j.Logger;
+
+import org.jboss.portal.presentation.model.Container;
+import org.jboss.portal.presentation.model.Window;
+
+import java.io.Serializable;
+
+/**
+ * This layout provides a Flexible Grid for laying out the UI components (which would be
Portlet Windows)
+ * inside a flexible coordinates based Grid on a classic HTML page
+ *
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class FlexibleGrid implements Serializable
+{
+ private static Logger log = Logger.getLogger(FlexibleGrid.class);
+
+ private FlexibleGridConstraints[] constraints = null;
+
+ private int rows = 0;
+ private int columns = 0;
+
+ /**
+ * Id of the container being laid out inside this grid. This is a required value
+ */
+ private String containerId = null;
+
+ /**
+ * minimumWidth of the grid
+ */
+ private int minimumWidth = 0;
+
+ /**
+ * Float this grid to the left side of the page so that another grid can be placed
next to it
+ *
+ * Used for placing multiple grids horizontally on the page
+ */
+ private boolean isFloatLeft = false;
+
+
+ /**
+ *
+ *
+ */
+ public FlexibleGrid(String containerId)
+ {
+ this.containerId = containerId;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public FlexibleGridConstraints[] getConstraints()
+ {
+ return constraints;
+ }
+
+ /**
+ *
+ * @param constraints
+ */
+ public void setConstraints(FlexibleGridConstraints[] constraints)
+ {
+ this.constraints = constraints;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public int getColumns()
+ {
+ return columns;
+ }
+
+ /**
+ *
+ * @param columns
+ */
+ public void setColumns(int columns)
+ {
+ this.columns = columns;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public int getRows()
+ {
+ return rows;
+ }
+
+ /**
+ *
+ * @param rows
+ */
+ public void setRows(int rows)
+ {
+ this.rows = rows;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public int getMinimumWidth()
+ {
+ return minimumWidth;
+ }
+
+
+ /**
+ *
+ * @param minimumWidth
+ */
+ public void setMinimumWidth(int minimumWidth)
+ {
+ this.minimumWidth = minimumWidth;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public boolean isFloatLeft()
+ {
+ return isFloatLeft;
+ }
+
+ /**
+ *
+ * @param isFloatLeft
+ */
+ public void setFloatLeft(boolean isFloatLeft)
+ {
+ this.isFloatLeft = isFloatLeft;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public String getContainerId()
+ {
+ return containerId;
+ }
+
+ /**
+ *
+ * @param containerId
+ */
+ public void setContainerId(String containerId)
+ {
+ this.containerId = containerId;
+ }
+
+ /**
+ * Note: this method is given only package level visibility since it should be used
only by the FlexibleGridLayoutManager
+ */
+
+ /**
+ *
+ */
+ String doLayout(Container container)
+ {
+ String output = null;
+
+ StringBuffer buffer = new StringBuffer();
+
+ buffer.append("<div
id=\"grid-"+this.containerId+"\">\n");
+
+ buffer.append("<table>\n");
+
+ for(int row=0;row<rows;row++)
+ {
+ buffer.append("<tr>\n");
+
+ for(int column=0;column<columns;column++)
+ {
+ buffer.append("<td>\n");
+
+ buffer.append("<div
id=\"grid-"+this.containerId+"-"+row+"-"+column+"\">\n");
+ buffer.append(this.getPortletMarkup(container, row, column));
+ buffer.append("</div>\n");
+
+ buffer.append("</td>\n");
+ }
+
+ buffer.append("</tr>\n");
+ }
+
+ buffer.append("</table>\n");
+
+ buffer.append("</div>\n");
+
+
+ output = buffer.toString();
+
+ 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 = "";
+
+ 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)
+ {
+ String componentId = constraint.getComponentId();
+ Window window = (Window)container.getComponent(componentId);
+ markup = window.getMarkup();
+ }
+
+ }
+ }
+
+ return markup;
+ }
+}
Added:
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/classic/layout/FlexibleGridConstraints.java
===================================================================
---
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/classic/layout/FlexibleGridConstraints.java
(rev 0)
+++
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/classic/layout/FlexibleGridConstraints.java 2007-11-13
17:19:15 UTC (rev 8907)
@@ -0,0 +1,234 @@
+/******************************************************************************
+ * 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.impl.classic.layout;
+
+import java.io.Serializable;
+
+/**
+ * The FlexibleGridConstraints class specifies constraints for components that are laid
out using the FlexibleGrid layout manager.
+ *
+ * These constraints apply to an instance of a UIComponent being laid out inside the
given cell of the FlexibleGrid
+ *
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class FlexibleGridConstraints implements Serializable
+{
+ /**
+ * Unique Id of the component that these constraints should be applied to
+ */
+ private String componentId = null;
+
+ /**
+ * width in percentage that this component should occupy in the grid
+ */
+ private String widthPercentage = null;
+
+ /**
+ * top position of the component inside a grid cell.
+ * Value calculated in percentage. A positive value moves the component downwards and
vice versa
+ */
+ private int top = 0;
+
+ /**
+ * bottom position of the component inside a grid cell.
+ * Value calculated in percentage. A positive value moves the component upwards and
vice versa
+ */
+ private int bottom = 0;
+
+ /**
+ * left position of the component inside a grid cell.
+ * Value calculated in percentage. A positive value moves the component to the right
and vice versa
+ */
+ private int left = 0;
+
+ /**
+ * right position of the component inside a grid cell.
+ * Value calculated in percentage. A positive value moves the component to the left
and vice versa
+ */
+ private int right = 0;
+
+ /**
+ * row in the grid where this component should be placed
+ */
+ private int row = 0;
+
+ /**
+ * column in the grid where this component should be placed
+ */
+ private int column = 0;
+
+
+ /**
+ *
+ *
+ */
+ public FlexibleGridConstraints()
+ {
+
+ }
+
+ /**
+ *
+ * @return
+ */
+ public int getColumn()
+ {
+ return column;
+ }
+
+ /**
+ *
+ * @param column
+ */
+ public void setColumn(int column)
+ {
+ this.column = column;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public String getComponentId()
+ {
+ return componentId;
+ }
+
+ /**
+ *
+ * @param componentId
+ */
+ public void setComponentId(String componentId)
+ {
+ this.componentId = componentId;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public int getRow()
+ {
+ return row;
+ }
+
+ /**
+ *
+ * @param row
+ */
+ public void setRow(int row)
+ {
+ this.row = row;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public String getWidthPercentage()
+ {
+ return widthPercentage;
+ }
+
+ /**
+ *
+ * @param widthPercentage
+ */
+ public void setWidthPercentage(String widthPercentage)
+ {
+ this.widthPercentage = widthPercentage;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public int getBottom()
+ {
+ return bottom;
+ }
+
+ /**
+ *
+ * @param bottom
+ */
+ public void setBottom(int bottom)
+ {
+ this.bottom = bottom;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public int getLeft()
+ {
+ return left;
+ }
+
+ /**
+ *
+ * @param left
+ */
+ public void setLeft(int left)
+ {
+ this.left = left;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public int getRight()
+ {
+ return right;
+ }
+
+ /**
+ *
+ * @param right
+ */
+ public void setRight(int right)
+ {
+ this.right = right;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public int getTop()
+ {
+ return top;
+ }
+
+ /**
+ *
+ * @param top
+ */
+ public void setTop(int top)
+ {
+ this.top = top;
+ }
+}
Added:
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/classic/layout/FlexibleGridLayoutManager.java
===================================================================
---
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/classic/layout/FlexibleGridLayoutManager.java
(rev 0)
+++
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/classic/layout/FlexibleGridLayoutManager.java 2007-11-13
17:19:15 UTC (rev 8907)
@@ -0,0 +1,186 @@
+/******************************************************************************
+ * 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.impl.classic.layout;
+
+import org.jboss.portal.presentation.model.Container;
+import org.jboss.portal.presentation.model.Page;
+import org.jboss.portal.presentation.layout.LayoutManager;
+
+
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * This layout manager provides a Flexible Grid for laying out the UI components (which
would be Portlet Windows)
+ * inside a flexible coordinates based Grid on a classic HTML page
+ *
+ *
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class FlexibleGridLayoutManager implements LayoutManager
+{
+ /**
+ * A list of array of flexible grids. Each element of this list is an array of
+ * flexible grid objects that needs to be laid out horizontally from left to right
+ * on the page. This array of FlexibleGrid objects can also be thought of as a row of
+ * FlexibleGrid objects
+ *
+ * The grids are laid out in the order they are added to this list
+ */
+ private List pageGrids = null;
+
+ /**
+ *
+ *
+ */
+ public FlexibleGridLayoutManager()
+ {
+ this.pageGrids = new ArrayList();
+ }
+
+ /**
+ *
+ * @param grids
+ */
+ public void addRowOfGrids(FlexibleGrid[] grids)
+ {
+ this.pageGrids.add(grids);
+ }
+
+
+ /**
+ *
+ */
+ public String doLayout(Page page)
+ {
+ String layoutOutput = "";
+
+ StringBuffer buffer = new StringBuffer();
+
+ if(this.pageGrids != null)
+ {
+ for(int i=0;i<this.pageGrids.size();i++)
+ {
+ FlexibleGrid[] grids = (FlexibleGrid[])this.pageGrids.get(i);
+ Container[] containers = this.findContainers(page, grids);
+
+ buffer.append(this.generateInlineStyle(grids, containers));
+
+ for(int gridCounter=0;gridCounter<grids.length;gridCounter++)
+ {
+ FlexibleGrid grid = grids[gridCounter];
+ Container container = containers[gridCounter];
+
+ buffer.append(grid.doLayout(container));
+ }
+
+ }
+ }
+
+ layoutOutput = buffer.toString();
+
+ return layoutOutput;
+ }
+
+ /**
+ *
+ * @param page
+ * @param grids
+ * @return
+ */
+ private Container[] findContainers(Page page, FlexibleGrid[] grids)
+ {
+ Container[] containers = null;
+
+ containers = new Container[grids.length];
+ List allContainers = page.getContainers();
+
+ //Find containers from the page associated with each grid instance in the array of
grids
+ for(int gridCount=0; gridCount<grids.length ; gridCount++)
+ {
+ FlexibleGrid grid = grids[gridCount];
+ String containerId = grid.getContainerId();
+
+ //Look for a container inside the page whose id matches the containerId that
+ //the grid is associated with
+ for(int containerCount=0; containerCount < allContainers.size();
containerCount++)
+ {
+ Container container = (Container)allContainers.get(containerCount);
+
+ if(container.getId().equals(containerId))
+ {
+ containers[gridCount] = container;
+ break;
+ }
+ }
+ }
+
+ return containers;
+ }
+
+ /**
+ *
+ * @param grids
+ * @param containers
+ * @return
+ */
+ private String generateInlineStyle(FlexibleGrid[] grids,Container[] containers)
+ {
+ String inlineStyle = null;
+
+ StringBuffer buffer = new StringBuffer();
+
+ buffer.append("<style type=\"text/css\">\n");
+
+ for(int gridCounter=0;gridCounter<grids.length;gridCounter++)
+ {
+ FlexibleGrid grid = grids[gridCounter];
+ Container container = containers[gridCounter];
+
+ buffer.append("#grid-"+grid.getContainerId()+"{text-align: left;
position: relative;");
+
+ if(grid.getMinimumWidth() > 0)
+ {
+ buffer.append(" min-width:
"+String.valueOf(grid.getMinimumWidth())+"px;");
+ }
+
+ if(gridCounter == 0 && grids.length > 1)
+ {
+ buffer.append(" float: left;");
+ }
+
+ buffer.append("}\n");
+
+ //Now generate the styles for each individual cell of the grid which will hold
+ //the components of this container
+ buffer.append(grid.generateInlineStyle(container));
+ }
+
+ buffer.append("</style>\n");
+
+ inlineStyle = buffer.toString();
+
+ return inlineStyle;
+ }
+}
Added:
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/classic/layout/RegionConstraints.java
===================================================================
---
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/classic/layout/RegionConstraints.java
(rev 0)
+++
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/classic/layout/RegionConstraints.java 2007-11-13
17:19:15 UTC (rev 8907)
@@ -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.presentation.impl.classic.layout;
+
+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/presentation/impl/classic/layout/RegionLayoutManager.java
===================================================================
---
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/classic/layout/RegionLayoutManager.java
(rev 0)
+++
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/classic/layout/RegionLayoutManager.java 2007-11-13
17:19:15 UTC (rev 8907)
@@ -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.presentation.impl.classic.layout;
+
+import java.util.List;
+import java.util.ArrayList;
+
+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.presentation.layout.LayoutManager;
+
+/**
+ * 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/presentation/layout/LayoutManager.java
===================================================================
---
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/layout/LayoutManager.java
(rev 0)
+++
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/layout/LayoutManager.java 2007-11-13
17:19:15 UTC (rev 8907)
@@ -0,0 +1,39 @@
+/******************************************************************************
+ * 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.layout;
+
+import org.jboss.portal.presentation.model.Page;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public interface LayoutManager
+{
+ /**
+ *
+ * @param container
+ * @return
+ */
+ public String doLayout(Page page);
+}
Added:
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/layout/LayoutService.java
===================================================================
---
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/layout/LayoutService.java
(rev 0)
+++
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/layout/LayoutService.java 2007-11-13
17:19:15 UTC (rev 8907)
@@ -0,0 +1,55 @@
+/******************************************************************************
+ * 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.layout;
+
+import org.jboss.portal.presentation.model.Page;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class LayoutService
+{
+ /**
+ *
+ *
+ */
+ public LayoutService()
+ {
+ }
+
+ /**
+ *
+ * @param container
+ * @param layoutManager
+ * @return
+ */
+ public String doLayout(Page page, LayoutManager layoutManager)
+ {
+ String output = null;
+
+ output = layoutManager.doLayout(page);
+
+ return output;
+ }
+}
Modified:
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/test/layout/TestFlexibleGrid.java
===================================================================
---
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/test/layout/TestFlexibleGrid.java 2007-11-13
17:07:24 UTC (rev 8906)
+++
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/test/layout/TestFlexibleGrid.java 2007-11-13
17:19:15 UTC (rev 8907)
@@ -31,9 +31,9 @@
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;
+import org.jboss.portal.presentation.impl.classic.layout.FlexibleGrid;
+import org.jboss.portal.presentation.impl.classic.layout.FlexibleGridConstraints;
+import org.jboss.portal.presentation.impl.classic.layout.FlexibleGridLayoutManager;
/**
* @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
Modified:
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/test/layout/TestRegionLayoutManager.java
===================================================================
---
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/test/layout/TestRegionLayoutManager.java 2007-11-13
17:07:24 UTC (rev 8906)
+++
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/test/layout/TestRegionLayoutManager.java 2007-11-13
17:19:15 UTC (rev 8907)
@@ -31,8 +31,8 @@
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;
+import org.jboss.portal.presentation.impl.classic.layout.RegionConstraints;
+import org.jboss.portal.presentation.impl.classic.layout.RegionLayoutManager;
/**
* @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
Modified:
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/service/PortalEntryPoint.java
===================================================================
---
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/service/PortalEntryPoint.java 2007-11-13
17:07:24 UTC (rev 8906)
+++
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/service/PortalEntryPoint.java 2007-11-13
17:19:15 UTC (rev 8907)
@@ -60,12 +60,12 @@
import org.jboss.portal.server.ServerResponse;
import org.jboss.portal.server.impl.ServerInvocationContextImpl;
import org.jboss.portal.server.request.URLContext;
-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.RegionConstraints;
-import org.jboss.portal.uiserver.layout.classic.RegionLayoutManager;
+import org.jboss.portal.presentation.layout.LayoutManager;
+import org.jboss.portal.presentation.impl.classic.layout.FlexibleGrid;
+import org.jboss.portal.presentation.impl.classic.layout.FlexibleGridConstraints;
+import org.jboss.portal.presentation.impl.classic.layout.FlexibleGridLayoutManager;
+import org.jboss.portal.presentation.impl.classic.layout.RegionConstraints;
+import org.jboss.portal.presentation.impl.classic.layout.RegionLayoutManager;
import org.jboss.portal.presentation.model.Container;
import org.jboss.portal.presentation.model.Page;
import org.jboss.portal.presentation.model.Window;