Author: julien(a)jboss.com
Date: 2008-05-19 17:01:35 -0400 (Mon, 19 May 2008)
New Revision: 10779
Added:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/view/
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
Removed:
modules/presentation/trunk/classic/src/main/java/org/jboss/portal/presentation/classic/model/DefaultPageViewPortScope.java
modules/presentation/trunk/classic/src/main/java/org/jboss/portal/presentation/classic/model/PageViewPortScope.java
modules/presentation/trunk/portlet/src/main/java/org/jboss/portal/presentation/portlet/controller/StructuralEventControllerContext.java
modules/presentation/trunk/portlet/src/main/java/org/jboss/portal/presentation/portlet/controller/StructuralPortletControllerContext.java
modules/presentation/trunk/portlet/src/main/java/org/jboss/portal/presentation/portlet/controller/StructuralPortletPageNavigationalState.java
modules/presentation/trunk/portlet/src/main/java/org/jboss/portal/presentation/portlet/controller/StructuralStateControllerContext.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model/UIObject.java
Modified:
modules/presentation/trunk/classic/src/main/java/org/jboss/portal/presentation/classic/ClassicPresentationClient.java
modules/presentation/trunk/pom.xml
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model/ui/UIAction.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model/ui/UIContainer.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model/ui/UIContext.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model/ui/UIPage.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model/ui/UIWindow.java
Log:
commiting pending changes in PF
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-05-19
11:05:59 UTC (rev 10778)
+++
modules/presentation/trunk/classic/src/main/java/org/jboss/portal/presentation/classic/ClassicPresentationClient.java 2008-05-19
21:01:35 UTC (rev 10779)
@@ -24,8 +24,8 @@
import org.jboss.portal.presentation.classic.model.ClassicUINode;
import org.jboss.portal.presentation.classic.model.ClassicViewPortContext;
-import org.jboss.portal.presentation.classic.model.DefaultPageViewPortScope;
-import org.jboss.portal.presentation.classic.model.PageViewPortScope;
+import org.jboss.portal.presentation.view.DefaultPageViewPortScope;
+import org.jboss.portal.presentation.view.PageViewPortScope;
import org.jboss.portal.presentation.classic.protocol.ActionDecoder;
import org.jboss.portal.presentation.classic.protocol.ActionEncoder;
import org.jboss.portal.presentation.client.PresentationClient;
Deleted:
modules/presentation/trunk/classic/src/main/java/org/jboss/portal/presentation/classic/model/DefaultPageViewPortScope.java
===================================================================
---
modules/presentation/trunk/classic/src/main/java/org/jboss/portal/presentation/classic/model/DefaultPageViewPortScope.java 2008-05-19
11:05:59 UTC (rev 10778)
+++
modules/presentation/trunk/classic/src/main/java/org/jboss/portal/presentation/classic/model/DefaultPageViewPortScope.java 2008-05-19
21:01:35 UTC (rev 10779)
@@ -1,136 +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.classic.model;
-
-import org.jboss.portal.presentation.model.ObjectTraversalType;
-import org.jboss.portal.presentation.model.ui.UIObject;
-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;
-
-/**
- * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
- * @version $Revision: 630 $
- */
-public class DefaultPageViewPortScope implements ViewPortScope
-{
-
- /** . */
- 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()
- {
- return rootId;
- }
-
- public ObjectTraversalType enterObject(UIObject object)
- {
- if (object instanceof UIPage)
- {
- 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();
- }
- }
- 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;
- }
- }
-
- 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;
- }
- }
- }
-}
Deleted:
modules/presentation/trunk/classic/src/main/java/org/jboss/portal/presentation/classic/model/PageViewPortScope.java
===================================================================
---
modules/presentation/trunk/classic/src/main/java/org/jboss/portal/presentation/classic/model/PageViewPortScope.java 2008-05-19
11:05:59 UTC (rev 10778)
+++
modules/presentation/trunk/classic/src/main/java/org/jboss/portal/presentation/classic/model/PageViewPortScope.java 2008-05-19
21:01:35 UTC (rev 10779)
@@ -1,136 +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.classic.model;
-
-import org.jboss.portal.presentation.model.ObjectTraversalType;
-import org.jboss.portal.presentation.model.ui.UIObject;
-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;
-
-/**
- * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
- * @version $Revision: 630 $
- */
-public class PageViewPortScope implements ViewPortScope
-{
-
- /** . */
- private static final int NO_PAGE = 0;
-
- /** . */
- private static final int PAGE = 1;
-
- /** . */
- private static final int PAGE_CHILD = 2;
-
- /** . */
- private static final int PAGE_SIBLING = 3;
-
- /** . */
- private final String pageId;
-
- /** . */
- private int pageStatus;
-
- public PageViewPortScope(String pageId)
- {
- this.pageId = pageId;
- this.pageStatus = 0;
- }
-
- public String getRootId()
- {
- return pageId;
- }
-
- public ObjectTraversalType enterObject(UIObject object)
- {
- if (object instanceof UIPage)
- {
- switch (pageStatus)
- {
- case NO_PAGE:
- if (pageId.equals(object.getId()))
- {
- pageStatus = PAGE;
-
- // We want to traverse the children of the default page
- return ObjectTraversalType.RECURSIVE;
- }
- else
- {
- pageStatus = PAGE_SIBLING;
-
- // We want to see the sibbling pages of the default page
- return ObjectTraversalType.SINGLE;
- }
- case PAGE:
- pageStatus = PAGE_CHILD;
-
- // We want to see the children pages of the default page
- return ObjectTraversalType.SINGLE;
- case PAGE_CHILD:
- case PAGE_SIBLING:
- return ObjectTraversalType.SKIP;
- default:
- throw new AssertionError();
- }
- }
- 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;
- }
- }
-
- public void leaveObject(UIObject object)
- {
- if (object instanceof UIPage)
- {
- switch (pageStatus)
- {
- case NO_PAGE:
- throw new AssertionError();
- case PAGE:
- pageStatus = NO_PAGE;
- break;
- case PAGE_SIBLING:
- pageStatus = NO_PAGE;
- break;
- case PAGE_CHILD:
- pageStatus = PAGE;
- break;
- }
- }
- }
-}
\ No newline at end of file
Modified: modules/presentation/trunk/pom.xml
===================================================================
--- modules/presentation/trunk/pom.xml 2008-05-19 11:05:59 UTC (rev 10778)
+++ modules/presentation/trunk/pom.xml 2008-05-19 21:01:35 UTC (rev 10779)
@@ -30,6 +30,7 @@
<module>presentation</module>
<module>portlet</module>
<module>classic</module>
+ <!--<module>ajax2</module>-->
<!--<module>ajax</module>-->
</modules>
</project>
Deleted:
modules/presentation/trunk/portlet/src/main/java/org/jboss/portal/presentation/portlet/controller/StructuralEventControllerContext.java
===================================================================
---
modules/presentation/trunk/portlet/src/main/java/org/jboss/portal/presentation/portlet/controller/StructuralEventControllerContext.java 2008-05-19
11:05:59 UTC (rev 10778)
+++
modules/presentation/trunk/portlet/src/main/java/org/jboss/portal/presentation/portlet/controller/StructuralEventControllerContext.java 2008-05-19
21:01:35 UTC (rev 10779)
@@ -1,70 +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.portlet.controller;
-
-import org.jboss.portal.portlet.controller.event.EventControllerContext;
-import org.jboss.portal.portlet.controller.event.EventPhaseContext;
-import org.jboss.portal.portlet.controller.event.PortletWindowEvent;
-import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
-import org.jboss.portal.portlet.info.PortletInfo;
-
-/**
- * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
- * @version $Revision: 630 $
- */
-public class StructuralEventControllerContext implements EventControllerContext
-{
-
- /** . */
- private final StructuralPortletControllerContext portletControllerContext;
-
- public StructuralEventControllerContext(StructuralPortletControllerContext
portletControllerContext)
- {
- this.portletControllerContext = portletControllerContext;
- }
-
- public void eventProduced(EventPhaseContext context, PortletWindowEvent producedEvent,
PortletWindowEvent sourceEvent)
- {
- for (String windowId : portletControllerContext.getWindowIds())
- {
- PortletInfo portletInfo = portletControllerContext.getPortletInfo(windowId);
- if
(portletInfo.getEventing().getConsumedEvents().containsKey(producedEvent.getName()))
- {
- PortletWindowEvent distributedEvent = new
PortletWindowEvent(producedEvent.getName(), producedEvent.getPayload(), windowId);
- context.queueEvent(distributedEvent);
- }
- }
- }
-
- public void eventConsumed(EventPhaseContext context, PortletWindowEvent consumedEvent,
PortletInvocationResponse consumerResponse)
- {
- }
-
- public void eventFailed(EventPhaseContext context, PortletWindowEvent failedEvent,
Throwable throwable)
- {
- }
-
- public void eventDiscarded(EventPhaseContext context, PortletWindowEvent
discardedEvent, int cause)
- {
- }
-}
Deleted:
modules/presentation/trunk/portlet/src/main/java/org/jboss/portal/presentation/portlet/controller/StructuralPortletControllerContext.java
===================================================================
---
modules/presentation/trunk/portlet/src/main/java/org/jboss/portal/presentation/portlet/controller/StructuralPortletControllerContext.java 2008-05-19
11:05:59 UTC (rev 10778)
+++
modules/presentation/trunk/portlet/src/main/java/org/jboss/portal/presentation/portlet/controller/StructuralPortletControllerContext.java 2008-05-19
21:01:35 UTC (rev 10779)
@@ -1,208 +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.portlet.controller;
-
-import org.jboss.portal.portlet.PortletInvoker;
-import org.jboss.portal.portlet.PortletInvokerException;
-import org.jboss.portal.portlet.PortletContext;
-import org.jboss.portal.portlet.Portlet;
-import org.jboss.portal.portlet.impl.spi.AbstractUserContext;
-import org.jboss.portal.portlet.controller.PortletControllerContext;
-import org.jboss.portal.portlet.controller.event.EventControllerContext;
-import org.jboss.portal.portlet.controller.state.StateControllerContext;
-import org.jboss.portal.portlet.controller.state.PortletPageNavigationalState;
-import org.jboss.portal.portlet.info.PortletInfo;
-import org.jboss.portal.portlet.invocation.ActionInvocation;
-import org.jboss.portal.portlet.invocation.EventInvocation;
-import org.jboss.portal.portlet.invocation.ResourceInvocation;
-import org.jboss.portal.portlet.invocation.RenderInvocation;
-import org.jboss.portal.portlet.invocation.PortletInvocation;
-import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
-import org.jboss.portal.portlet.spi.PortletInvocationContext;
-import org.jboss.portal.presentation.portlet.spi.PresentationPortletInvocationContext;
-import org.jboss.portal.presentation.portlet.spi.PresentationServerContext;
-import org.jboss.portal.presentation.portlet.spi.PresentationWindowContext;
-import org.jboss.portal.presentation.portlet.spi.PresentationInstanceContext;
-import org.jboss.portal.presentation.portlet.spi.PresentationClientContext;
-import org.jboss.portal.presentation.portlet.spi.PresentationPortalContext;
-import org.jboss.portal.presentation.portlet.spi.PresentationSecurityContext;
-import org.jboss.portal.presentation.client.PresentationClient;
-import org.jboss.portal.presentation.model.tree.UINode;
-import org.jboss.portal.presentation.model.ui.UIObject;
-import org.jboss.portal.presentation.model.ui.UIWindow;
-import org.jboss.portal.presentation.state.StateType;
-
-import javax.servlet.http.Cookie;
-import java.util.List;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.Set;
-
-/**
- * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
- * @version $Revision: 630 $
- */
-public class StructuralPortletControllerContext implements PortletControllerContext
-{
-
- /** . */
- private final UINode pageNode;
-
- /** . */
- private final PortletInvoker invoker;
-
- /** . */
- private final StateControllerContext stateControllerContext;
-
- /** A map of window ids to portlets. */
- private final Map<String, Portlet> portlets;
-
- /** A map of window ids to windows. */
- private final Map<String, UINode> windows;
-
- /** . */
- private final PresentationClient client;
-
- /** . */
- private final EventControllerContext eventControllerContext;
-
- public StructuralPortletControllerContext(
- PresentationClient client,
- UINode pageNode,
- PortletInvoker invoker)
- {
- Map<String, Portlet> portlets = new HashMap<String, Portlet>();
- Map<String, UINode> windows = new HashMap<String, UINode>();
-
- //
- for (UINode childNode : pageNode.getChildren())
- {
- UIObject child = childNode.getObject();
-
- if (child instanceof UIWindow)
- {
- String portletRef = child.getProperty(StateType.STRUCTURAL,
"portlet-ref", String.class);
-
- //
- if (portletRef != null)
- {
- try
- {
- Portlet portlet =
invoker.getPortlet(PortletContext.createPortletContext(portletRef));
-
- //
- portlets.put(child.getId(), portlet);
- windows.put(child.getId(), childNode);
- }
- catch (PortletInvokerException e)
- {
- e.printStackTrace();
- }
- }
- }
- }
-
- //
- this.client = client;
- this.pageNode = pageNode;
- this.invoker = invoker;
- this.stateControllerContext = new StructuralStateControllerContext(this);
- this.portlets = portlets;
- this.windows = windows;
- this.eventControllerContext = new StructuralEventControllerContext(this);
- }
-
- public String getPageId()
- {
- return pageNode.getObject().getId();
- }
-
- public Set<String> getWindowIds()
- {
- return windows.keySet();
- }
-
- public PortletInfo getPortletInfo(String windowId)
- {
- return portlets.get(windowId).getInfo();
- }
-
- public PortletInvocationContext createPortletInvocationContext(String windowId,
PortletPageNavigationalState pageNavigationalState)
- {
- return new PresentationPortletInvocationContext(client, this, windowId);
- }
-
- public PortletInvocationResponse invoke(ActionInvocation actionInvocation) throws
PortletInvokerException
- {
- return invoke((PortletInvocation)actionInvocation);
- }
-
- public PortletInvocationResponse invoke(List<Cookie> requestCookies,
EventInvocation eventInvocation) throws PortletInvokerException
- {
- return invoke(eventInvocation);
- }
-
- public PortletInvocationResponse invoke(List<Cookie> requestCookies,
RenderInvocation renderInvocation) throws PortletInvokerException
- {
- return invoke(renderInvocation);
- }
-
- public PortletInvocationResponse invoke(ResourceInvocation resourceInvocation) throws
PortletInvokerException
- {
- return invoke((PortletInvocation)resourceInvocation);
- }
-
- private PortletInvocationResponse invoke(PortletInvocation portletInvocation) throws
PortletInvokerException
- {
- PresentationPortletInvocationContext ctx =
(PresentationPortletInvocationContext)portletInvocation.getContext();
-
- //
- UINode window = windows.get(ctx.getWindowId());
-
- //
- portletInvocation.setServerContext(new PresentationServerContext(client));
- portletInvocation.setSecurityContext(new PresentationSecurityContext());
- portletInvocation.setClientContext(new PresentationClientContext());
- portletInvocation.setInstanceContext(new PresentationInstanceContext(window));
- portletInvocation.setPortalContext(new PresentationPortalContext());
- portletInvocation.setUserContext(new AbstractUserContext());
- portletInvocation.setWindowContext(new PresentationWindowContext(window));
-
- //
- Portlet portlet = portlets.get(ctx.getWindowId());
- portletInvocation.setTarget(portlet.getContext());
-
- //
- return invoker.invoke(portletInvocation);
- }
-
- public EventControllerContext getEventControllerContext()
- {
- return eventControllerContext;
- }
-
- public StateControllerContext getStateControllerContext()
- {
- return stateControllerContext;
- }
-}
Deleted:
modules/presentation/trunk/portlet/src/main/java/org/jboss/portal/presentation/portlet/controller/StructuralPortletPageNavigationalState.java
===================================================================
---
modules/presentation/trunk/portlet/src/main/java/org/jboss/portal/presentation/portlet/controller/StructuralPortletPageNavigationalState.java 2008-05-19
11:05:59 UTC (rev 10778)
+++
modules/presentation/trunk/portlet/src/main/java/org/jboss/portal/presentation/portlet/controller/StructuralPortletPageNavigationalState.java 2008-05-19
21:01:35 UTC (rev 10779)
@@ -1,290 +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.portlet.controller;
-
-import org.jboss.portal.portlet.controller.state.PortletPageNavigationalState;
-import org.jboss.portal.portlet.controller.state.PortletWindowNavigationalState;
-import org.jboss.portal.portlet.StateString;
-import org.jboss.portal.portlet.info.ParameterInfo;
-import org.jboss.portal.portlet.info.NavigationInfo;
-import org.jboss.portal.presentation.state.navigational.NavigationalStateContext;
-import
org.jboss.portal.presentation.impl.state.navigational.DelegatingNavigationalStateContext;
-import org.jboss.portal.Mode;
-import org.jboss.portal.WindowState;
-
-import javax.xml.namespace.QName;
-import java.util.Set;
-import java.util.Map;
-import java.util.HashMap;
-
-/**
- * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
- * @version $Revision: 630 $
- */
-public class StructuralPortletPageNavigationalState implements
PortletPageNavigationalState
-{
-
- /** . */
- public static final int READ_ONLY_MODE = 0;
-
- /** . */
- public static final int READ_WRITE_MODE = 1;
-
- /** . */
- public static final int CLONE_AND_WRITE_MODE = 2;
-
- /** . */
- private final StructuralPortletControllerContext portletControllerContext;
-
- /** . */
- private final NavigationalStateContext navigationalStateContext;
-
- /** . */
- private final boolean modifiable;
-
- public StructuralPortletPageNavigationalState(
- StructuralPortletControllerContext portletControllerContext,
- NavigationalStateContext navigationalStateContext,
- int mode)
- {
- boolean modifiable;
- switch (mode)
- {
- case READ_ONLY_MODE:
- modifiable = false;
- break;
- case READ_WRITE_MODE:
- modifiable = true;
- break;
- case CLONE_AND_WRITE_MODE:
- modifiable = true;
- navigationalStateContext = new
DelegatingNavigationalStateContext(navigationalStateContext);
- break;
- default:
- throw new AssertionError();
- }
-
- //
- this.portletControllerContext = portletControllerContext;
- this.navigationalStateContext = navigationalStateContext;
- this.modifiable = modifiable;
- }
-
- public StructuralPortletPageNavigationalState(
- StructuralPortletPageNavigationalState pageNavigationalState,
- int mode)
- {
- NavigationalStateContext navigationalStateContext =
pageNavigationalState.navigationalStateContext;
- boolean modifiable;
- switch (mode)
- {
- case READ_ONLY_MODE:
- modifiable = false;
- break;
- case READ_WRITE_MODE:
- modifiable = true;
- break;
- case CLONE_AND_WRITE_MODE:
- modifiable = true;
- navigationalStateContext = new
DelegatingNavigationalStateContext(navigationalStateContext);
- break;
- default:
- throw new AssertionError();
- }
-
- //
- this.portletControllerContext = pageNavigationalState.portletControllerContext;
- this.navigationalStateContext = navigationalStateContext;
- this.modifiable = modifiable;
- }
-
- public void flush()
- {
- if (navigationalStateContext instanceof DelegatingNavigationalStateContext)
- {
- ((DelegatingNavigationalStateContext)navigationalStateContext).flush(true);
- }
- }
-
- public Set<String> getPortletWindowIds()
- {
- return portletControllerContext.getWindowIds();
- }
-
- public PortletWindowNavigationalState getPortletWindowNavigationalState(String
portletWindowId) throws IllegalArgumentException
- {
- Mode mode = (Mode)navigationalStateContext.getProperty(portletWindowId,
"mode");
- WindowState windowState =
(WindowState)navigationalStateContext.getProperty(portletWindowId,
"windowstate");
- StateString portletNavigationalState =
(StateString)navigationalStateContext.getProperty(portletWindowId, "portlet");
- return new PortletWindowNavigationalState(portletNavigationalState, mode,
windowState);
- }
-
- public void setPortletWindowNavigationalState(String portletWindowId,
PortletWindowNavigationalState portletWindowState) throws IllegalArgumentException,
IllegalStateException
- {
- if (!modifiable)
- {
- throw new IllegalStateException();
- }
-
- //
- navigationalStateContext.setProperty(portletWindowId, "windowstate",
portletWindowState.getWindowState());
- navigationalStateContext.setProperty(portletWindowId, "mode",
portletWindowState.getMode());
- navigationalStateContext.setProperty(portletWindowId, "portlet",
portletWindowState.getPortletNavigationalState());
- }
-
- public Map<String, String[]> getPortletPublicNavigationalState(String
portletWindowId) throws IllegalArgumentException
- {
- Map<QName, String[]> pageParameters = (Map<QName,
String[]>)navigationalStateContext.getProperty(portletControllerContext.getPageId(),
"portlet");
-
- //
- Map<String, String[]> portletParameters = null;
-
- //
- if (pageParameters != null)
- {
- NavigationInfo navigationInfo =
portletControllerContext.getPortletInfo(portletWindowId).getNavigation();
-
- //
- for (ParameterInfo parameterInfo : navigationInfo.getPublicParameters())
- {
- QName parameterName = parameterInfo.getName();
- String[] parameterValue = pageParameters.get(parameterName);
-
- //
- if (parameterValue != null)
- {
- if (portletParameters == null)
- {
- portletParameters = new HashMap<String, String[]>();
- }
-
- //
- portletParameters.put(parameterInfo.getId(), parameterValue);
- }
- }
- }
-
- //
- return portletParameters;
- }
-
- public void setPortletPublicNavigationalState(String portletWindowId, Map<String,
String[]> update) throws IllegalArgumentException, IllegalStateException
- {
- if (!modifiable)
- {
- throw new IllegalStateException();
- }
-
- //
- HashMap<QName, String[]> pageParameters = (HashMap<QName,
String[]>)navigationalStateContext.getProperty(portletControllerContext.getPageId(),
"portlet");
-
- //
- if (pageParameters == null)
- {
- pageParameters = new HashMap<QName, String[]>();
- }
-
- //
- NavigationInfo navigationInfo =
portletControllerContext.getPortletInfo(portletWindowId).getNavigation();
-
- //
- for (Map.Entry<String, String[]> entry : update.entrySet())
- {
- ParameterInfo parameterInfo =
navigationInfo.getPublicParameter(entry.getKey());
-
- //
- QName parameterName = parameterInfo.getName();
-
- if (entry.getValue().length == 0)
- {
- pageParameters.remove(parameterName);
- }
- else
- {
- pageParameters.put(parameterName, entry.getValue());
- }
- }
-
- //
- navigationalStateContext.setProperty(portletControllerContext.getPageId(),
"portlet", pageParameters);
- }
-
- public Set<QName> getPublicNames()
- {
- HashMap<QName, String[]> pageParameters = (HashMap<QName,
String[]>)navigationalStateContext.getProperty(portletControllerContext.getPageId(),
"portlet");
-
- //
- return pageParameters != null ? pageParameters.keySet() : null;
- }
-
- public String[] getPublicNavigationalState(QName name) throws
IllegalArgumentException
- {
- Map<QName, String[]> pageParameters = (Map<QName,
String[]>)navigationalStateContext.getProperty(portletControllerContext.getPageId(),
"portlet");
-
- //
- return pageParameters != null ? pageParameters.get(name) : null;
- }
-
- public void setPublicNavigationalState(QName name, String[] value) throws
IllegalArgumentException, IllegalStateException
- {
- if (!modifiable)
- {
- throw new IllegalStateException();
- }
-
- //
- HashMap<QName, String[]> pageParameters = (HashMap<QName,
String[]>)navigationalStateContext.getProperty(portletControllerContext.getPageId(),
"portlet");
-
- //
- if (pageParameters == null)
- {
- pageParameters = new HashMap<QName, String[]>();
- }
-
- //
- pageParameters.put(name, value);
-
- //
- navigationalStateContext.setProperty(portletControllerContext.getPageId(),
"portlet", pageParameters);
- }
-
- public void removePublicNavigationalState(QName name) throws IllegalArgumentException,
IllegalStateException
- {
- if (!modifiable)
- {
- throw new IllegalStateException();
- }
-
- //
- HashMap<QName, String[]> pageParameters = (HashMap<QName,
String[]>)navigationalStateContext.getProperty(portletControllerContext.getPageId(),
"portlet");
-
- //
- if (pageParameters != null)
- {
- pageParameters.remove(name);
-
- //
- navigationalStateContext.setProperty(portletControllerContext.getPageId(),
"portlet", pageParameters);
- }
- }
-}
Deleted:
modules/presentation/trunk/portlet/src/main/java/org/jboss/portal/presentation/portlet/controller/StructuralStateControllerContext.java
===================================================================
---
modules/presentation/trunk/portlet/src/main/java/org/jboss/portal/presentation/portlet/controller/StructuralStateControllerContext.java 2008-05-19
11:05:59 UTC (rev 10778)
+++
modules/presentation/trunk/portlet/src/main/java/org/jboss/portal/presentation/portlet/controller/StructuralStateControllerContext.java 2008-05-19
21:01:35 UTC (rev 10779)
@@ -1,59 +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.portlet.controller;
-
-import org.jboss.portal.portlet.controller.state.StateControllerContext;
-import org.jboss.portal.portlet.controller.state.PortletPageNavigationalState;
-import
org.jboss.portal.presentation.impl.state.navigational.NavigationalStateContextImpl;
-
-/**
- * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
- * @version $Revision: 630 $
- */
-public class StructuralStateControllerContext implements StateControllerContext
-{
-
- /** . */
- private StructuralPortletControllerContext portletControllerContext;
-
- public StructuralStateControllerContext(StructuralPortletControllerContext
portletControllerContext)
- {
- this.portletControllerContext = portletControllerContext;
- }
-
- public PortletPageNavigationalState
clonePortletPageNavigationalState(PortletPageNavigationalState
portletPageNavigationalState, boolean modifiable)
- {
-
- return new StructuralPortletPageNavigationalState(
- (StructuralPortletPageNavigationalState)portletPageNavigationalState,
- modifiable ? StructuralPortletPageNavigationalState.CLONE_AND_WRITE_MODE :
StructuralPortletPageNavigationalState.READ_ONLY_MODE);
- }
-
- public PortletPageNavigationalState createPortletPageNavigationalState(boolean
modifiable)
- {
- return new StructuralPortletPageNavigationalState(
- portletControllerContext,
- new NavigationalStateContextImpl(),
- modifiable ? StructuralPortletPageNavigationalState.READ_WRITE_MODE :
StructuralPortletPageNavigationalState.READ_ONLY_MODE);
- }
-}
Deleted:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model/UIObject.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model/UIObject.java 2008-05-19
11:05:59 UTC (rev 10778)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model/UIObject.java 2008-05-19
21:01:35 UTC (rev 10779)
@@ -1,73 +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.model;
-
-import org.jboss.portal.presentation.state.StateException;
-import org.jboss.portal.presentation.state.StateType;
-
-import java.util.Set;
-
-/**
- * A wrapper of a structural object. The main goal of this object is to let the viewport
add custom payload
- * in addition of the structural state.
- *
- * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
- * @version $Revision: 630 $
- */
-public interface UIObject
-{
-
- /**
- * Returns the id.
- *
- * @return the id
- */
- String getId();
-
- /**
- * Returns the name.
- *
- * @return the name
- */
- String getName();
-
- /**
- * Returns a property value or null if it does not exist.
- *
- * @param stateType the state type
- * @param propertyName the property name
- * @param propertyType the expected property type @return the property value @return
the property value
- * @return the property value
- * @throws IllegalArgumentException if any argument is null or not valid
- * @throws StateException any state exception
- */
- <T> T getProperty(StateType stateType, String propertyName, Class<T>
propertyType) throws IllegalArgumentException, StateException;
-
- /**
- * Returns the set of property names of this object
- *
- * @param stateType the state type
- * @return the property names
- */
- Set<String> getPropertyNames(StateType stateType);
-}
Modified:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model/ui/UIAction.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model/ui/UIAction.java 2008-05-19
11:05:59 UTC (rev 10778)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model/ui/UIAction.java 2008-05-19
21:01:35 UTC (rev 10779)
@@ -22,9 +22,6 @@
******************************************************************************/
package org.jboss.portal.presentation.model.ui;
-import org.jboss.portal.presentation.model.ui.UIObject;
-
-
/**
* An action that can be triggered.
*
Modified:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model/ui/UIContainer.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model/ui/UIContainer.java 2008-05-19
11:05:59 UTC (rev 10778)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model/ui/UIContainer.java 2008-05-19
21:01:35 UTC (rev 10779)
@@ -22,8 +22,6 @@
******************************************************************************/
package org.jboss.portal.presentation.model.ui;
-import org.jboss.portal.presentation.model.ui.UIObject;
-
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
Modified:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model/ui/UIContext.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model/ui/UIContext.java 2008-05-19
11:05:59 UTC (rev 10778)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model/ui/UIContext.java 2008-05-19
21:01:35 UTC (rev 10779)
@@ -22,8 +22,6 @@
******************************************************************************/
package org.jboss.portal.presentation.model.ui;
-import org.jboss.portal.presentation.model.ui.UIObject;
-
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
Modified:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model/ui/UIPage.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model/ui/UIPage.java 2008-05-19
11:05:59 UTC (rev 10778)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model/ui/UIPage.java 2008-05-19
21:01:35 UTC (rev 10779)
@@ -22,8 +22,6 @@
******************************************************************************/
package org.jboss.portal.presentation.model.ui;
-import org.jboss.portal.presentation.model.ui.UIObject;
-
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
Modified:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model/ui/UIWindow.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model/ui/UIWindow.java 2008-05-19
11:05:59 UTC (rev 10778)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model/ui/UIWindow.java 2008-05-19
21:01:35 UTC (rev 10779)
@@ -24,7 +24,6 @@
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
-import org.jboss.portal.presentation.model.ui.UIObject;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
Added:
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
(rev 0)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/view/DefaultPageViewPortScope.java 2008-05-19
21:01:35 UTC (rev 10779)
@@ -0,0 +1,136 @@
+/******************************************************************************
+ * 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.view;
+
+import org.jboss.portal.presentation.model.ObjectTraversalType;
+import org.jboss.portal.presentation.model.ui.UIObject;
+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;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
+ * @version $Revision: 630 $
+ */
+public class DefaultPageViewPortScope implements ViewPortScope
+{
+
+ /** . */
+ 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()
+ {
+ return rootId;
+ }
+
+ public ObjectTraversalType enterObject(UIObject object)
+ {
+ if (object instanceof UIPage)
+ {
+ 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();
+ }
+ }
+ 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;
+ }
+ }
+
+ 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;
+ }
+ }
+ }
+}
Added:
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
(rev 0)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/view/PageViewPortScope.java 2008-05-19
21:01:35 UTC (rev 10779)
@@ -0,0 +1,136 @@
+/******************************************************************************
+ * 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.view;
+
+import org.jboss.portal.presentation.model.ObjectTraversalType;
+import org.jboss.portal.presentation.model.ui.UIObject;
+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;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
+ * @version $Revision: 630 $
+ */
+public class PageViewPortScope implements ViewPortScope
+{
+
+ /** . */
+ private static final int NO_PAGE = 0;
+
+ /** . */
+ private static final int PAGE = 1;
+
+ /** . */
+ private static final int PAGE_CHILD = 2;
+
+ /** . */
+ private static final int PAGE_SIBLING = 3;
+
+ /** . */
+ private final String pageId;
+
+ /** . */
+ private int pageStatus;
+
+ public PageViewPortScope(String pageId)
+ {
+ this.pageId = pageId;
+ this.pageStatus = 0;
+ }
+
+ public String getRootId()
+ {
+ return pageId;
+ }
+
+ public ObjectTraversalType enterObject(UIObject object)
+ {
+ if (object instanceof UIPage)
+ {
+ switch (pageStatus)
+ {
+ case NO_PAGE:
+ if (pageId.equals(object.getId()))
+ {
+ pageStatus = PAGE;
+
+ // We want to traverse the children of the default page
+ return ObjectTraversalType.RECURSIVE;
+ }
+ else
+ {
+ pageStatus = PAGE_SIBLING;
+
+ // We want to see the sibbling pages of the default page
+ return ObjectTraversalType.SINGLE;
+ }
+ case PAGE:
+ pageStatus = PAGE_CHILD;
+
+ // We want to see the children pages of the default page
+ return ObjectTraversalType.SINGLE;
+ case PAGE_CHILD:
+ case PAGE_SIBLING:
+ return ObjectTraversalType.SKIP;
+ default:
+ throw new AssertionError();
+ }
+ }
+ 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;
+ }
+ }
+
+ public void leaveObject(UIObject object)
+ {
+ if (object instanceof UIPage)
+ {
+ switch (pageStatus)
+ {
+ case NO_PAGE:
+ throw new AssertionError();
+ case PAGE:
+ pageStatus = NO_PAGE;
+ break;
+ case PAGE_SIBLING:
+ pageStatus = NO_PAGE;
+ break;
+ case PAGE_CHILD:
+ pageStatus = PAGE;
+ break;
+ }
+ }
+ }
+}
\ No newline at end of file