Author: sohil.shah(a)jboss.com
Date: 2008-04-17 20:34:17 -0400 (Thu, 17 Apr 2008)
New Revision: 10629
Added:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ChildrenVisit.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/CreateDiffPhase.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/CreateUpdatePhase.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ObjectUpdate.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ObjectVisit.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/UIModelImpl.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/UIObjectImpl.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/UIObjectRef.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ViewPortImpl.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ui/
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/UIPageImpl.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ui/UIWindowImpl.java
Removed:
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/UIPageImpl.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/impl/model2/
Modified:
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/AjaxPresentationClient.java
modules/presentation/trunk/classic/src/main/java/org/jboss/portal/presentation/classic/ClassicPresentationClient.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/AbstractModelTestCase.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/TraversalModelTestCase.java
Log:
refactoring model2 package to model
Modified:
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/AjaxPresentationClient.java
===================================================================
---
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/AjaxPresentationClient.java 2008-04-18
00:31:55 UTC (rev 10628)
+++
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/AjaxPresentationClient.java 2008-04-18
00:34:17 UTC (rev 10629)
@@ -25,7 +25,7 @@
import java.io.IOException;
import java.util.Collection;
-import org.jboss.portal.presentation.impl.model2.UIModelImpl;
+import org.jboss.portal.presentation.impl.model.UIModelImpl;
import org.jboss.portal.presentation.model.UIModel;
import org.jboss.portal.presentation.model.UIObject;
import org.jboss.portal.presentation.model.ViewPort;
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-04-18
00:31:55 UTC (rev 10628)
+++
modules/presentation/trunk/classic/src/main/java/org/jboss/portal/presentation/classic/ClassicPresentationClient.java 2008-04-18
00:34:17 UTC (rev 10629)
@@ -35,7 +35,7 @@
import org.jboss.portal.presentation.server2.PresentationServerException;
import org.jboss.portal.presentation.server2.PresentationRequest;
import org.jboss.portal.presentation.server2.PresentationResponse;
-import org.jboss.portal.presentation.impl.model2.UIModelImpl;
+import org.jboss.portal.presentation.impl.model.UIModelImpl;
import org.jboss.portal.presentation.model.UIModel;
import org.jboss.portal.presentation.model.UIObject;
import org.jboss.portal.presentation.model.ViewPort;
Copied:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ChildrenVisit.java
(from rev 10627,
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/ChildrenVisit.java)
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ChildrenVisit.java
(rev 0)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ChildrenVisit.java 2008-04-18
00:34:17 UTC (rev 10629)
@@ -0,0 +1,70 @@
+/******************************************************************************
+ * 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 java.util.Collection;
+import java.util.ArrayList;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
+ * @version $Revision: 630 $
+ */
+public class ChildrenVisit
+{
+
+ /** . */
+ final Collection<ObjectVisit> addedObjects = new
ArrayList<ObjectVisit>();
+
+ /** . */
+ final Collection<ObjectVisit> validObjects = new
ArrayList<ObjectVisit>();
+
+ /** . */
+ final Collection<ObjectVisit> staleObjects = new
ArrayList<ObjectVisit>();
+
+ /** . */
+ final Collection<String> removedObjects = new ArrayList<String>();
+
+ ChildrenVisit()
+ {
+ }
+
+ public Collection<ObjectVisit> getAddedObjects()
+ {
+ return addedObjects;
+ }
+
+ public Collection<String> getRemovedObjects()
+ {
+ return removedObjects;
+ }
+
+ public Collection<ObjectVisit> getValidObjects()
+ {
+ return validObjects;
+ }
+
+ public Collection<ObjectVisit> getStaleObjects()
+ {
+ return staleObjects;
+ }
+}
Copied:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/CreateDiffPhase.java
(from rev 10628,
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/CreateDiffPhase.java)
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/CreateDiffPhase.java
(rev 0)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/CreateDiffPhase.java 2008-04-18
00:34:17 UTC (rev 10629)
@@ -0,0 +1,193 @@
+/******************************************************************************
+ * 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.ObjectTraversalType;
+import org.jboss.portal.presentation.model.ViewPortContext;
+import org.jboss.portal.presentation.model.ViewPortScope;
+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 CreateDiffPhase
+{
+
+ /** . */
+ private final ViewPortContext context;
+
+ /** . */
+ private final ViewPortScope scope;
+
+ /** . */
+ private final NavigationalStateContext navigationalStateContext;
+
+ /** . */
+ private final StructuralStateContext structuralStateContext;
+
+ /** . */
+ private ObjectVisit rootVisit;
+
+ public CreateDiffPhase(
+ ViewPortContext context,
+ ViewPortScope scope,
+ NavigationalStateContext navigationalStateContext,
+ StructuralStateContext structuralStateContext)
+ {
+ this.context = context;
+ this.scope = scope;
+ this.navigationalStateContext = navigationalStateContext;
+ this.structuralStateContext = structuralStateContext;
+ }
+
+ public void perform()
+ {
+ rootVisit = diff(scope.getRootId());
+ }
+
+ public ObjectVisit getRootVisit()
+ {
+ return rootVisit;
+ }
+
+ private ObjectVisit diff(String objectId)
+ {
+ UIObjectImpl object = (UIObjectImpl)context.getObject(objectId);
+
+ //
+ if (object == null)
+ {
+ StructuralObject structuralObject = structuralStateContext.load(objectId);
+
+ //
+ if (structuralObject == null)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ //
+ return load(structuralObject);
+ }
+ else
+ {
+ return diff(object);
+ }
+ }
+
+ private ObjectVisit diff(UIObjectImpl object)
+ {
+ ObjectTraversalType traversalType = scope.enterObject(object);
+
+ //
+ try
+ {
+ switch (traversalType)
+ {
+ case SKIP:
+ return new ObjectVisit(object, false);
+ case SINGLE:
+ return new ObjectVisit(object, true);
+ case RECURSIVE:
+ StructuralObject.Refresh refresh =
structuralStateContext.refresh(object.structuralObject);
+ ChildrenVisit childrenVisit = new ChildrenVisit();
+
+ //
+ for (StructuralObject addedStructuralChild : refresh.getAddedChildren())
+ {
+ ObjectVisit childVisit = load(addedStructuralChild);
+ childrenVisit.addedObjects.add(childVisit);
+ }
+
+ //
+ for (StructuralObject staleStructuralChild :
refresh.getStaleChildren().values())
+ {
+ ObjectVisit childVisit = diff(staleStructuralChild.getId());
+ childrenVisit.staleObjects.add(childVisit);
+ }
+
+ //
+ for (String validChildId : refresh.getValidChildren())
+ {
+ ObjectVisit childVisit = diff(validChildId);
+ childrenVisit.validObjects.add(childVisit);
+ }
+
+ //
+ childrenVisit.removedObjects.addAll(refresh.getRemovedChildren());
+
+ //
+ return new ObjectVisit(object, childrenVisit);
+ default:
+ throw new AssertionError();
+ }
+ }
+ finally
+ {
+ scope.leaveObject(object);
+ }
+ }
+
+ private ObjectVisit load(StructuralObject structuralObject)
+ {
+ UIObjectImpl object = UIObjectImpl.create(navigationalStateContext,
structuralObject);
+
+ //
+ ObjectTraversalType traversalType = scope.enterObject(object);
+
+ //
+ try
+ {
+ ObjectVisit visit;
+ switch (traversalType)
+ {
+ case SKIP:
+ visit = new ObjectVisit(object, false);
+ break;
+ case SINGLE:
+ visit = new ObjectVisit(object, true);
+ break;
+ case RECURSIVE:
+ ChildrenVisit childrenVisit = new ChildrenVisit();
+ for (StructuralObject structuralChild :
structuralStateContext.loadChildren(structuralObject))
+ {
+ ObjectVisit childVisit = load(structuralChild);
+ childrenVisit.addedObjects.add(childVisit);
+ }
+ visit = new ObjectVisit(object, childrenVisit);
+ break;
+ default:
+ throw new AssertionError();
+ }
+
+ //
+ return visit;
+ }
+ finally
+ {
+ scope.leaveObject(object);
+ }
+ }
+}
Copied:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/CreateUpdatePhase.java
(from rev 10628,
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/CreateUpdatePhase.java)
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/CreateUpdatePhase.java
(rev 0)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/CreateUpdatePhase.java 2008-04-18
00:34:17 UTC (rev 10629)
@@ -0,0 +1,300 @@
+/******************************************************************************
+ * 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.ViewPortContext;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Set;
+import java.util.HashSet;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
+ * @version $Revision: 630 $
+ */
+public class CreateUpdatePhase
+{
+
+ /** . */
+ private final ViewPortContext context;
+
+ /** . */
+ private ObjectVisit rootVisit;
+
+ /** . */
+ private ObjectUpdate rootUpdate;
+
+ /** . */
+ private Map<String, ObjectUpdate.AddChild> deferredAddChildUpdates;
+
+ /** . */
+ private Set<String> removedChildren;
+
+ public CreateUpdatePhase(ViewPortContext context, ObjectVisit rootVisit)
+ {
+ this.context = context;
+ this.rootVisit = rootVisit;
+ }
+
+ public ObjectUpdate getRootUpdate()
+ {
+ return rootUpdate;
+ }
+
+ public void perform()
+ {
+ deferredAddChildUpdates = new HashMap<String, ObjectUpdate.AddChild>();
+ removedChildren = new HashSet<String>();
+
+ //
+ rootUpdate = createUpdate(rootVisit);
+
+ //
+ if (deferredAddChildUpdates.size() > 0)
+ {
+ throw new IllegalStateException("Was expecting the deferred update to be
empty");
+ }
+ }
+
+ private ObjectUpdate createUpdate(ObjectVisit objectVisit)
+ {
+ UIObjectImpl object = (UIObjectImpl)context.getObject(objectVisit.getObjectId());
+
+ if (objectVisit.getLoaded())
+ {
+ ChildrenVisit childrenVisit = objectVisit.getChildrenVisit();
+
+ //
+ if (object != null)
+ {
+ if (object != objectVisit.getObject())
+ {
+ // The object is stale, we need to update the state maybe
+ }
+ }
+
+ //
+ if (childrenVisit != null)
+ {
+ Map<String, Boolean> childrenStatus = new HashMap<String,
Boolean>();
+ List<ObjectUpdate.AddChild> addedChildrenUpdates = new
ArrayList<ObjectUpdate.AddChild>();
+ List<ObjectUpdate.RemoveChild> removedChildrenUpdates = new
ArrayList<ObjectUpdate.RemoveChild>();
+ List<ObjectUpdate.UpdateObject> updateChildrenUpdates = new
ArrayList<ObjectUpdate.UpdateObject>();
+
+ //
+ for (ObjectVisit addedObjectVisit : childrenVisit.getAddedObjects())
+ {
+ ObjectUpdate childUpdate = createUpdate(addedObjectVisit);
+
+ //
+ if (childUpdate instanceof ObjectUpdate.AddObject)
+ {
+ addedChildrenUpdates.add(new
ObjectUpdate.AddChild(objectVisit.getObjectId(), (ObjectUpdate.AddObject)childUpdate));
+ childrenStatus.put(addedObjectVisit.getObjectId(), true);
+ }
+ else if (childUpdate == null)
+ {
+ childrenStatus.put(addedObjectVisit.getObjectId(), false);
+ }
+ else if (childUpdate instanceof ObjectUpdate.UpdateObject)
+ {
+ // This is 'the' trick becaue this is likely a 'move'
operation that we may need
+ // to handle differently as a deferred add child
+ ObjectUpdate.UpdateObject updateChildUpdate =
(ObjectUpdate.UpdateObject)childUpdate;
+
+ //
+ ObjectUpdate.AddObject addObjectUpdate = new ObjectUpdate.AddObject(
+ addedObjectVisit.getObject(),
+ updateChildUpdate.childrenStatus,
+ updateChildUpdate.addedChildrenUpdates,
+ updateChildUpdate.removedChildrenUpdates,
+ updateChildUpdate.updateChildrenUpdates);
+
+ //
+ ObjectUpdate.AddChild addChildUpdate = new
ObjectUpdate.AddChild(objectVisit.getObjectId(), addObjectUpdate);
+
+ //
+ if (removedChildren.contains(addedObjectVisit.getObjectId()))
+ {
+ addedChildrenUpdates.add(addChildUpdate);
+ }
+ else
+ {
+ deferredAddChildUpdates.put(addedObjectVisit.getObjectId(),
addChildUpdate);
+ }
+
+ //
+ childrenStatus.put(addedObjectVisit.getObjectId(), true);
+ }
+ else
+ {
+ throw new UnsupportedOperationException("Was not expecting update
of type " + childUpdate.getClass().getSimpleName());
+ }
+ }
+
+ //
+ for (String removeObjectId : childrenVisit.getRemovedObjects())
+ {
+ UIObjectImpl child = (UIObjectImpl)context.getObject(removeObjectId);
+ removedChildrenUpdates.add(new
ObjectUpdate.RemoveChild(objectVisit.getObjectId(), createRemove(child)));
+ }
+
+ List<ObjectVisit> existingObjectVisits = new
ArrayList<ObjectVisit>();
+ existingObjectVisits.addAll(childrenVisit.getValidObjects());
+ existingObjectVisits.addAll(childrenVisit.getStaleObjects());
+
+ //
+ for (ObjectVisit validObjectVisit : existingObjectVisits)
+ {
+ ObjectUpdate childUpdate = createUpdate(validObjectVisit);
+
+ //
+ if (childUpdate == null)
+ {
+ childrenStatus.put(validObjectVisit.getObjectId(), false);
+ }
+ else if (childUpdate instanceof ObjectUpdate.UpdateObject)
+ {
+ updateChildrenUpdates.add((ObjectUpdate.UpdateObject)childUpdate);
+ childrenStatus.put(validObjectVisit.getObjectId(), true);
+ }
+ else if (childUpdate instanceof ObjectUpdate.RemoveObject)
+ {
+ removedChildrenUpdates.add(new
ObjectUpdate.RemoveChild(objectVisit.getObjectId(),
(ObjectUpdate.RemoveObject)childUpdate));
+ childrenStatus.put(validObjectVisit.getObjectId(), false);
+ }
+ else if (childUpdate instanceof ObjectUpdate.AddObject)
+ {
+ addedChildrenUpdates.add(new
ObjectUpdate.AddChild(objectVisit.getObjectId(), (ObjectUpdate.AddObject)childUpdate));
+ childrenStatus.put(validObjectVisit.getObjectId(), true);
+ }
+ else
+ {
+ throw new UnsupportedOperationException("Was not expecting update
of type " + childUpdate.getClass().getSimpleName());
+ }
+ }
+
+ //
+ for (ObjectUpdate.RemoveChild removeChildUpdate : removedChildrenUpdates)
+ {
+ removedChildren.add(removeChildUpdate.removedObjectUpdate.objectId);
+ }
+
+ //
+ if (object != null)
+ {
+ return new ObjectUpdate.UpdateObject(
+ object.structuralObject,
+ childrenStatus,
+ addedChildrenUpdates,
+ removedChildrenUpdates,
+ updateChildrenUpdates);
+ }
+ else
+ {
+ return new ObjectUpdate.AddObject(
+ objectVisit.getObject(),
+ childrenStatus,
+ addedChildrenUpdates,
+ removedChildrenUpdates,
+ updateChildrenUpdates);
+ }
+ }
+ else
+ {
+ if (object != null)
+ {
+ List<ObjectUpdate.RemoveChild> removedChildrenUpdates = new
ArrayList<ObjectUpdate.RemoveChild>();
+
+ //
+ if (object.childRefs != null)
+ {
+ for (UIObjectRef removedChildRef : object.childRefs.values())
+ {
+ if (removedChildRef.loaded)
+ {
+ UIObjectImpl child =
(UIObjectImpl)context.getObject(removedChildRef.getId());
+
+ //
+ removedChildrenUpdates.add(new
ObjectUpdate.RemoveChild(objectVisit.getObjectId(), createRemove(child)));
+ }
+ }
+ }
+
+ //
+ for (ObjectUpdate.RemoveChild removeChildUpdate : removedChildrenUpdates)
+ {
+ removedChildren.add(removeChildUpdate.removedObjectUpdate.objectId);
+ }
+
+ //
+ return new ObjectUpdate.UpdateObject(object.structuralObject,
removedChildrenUpdates);
+ }
+ else
+ {
+ return new ObjectUpdate.AddObject(objectVisit.getObject());
+ }
+ }
+ }
+ else
+ {
+ if (object != null)
+ {
+ return createRemove(object);
+ }
+ else
+ {
+ return null;
+ }
+ }
+ }
+
+ private ObjectUpdate.RemoveObject createRemove(UIObjectImpl object)
+ {
+ List<ObjectUpdate.RemoveObject> removedChildrenUpdates = new
ArrayList<ObjectUpdate.RemoveObject>();
+
+ //
+ if (object.childRefs != null)
+ {
+ for (UIObjectRef removedChildRef : object.childRefs.values())
+ {
+ if (removedChildRef.loaded)
+ {
+ UIObjectImpl removedChild =
(UIObjectImpl)context.getObject(removedChildRef.getId());
+
+ //
+ removedChildrenUpdates.add(createRemove(removedChild));
+ }
+ }
+ }
+
+ //
+ ObjectUpdate.AddChild addChildUpdate =
deferredAddChildUpdates.remove(object.getId());
+
+ //
+ return new ObjectUpdate.RemoveObject(object.getId(), removedChildrenUpdates,
addChildUpdate);
+ }
+}
Copied:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ObjectUpdate.java
(from rev 10628,
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/ObjectUpdate.java)
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ObjectUpdate.java
(rev 0)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ObjectUpdate.java 2008-04-18
00:34:17 UTC (rev 10629)
@@ -0,0 +1,358 @@
+/******************************************************************************
+ * 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.ViewPortContext;
+import org.jboss.portal.presentation.state.structural.StructuralObject;
+
+import java.util.List;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
+ * @version $Revision: 630 $
+ */
+public abstract class ObjectUpdate
+{
+
+ public abstract void execute(ViewPortContext context);
+
+ /**
+ * Not really carrying any state for now... until we really implement it.
+ */
+ public static class UpdateObject extends ObjectUpdate
+ {
+
+ /** . */
+ final StructuralObject structuralObject;
+
+ /** . */
+ final Map<String, Boolean> childrenStatus;
+
+ /** . */
+ final List<AddChild> addedChildrenUpdates;
+
+ /** . */
+ final List<RemoveChild> removedChildrenUpdates;
+
+ /** . */
+ final List<UpdateObject> updateChildrenUpdates;
+
+ public UpdateObject(StructuralObject structuralObject, List<RemoveChild>
removeChildrenUpdates)
+ {
+ if (structuralObject == null)
+ {
+ throw new IllegalArgumentException("No null object id accepted");
+ }
+ if (removeChildrenUpdates == null)
+ {
+ throw new IllegalArgumentException("No null removed children
accepted");
+ }
+
+ //
+ this.structuralObject = structuralObject;
+ this.childrenStatus = null;
+ this.addedChildrenUpdates = null;
+ this.removedChildrenUpdates = removeChildrenUpdates;
+ this.updateChildrenUpdates = null;
+ }
+
+ public UpdateObject(
+ StructuralObject structuralObject,
+ Map<String, Boolean> childrenStatus,
+ List<AddChild> addedChildrenUpdates,
+ List<RemoveChild> removedChildrenUpdates,
+ List<UpdateObject> updateChildrenUpdates)
+ {
+ if (structuralObject == null)
+ {
+ throw new IllegalArgumentException("No null object id accepted");
+ }
+ if (addedChildrenUpdates == null)
+ {
+ throw new IllegalArgumentException("No null added children
accepted");
+ }
+ if (removedChildrenUpdates == null)
+ {
+ throw new IllegalArgumentException("No null removed children
accepted");
+ }
+ if (updateChildrenUpdates == null)
+ {
+ throw new IllegalArgumentException("No null update children
accepted");
+ }
+
+ //
+ this.structuralObject = structuralObject;
+ this.childrenStatus = childrenStatus;
+ this.addedChildrenUpdates = addedChildrenUpdates;
+ this.removedChildrenUpdates = removedChildrenUpdates;
+ this.updateChildrenUpdates = updateChildrenUpdates;
+ }
+
+ public void execute(ViewPortContext context)
+ {
+ UIObjectImpl object =
(UIObjectImpl)context.getObject(structuralObject.getId());
+
+ // Normally should be ok because if we have removed children updates it means
+ // that it was created because the existing object was referencing children
+ for (RemoveChild removedChildUpdate : removedChildrenUpdates)
+ {
+ removedChildUpdate.execute(context);
+ }
+
+ // Perform state update
+ if (object.structuralObject.equals(structuralObject))
+ {
+ object.structuralObject = structuralObject;
+ context.updateObject(structuralObject.getId());
+ }
+
+ //
+ if (childrenStatus != null)
+ {
+ if (object.childRefs == null)
+ {
+ object.childRefs = new HashMap<String, UIObjectRef>();
+ for (Map.Entry<String, Boolean> childRefEntry :
childrenStatus.entrySet())
+ {
+ object.childRefs.put(childRefEntry.getKey(), new
UIObjectRef(childRefEntry.getKey(), childRefEntry.getValue()));
+ }
+
+ //
+ context.createChildren(structuralObject.getId());
+ }
+
+ //
+ for (AddChild addedChildUpdate : addedChildrenUpdates)
+ {
+ addedChildUpdate.execute(context);
+ }
+
+ //
+ for (UpdateObject updateChildUpdate : updateChildrenUpdates)
+ {
+ updateChildUpdate.execute(context);
+ }
+ }
+ else
+ {
+ if (object.childRefs != null)
+ {
+ context.destroyChildren(structuralObject.getId());
+ }
+ }
+ }
+ }
+
+ public static class AddObject extends ObjectUpdate
+ {
+
+ /** . */
+ private final UIObjectImpl object;
+
+ /** . */
+ private final Map<String, Boolean> childrenStatus;
+
+ /** . */
+ private final List<AddChild> addedChildrenUpdates;
+
+ /** . */
+ private final List<RemoveChild> removedChildrenUpdates;
+
+ /** . */
+ private final List<UpdateObject> updateChildrenUpdates;
+
+ public AddObject(UIObjectImpl object)
+ {
+ if (object == null)
+ {
+ throw new IllegalArgumentException("No null object accepted");
+ }
+
+ //
+ this.object = object;
+ this.childrenStatus = null;
+ this.addedChildrenUpdates = null;
+ this.removedChildrenUpdates = null;
+ this.updateChildrenUpdates = null;
+ }
+
+ public AddObject(
+ UIObjectImpl object,
+ Map<String, Boolean> childrenStatus,
+ List<AddChild> addedChildrenUpdates,
+ List<RemoveChild> removedChildrenUpdates,
+ List<UpdateObject> updateChildrenUpdates)
+ {
+ if (object == null)
+ {
+ throw new IllegalArgumentException("No null object accepted");
+ }
+ if (addedChildrenUpdates == null)
+ {
+ throw new IllegalArgumentException("No null added children
accepted");
+ }
+ if (removedChildrenUpdates == null)
+ {
+ throw new IllegalArgumentException("No null removed children
accepted");
+ }
+ if (updateChildrenUpdates == null)
+ {
+ throw new IllegalArgumentException("No null update children
accepted");
+ }
+
+
+ //
+ this.object = object;
+ this.childrenStatus = childrenStatus;
+ this.addedChildrenUpdates = addedChildrenUpdates;
+ this.removedChildrenUpdates = removedChildrenUpdates;
+ this.updateChildrenUpdates = updateChildrenUpdates;
+ }
+
+ public void execute(ViewPortContext context)
+ {
+ context.addObject(object);
+
+ //
+ if (childrenStatus != null)
+ {
+ object.childRefs = new HashMap<String, UIObjectRef>();
+ for (Map.Entry<String, Boolean> childRefEntry :
childrenStatus.entrySet())
+ {
+ object.childRefs.put(childRefEntry.getKey(), new
UIObjectRef(childRefEntry.getKey(), childRefEntry.getValue()));
+ }
+
+ //
+ context.createChildren(object.getId());
+
+ //
+ for (AddChild addedChildUpdate : addedChildrenUpdates)
+ {
+ addedChildUpdate.execute(context);
+ }
+
+ //
+ for (RemoveChild removedChildUpdate : removedChildrenUpdates)
+ {
+ removedChildUpdate.execute(context);
+ }
+
+ //
+ for (UpdateObject updateChildUpdate : updateChildrenUpdates)
+ {
+ updateChildUpdate.execute(context);
+ }
+ }
+ }
+ }
+
+ public static class RemoveObject extends ObjectUpdate
+ {
+
+ /** . */
+ final String objectId;
+
+ /** . */
+ private final List<RemoveObject> removedChildrenUpdates;
+
+ /** . */
+ private final AddChild addChildUpdate;
+
+ public RemoveObject(String objectId, List<RemoveObject>
removedChildrenUpdates, AddChild addChildUpdate)
+ {
+ this.objectId = objectId;
+ this.removedChildrenUpdates = removedChildrenUpdates;
+ this.addChildUpdate = addChildUpdate;
+ }
+
+ public void execute(ViewPortContext context)
+ {
+ for (RemoveObject removedChildUpdate : removedChildrenUpdates)
+ {
+ context.removeChild(objectId, removedChildUpdate.objectId);
+
+ //
+ removedChildUpdate.execute(context);
+ }
+
+ //
+ context.removeObject(objectId);
+
+ //
+ if (addChildUpdate != null)
+ {
+ addChildUpdate.execute(context);
+ }
+ }
+ }
+
+ public static class AddChild extends ObjectUpdate
+ {
+
+ /** . */
+ private final String parentId;
+
+ /** . */
+ private final AddObject addedObjectUpdate;
+
+ public AddChild(String parentId, AddObject addedObjectUpdate)
+ {
+ this.parentId = parentId;
+ this.addedObjectUpdate = addedObjectUpdate;
+ }
+
+ public void execute(ViewPortContext context)
+ {
+ addedObjectUpdate.execute(context);
+
+ //
+ context.addChild(parentId, addedObjectUpdate.object.getId());
+ }
+ }
+
+ public static class RemoveChild extends ObjectUpdate
+ {
+
+ /** . */
+ private final String parentId;
+
+ /** . */
+ final RemoveObject removedObjectUpdate;
+
+ public RemoveChild(String parentId, RemoveObject removedObjectUpdate)
+ {
+ this.parentId = parentId;
+ this.removedObjectUpdate = removedObjectUpdate;
+ }
+
+ public void execute(ViewPortContext context)
+ {
+ context.removeChild(parentId, removedObjectUpdate.objectId);
+
+ //
+ removedObjectUpdate.execute(context);
+ }
+ }
+}
Copied:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ObjectVisit.java
(from rev 10627,
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/ObjectVisit.java)
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ObjectVisit.java
(rev 0)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ObjectVisit.java 2008-04-18
00:34:17 UTC (rev 10629)
@@ -0,0 +1,74 @@
+/******************************************************************************
+ * 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;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
+ * @version $Revision: 630 $
+ */
+public class ObjectVisit
+{
+
+ /** . */
+ private final UIObjectImpl object;
+
+ /** . */
+ private final boolean loaded;
+
+ /** . */
+ private final ChildrenVisit children;
+
+ ObjectVisit(UIObjectImpl object, ChildrenVisit children)
+ {
+ this.object = object;
+ this.loaded = true;
+ this.children = children;
+ }
+
+ ObjectVisit(UIObjectImpl object, boolean loaded)
+ {
+ this.object = object;
+ this.loaded = loaded;
+ this.children = null;
+ }
+
+ public String getObjectId()
+ {
+ return object.getId();
+ }
+
+ public UIObjectImpl getObject()
+ {
+ return object;
+ }
+
+ public boolean getLoaded()
+ {
+ return loaded;
+ }
+
+ public ChildrenVisit getChildrenVisit()
+ {
+ return children;
+ }
+}
Copied:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/UIModelImpl.java
(from rev 10628,
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/UIModelImpl.java)
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/UIModelImpl.java
(rev 0)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/UIModelImpl.java 2008-04-18
00:34:17 UTC (rev 10629)
@@ -0,0 +1,70 @@
+/******************************************************************************
+ * 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.state.structural.StructuralStateContext;
+import org.jboss.portal.presentation.state.navigational.NavigationalStateContext;
+import org.jboss.portal.presentation.model.UIModel;
+import org.jboss.portal.presentation.model.ViewPort;
+import org.jboss.portal.presentation.model.ViewPortContext;
+import org.jboss.portal.presentation.model.ViewPortScope;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
+ * @version $Revision: 630 $
+ */
+public class UIModelImpl implements UIModel
+{
+
+ /** . */
+ final NavigationalStateContext navigationalStateContext;
+
+ /** . */
+ final StructuralStateContext structuralStateContext;
+
+ public UIModelImpl(NavigationalStateContext navigationalStateContext,
StructuralStateContext structuralStateContext)
+ {
+ this.navigationalStateContext = navigationalStateContext;
+ this.structuralStateContext = structuralStateContext;
+ }
+
+ public NavigationalStateContext getNavigationalStateContext()
+ {
+ return navigationalStateContext;
+ }
+
+ public StructuralStateContext getStructuralStateContext()
+ {
+ return structuralStateContext;
+ }
+
+ public String getRootId()
+ {
+ return structuralStateContext.getRootId();
+ }
+
+ public ViewPort createViewPort(ViewPortContext context, ViewPortScope scope)
+ {
+ return new ViewPortImpl(this, context, scope);
+ }
+}
\ No newline at end of file
Copied:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/UIObjectImpl.java
(from rev 10628,
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/UIObjectImpl.java)
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/UIObjectImpl.java
(rev 0)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/UIObjectImpl.java 2008-04-18
00:34:17 UTC (rev 10629)
@@ -0,0 +1,148 @@
+/******************************************************************************
+ * 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.UIObject;
+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.state.StateException;
+import org.jboss.portal.presentation.state.StateType;
+import org.jboss.portal.presentation.state.navigational.NavigationalStateContext;
+import org.jboss.portal.presentation.state.structural.StructuralObject;
+import org.jboss.portal.presentation.impl.model.ui.UIContextImpl;
+import org.jboss.portal.presentation.impl.model.ui.UIPageImpl;
+import org.jboss.portal.presentation.impl.model.ui.UIWindowImpl;
+import org.jboss.portal.common.reflect.Reflection;
+import org.jboss.portal.common.NotYetImplemented;
+
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
+ * @version $Revision: 630 $
+ */
+public abstract class UIObjectImpl implements UIObject
+{
+
+ /** . */
+ private final NavigationalStateContext navigationalStateContext;
+
+ /** . */
+ StructuralObject structuralObject;
+
+ /** We keep track of what was loaded by the scope. */
+ Map<String, UIObjectRef> childRefs;
+
+ public static UIObjectImpl create(NavigationalStateContext navigationalStateContext,
StructuralObject structuralObject)
+ {
+ UIObjectImpl object;
+
+ //
+ Class type = structuralObject.getState().getType();
+
+ //
+ if (type == UIWindow.class)
+ {
+ object = new UIWindowImpl(navigationalStateContext, structuralObject);
+ }
+ else if (type == UIPage.class)
+ {
+ object = new UIPageImpl(navigationalStateContext, structuralObject);
+ }
+ else if (type == UIContext.class)
+ {
+ object = new UIContextImpl(navigationalStateContext, structuralObject);
+ }
+ else
+ {
+ throw new NotYetImplemented();
+ }
+
+ //
+ return object;
+ }
+
+ public UIObjectImpl(NavigationalStateContext navigationalStateContext,
StructuralObject structuralObject)
+ {
+ this.navigationalStateContext = navigationalStateContext;
+ this.structuralObject = structuralObject;
+ }
+
+ public String getId()
+ {
+ return structuralObject.getId();
+ }
+
+ public String getName()
+ {
+ return structuralObject.getState().getName();
+ }
+
+ public <T> T getProperty(StateType stateType, String propertyName,
Class<T> propertyType) throws IllegalArgumentException, StateException
+ {
+ if (stateType == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (propertyName == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (propertyType == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ switch (stateType)
+ {
+ case STRUCTURAL:
+ return
Reflection.safeCast(structuralObject.getState().getProperties().get(propertyName),
propertyType);
+ case NAVIGATIONAL:
+ return
Reflection.safeCast(navigationalStateContext.getProperty(structuralObject.getId(),
propertyName), propertyType);
+ default:
+ throw new AssertionError();
+ }
+ }
+
+ public Set<String> getPropertyNames(StateType stateType)
+ {
+ if (stateType == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ switch (stateType)
+ {
+ case STRUCTURAL:
+ return structuralObject.getState().getProperties().keySet();
+ case NAVIGATIONAL:
+ return navigationalStateContext.getPropertyNames(structuralObject.getId());
+ default:
+ throw new AssertionError();
+ }
+ }
+}
\ No newline at end of file
Copied:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/UIObjectRef.java
(from rev 10627,
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/UIObjectRef.java)
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/UIObjectRef.java
(rev 0)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/UIObjectRef.java 2008-04-18
00:34:17 UTC (rev 10629)
@@ -0,0 +1,48 @@
+/******************************************************************************
+ * 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;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
+ * @version $Revision: 630 $
+ */
+public class UIObjectRef
+{
+
+ /** The child id. */
+ final String id;
+
+ /** Whether or not the child is loaded. */
+ public boolean loaded;
+
+ public UIObjectRef(String id, boolean loaded)
+ {
+ this.id = id;
+ this.loaded = loaded;
+ }
+
+ public String getId()
+ {
+ return id;
+ }
+}
Copied:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ViewPortImpl.java
(from rev 10628,
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/ViewPortImpl.java)
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ViewPortImpl.java
(rev 0)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ViewPortImpl.java 2008-04-18
00:34:17 UTC (rev 10629)
@@ -0,0 +1,84 @@
+/******************************************************************************
+ * 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.ViewPort;
+import org.jboss.portal.presentation.model.ViewPortContext;
+import org.jboss.portal.presentation.model.ViewPortScope;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
+ * @version $Revision: 630 $
+ */
+public class ViewPortImpl implements ViewPort
+{
+
+ /** . */
+ final UIModelImpl model;
+
+ /** . */
+ final ViewPortContext context;
+
+ /** . */
+ final ViewPortScope scope;
+
+ public ViewPortImpl(UIModelImpl model, ViewPortContext context, ViewPortScope scope)
+ {
+ this.model = model;
+ this.context = context;
+ this.scope = scope;
+ }
+
+ public void refresh()
+ {
+ CreateDiffPhase createDiffPhase = new CreateDiffPhase(context, scope,
model.navigationalStateContext, model.structuralStateContext);
+
+ //
+ createDiffPhase.perform();
+
+ //
+ ObjectVisit rootVisit = createDiffPhase.getRootVisit();
+
+ //
+ CreateUpdatePhase createUpdatePhase = new CreateUpdatePhase(context, rootVisit);
+
+ //
+ createUpdatePhase.perform();
+
+ //
+ ObjectUpdate rootUpdate = createUpdatePhase.getRootUpdate();
+
+ //
+ rootUpdate.execute(context);
+ }
+
+ public ViewPortContext getContext()
+ {
+ return context;
+ }
+
+ public ViewPortScope getScope()
+ {
+ return scope;
+ }
+}
\ No newline at end of file
Copied:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ui
(from rev 10627,
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/ui)
Deleted:
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/model2/ui/UIContextImpl.java 2008-04-17
21:52:02 UTC (rev 10627)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ui/UIContextImpl.java 2008-04-18
00:34:17 UTC (rev 10629)
@@ -1,40 +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.model2.ui;
-
-import org.jboss.portal.presentation.model2.ui.UIContext;
-import org.jboss.portal.presentation.state.structural.StructuralObject;
-import org.jboss.portal.presentation.state.navigational.NavigationalStateContext;
-import org.jboss.portal.presentation.impl.model2.UIObjectImpl;
-
-/**
- * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
- * @version $Revision: 630 $
- */
-public class UIContextImpl extends UIObjectImpl implements UIContext
-{
- public UIContextImpl(NavigationalStateContext navigationalStateContext,
StructuralObject structuralObject)
- {
- super(navigationalStateContext, structuralObject);
- }
-}
\ No newline at end of file
Copied:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ui/UIContextImpl.java
(from rev 10628,
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/ui/UIContextImpl.java)
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ui/UIContextImpl.java
(rev 0)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ui/UIContextImpl.java 2008-04-18
00:34:17 UTC (rev 10629)
@@ -0,0 +1,40 @@
+/******************************************************************************
+ * 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.ui;
+
+import org.jboss.portal.presentation.model.ui.UIContext;
+import org.jboss.portal.presentation.state.structural.StructuralObject;
+import org.jboss.portal.presentation.state.navigational.NavigationalStateContext;
+import org.jboss.portal.presentation.impl.model.UIObjectImpl;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
+ * @version $Revision: 630 $
+ */
+public class UIContextImpl extends UIObjectImpl implements UIContext
+{
+ public UIContextImpl(NavigationalStateContext navigationalStateContext,
StructuralObject structuralObject)
+ {
+ super(navigationalStateContext, structuralObject);
+ }
+}
\ No newline at end of file
Deleted:
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/model2/ui/UIPageImpl.java 2008-04-17
21:52:02 UTC (rev 10627)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ui/UIPageImpl.java 2008-04-18
00:34:17 UTC (rev 10629)
@@ -1,40 +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.model2.ui;
-
-import org.jboss.portal.presentation.model2.ui.UIPage;
-import org.jboss.portal.presentation.state.structural.StructuralObject;
-import org.jboss.portal.presentation.state.navigational.NavigationalStateContext;
-import org.jboss.portal.presentation.impl.model2.UIObjectImpl;
-
-/**
- * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
- * @version $Revision: 630 $
- */
-public class UIPageImpl extends UIObjectImpl implements UIPage
-{
- public UIPageImpl(NavigationalStateContext navigationalStateContext, StructuralObject
structuralObject)
- {
- super(navigationalStateContext, structuralObject);
- }
-}
Copied:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ui/UIPageImpl.java
(from rev 10628,
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/ui/UIPageImpl.java)
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ui/UIPageImpl.java
(rev 0)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ui/UIPageImpl.java 2008-04-18
00:34:17 UTC (rev 10629)
@@ -0,0 +1,40 @@
+/******************************************************************************
+ * 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.ui;
+
+import org.jboss.portal.presentation.model.ui.UIPage;
+import org.jboss.portal.presentation.state.structural.StructuralObject;
+import org.jboss.portal.presentation.state.navigational.NavigationalStateContext;
+import org.jboss.portal.presentation.impl.model.UIObjectImpl;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
+ * @version $Revision: 630 $
+ */
+public class UIPageImpl extends UIObjectImpl implements UIPage
+{
+ public UIPageImpl(NavigationalStateContext navigationalStateContext, StructuralObject
structuralObject)
+ {
+ super(navigationalStateContext, structuralObject);
+ }
+}
Deleted:
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/model2/ui/UIWindowImpl.java 2008-04-17
21:52:02 UTC (rev 10627)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ui/UIWindowImpl.java 2008-04-18
00:34:17 UTC (rev 10629)
@@ -1,54 +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.model2.ui;
-
-import org.jboss.portal.presentation.model2.ui.UIWindow;
-import org.jboss.portal.presentation.state.structural.StructuralObject;
-import org.jboss.portal.presentation.state.StateType;
-import org.jboss.portal.presentation.state.navigational.NavigationalStateContext;
-import org.jboss.portal.presentation.impl.model2.UIObjectImpl;
-import org.jboss.portal.WindowState;
-import org.jboss.portal.Mode;
-
-/**
- * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
- * @version $Revision: 630 $
- */
-public class UIWindowImpl extends UIObjectImpl implements UIWindow
-{
-
- public UIWindowImpl(NavigationalStateContext navigationalStateContext,
StructuralObject structuralObject)
- {
- super(navigationalStateContext, structuralObject);
- }
-
- public WindowState getWindowState()
- {
- return getProperty(StateType.NAVIGATIONAL, "windowstate",
WindowState.class);
- }
-
- public Mode getMode()
- {
- return getProperty(StateType.NAVIGATIONAL, "mode", Mode.class);
- }
-}
Copied:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ui/UIWindowImpl.java
(from rev 10628,
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/ui/UIWindowImpl.java)
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ui/UIWindowImpl.java
(rev 0)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ui/UIWindowImpl.java 2008-04-18
00:34:17 UTC (rev 10629)
@@ -0,0 +1,54 @@
+/******************************************************************************
+ * 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.ui;
+
+import org.jboss.portal.presentation.model.ui.UIWindow;
+import org.jboss.portal.presentation.state.structural.StructuralObject;
+import org.jboss.portal.presentation.state.StateType;
+import org.jboss.portal.presentation.state.navigational.NavigationalStateContext;
+import org.jboss.portal.presentation.impl.model.UIObjectImpl;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.Mode;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
+ * @version $Revision: 630 $
+ */
+public class UIWindowImpl extends UIObjectImpl implements UIWindow
+{
+
+ public UIWindowImpl(NavigationalStateContext navigationalStateContext,
StructuralObject structuralObject)
+ {
+ super(navigationalStateContext, structuralObject);
+ }
+
+ public WindowState getWindowState()
+ {
+ return getProperty(StateType.NAVIGATIONAL, "windowstate",
WindowState.class);
+ }
+
+ public Mode getMode()
+ {
+ return getProperty(StateType.NAVIGATIONAL, "mode", Mode.class);
+ }
+}
Modified:
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/AbstractModelTestCase.java
===================================================================
---
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/AbstractModelTestCase.java 2008-04-18
00:31:55 UTC (rev 10628)
+++
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/AbstractModelTestCase.java 2008-04-18
00:34:17 UTC (rev 10629)
@@ -27,7 +27,8 @@
import org.jboss.portal.presentation.test.model.state.structural.MockModelImpl;
import
org.jboss.portal.presentation.impl.state.navigational.NavigationalStateContextImpl;
import org.jboss.portal.presentation.state.structural.StructuralStateContext;
-import org.jboss.portal.presentation.impl.model2.UIModelImpl;
+import org.jboss.portal.presentation.impl.model.UIModelImpl;
+
import junit.framework.TestCase;
/**
Modified:
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/TraversalModelTestCase.java
===================================================================
---
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/TraversalModelTestCase.java 2008-04-18
00:31:55 UTC (rev 10628)
+++
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/TraversalModelTestCase.java 2008-04-18
00:34:17 UTC (rev 10629)
@@ -28,7 +28,7 @@
import org.jboss.portal.presentation.test.model.state.structural.MockModelImpl;
import
org.jboss.portal.presentation.impl.state.navigational.NavigationalStateContextImpl;
import org.jboss.portal.presentation.state.structural.StructuralStateContext;
-import org.jboss.portal.presentation.impl.model2.UIModelImpl;
+import org.jboss.portal.presentation.impl.model.UIModelImpl;
import java.util.Collection;
import java.util.Collections;