Author: sohil.shah(a)jboss.com
Date: 2007-08-01 12:16:54 -0400 (Wed, 01 Aug 2007)
New Revision: 7857
Added:
branches/UIServer/uiserver/
branches/UIServer/uiserver/build.bat
branches/UIServer/uiserver/build.sh
branches/UIServer/uiserver/build.xml
branches/UIServer/uiserver/src/
branches/UIServer/uiserver/src/main/
branches/UIServer/uiserver/src/main/org/
branches/UIServer/uiserver/src/main/org/jboss/
branches/UIServer/uiserver/src/main/org/jboss/portal/
branches/UIServer/uiserver/src/main/org/jboss/portal/test/
branches/UIServer/uiserver/src/main/org/jboss/portal/test/uiserver/
branches/UIServer/uiserver/src/main/org/jboss/portal/test/uiserver/layout/
branches/UIServer/uiserver/src/main/org/jboss/portal/test/uiserver/layout/TestFlexibleGrid.java
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/ClassicUI.java
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/ClientUI.java
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/PartialRefreshUI.java
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/UIServer.java
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/UIServerImpl.java
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/UIServerPageRendition.java
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/UIServerRequest.java
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/layout/
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/layout/Component.java
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/layout/Container.java
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/layout/LayoutManager.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/
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/layout/classic/FlexibleGrid.java
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/layout/classic/FlexibleGridConstraints.java
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/layout/classic/FlexibleGridLayoutManager.java
branches/UIServer/uiserver/src/resources/
Modified:
branches/UIServer/build/build.xml
branches/UIServer/core-wsrp/
branches/UIServer/core/build.xml
branches/UIServer/thirdparty/
branches/UIServer/tools/etc/buildfragments/modules.ent
Log:
first cut of Flexible Grid Layout Manager in UiServer
Modified: branches/UIServer/build/build.xml
===================================================================
--- branches/UIServer/build/build.xml 2007-08-01 11:36:24 UTC (rev 7856)
+++ branches/UIServer/build/build.xml 2007-08-01 16:16:54 UTC (rev 7857)
@@ -138,13 +138,14 @@
<module name="registration"/>
<module name="workflow"/>
<module name="widget"/>
+ <module name="uiserver"/>
<!--<module name="core-admin"/>-->
<!-- Module groups -->
<group name="portal">
<include
- modules="common, test, api, web, jems, server, security, identity,
search, format, portlet, portlet-server, bridge, faces, portlet-federation, theme,
workflow, cms, registration, core, wsrp, core-admin, core-cms, core-management,
core-samples, widget"/>
+ modules="common, test, api, web, jems, server, security, identity,
search, format, portlet, portlet-server, bridge, faces, portlet-federation, theme,
workflow, cms, registration, uiserver, core, wsrp, core-admin, core-cms, core-management,
core-samples, widget"/>
</group>
<group name="cms">
Modified: branches/UIServer/core/build.xml
===================================================================
--- branches/UIServer/core/build.xml 2007-08-01 11:36:24 UTC (rev 7856)
+++ branches/UIServer/core/build.xml 2007-08-01 16:16:54 UTC (rev 7857)
@@ -133,6 +133,7 @@
<path refid="jboss.portlet-api.classpath"/>
<path refid="jboss.portal-theme.classpath"/>
<path refid="jboss.portal-security.classpath"/>
+ <path refid="jboss.portal-uiserver.classpath"/>
<path refid="jboss.portal-test.classpath"/>
</path>
@@ -334,6 +335,7 @@
<fileset dir="${jboss.portal-search.root}/lib"
includes="portal-search-lib.jar"/>
<fileset dir="${jboss.portal-identity.root}/lib"
includes="portal-identity-lib.jar"/>
<fileset dir="${jboss.portal-registration.root}/lib"
includes="portal-registration-lib.jar"/>
+ <fileset dir="${jboss.portal-uiserver.root}/lib"
includes="portal-uiserver-lib.jar"/>
<fileset dir="${ehcache.ehcache.lib}"
includes="ehcache.jar"/>
<fileset dir="${apache.collections.lib}"
includes="commons-collections.jar"/>
<fileset dir="${javassist.javassist.lib}"
includes="javassist.jar"/>
@@ -348,7 +350,6 @@
<copy todir="${build.resources}/jboss-portal/dtd">
<fileset dir="${jboss.portal-identity.root}/resources/dtd"
includes="*.dtd"/>
</copy>
-
</target>
Property changes on: branches/UIServer/core-wsrp
___________________________________________________________________
Name: svn:ignore
+ output
Property changes on: branches/UIServer/thirdparty
___________________________________________________________________
Name: svn:ignore
- antlr
*.ent
+ antlr
*.ent
*
Modified: branches/UIServer/tools/etc/buildfragments/modules.ent
===================================================================
--- branches/UIServer/tools/etc/buildfragments/modules.ent 2007-08-01 11:36:24 UTC (rev
7856)
+++ branches/UIServer/tools/etc/buildfragments/modules.ent 2007-08-01 16:16:54 UTC (rev
7857)
@@ -193,4 +193,11 @@
<path id="jboss.portal-samples.classpath">
<pathelement
path="${jboss.portal-samples.lib}/portal-samples-lib.jar"/>
</path>
+
+ <!-- uiserver -->
+ <property name="jboss.portal-uiserver.root"
value="${project.root}/uiserver/output"/>
+ <property name="jboss.portal-uiserver.lib"
value="${jboss.portal-uiserver.root}/lib"/>
+ <path id="jboss.portal-uiserver.classpath">
+ <pathelement
path="${jboss.portal-uiserver.lib}/portal-uiserver-lib.jar"/>
+ </path>
</target>
Added: branches/UIServer/uiserver/build.bat
===================================================================
--- branches/UIServer/uiserver/build.bat (rev 0)
+++ branches/UIServer/uiserver/build.bat 2007-08-01 16:16:54 UTC (rev 7857)
@@ -0,0 +1,54 @@
+@echo off
+rem
+rem Invokes a script of the same name in the 'tools' module.
+rem
+rem The 'tools' module is expected to be a peer directory of the directory
+rem in which this script lives.
+rem
+rem @author Jason Dillon <jason(a)planet57.com>
+rem
+
+rem $Id: build.bat 1015 2005-11-04 20:15:13Z mholzner $
+
+setlocal
+
+set PROGNAME=%~nx0
+set DIRNAME=%~dp0
+
+rem Legacy shell support
+if x%PROGNAME%==x set PROGNAME=build.bat
+if x%DIRNAME%==x set DIRNAME=.\
+
+set MODULE_ROOT=%DIRNAME%
+if x%TOOLS_ROOT%==x set TOOLS_ROOT=%DIRNAME%..\tools
+set TARGET=%TOOLS_ROOT%\bin\build.bat
+set ARGS=%*
+
+rem Start'er up yo
+goto main
+
+:debug
+if not x%DEBUG%==x echo %PROGNAME%: %*
+goto :EOF
+
+:main
+call :debug PROGNAME=%PROGNAME%
+call :debug DIRNAME=%DIRNAME%
+call :debug TOOLS_ROOT=%TOOLS_ROOT%
+call :debug TARGET=%TARGET%
+
+if exist %TARGET% call :call-script & goto :EOF
+rem else fail, we can not go on
+
+echo %PROGNAME%: *ERROR* The target executable does not exist:
+echo %PROGNAME%:
+echo %PROGNAME%: %TARGET%
+echo %PROGNAME%:
+echo %PROGNAME%: Please make sure you have checked out the 'tools' module
+echo %PROGNAME%: and make sure it is up to date.
+goto :EOF
+
+:call-script
+call :debug Executing %TARGET% %ARGS%
+call %TARGET% %ARGS%
+goto :EOF
Property changes on: branches/UIServer/uiserver/build.bat
___________________________________________________________________
Name: svn:executable
+ *
Added: branches/UIServer/uiserver/build.sh
===================================================================
--- branches/UIServer/uiserver/build.sh (rev 0)
+++ branches/UIServer/uiserver/build.sh 2007-08-01 16:16:54 UTC (rev 7857)
@@ -0,0 +1,49 @@
+#!/bin/sh
+##
+## Invokes a script of the same name in the 'tools' module.
+##
+## The 'tools' module is expected to be a peer directory of the directory
+## in which this script lives.
+##
+## @author Jason Dillon <jason(a)planet57.com>
+##
+
+# $Id: build.sh 1015 2005-11-04 20:15:13Z mholzner $
+
+PROGNAME=`basename $0`
+DIRNAME=`dirname $0`
+
+# Buss it yo
+main() {
+ if [ "x$TOOLS_ROOT" = "x" ]; then
+ TOOLS_ROOT=`cd $DIRNAME/../tools && pwd`
+ fi
+
+ MODULE_ROOT=`cd $DIRNAME; pwd`
+ export TOOLS_ROOT MODULE_ROOT DEBUG TRACE
+
+ # Where is the target script?
+ target="$TOOLS_ROOT/bin/$PROGNAME"
+ if [ ! -f "$target" ]; then
+ echo "${PROGNAME}: *ERROR* The target executable does not exist:"
+ echo "${PROGNAME}:"
+ echo "${PROGNAME}: $target"
+ echo "${PROGNAME}:"
+ echo "${PROGNAME}: Please make sure you have checked out the 'tools'
module"
+ echo "${PROGNAME}: and make sure it is up to date."
+ exit 2
+ fi
+
+ # Get busy yo!
+ if [ "x$DEBUG" != "x" ]; then
+ echo "${PROGNAME}: Executing: /bin/sh $target $@"
+ fi
+ if [ "x$TRACE" = "x" ]; then
+ exec /bin/sh $target "$@"
+ else
+ exec /bin/sh -x $target "$@"
+ fi
+}
+
+# Lets get ready to rumble!
+main "$@"
Property changes on: branches/UIServer/uiserver/build.sh
___________________________________________________________________
Name: svn:executable
+ *
Added: branches/UIServer/uiserver/build.xml
===================================================================
--- branches/UIServer/uiserver/build.xml (rev 0)
+++ branches/UIServer/uiserver/build.xml 2007-08-01 16:16:54 UTC (rev 7857)
@@ -0,0 +1,247 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ 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. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<!DOCTYPE project [
+ <!ENTITY libraries SYSTEM "../thirdparty/libraries.ent">
+ <!ENTITY buildmagic SYSTEM
"../tools/etc/buildfragments/buildmagic.ent">
+ <!ENTITY tools SYSTEM "../tools/etc/buildfragments/tools.ent">
+ <!ENTITY modules SYSTEM "../tools/etc/buildfragments/modules.ent">
+ <!ENTITY defaults SYSTEM
"../tools/etc/buildfragments/defaults.ent">
+ <!ENTITY targets SYSTEM "../tools/etc/buildfragments/targets.ent">
+ ]>
+
+<!--+======================================================================+-->
+<!--| JBoss Portal (The OpenSource Portal) Build File |-->
+<!--| |-->
+<!--| Distributable under LGPL license. |-->
+<!--| See terms of license at
http://www.gnu.org. |-->
+<!--| |-->
+<!--| This file has been designed to work with the 'tools' module and
|-->
+<!--| Buildmagic extentions. |-->
+<!--+======================================================================+-->
+
+<project default="main" name="JBoss Portal">
+
+ <!--+====================================================================+-->
+ <!--| Setup |-->
+ <!--| |-->
+ <!--| Include the common build elements. |-->
+ <!--| |-->
+ <!--| This defines several different targets, properties and paths. |-->
+ <!--| It also sets up the basic extention tasks amoung other things. |-->
+ <!--+====================================================================+-->
+
+ &buildmagic;
+ &modules;
+ &defaults;
+ &tools;
+ &targets;
+
+ <!-- ================================================================== -->
+ <!-- Initialization -->
+ <!-- ================================================================== -->
+
+ <!--
+ | Initialize the build system. Must depend on '_buildmagic:init'.
+ | Other targets should depend on 'init' or things will mysteriously fail.
+ -->
+
+ <target name="init" unless="init.disable"
depends="_buildmagic:init">
+ </target>
+
+ <!--+====================================================================+-->
+ <!--| Configuration |-->
+ <!--| |-->
+ <!--| This target is invoked by the Buildmagic initialization logic |-->
+ <!--| and should contain module specific configuration elements. |-->
+ <!--+====================================================================+-->
+
+ <target name="configure" unless="configure.disable">
+
+ <!-- Configure some properties -->
+ <property name="jboss-junit-configuration" value=""/>
+ <property name="junit.formatter.usefile" value="true"/>
+
+ <!-- Configure thirdparty libraries -->
+ &libraries;
+
+ <path id="library.classpath">
+ <path refid="jbossas/core.libs.classpath"/>
+ <path refid="sun.servlet.classpath"/>
+ <path refid="apache.log4j.classpath"/>
+ <path refid="junit.junit.classpath"/>
+ </path>
+
+ <!-- Configure modules -->
+ <call target="configure-modules"/>
+ <path id="dependentmodule.classpath">
+ <path refid="jboss.portal-common.classpath"/>
+ <path refid="jboss.portal-jems.classpath"/>
+ <path refid="jboss.portal-server.classpath"/>
+ <path refid="jboss.portal-theme.classpath"/>
+ <path refid="jboss.portal-web.classpath"/>
+ </path>
+
+ <!--+=======================================+-->
+ <!--| Override any default properties here. |-->
+ <!--+=======================================+-->
+
+ <!-- Configure defaults & build tools -->
+ <call target="configure-defaults"/>
+ <call target="configure-tools"/>
+ <call target="configure-explode"/>
+ <call target="configure-jbossaop"/>
+
+ <!--+=======================================+-->
+ <!--| Define module specific elements here. |-->
+ <!--+=======================================+-->
+ <property name="javadoc.private" value="true"/>
+ <property name="javadoc.protected" value="false"/>
+
+ <path id="hibernate.classpath">
+ <path refid="apache.commons.classpath"/>
+ <path refid="asm.asm.classpath"/>
+ <path refid="cglib.cglib.classpath"/>
+ <path refid="antlr.antlr.classpath"/>
+ <path refid="odmg.odmg.classpath"/>
+ <path refid="ehcache.ehcache.classpath"/>
+ <path refid="hibernate.hibernate.classpath"/>
+ </path>
+
+ <path id="aop.classpath">
+ <pathelement
path="${jbossas/core.libs.lib}/jboss-aspect-library.jar"/>
+ <pathelement path="${jboss.aop.lib}/jboss-aop.jar"/>
+ <path refid="javassist.javassist.classpath"/>
+ <path refid="oswego.concurrent.classpath"/>
+ <path refid="trove.trove.classpath"/>
+ <path refid="qdox.qdox.classpath"/>
+ </path>
+
+ <taskdef name="explode"
+ classname="org.jboss.portal.common.ant.Explode"
+ classpathref="explode.task.classpath"/>
+ <taskdef name="implode"
+ classname="org.jboss.portal.common.ant.Implode"
+ classpathref="explode.task.classpath"/>
+
+ </target>
+
+ <target name="configure-explode">
+ <path id="explode.task.classpath">
+ <pathelement location="${project.tools}/lib/explode.jar"/>
+ <path refid="apache.ant.classpath"/>
+ </path>
+ <taskdef
+ name="explode"
+ classname="org.jboss.portal.common.ant.Explode"
+ classpathref="explode.task.classpath"/>
+ </target>
+
+ <target name="configure-jbossaop">
+ <path id="jbossaop.task.classpath">
+ <path refid="jboss.aop.classpath"/>
+ <path refid="javassist.javassist.classpath"/>
+ <path refid="oswego.concurrent.classpath"/>
+ <path refid="trove.trove.classpath"/>
+ <path refid="qdox.qdox.classpath"/>
+ </path>
+ <taskdef
+ name="aopc"
+ classname="org.jboss.aop.ant.AopC"
+ classpathref="jbossaop.task.classpath"/>
+ </target>
+
+ <!--+====================================================================+-->
+ <!--| Compile |-->
+ <!--| |-->
+ <!--| This target should depend on other compile-* targets for each |-->
+ <!--| different type of compile that needs to be performed, short of |-->
+ <!--| documentation compiles. |-->
+ <!--+====================================================================+-->
+
+ <target name="compile"
+ description="Compile all source files."
+ depends="_default:compile-classes,
+ _default:compile-etc,
+ _default:compile-resources">
+ </target>
+
+ <!--+====================================================================+-->
+ <!--| Generate Output |-->
+ <!--| |-->
+ <!--| Generates the target output for this module. Target output is |-->
+ <!--| the output which is ment to be released or used by external |-->
+ <!--| modules. |-->
+ <!--+====================================================================+-->
+
+ <target name="artifacts"
+ description="Generate all target output."
+ depends="compile">
+
+ <mkdir dir="${build.lib}"/>
+
+ <!-- portal-uiserver-lib.jar -->
+ <jar jarfile="${build.lib}/portal-uiserver-lib.jar">
+ <fileset dir="${build.classes}">
+ </fileset>
+ <fileset dir="../portlet/output/classes">
+ </fileset>
+ </jar>
+ </target>
+
+ <target name="output" depends="artifacts">
+ </target>
+
+ <!-- ================================================================== -->
+ <!-- Cleaning -->
+ <!-- ================================================================== -->
+
+ <!-- Clean up all build output -->
+ <target name="clean" depends="_default:clean">
+ <!-- Add module specific elements here. -->
+ </target>
+
+ <!--+====================================================================+-->
+ <!--| Documents |-->
+ <!--| |-->
+ <!--| Generate all documentation for this module. |-->
+ <!--+====================================================================+-->
+
+ <target name="docs" depends="_default:docs">
+ <!-- Add module specific elements here. -->
+ </target>
+
+ <!-- ================================================================== -->
+ <!-- Misc. -->
+ <!-- ================================================================== -->
+
+ <target name="main" depends="most"/>
+ <target name="all" depends="_default:all"/>
+ <target name="most" depends="_default:most"/>
+ <target name="help" depends="_default:help"/>
+
+ <!-- ================================================================== -->
+ <!-- Deployment -->
+ <!-- ================================================================== -->
+</project>
Property changes on: branches/UIServer/uiserver/build.xml
___________________________________________________________________
Name: svn:executable
+ *
Added:
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
(rev 0)
+++
branches/UIServer/uiserver/src/main/org/jboss/portal/test/uiserver/layout/TestFlexibleGrid.java 2007-08-01
16:16:54 UTC (rev 7857)
@@ -0,0 +1,201 @@
+/******************************************************************************
+ * 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.FlexibleGrid;
+import org.jboss.portal.uiserver.layout.classic.FlexibleGridConstraints;
+import org.jboss.portal.uiserver.layout.classic.FlexibleGridLayoutManager;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class TestFlexibleGrid extends TestCase
+{
+ /**
+ *
+ */
+ private static Logger log = 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 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.getContainers().add(container);
+
+ Container container2 = new Container("container-2");
+ container2.addComponent(window1);
+ container2.addComponent(window2);
+ page.getContainers().add(container2);
+
+
+ // Setup a Flexible Grid for laying out a container of portlet windows
+ FlexibleGrid grid1 = this.getGrid("container-1", 1, 2);
+ FlexibleGridConstraints constraints = this.getConstraints("window-1",
"50", 0, 0, 25, 0, 0, 0);
+ FlexibleGridConstraints constraints2 = this.getConstraints("window-1",
"50", 0, 0, 25, 0, 0, 1);
+ FlexibleGridConstraints[] firstGridConstraints = { constraints, constraints2 };
+ grid1.setConstraints(firstGridConstraints);
+
+
+ //Setup another Grid to be added right next to the previous grid
+ FlexibleGrid grid2 = this.getGrid("container-2", 1, 2);
+ constraints = this.getConstraints("window-1", "50", 0, 0, 25,
0, 0, 0);
+ constraints2 = this.getConstraints("window-1", "50", 0, 0, 25,
0, 0, 1);
+ FlexibleGridConstraints[] secondGridConstraints = { constraints, constraints2 };
+ grid2.setConstraints(secondGridConstraints);
+
+
+ // Setup the FlexibleGridLayoutManager for doing a layout and apply it
+ // to the Page
+ FlexibleGrid[] row1 = { grid1 };
+ FlexibleGrid[] row2 = { grid2 };
+ FlexibleGridLayoutManager layoutManager = new FlexibleGridLayoutManager();
+ layoutManager.addRowOfGrids(row1);
+ layoutManager.addRowOfGrids(row2);
+
+ // Perform the actual layout of the Page using the
+ // FlexibleGridLayoutManager
+ 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/flexibleGrid.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/greetings.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;
+ }
+
+ /**
+ *
+ * @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);
+ return constraints;
+ }
+}
Added: branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/ClassicUI.java
===================================================================
--- branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/ClassicUI.java
(rev 0)
+++
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/ClassicUI.java 2007-08-01
16:16:54 UTC (rev 7857)
@@ -0,0 +1,52 @@
+/******************************************************************************
+ * 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;
+
+import org.jboss.portal.server.ServerInvocation;
+import org.jboss.portal.web.ServletContextDispatcher;
+import org.jboss.portal.common.util.MarkupInfo;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class ClassicUI implements ClientUI
+{
+ /**
+ *
+ * @param request
+ */
+ public void sendResponse(UIServerRequest request) throws Exception
+ {
+ ServerInvocation invocation =
(ServerInvocation)request.getAttribute(UIServerRequest.SERVER_INVOCATION);
+ UIServerPageRendition rendition =
(UIServerPageRendition)request.getAttribute(UIServerRequest.UI_INDICATOR);
+
+ ServletContextDispatcher dispatcher = new
ServletContextDispatcher(invocation.getServerContext().getClientRequest(),
+ invocation.getServerContext().getClientResponse(),
+ invocation.getRequest().getServer().getServletContainerContext());
+
+ MarkupInfo markupInfo = (MarkupInfo)invocation.getResponse().getContentInfo();
+
+ rendition.render(markupInfo, dispatcher);
+ }
+}
Added: branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/ClientUI.java
===================================================================
--- branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/ClientUI.java
(rev 0)
+++ branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/ClientUI.java 2007-08-01
16:16:54 UTC (rev 7857)
@@ -0,0 +1,36 @@
+/******************************************************************************
+ * 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;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public interface ClientUI
+{
+ /**
+ *
+ * @param request
+ */
+ public void sendResponse(UIServerRequest request) throws Exception;
+}
Added:
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/PartialRefreshUI.java
===================================================================
--- branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/PartialRefreshUI.java
(rev 0)
+++
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/PartialRefreshUI.java 2007-08-01
16:16:54 UTC (rev 7857)
@@ -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.uiserver;
+
+import javax.servlet.http.HttpServletResponse;
+
+import org.jboss.portal.server.ServerInvocation;
+
+import org.jboss.portal.theme.impl.render.dynamic.JSONMarshaller;
+import org.jboss.portal.theme.impl.render.dynamic.DynaResponse;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class PartialRefreshUI implements ClientUI
+{
+ /**
+ *
+ */
+ private static final JSONMarshaller marshaller = new JSONMarshaller();
+
+ /**
+ *
+ */
+ public void sendResponse(UIServerRequest request) throws Exception
+ {
+ ServerInvocation serverInvocation =
(ServerInvocation)request.getAttribute(UIServerRequest.SERVER_INVOCATION);
+ HttpServletResponse resp =
serverInvocation.getServerContext().getClientResponse();
+ DynaResponse dynaResponse =
(DynaResponse)request.getAttribute(UIServerRequest.UI_INDICATOR);
+
+ resp.setContentType("text/html");
+ marshaller.write(dynaResponse, resp.getWriter());
+ }
+}
Added: branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/UIServer.java
===================================================================
--- branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/UIServer.java
(rev 0)
+++ branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/UIServer.java 2007-08-01
16:16:54 UTC (rev 7857)
@@ -0,0 +1,36 @@
+/******************************************************************************
+ * 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;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public interface UIServer
+{
+ /**
+ *
+ * @param uiServerContext
+ */
+ public void aggregate(UIServerRequest uiServerRequest);
+}
Added: branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/UIServerImpl.java
===================================================================
--- branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/UIServerImpl.java
(rev 0)
+++
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/UIServerImpl.java 2007-08-01
16:16:54 UTC (rev 7857)
@@ -0,0 +1,141 @@
+/******************************************************************************
+ * 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;
+
+import java.util.Map;
+import java.util.Iterator;
+import java.util.HashMap;
+import java.util.Properties;
+
+import org.w3c.dom.Element;
+import org.apache.log4j.Logger;
+
+import org.jboss.portal.common.xml.XMLTools;
+import org.jboss.portal.jems.as.system.AbstractJBossService;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class UIServerImpl extends AbstractJBossService implements UIServer
+{
+ /**
+ *
+ */
+ private static Logger log = Logger.getLogger(UIServerImpl.class);
+
+ /**
+ * A map of some UIIndicator object provided from the Controller Layer to the
corresponding Client Side
+ * UI technology which will be used to handle the UI related tasks
+ */
+ private Map clientUiConfig = null;
+
+
+ /**
+ *
+ *
+ */
+ public UIServerImpl()
+ {
+ this.clientUiConfig = new HashMap();
+ }
+
+ /**
+ *
+ */
+ protected void startService() throws Exception
+ {
+ super.startService();
+ }
+
+ /**
+ *
+ */
+ protected void stopService() throws Exception
+ {
+ super.stopService();
+ this.clientUiConfig = null;
+ }
+
+
+ /**
+ * Used to register the different Client side UI technologies supported by the Portal
+ *
+ * @param clientUiConfig
+ */
+ public void setClientUiConfig(Element clientUiConfigElement)
+ {
+ try
+ {
+ Properties properties = XMLTools.loadXMLProperties(clientUiConfigElement);
+ if(properties != null)
+ {
+ for(Iterator itr=properties.keySet().iterator();itr.hasNext();)
+ {
+ String key = (String)itr.next();
+ String value = (String)properties.get(key);
+
+ this.clientUiConfig.put(key,
+
Thread.currentThread().getContextClassLoader().loadClass(value).newInstance());
+ }
+ }
+ }
+ catch(Exception e)
+ {
+ log.error(this,e);
+ try
+ {
+ this.stopService();
+ }
+ catch(Exception ex)
+ {
+ //Dont worry about it...we tried to stop it..
+ //Just cleanup now and proceed
+ this.clientUiConfig = null;
+ }
+ throw new RuntimeException(e);
+ }
+ }
+ //--------UIServer
implementation----------------------------------------------------------------------------------------------------
+ /**
+ *
+ */
+ public void aggregate(UIServerRequest uiServerRequest)
+ {
+ try
+ {
+ Object uiIndicator =
uiServerRequest.getAttribute(UIServerRequest.UI_INDICATOR);
+
+ //Lookup the client UI that should be used to handle the aggregation/response
back to the Client
+ ClientUI clientUI =
(ClientUI)this.clientUiConfig.get(uiIndicator.getClass().getName());
+
+ //Actually send an aggregated response back to the Client
+ clientUI.sendResponse(uiServerRequest);
+ }
+ catch(Exception e)
+ {
+ log.error(this,e);
+ throw new RuntimeException(e);
+ }
+ }
+}
Added:
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/UIServerPageRendition.java
===================================================================
---
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/UIServerPageRendition.java
(rev 0)
+++
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/UIServerPageRendition.java 2007-08-01
16:16:54 UTC (rev 7857)
@@ -0,0 +1,104 @@
+/******************************************************************************
+ * 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;
+
+import org.jboss.portal.theme.PageService;
+import org.jboss.portal.theme.render.RendererContext;
+import org.jboss.portal.theme.render.RenderException;
+import org.jboss.portal.theme.render.ThemeContext;
+import org.jboss.portal.theme.PortalLayout;
+import org.jboss.portal.theme.PortalTheme;
+import org.jboss.portal.theme.page.PageResult;
+import org.jboss.portal.common.util.MarkupInfo;
+import org.jboss.portal.web.ServletContextDispatcher;
+
+import javax.servlet.ServletException;
+import java.io.IOException;
+
+/**
+ * Should not be a controller response, but it comes from legacy design.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class UIServerPageRendition
+{
+
+ /** . */
+ private PortalLayout layout;
+
+ /** . */
+ private PageResult pageResult;
+
+ /** . */
+ private PortalTheme theme;
+
+ /** . */
+ private PageService pageService;
+
+ public UIServerPageRendition(
+ PortalLayout layout,
+ PortalTheme theme,
+ PageResult markupResult,
+ PageService pageService)
+ {
+ this.layout = layout;
+ this.theme = theme;
+ this.pageResult = markupResult;
+ this.pageService = pageService;
+ }
+
+ /** 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 = markupInfo.getContentType() + "; charset=" +
markupInfo.getCharset();
+
+ // Set charset and content type on the response
+ dispatcher.getResponse().setContentType(contentType);
+ dispatcher.getResponse().setCharacterEncoding(markupInfo.getCharset());
+
+
+ //
+ ThemeContext themeContext = new ThemeContext(theme,
pageService.getThemeService());
+
+ //
+ RendererContext rendererContext = layout.getRenderContext(themeContext, markupInfo,
dispatcher);
+
+ //
+ try
+ {
+ rendererContext.render(pageResult);
+ }
+ catch (RenderException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public PageResult getPageResult()
+ {
+ return pageResult;
+ }
+}
Added: branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/UIServerRequest.java
===================================================================
--- branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/UIServerRequest.java
(rev 0)
+++
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/UIServerRequest.java 2007-08-01
16:16:54 UTC (rev 7857)
@@ -0,0 +1,94 @@
+/******************************************************************************
+ * 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;
+
+import java.io.Serializable;
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class UIServerRequest implements Serializable
+{
+ public static final String UI_INDICATOR = "uiIndicator";
+ public static final String SERVER_INVOCATION = "serverInvocation";
+
+ /**
+ *
+ */
+ private Map attributes = null;
+
+ /**
+ *
+ *
+ */
+ public UIServerRequest()
+ {
+ this.attributes = new HashMap();
+ }
+
+ /**
+ *
+ * @param name
+ * @param value
+ */
+ public void setAttribute(String name,Object value)
+ {
+ if(name == null)
+ {
+ throw new IllegalArgumentException("Attribute Name cannot be null");
+ }
+
+ if(value == null)
+ {
+ this.removeAttribute(name);
+ return;
+ }
+
+ this.attributes.put(name, value);
+ }
+
+ /**
+ *
+ * @param name
+ * @return
+ */
+ public Object getAttribute(String name)
+ {
+ return this.attributes.get(name);
+ }
+
+ /**
+ *
+ * @param name
+ */
+ public void removeAttribute(String name)
+ {
+ if(this.attributes.containsKey(name))
+ {
+ this.attributes.remove(name);
+ }
+ }
+}
Added:
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/layout/Component.java
===================================================================
--- branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/layout/Component.java
(rev 0)
+++
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/layout/Component.java 2007-08-01
16:16:54 UTC (rev 7857)
@@ -0,0 +1,73 @@
+/******************************************************************************
+ * 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;
+
+import java.io.Serializable;
+
+/**
+ * Component represents a UI entity that will be rendered eventually on the client
+ *
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public abstract class Component implements Serializable
+{
+ /**
+ * required unique id of the component. uniqueness in relation to
+ * other components added to the same instance of the container
+ */
+ protected String id = null;
+
+ /**
+ *
+ * @param id
+ */
+ public Component(String id)
+ {
+ this.id = id;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public String getId()
+ {
+ return id;
+ }
+
+ /**
+ *
+ * @param id
+ */
+ public void setId(String id)
+ {
+ this.id = id;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public abstract String render();
+}
Added:
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/layout/Container.java
===================================================================
--- branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/layout/Container.java
(rev 0)
+++
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/layout/Container.java 2007-08-01
16:16:54 UTC (rev 7857)
@@ -0,0 +1,134 @@
+/******************************************************************************
+ * 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;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * Container is an organizational entity which aggregates the Components that will be
rendered on the client
+ *
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class Container implements Serializable
+{
+ /**
+ * required unique id of the container. uniqueness in relation to
+ * other containers added to the same instance of the page
+ */
+ protected String id = null;
+
+
+ /**
+ *
+ */
+ private List components = null;
+
+ /**
+ *
+ *
+ */
+ public Container(String id)
+ {
+ this.id = id;
+ this.components = new ArrayList();
+ }
+
+ /**
+ *
+ * @return
+ */
+ public String getId()
+ {
+ return id;
+ }
+
+ /**
+ *
+ * @param id
+ */
+ public void setId(String id)
+ {
+ this.id = id;
+ }
+
+
+ /**
+ *
+ * @return
+ */
+ public List getComponents()
+ {
+ return components;
+ }
+
+ /**
+ *
+ * @param components
+ */
+ public void setComponents(List components)
+ {
+ this.components = components;
+ }
+
+ /**
+ *
+ * @param componentId
+ * @return
+ */
+ public Component getComponent(String componentId)
+ {
+ Component component = null;
+
+ if(this.components != null)
+ {
+ for(int i=0;i<this.components.size();i++)
+ {
+ Component cour = (Component)this.components.get(i);
+ if(cour.getId().equals(componentId))
+ {
+ component = cour;
+ break;
+ }
+ }
+ }
+
+ return component;
+ }
+
+ /**
+ *
+ * @param component
+ */
+ public void addComponent(Component component)
+ {
+ if(this.components == null)
+ {
+ this.components = new ArrayList();
+ }
+
+ this.components.add(component);
+ }
+}
Added:
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/layout/LayoutManager.java
===================================================================
---
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/layout/LayoutManager.java
(rev 0)
+++
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/layout/LayoutManager.java 2007-08-01
16:16:54 UTC (rev 7857)
@@ -0,0 +1,37 @@
+/******************************************************************************
+ * 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;
+
+/**
+ * @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/uiserver/layout/LayoutService.java
===================================================================
---
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/layout/LayoutService.java
(rev 0)
+++
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/layout/LayoutService.java 2007-08-01
16:16:54 UTC (rev 7857)
@@ -0,0 +1,54 @@
+/******************************************************************************
+ * 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;
+
+/**
+ * @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;
+ }
+}
Added: branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/layout/Page.java
===================================================================
--- branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/layout/Page.java
(rev 0)
+++
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/layout/Page.java 2007-08-01
16:16:54 UTC (rev 7857)
@@ -0,0 +1,74 @@
+/******************************************************************************
+ * 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;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * A Page is a domain level representation of the final output produced by the Portal.
+ *
+ * It aggregates the output of multiple containers. It is decoupled from any particular
LayoutManager
+ *
+ * Eventually the LayoutService processes an instance of a Page to properly layout the
containers depending on
+ * the layout strategy of the LayoutManager
+ *
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class Page implements Serializable
+{
+ /**
+ * A page consists of multiple containers that are to be displayed/aggregated along
with their corresponding
+ * UI components
+ */
+ private List containers = null;
+
+ /**
+ *
+ *
+ */
+ public Page()
+ {
+ this.containers = new ArrayList();
+ }
+
+ /**
+ *
+ * @return
+ */
+ public List getContainers()
+ {
+ return containers;
+ }
+
+ /**
+ *
+ * @param containers
+ */
+ public void setContainers(List containers)
+ {
+ this.containers = containers;
+ }
+}
Added: branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/layout/Window.java
===================================================================
--- branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/layout/Window.java
(rev 0)
+++
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/layout/Window.java 2007-08-01
16:16:54 UTC (rev 7857)
@@ -0,0 +1,69 @@
+/******************************************************************************
+ * 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;
+
+/**
+ * Window is a UI component which represents a Portlet Window and its corresponding
markup which will be eventually rendered on the client
+ *
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class Window extends Component
+{
+ /**
+ *
+ */
+ private String content = null;
+
+ /**
+ *
+ * @param id
+ */
+ public Window(String id)
+ {
+ super(id);
+ }
+
+ /**
+ *
+ * @param id
+ * @param content markup content produced by a portlet to be displayed inside this
window
+ */
+ public Window(String id,String content)
+ {
+ this(id);
+ this.content = content;
+ }
+
+ /**
+ *
+ */
+ public String render()
+ {
+ String markup = "";
+
+ markup = this.content;
+
+ return markup;
+ }
+}
Added:
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
(rev 0)
+++
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/layout/classic/FlexibleGrid.java 2007-08-01
16:16:54 UTC (rev 7857)
@@ -0,0 +1,257 @@
+/******************************************************************************
+ * 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 org.apache.log4j.Logger;
+
+import org.jboss.portal.uiserver.layout.Container;
+import org.jboss.portal.uiserver.layout.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 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.render();
+ }
+
+ }
+ }
+
+ return markup;
+ }
+}
Added:
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/layout/classic/FlexibleGridConstraints.java
===================================================================
---
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/layout/classic/FlexibleGridConstraints.java
(rev 0)
+++
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/layout/classic/FlexibleGridConstraints.java 2007-08-01
16:16:54 UTC (rev 7857)
@@ -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.uiserver.layout.classic;
+
+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/uiserver/layout/classic/FlexibleGridLayoutManager.java
===================================================================
---
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/layout/classic/FlexibleGridLayoutManager.java
(rev 0)
+++
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/layout/classic/FlexibleGridLayoutManager.java 2007-08-01
16:16:54 UTC (rev 7857)
@@ -0,0 +1,289 @@
+/******************************************************************************
+ * 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 org.jboss.portal.uiserver.layout.Container;
+import org.jboss.portal.uiserver.layout.LayoutManager;
+import org.jboss.portal.uiserver.layout.Page;
+
+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(this.generateMarkup(grid, 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(this.generateInlineStyle(grid, container));
+ }
+
+ buffer.append("</style>\n");
+
+ 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;
+ }
+}