Author: julien(a)jboss.com
Date: 2008-06-10 09:49:38 -0400 (Tue, 10 Jun 2008)
New Revision: 10971
Added:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/pull/
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/pull/DetachedUINode.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/pull/DetachedViewPortContext.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/pull/UINodeFactory.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/pull/UINodeImpl.java
Removed:
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/servlet/StructuralStateContextImporter.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/UINodeFactory.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/UINodeImpl.java
Modified:
modules/presentation/trunk/classic/src/main/java/org/jboss/portal/presentation/classic/ClassicPresentationClient.java
modules/presentation/trunk/classic/src/main/java/org/jboss/portal/presentation/classic/model/ClassicUINode.java
modules/presentation/trunk/pom.xml
modules/presentation/trunk/portal/pom.xml
modules/presentation/trunk/portal/src/assemble/presentation-portal-war.xml
modules/presentation/trunk/portal/src/main/artifacts/presentation-portal-war/WEB-INF/web.xml
modules/presentation/trunk/portal/src/test/java/org/jboss/portal/presentation/portal/model/StructuralStateContextTestCase.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model/UINode.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/view/DefaultPageViewPortScope.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/view/PageViewPortScope.java
Log:
improved
Modified:
modules/presentation/trunk/classic/src/main/java/org/jboss/portal/presentation/classic/ClassicPresentationClient.java
===================================================================
---
modules/presentation/trunk/classic/src/main/java/org/jboss/portal/presentation/classic/ClassicPresentationClient.java 2008-06-10
05:35:22 UTC (rev 10970)
+++
modules/presentation/trunk/classic/src/main/java/org/jboss/portal/presentation/classic/ClassicPresentationClient.java 2008-06-10
13:49:38 UTC (rev 10971)
@@ -38,6 +38,7 @@
import org.jboss.portal.presentation.model.ui.UIObject;
import org.jboss.portal.presentation.model.ViewPort;
import org.jboss.portal.presentation.model.ViewPortScope;
+import org.jboss.portal.presentation.model.UINode;
import org.jboss.portal.presentation.model.layout.LayoutFactory;
import org.jboss.portal.presentation.model.layout.Layout;
import org.jboss.portal.presentation.model.layout.SimpleLayout;
@@ -224,8 +225,15 @@
else
{
StructuralStateContext ssc = server.getStructuralStateContext();
- DefaultPageViewPortScope scope = new DefaultPageViewPortScope(ssc.getRootId());
- renderDocument(scope, ssc.getRootId());
+ ViewPortScope scope = new DefaultPageViewPortScope(ssc.getRootId());
+ ClassicViewPortContext context = new ClassicViewPortContext();
+ UIModel model = new UIModelImpl(null, ssc);
+ ViewPort viewPort = model.createViewPort(context, scope);
+ viewPort.refresh();
+ UINode root = context.getNode(ssc.getRootId());
+ UINode defaultPage = root.getChildren().iterator().next();
+ String defaultPageId = defaultPage.getObject().getId();
+ renderDocument(new PageViewPortScope(defaultPageId), defaultPageId);
}
}
@@ -259,7 +267,7 @@
writer.print("</body></html>");
}
- private void renderNode(ClassicUINode node, PrintWriter writer)
+ private void renderNode(UINode node, PrintWriter writer)
{
UIObject object = node.getObject();
@@ -315,7 +323,7 @@
writer.println("</div>");
}
- private void renderPane(ClassicUINode node, PrintWriter writer)
+ private void renderPane(UINode node, PrintWriter writer)
{
LayoutFactory layoutFactory = new LayoutFactory();
@@ -342,12 +350,12 @@
}
//
- Collection<ClassicUINode> children = node.getChildren();
+ Collection<? extends UINode> children = node.getChildren();
//
if (children != null)
{
- for (ClassicUINode child : children)
+ for (UINode child : children)
{
if (orientation == Orientation.HORIZONTAL)
{
@@ -379,14 +387,14 @@
}
}
- private void renderChildren(ClassicUINode node, PrintWriter writer)
+ private void renderChildren(UINode node, PrintWriter writer)
{
- Collection<ClassicUINode> children = node.getChildren();
+ Collection<? extends UINode> children = node.getChildren();
//
if (children != null)
{
- for (ClassicUINode child : children)
+ for (UINode child : children)
{
renderNode(child, writer);
}
Modified:
modules/presentation/trunk/classic/src/main/java/org/jboss/portal/presentation/classic/model/ClassicUINode.java
===================================================================
---
modules/presentation/trunk/classic/src/main/java/org/jboss/portal/presentation/classic/model/ClassicUINode.java 2008-06-10
05:35:22 UTC (rev 10970)
+++
modules/presentation/trunk/classic/src/main/java/org/jboss/portal/presentation/classic/model/ClassicUINode.java 2008-06-10
13:49:38 UTC (rev 10971)
@@ -69,7 +69,7 @@
return object;
}
- public Collection getChildren()
+ public Collection<? extends UINode> getChildren()
{
return children == null ? null : children.values();
}
Modified: modules/presentation/trunk/pom.xml
===================================================================
--- modules/presentation/trunk/pom.xml 2008-06-10 05:35:22 UTC (rev 10970)
+++ modules/presentation/trunk/pom.xml 2008-06-10 13:49:38 UTC (rev 10971)
@@ -30,7 +30,7 @@
<module>presentation</module>
<module>classic</module>
<module>portal</module>
- <!--<module>ajax2</module>-->
+ <module>ajax2</module>
<!--<module>ajax</module>-->
</modules>
</project>
Modified: modules/presentation/trunk/portal/pom.xml
===================================================================
--- modules/presentation/trunk/portal/pom.xml 2008-06-10 05:35:22 UTC (rev 10970)
+++ modules/presentation/trunk/portal/pom.xml 2008-06-10 13:49:38 UTC (rev 10971)
@@ -27,6 +27,19 @@
</dependency>
<dependency>
+ <groupId>org.jboss.portal.presentation</groupId>
+ <artifactId>presentation-ajax2</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.portal.presentation</groupId>
+ <artifactId>presentation-ajax2</artifactId>
+ <version>${project.version}</version>
+ <type>war</type>
+ </dependency>
+
+ <dependency>
<groupId>sun-servlet</groupId>
<artifactId>servlet-api</artifactId>
</dependency>
@@ -119,7 +132,30 @@
<argLine>-enableassertions</argLine>
</configuration>
</plugin>
+
<plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>unpack-presesntation-ajax</id>
+ <goals>
+ <goal>unpack-dependencies</goal>
+ </goals>
+ <phase>generate-resources</phase>
+ <configuration>
+
<outputDirectory>target/presentation-portal-war</outputDirectory>
+
<includeArtifacIds>presentation-ajax2</includeArtifacIds>
+
<includeGroupIds>org.jboss.portal.presentation</includeGroupIds>
+ <includeTypes>war</includeTypes>
+ <excludeTransitive>true</excludeTransitive>
+
<outputAbsoluteArtifactFilename>true</outputAbsoluteArtifactFilename>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<finalName>portal</finalName>
Modified: modules/presentation/trunk/portal/src/assemble/presentation-portal-war.xml
===================================================================
--- modules/presentation/trunk/portal/src/assemble/presentation-portal-war.xml 2008-06-10
05:35:22 UTC (rev 10970)
+++ modules/presentation/trunk/portal/src/assemble/presentation-portal-war.xml 2008-06-10
13:49:38 UTC (rev 10971)
@@ -13,6 +13,11 @@
</fileSet>
<fileSet>
+ <directory>target/presentation-portal-war</directory>
+ <outputDirectory></outputDirectory>
+ </fileSet>
+
+ <fileSet>
<directory>target/classes</directory>
<outputDirectory>WEB-INF/classes</outputDirectory>
</fileSet>
@@ -20,7 +25,18 @@
</fileSets>
<dependencySets>
+
+<!--
<dependencySet>
+ <unpack>true</unpack>
+ <outputDirectory></outputDirectory>
+ <includes>
+
<include>org.jboss.portal.presentation:presentation-ajax2:war</include>
+ </includes>
+ </dependencySet>
+-->
+
+ <dependencySet>
<outputDirectory>WEB-INF/lib</outputDirectory>
<includes>
@@ -33,8 +49,12 @@
<include>org.jboss.portal.portlet:portlet-mc</include>
<include>org.jboss.portal.portlet:portlet-samples</include>
<include>org.jboss.portal.presentation:presentation-presentation</include>
+
<include>org.jboss.portal.presentation:presentation-classic</include>
+
<include>org.jboss.portal.presentation:presentation-ajax2</include>
+ <include>com.google.gwt:gwt-user</include>
+
<include>javax.ccpp:ccpp</include>
<include>javax.portlet:portlet-api</include>
Modified:
modules/presentation/trunk/portal/src/main/artifacts/presentation-portal-war/WEB-INF/web.xml
===================================================================
---
modules/presentation/trunk/portal/src/main/artifacts/presentation-portal-war/WEB-INF/web.xml 2008-06-10
05:35:22 UTC (rev 10970)
+++
modules/presentation/trunk/portal/src/main/artifacts/presentation-portal-war/WEB-INF/web.xml 2008-06-10
13:49:38 UTC (rev 10971)
@@ -44,8 +44,18 @@
<servlet-mapping>
<servlet-name>ClassicPresentationServlet</servlet-name>
- <url-pattern>/*</url-pattern>
+ <url-pattern>/classic/*</url-pattern>
</servlet-mapping>
+ <servlet>
+ <servlet-name>AjaxPresentationServlet</servlet-name>
+
<servlet-class>org.jboss.portal.presentation.ajax2.server.PresentationClientServlet</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>AjaxPresentationServlet</servlet-name>
+ <url-pattern>/remote</url-pattern>
+ </servlet-mapping>
+
</web-app>
\ No newline at end of file
Deleted:
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/servlet/StructuralStateContextImporter.java
===================================================================
---
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/servlet/StructuralStateContextImporter.java 2008-06-10
05:35:22 UTC (rev 10970)
+++
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/servlet/StructuralStateContextImporter.java 2008-06-10
13:49:38 UTC (rev 10971)
@@ -1,95 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2008, 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.portal.servlet;
-
-import org.jboss.portal.presentation.portal.model.object.PortalNodeManager;
-import org.jboss.portal.presentation.portal.model.ModelImporter;
-import org.jboss.portal.presentation.portal.model.object.ContextNode;
-import org.jboss.portal.presentation.portal.model.layout.LayoutStore;
-import org.jboss.portal.common.io.IOTools;
-
-import javax.servlet.ServletContext;
-import java.io.InputStream;
-
-/**
- * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
- * @version $Revision: 630 $
- */
-public class StructuralStateContextImporter
-{
-
- /** . */
- private ServletContext servletContext;
-
- /** . */
- private PortalNodeManager portalNodeManager;
-
- /** . */
- private LayoutStore layoutStore;
-
- public ServletContext getServletContext()
- {
- return servletContext;
- }
-
- public void setServletContext(ServletContext servletContext)
- {
- this.servletContext = servletContext;
- }
-
- public PortalNodeManager getPortalNodeManager()
- {
- return portalNodeManager;
- }
-
- public void setPortalNodeManager(PortalNodeManager portalNodeManager)
- {
- this.portalNodeManager = portalNodeManager;
- }
-
- public LayoutStore getLayoutStore()
- {
- return layoutStore;
- }
-
- public void setLayoutStore(LayoutStore layoutStore)
- {
- this.layoutStore = layoutStore;
- }
-
- public void start() throws Exception
- {
- InputStream in =
servletContext.getResourceAsStream("/WEB-INF/page-structure.xml");
-
- //
- try
- {
- ContextNode root = portalNodeManager.getRoot();
- new ModelImporter(root, layoutStore).importDocument(in);
- }
- finally
- {
- IOTools.safeClose(in);
- }
- }
-}
Modified:
modules/presentation/trunk/portal/src/test/java/org/jboss/portal/presentation/portal/model/StructuralStateContextTestCase.java
===================================================================
---
modules/presentation/trunk/portal/src/test/java/org/jboss/portal/presentation/portal/model/StructuralStateContextTestCase.java 2008-06-10
05:35:22 UTC (rev 10970)
+++
modules/presentation/trunk/portal/src/test/java/org/jboss/portal/presentation/portal/model/StructuralStateContextTestCase.java 2008-06-10
13:49:38 UTC (rev 10971)
@@ -34,7 +34,6 @@
import org.jboss.portal.presentation.portal.model.object.ContextNode;
import org.jboss.portal.presentation.portal.model.object.PageNode;
import org.jboss.portal.presentation.portal.model.object.PortalNode;
-import org.jboss.portal.presentation.portal.model.ModelAdapter;
import org.jboss.portal.presentation.portal.model.object.PortalNodeManager;
import org.jboss.portal.presentation.portal.model.object.WindowNode;
Deleted:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/UINodeFactory.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/UINodeFactory.java 2008-06-10
05:35:22 UTC (rev 10970)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/UINodeFactory.java 2008-06-10
13:49:38 UTC (rev 10971)
@@ -1,63 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2008, 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.model;
-
-import org.jboss.portal.presentation.model.UINode;
-import org.jboss.portal.presentation.state.structural.StructuralStateContext;
-import org.jboss.portal.presentation.state.structural.StructuralObject;
-import org.jboss.portal.presentation.state.navigational.NavigationalStateContext;
-
-/**
- * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
- * @version $Revision: 630 $
- */
-public class UINodeFactory
-{
-
- /**
- * Creates a user interface node.
- *
- * @param navigationalStateContext the navigational state context
- * @param structuralStateContext the structural state context
- * @param objectId the object id
- * @return the corresponding node
- */
- public static UINode createNode(
- NavigationalStateContext navigationalStateContext,
- StructuralStateContext structuralStateContext,
- String objectId)
- {
- StructuralObject object = structuralStateContext.load(objectId);
-
- //
- if (object != null)
- {
- return new UINodeImpl(navigationalStateContext, structuralStateContext,
object);
- }
- else
- {
- return null;
- }
- }
-
-}
Deleted:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/UINodeImpl.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/UINodeImpl.java 2008-06-10
05:35:22 UTC (rev 10970)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/UINodeImpl.java 2008-06-10
13:49:38 UTC (rev 10971)
@@ -1,164 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2008, 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.model;
-
-import org.jboss.portal.presentation.model.UINode;
-import org.jboss.portal.presentation.model.ui.UIObject;
-import org.jboss.portal.presentation.state.structural.StructuralObject;
-import org.jboss.portal.presentation.state.structural.StructuralStateContext;
-import org.jboss.portal.presentation.state.navigational.NavigationalStateContext;
-import org.jboss.portal.presentation.impl.model.ui.UIObjectContext;
-import org.jboss.portal.presentation.impl.model.ui.UIObjectImpl;
-
-import java.util.Collection;
-import java.util.ArrayList;
-
-/**
- * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
- * @version $Revision: 630 $
- */
-class UINodeImpl implements UINode, UIObjectContext
-{
-
- /** . */
- private final NavigationalStateContext navigationalStateContext;
-
- /** . */
- private final StructuralStateContext structuralStateContext;
-
- /** . */
- private final StructuralObject structuralObject;
-
- /** . */
- private Collection<UINode> children;
-
- /** . */
- private UINode parent;
-
- /** . */
- private boolean parentVisited;
-
- /** . */
- private UIObject object;
-
- UINodeImpl(NavigationalStateContext navigationalStateContext, StructuralStateContext
structuralStateContext, StructuralObject structuralObject)
- {
- this.navigationalStateContext = navigationalStateContext;
- this.structuralStateContext = structuralStateContext;
- this.structuralObject = structuralObject;
- this.children = null;
- this.parentVisited = false;
- }
-
- private UINodeImpl(NavigationalStateContext navigationalStateContext,
StructuralStateContext structuralStateContext, StructuralObject structuralObject,
Collection<UINode> children)
- {
- this.navigationalStateContext = navigationalStateContext;
- this.structuralStateContext = structuralStateContext;
- this.structuralObject = structuralObject;
- this.children = children;
- this.parentVisited = true;
- }
-
- public UIObject getObject()
- {
- if (object == null)
- {
- object = UIObjectImpl.create(structuralObject, this);
- }
-
- //
- return object;
- }
-
- public UINode getParent()
- {
- if (!parentVisited)
- {
- StructuralObject parentObject =
structuralStateContext.loadParent(structuralObject);
-
- //
- if (parentObject != null)
- {
- Collection<StructuralObject> siblingObjects =
structuralStateContext.loadChildren(parentObject);
- ArrayList<UINode> siblings = new
ArrayList<UINode>(siblingObjects.size());
- for (StructuralObject siblingObject : siblingObjects)
- {
- UINodeImpl sibling;
- if (siblingObject.getId().equals(structuralObject.getId()))
- {
- sibling = this;
- }
- else
- {
- sibling = new UINodeImpl(navigationalStateContext,
structuralStateContext, siblingObject);
- sibling.parent = this;
- sibling.parentVisited = true;
- }
-
- //
- siblings.add(sibling);
- }
-
- //
- parent = new UINodeImpl(navigationalStateContext, structuralStateContext,
parentObject, siblings);
- }
-
- //
- parentVisited = true;
- }
-
- //
- return parent;
- }
-
- public Collection<UINode> getChildren()
- {
- if (children == null)
- {
- Collection<StructuralObject> childrenObject =
structuralStateContext.loadChildren(structuralObject);
- ArrayList<UINode> children = new
ArrayList<UINode>(childrenObject.size());
- for (StructuralObject childObject : childrenObject)
- {
- UINodeImpl child = new UINodeImpl(navigationalStateContext,
structuralStateContext, childObject);
- child.parent = this;
- child.parentVisited = true;
-
- //
- children.add(child);
- }
-
- //
- this.children = children;
- }
-
- //
- return children;
- }
-
- // UIObjectContext implementation
***********************************************************************************
-
- public NavigationalStateContext getNavigationalStateContext()
- {
- return navigationalStateContext;
- }
-}
Added:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/pull/DetachedUINode.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/pull/DetachedUINode.java
(rev 0)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/pull/DetachedUINode.java 2008-06-10
13:49:38 UTC (rev 10971)
@@ -0,0 +1,76 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, 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.model.pull;
+
+import org.jboss.portal.presentation.model.ui.UIObject;
+import org.jboss.portal.presentation.model.UINode;
+
+import java.util.Collection;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
+ * @version $Revision: 630 $
+ */
+public class DetachedUINode implements UINode
+{
+
+ /** . */
+ private final UIObject object;
+
+ /** . */
+ DetachedUINode parent;
+
+ /** . */
+ Map<String, DetachedUINode> children;
+
+ public DetachedUINode(UIObject object)
+ {
+ this.object = object;
+ }
+
+ public DetachedUINode getParent()
+ {
+ return parent;
+ }
+
+ public String getId()
+ {
+ return object.getId();
+ }
+
+ public String getName()
+ {
+ return object.getName();
+ }
+
+ public UIObject getObject()
+ {
+ return object;
+ }
+
+ public Collection<? extends UINode> getChildren()
+ {
+ return children == null ? null : children.values();
+ }
+}
\ No newline at end of file
Copied:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/pull/DetachedViewPortContext.java
(from rev 10942,
modules/presentation/trunk/classic/src/main/java/org/jboss/portal/presentation/classic/model/ClassicViewPortContext.java)
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/pull/DetachedViewPortContext.java
(rev 0)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/pull/DetachedViewPortContext.java 2008-06-10
13:49:38 UTC (rev 10971)
@@ -0,0 +1,103 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, 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.model.pull;
+
+import org.jboss.portal.presentation.model.ui.UIObject;
+import org.jboss.portal.presentation.model.ViewPortContext;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
+ * @version $Revision: 630 $
+ */
+public class DetachedViewPortContext implements ViewPortContext
+{
+
+ /** . */
+ final Map<String, DetachedUINode> nodes = new HashMap<String,
DetachedUINode>();
+
+ public DetachedUINode getNode(String nodeId)
+ {
+ return nodes.get(nodeId);
+ }
+
+ public UIObject getObject(String objectId)
+ {
+ DetachedUINode node = nodes.get(objectId);
+
+ //
+ if (node == null)
+ {
+ return null;
+ }
+ else
+ {
+ return node.getObject();
+ }
+ }
+
+ public void addObject(UIObject object)
+ {
+ DetachedUINode node = new DetachedUINode(object);
+
+ //
+ nodes.put(node.getId(), node);
+ }
+
+ public void updateObject(String objectId)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void removeObject(String objectId)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void createChildren(String parentId)
+ {
+ nodes.get(parentId).children = new HashMap<String, DetachedUINode>();
+ }
+
+ public void destroyChildren(String parentId)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void addChild(String parentId, String childId)
+ {
+ DetachedUINode parent = nodes.get(parentId);
+ DetachedUINode child = nodes.get(childId);
+
+ //
+ parent.children.put(child.getName(), child);
+ child.parent = parent;
+ }
+
+ public void removeChild(String parentId, String childId)
+ {
+ throw new UnsupportedOperationException();
+ }
+}
\ No newline at end of file
Copied:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/pull/UINodeFactory.java
(from rev 10942,
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/UINodeFactory.java)
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/pull/UINodeFactory.java
(rev 0)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/pull/UINodeFactory.java 2008-06-10
13:49:38 UTC (rev 10971)
@@ -0,0 +1,62 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, 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.model.pull;
+
+import org.jboss.portal.presentation.model.UINode;
+import org.jboss.portal.presentation.state.structural.StructuralStateContext;
+import org.jboss.portal.presentation.state.structural.StructuralObject;
+import org.jboss.portal.presentation.state.navigational.NavigationalStateContext;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
+ * @version $Revision: 630 $
+ */
+public class UINodeFactory
+{
+
+ /**
+ * Creates a user interface node.
+ *
+ * @param navigationalStateContext the navigational state context
+ * @param structuralStateContext the structural state context
+ * @param objectId the object id
+ * @return the corresponding node
+ */
+ public static UINode createNode(
+ NavigationalStateContext navigationalStateContext,
+ StructuralStateContext structuralStateContext,
+ String objectId)
+ {
+ StructuralObject object = structuralStateContext.load(objectId);
+
+ //
+ if (object != null)
+ {
+ return new UINodeImpl(navigationalStateContext, structuralStateContext,
object);
+ }
+ else
+ {
+ return null;
+ }
+ }
+}
Copied:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/pull/UINodeImpl.java
(from rev 10942,
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/UINodeImpl.java)
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/pull/UINodeImpl.java
(rev 0)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/pull/UINodeImpl.java 2008-06-10
13:49:38 UTC (rev 10971)
@@ -0,0 +1,164 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, 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.model.pull;
+
+import org.jboss.portal.presentation.model.UINode;
+import org.jboss.portal.presentation.model.ui.UIObject;
+import org.jboss.portal.presentation.state.structural.StructuralObject;
+import org.jboss.portal.presentation.state.structural.StructuralStateContext;
+import org.jboss.portal.presentation.state.navigational.NavigationalStateContext;
+import org.jboss.portal.presentation.impl.model.ui.UIObjectContext;
+import org.jboss.portal.presentation.impl.model.ui.UIObjectImpl;
+
+import java.util.Collection;
+import java.util.ArrayList;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
+ * @version $Revision: 630 $
+ */
+class UINodeImpl implements UINode, UIObjectContext
+{
+
+ /** . */
+ private final NavigationalStateContext navigationalStateContext;
+
+ /** . */
+ private final StructuralStateContext structuralStateContext;
+
+ /** . */
+ private final StructuralObject structuralObject;
+
+ /** . */
+ private Collection<UINode> children;
+
+ /** . */
+ private UINode parent;
+
+ /** . */
+ private boolean parentVisited;
+
+ /** . */
+ private UIObject object;
+
+ UINodeImpl(NavigationalStateContext navigationalStateContext, StructuralStateContext
structuralStateContext, StructuralObject structuralObject)
+ {
+ this.navigationalStateContext = navigationalStateContext;
+ this.structuralStateContext = structuralStateContext;
+ this.structuralObject = structuralObject;
+ this.children = null;
+ this.parentVisited = false;
+ }
+
+ private UINodeImpl(NavigationalStateContext navigationalStateContext,
StructuralStateContext structuralStateContext, StructuralObject structuralObject,
Collection<UINode> children)
+ {
+ this.navigationalStateContext = navigationalStateContext;
+ this.structuralStateContext = structuralStateContext;
+ this.structuralObject = structuralObject;
+ this.children = children;
+ this.parentVisited = true;
+ }
+
+ public UIObject getObject()
+ {
+ if (object == null)
+ {
+ object = UIObjectImpl.create(structuralObject, this);
+ }
+
+ //
+ return object;
+ }
+
+ public UINode getParent()
+ {
+ if (!parentVisited)
+ {
+ StructuralObject parentObject =
structuralStateContext.loadParent(structuralObject);
+
+ //
+ if (parentObject != null)
+ {
+ Collection<StructuralObject> siblingObjects =
structuralStateContext.loadChildren(parentObject);
+ ArrayList<UINode> siblings = new
ArrayList<UINode>(siblingObjects.size());
+ for (StructuralObject siblingObject : siblingObjects)
+ {
+ UINodeImpl sibling;
+ if (siblingObject.getId().equals(structuralObject.getId()))
+ {
+ sibling = this;
+ }
+ else
+ {
+ sibling = new UINodeImpl(navigationalStateContext,
structuralStateContext, siblingObject);
+ sibling.parent = this;
+ sibling.parentVisited = true;
+ }
+
+ //
+ siblings.add(sibling);
+ }
+
+ //
+ parent = new UINodeImpl(navigationalStateContext, structuralStateContext,
parentObject, siblings);
+ }
+
+ //
+ parentVisited = true;
+ }
+
+ //
+ return parent;
+ }
+
+ public Collection<? extends UINode> getChildren()
+ {
+ if (children == null)
+ {
+ Collection<StructuralObject> childrenObject =
structuralStateContext.loadChildren(structuralObject);
+ ArrayList<UINode> children = new
ArrayList<UINode>(childrenObject.size());
+ for (StructuralObject childObject : childrenObject)
+ {
+ UINodeImpl child = new UINodeImpl(navigationalStateContext,
structuralStateContext, childObject);
+ child.parent = this;
+ child.parentVisited = true;
+
+ //
+ children.add(child);
+ }
+
+ //
+ this.children = children;
+ }
+
+ //
+ return children;
+ }
+
+ // UIObjectContext implementation
***********************************************************************************
+
+ public NavigationalStateContext getNavigationalStateContext()
+ {
+ return navigationalStateContext;
+ }
+}
Modified:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model/UINode.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model/UINode.java 2008-06-10
05:35:22 UTC (rev 10970)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model/UINode.java 2008-06-10
13:49:38 UTC (rev 10971)
@@ -55,6 +55,6 @@
*
* @return the children
*/
- Collection<UINode> getChildren();
+ Collection<? extends UINode> getChildren();
}
Modified:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/view/DefaultPageViewPortScope.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/view/DefaultPageViewPortScope.java 2008-06-10
05:35:22 UTC (rev 10970)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/view/DefaultPageViewPortScope.java 2008-06-10
13:49:38 UTC (rev 10971)
@@ -27,10 +27,10 @@
import org.jboss.portal.presentation.model.ViewPortScope;
import org.jboss.portal.presentation.model.ui.UIContext;
import org.jboss.portal.presentation.model.ui.UIPage;
-import org.jboss.portal.presentation.model.ui.UIWindow;
-import org.jboss.portal.presentation.model.ui.UIPane;
/**
+ * A scope implementation that retrieves the default page of the root context.
+ *
* @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
* @version $Revision: 630 $
*/
@@ -38,27 +38,11 @@
{
/** . */
- private static final int NO_PAGE = 0;
-
- /** . */
- private static final int DEFAULT_PAGE = 1;
-
- /** . */
- private static final int DEFAULT_PAGE_CHILD = 2;
-
- /** . */
- private static final int DEFAULT_PAGE_SIBLING = 3;
-
- /** . */
private final String rootId;
- /** . */
- private int pageStatus;
-
public DefaultPageViewPortScope(String rootId)
{
this.rootId = rootId;
- this.pageStatus = 0;
}
public String getRootId()
@@ -68,53 +52,21 @@
public ObjectTraversalType enterObject(UIObject object)
{
- if (object instanceof UIPane)
+ if (object instanceof UIContext)
{
- if (object instanceof UIPage)
+ return ObjectTraversalType.RECURSIVE;
+ }
+ if (object instanceof UIPage)
+ {
+ if ("default".equals(object.getName()))
{
- switch (pageStatus)
- {
- case NO_PAGE:
- if ("default".equals(object.getName()))
- {
- pageStatus = DEFAULT_PAGE;
-
- // We want to traverse the children of the default page
- return ObjectTraversalType.RECURSIVE;
- }
- else
- {
- pageStatus = DEFAULT_PAGE_SIBLING;
-
- // We want to see the sibbling pages of the default page
- return ObjectTraversalType.SINGLE;
- }
- case DEFAULT_PAGE:
- pageStatus = DEFAULT_PAGE_CHILD;
-
- // We want to see the children pages of the default page
- return ObjectTraversalType.SINGLE;
- case DEFAULT_PAGE_CHILD:
- case DEFAULT_PAGE_SIBLING:
- return ObjectTraversalType.SKIP;
- default:
- throw new AssertionError();
- }
+ return ObjectTraversalType.SINGLE;
}
else
{
- return ObjectTraversalType.RECURSIVE;
+ return ObjectTraversalType.SKIP;
}
}
- else if (object instanceof UIWindow)
- {
- // We don't traverse windows (for now as they are supposed to be leaves)
- return ObjectTraversalType.SINGLE;
- }
- else if (object instanceof UIContext)
- {
- return ObjectTraversalType.RECURSIVE;
- }
else
{
return ObjectTraversalType.SKIP;
@@ -123,22 +75,5 @@
public void leaveObject(UIObject object)
{
- if (object instanceof UIPage)
- {
- switch (pageStatus)
- {
- case NO_PAGE:
- throw new AssertionError();
- case DEFAULT_PAGE:
- pageStatus = NO_PAGE;
- break;
- case DEFAULT_PAGE_SIBLING:
- pageStatus = NO_PAGE;
- break;
- case DEFAULT_PAGE_CHILD:
- pageStatus = DEFAULT_PAGE;
- break;
- }
- }
}
}
Modified:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/view/PageViewPortScope.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/view/PageViewPortScope.java 2008-06-10
05:35:22 UTC (rev 10970)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/view/PageViewPortScope.java 2008-06-10
13:49:38 UTC (rev 10971)
@@ -31,6 +31,8 @@
import org.jboss.portal.presentation.model.ui.UIPane;
/**
+ * A view scope that retrieves a page and its visible content.
+ *
* @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
* @version $Revision: 630 $
*/