Author: julien(a)jboss.com
Date: 2008-07-07 12:37:56 -0400 (Mon, 07 Jul 2008)
New Revision: 11321
Modified:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/DiffPhase.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/InternalObjectContext.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ObjectDiff.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/pull/UINodeImpl.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ui/UIContextImpl.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ui/UILayoutImpl.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ui/UIObjectContext.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ui/UIObjectImpl.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ui/UIPageImpl.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ui/UIPaneImpl.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ui/UIWindowImpl.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model/ViewPortScope.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/view/PageViewPortScope.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/CustomScope.java
Log:
use StructuralObject in the ViewPortScope interface instead of UIObject
Modified:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/DiffPhase.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/DiffPhase.java 2008-07-07
16:15:04 UTC (rev 11320)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/DiffPhase.java 2008-07-07
16:37:56 UTC (rev 11321)
@@ -143,7 +143,7 @@
private ObjectDiff diff(UIObjectImpl object)
{
- ObjectTraversalType traversalType = scope.enterObject(object);
+ ObjectTraversalType traversalType =
scope.enterObject(object.getContext().getStructuralObject());
//
try
@@ -233,16 +233,16 @@
}
finally
{
- scope.leaveObject(object);
+ scope.leaveObject(object.getContext().getStructuralObject());
}
}
private ObjectDiff load(StructuralObject structuralObject)
{
- UIObjectImpl object = UIObjectImpl.create(structuralObject, new
InternalObjectContext(navigationalStateContext));
+ UIObjectImpl object = UIObjectImpl.create(new
InternalObjectContext(navigationalStateContext, structuralObject));
//
- ObjectTraversalType traversalType = scope.enterObject(object);
+ ObjectTraversalType traversalType = scope.enterObject(structuralObject);
//
try
@@ -270,7 +270,7 @@
}
finally
{
- scope.leaveObject(object);
+ scope.leaveObject(structuralObject);
}
}
}
Modified:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/InternalObjectContext.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/InternalObjectContext.java 2008-07-07
16:15:04 UTC (rev 11320)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/InternalObjectContext.java 2008-07-07
16:37:56 UTC (rev 11321)
@@ -24,6 +24,7 @@
import org.jboss.portal.presentation.impl.model.ui.UIObjectContext;
import org.jboss.portal.presentation.state.navigational.NavigationalStateContext;
+import org.jboss.portal.presentation.state.structural.StructuralObject;
import java.util.Map;
@@ -39,11 +40,19 @@
final NavigationalStateContext navigationalStateContext;
- InternalObjectContext(NavigationalStateContext navigationalStateContext)
+ final StructuralObject structuralObject;
+
+ InternalObjectContext(NavigationalStateContext navigationalStateContext,
StructuralObject structuralObject)
{
this.navigationalStateContext = navigationalStateContext;
+ this.structuralObject = structuralObject;
}
+ public StructuralObject getStructuralObject()
+ {
+ return structuralObject;
+ }
+
public NavigationalStateContext getNavigationalStateContext()
{
return navigationalStateContext;
Modified:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ObjectDiff.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ObjectDiff.java 2008-07-07
16:15:04 UTC (rev 11320)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ObjectDiff.java 2008-07-07
16:37:56 UTC (rev 11321)
@@ -67,7 +67,7 @@
}
static RecursiveUpdate createRecursiveUpdate(
- UIObjectImpl object,
+ UIObjectImpl object,
Set<String> removedProperties,
Map<String, Serializable> updatedProperties,
Map<String, Serializable> addedProperties,
Modified:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/pull/UINodeImpl.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/pull/UINodeImpl.java 2008-07-07
16:15:04 UTC (rev 11320)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/pull/UINodeImpl.java 2008-07-07
16:37:56 UTC (rev 11321)
@@ -79,11 +79,16 @@
this.parentVisited = true;
}
+ public StructuralObject getStructuralObject()
+ {
+ return structuralObject;
+ }
+
public UIObject getObject()
{
if (object == null)
{
- object = UIObjectImpl.create(structuralObject, this);
+ object = UIObjectImpl.create(this);
}
//
Modified:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ui/UIContextImpl.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ui/UIContextImpl.java 2008-07-07
16:15:04 UTC (rev 11320)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ui/UIContextImpl.java 2008-07-07
16:37:56 UTC (rev 11321)
@@ -31,10 +31,8 @@
*/
public class UIContextImpl extends UILayoutImpl implements UIContext
{
- public UIContextImpl(
- StructuralObject structuralObject,
- UIObjectContext context)
+ public UIContextImpl(UIObjectContext context)
{
- super(structuralObject, context);
+ super(context);
}
}
\ No newline at end of file
Modified:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ui/UILayoutImpl.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ui/UILayoutImpl.java 2008-07-07
16:15:04 UTC (rev 11320)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ui/UILayoutImpl.java 2008-07-07
16:37:56 UTC (rev 11321)
@@ -32,8 +32,8 @@
public abstract class UILayoutImpl extends UIObjectImpl implements UILayout
{
- public UILayoutImpl(StructuralObject structuralObject, UIObjectContext context)
+ public UILayoutImpl(UIObjectContext context)
{
- super(structuralObject, context);
+ super(context);
}
}
Modified:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ui/UIObjectContext.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ui/UIObjectContext.java 2008-07-07
16:15:04 UTC (rev 11320)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ui/UIObjectContext.java 2008-07-07
16:37:56 UTC (rev 11321)
@@ -23,6 +23,7 @@
package org.jboss.portal.presentation.impl.model.ui;
import org.jboss.portal.presentation.state.navigational.NavigationalStateContext;
+import org.jboss.portal.presentation.state.structural.StructuralObject;
/**
* Just some context data for a uiobject that can be used by different concerns.
@@ -35,4 +36,5 @@
NavigationalStateContext getNavigationalStateContext();
+ StructuralObject getStructuralObject();
}
Modified:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ui/UIObjectImpl.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ui/UIObjectImpl.java 2008-07-07
16:15:04 UTC (rev 11320)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ui/UIObjectImpl.java 2008-07-07
16:37:56 UTC (rev 11321)
@@ -45,34 +45,32 @@
/** . */
private final UIObjectContext context;
- /** . */
- private StructuralObject structuralObject;
-
- public static UIObjectImpl create(
- StructuralObject structuralObject,
- UIObjectContext objectContext)
+ public static UIObjectImpl create(UIObjectContext objectContext)
{
UIObjectImpl object;
//
+ StructuralObject structuralObject = objectContext.getStructuralObject();
+
+ //
Class type = structuralObject.getState().getType();
//
if (type == UIWindow.class)
{
- object = new UIWindowImpl(structuralObject, objectContext);
+ object = new UIWindowImpl(objectContext);
}
else if (type == UIPage.class)
{
- object = new UIPageImpl(structuralObject, objectContext);
+ object = new UIPageImpl(objectContext);
}
else if (type == UIPane.class)
{
- object = new UIPaneImpl(structuralObject, objectContext);
+ object = new UIPaneImpl(objectContext);
}
else if (type == UIContext.class)
{
- object = new UIContextImpl(structuralObject, objectContext);
+ object = new UIContextImpl(objectContext);
}
else
{
@@ -84,16 +82,14 @@
}
public UIObjectImpl(
- StructuralObject structuralObject,
UIObjectContext context)
{
- this.structuralObject = structuralObject;
this.context = context;
}
public String getId()
{
- return structuralObject.getId();
+ return context.getStructuralObject().getId();
}
public <T> T getPropertyValue(StateType stateType, String propertyName,
Class<T> propertyType) throws IllegalArgumentException, StateException
@@ -115,7 +111,7 @@
switch (stateType)
{
case STRUCTURAL:
- return
Reflection.safeCast(structuralObject.getState().getProperties().get(propertyName),
propertyType);
+ return
Reflection.safeCast(context.getStructuralObject().getState().getProperties().get(propertyName),
propertyType);
case NAVIGATIONAL:
return
Reflection.safeCast(context.getNavigationalStateContext().getProperty(getStructuralObject().getId(),
propertyName), propertyType);
default:
@@ -134,9 +130,9 @@
switch (stateType)
{
case STRUCTURAL:
- return structuralObject.getState().getProperties().keySet();
+ return context.getStructuralObject().getState().getProperties().keySet();
case NAVIGATIONAL:
- return
context.getNavigationalStateContext().getPropertyNames(structuralObject.getId());
+ return
context.getNavigationalStateContext().getPropertyNames(context.getStructuralObject().getId());
default:
throw new AssertionError();
}
@@ -144,22 +140,9 @@
public StructuralObject getStructuralObject()
{
- return structuralObject;
+ return context.getStructuralObject();
}
- public void setStructuralObject(StructuralObject structuralObject)
- {
- if
(!structuralObject.getState().getType().equals(this.structuralObject.getState().getType()))
- {
- // It means that actually we should not update the state but rather recreate the
node in the
- // view port, we need to think about what to do when this happens
- throw new NotYetImplemented();
- }
-
- //
- this.structuralObject = structuralObject;
- }
-
public UIObjectContext getContext()
{
return context;
Modified:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ui/UIPageImpl.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ui/UIPageImpl.java 2008-07-07
16:15:04 UTC (rev 11320)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ui/UIPageImpl.java 2008-07-07
16:37:56 UTC (rev 11321)
@@ -31,10 +31,8 @@
*/
public class UIPageImpl extends UILayoutImpl implements UIPage
{
- public UIPageImpl(
- StructuralObject structuralObject,
- UIObjectContext context)
+ public UIPageImpl(UIObjectContext context)
{
- super(structuralObject, context);
+ super(context);
}
}
Modified:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ui/UIPaneImpl.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ui/UIPaneImpl.java 2008-07-07
16:15:04 UTC (rev 11320)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ui/UIPaneImpl.java 2008-07-07
16:37:56 UTC (rev 11321)
@@ -30,8 +30,8 @@
*/
public class UIPaneImpl extends UILayoutImpl
{
- public UIPaneImpl(StructuralObject structuralObject, UIObjectContext context)
+ public UIPaneImpl(UIObjectContext context)
{
- super(structuralObject, context);
+ super(context);
}
}
Modified:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ui/UIWindowImpl.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ui/UIWindowImpl.java 2008-07-07
16:15:04 UTC (rev 11320)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ui/UIWindowImpl.java 2008-07-07
16:37:56 UTC (rev 11321)
@@ -35,11 +35,9 @@
public class UIWindowImpl extends UIObjectImpl implements UIWindow
{
- public UIWindowImpl(
- StructuralObject structuralObject,
- UIObjectContext context)
+ public UIWindowImpl(UIObjectContext context)
{
- super(structuralObject, context);
+ super(context);
}
public WindowState getWindowState()
Modified:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model/ViewPortScope.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model/ViewPortScope.java 2008-07-07
16:15:04 UTC (rev 11320)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model/ViewPortScope.java 2008-07-07
16:37:56 UTC (rev 11321)
@@ -23,6 +23,7 @@
package org.jboss.portal.presentation.model;
import org.jboss.portal.presentation.model.ui.UIObject;
+import org.jboss.portal.presentation.state.structural.StructuralObject;
/**
* Defines the scope of a viewport. This interface is separated from the viewport context
in order to
@@ -47,7 +48,7 @@
* @param object the object
* @return true if it should be visited
*/
- ObjectTraversalType enterObject(UIObject object);
+ ObjectTraversalType enterObject(StructuralObject object);
/**
* Callback to signal that an object visit is terminated. It can be used by the scope
to maintain a data
@@ -55,5 +56,5 @@
*
* @param object the object
*/
- void leaveObject(UIObject object);
+ void leaveObject(StructuralObject object);
}
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-07-07
16:15:04 UTC (rev 11320)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/view/PageViewPortScope.java 2008-07-07
16:37:56 UTC (rev 11321)
@@ -28,6 +28,7 @@
import org.jboss.portal.presentation.model.ui.UIPage;
import org.jboss.portal.presentation.model.ui.UIWindow;
import org.jboss.portal.presentation.model.ui.UILayout;
+import org.jboss.portal.presentation.state.structural.StructuralObject;
/**
* A view scope that retrieves a page and its visible content.
@@ -67,11 +68,14 @@
return pageId;
}
- public ObjectTraversalType enterObject(UIObject object)
+ public ObjectTraversalType enterObject(StructuralObject object)
{
- if (object instanceof UILayout)
+ Class<? extends UIObject> type = object.getState().getType();
+
+ //
+ if (UILayout.class.isAssignableFrom(type))
{
- if (object instanceof UIPage)
+ if (UIPage.class.isAssignableFrom(type))
{
switch (pageStatus)
{
@@ -107,7 +111,7 @@
return ObjectTraversalType.RECURSIVE;
}
}
- else if (object instanceof UIWindow)
+ else if (UIWindow.class.isAssignableFrom(type))
{
// We don't traverse windows (for now as they are supposed to be leaves)
return ObjectTraversalType.SINGLE;
@@ -118,9 +122,9 @@
}
}
- public void leaveObject(UIObject object)
+ public void leaveObject(StructuralObject object)
{
- if (object instanceof UIPage)
+ if (UIPage.class.isAssignableFrom(object.getState().getType()))
{
switch (pageStatus)
{
Modified:
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/CustomScope.java
===================================================================
---
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/CustomScope.java 2008-07-07
16:15:04 UTC (rev 11320)
+++
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/CustomScope.java 2008-07-07
16:37:56 UTC (rev 11321)
@@ -24,10 +24,10 @@
import org.jboss.portal.presentation.model.ObjectTraversalType;
import org.jboss.portal.presentation.model.UIModel;
-import org.jboss.portal.presentation.model.ui.UIObject;
import org.jboss.portal.presentation.model.ViewPortScope;
import org.jboss.portal.presentation.test.state.mock.MockModel;
import org.jboss.portal.presentation.test.state.mock.MockObject;
+import org.jboss.portal.presentation.state.structural.StructuralObject;
/**
* @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
@@ -67,7 +67,7 @@
return model.getRootId();
}
- public ObjectTraversalType enterObject(UIObject object)
+ public ObjectTraversalType enterObject(StructuralObject object)
{
if (current == null)
{
@@ -107,7 +107,7 @@
return current.getTraversal();
}
- public void leaveObject(UIObject object)
+ public void leaveObject(StructuralObject object)
{
current = current.getParent();
}