Author: julien(a)jboss.com
Date: 2008-04-03 17:40:50 -0400 (Thu, 03 Apr 2008)
New Revision: 10495
Added:
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/model2/CreateDiffPhase.java
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/model2/ObjectUpdate.java
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/model2/UIObjectImpl.java
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/model2/ui/UIPageImpl.java
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/model2/UIObject.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/state/StateType.java
Removed:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/diff/ChildrenVisit.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/diff/CreateDiffPhase.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/diff/ObjectVisit.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/update/CreateUpdatePhase.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/update/ObjectUpdate.java
Modified:
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/state/navigational/NavigationalStateContextImpl.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/state/structural/ContextNode.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/state/structural/PageNode.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/state/structural/StructuralNode.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/state/structural/StructuralStateImpl.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/state/structural/WindowNode.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/ViewPortContext.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/ViewPortScope.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/ui/UIContainer.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/ui/UIContext.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/ui/UIPage.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/ui/UIWindow.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/state/navigational/NavigationalStateContext.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/state/structural/StructuralState.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/AbstractModelTestCase.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/MockModelTestCase.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/structural/MockModelImpl.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/structural/MockObject.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/structural/StructuralStateImpl.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/CustomScope.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/UIObjectNode.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/UIObjectTree.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/structural/StructuralStateContextTestCase.java
Log:
- added uiobject subclasses implementation
- moved impl model subpackage to model package as those are really related and need to
access package protected fields of some objects
Copied:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/ChildrenVisit.java
(from rev 10491,
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/diff/ChildrenVisit.java)
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/ChildrenVisit.java
(rev 0)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/ChildrenVisit.java 2008-04-03
21:40:50 UTC (rev 10495)
@@ -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.model2;
+
+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/model2/CreateDiffPhase.java
(from rev 10491,
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/diff/CreateDiffPhase.java)
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/CreateDiffPhase.java
(rev 0)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/CreateDiffPhase.java 2008-04-03
21:40:50 UTC (rev 10495)
@@ -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.model2;
+
+import org.jboss.portal.presentation.model2.ViewPortScope;
+import org.jboss.portal.presentation.model2.ViewPortContext;
+import org.jboss.portal.presentation.model2.ObjectTraversalType;
+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/model2/CreateUpdatePhase.java
(from rev 10491,
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/update/CreateUpdatePhase.java)
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/CreateUpdatePhase.java
(rev 0)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/CreateUpdatePhase.java 2008-04-03
21:40:50 UTC (rev 10495)
@@ -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.model2;
+
+import org.jboss.portal.presentation.model2.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/model2/ObjectUpdate.java
(from rev 10491,
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/update/ObjectUpdate.java)
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/ObjectUpdate.java
(rev 0)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/ObjectUpdate.java 2008-04-03
21:40:50 UTC (rev 10495)
@@ -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.model2;
+
+import org.jboss.portal.presentation.model2.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/model2/ObjectVisit.java
(from rev 10491,
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/diff/ObjectVisit.java)
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/ObjectVisit.java
(rev 0)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/ObjectVisit.java 2008-04-03
21:40:50 UTC (rev 10495)
@@ -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.model2;
+
+/**
+ * @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/model2/UIObjectImpl.java
(from rev 10491,
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/ui/UIObjectImpl.java)
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/UIObjectImpl.java
(rev 0)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/UIObjectImpl.java 2008-04-03
21:40:50 UTC (rev 10495)
@@ -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.model2;
+
+import org.jboss.portal.presentation.model2.UIObject;
+import org.jboss.portal.presentation.model2.ui.UIWindow;
+import org.jboss.portal.presentation.model2.ui.UIPage;
+import org.jboss.portal.presentation.model2.ui.UIContext;
+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.model2.ui.UIWindowImpl;
+import org.jboss.portal.presentation.impl.model2.ui.UIContextImpl;
+import org.jboss.portal.presentation.impl.model2.ui.UIPageImpl;
+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
Modified:
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/model2/ViewPortImpl.java 2008-04-03
19:45:14 UTC (rev 10494)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/ViewPortImpl.java 2008-04-03
21:40:50 UTC (rev 10495)
@@ -25,10 +25,6 @@
import org.jboss.portal.presentation.model2.ViewPort;
import org.jboss.portal.presentation.model2.ViewPortContext;
import org.jboss.portal.presentation.model2.ViewPortScope;
-import org.jboss.portal.presentation.impl.model2.diff.CreateDiffPhase;
-import org.jboss.portal.presentation.impl.model2.diff.ObjectVisit;
-import org.jboss.portal.presentation.impl.model2.update.CreateUpdatePhase;
-import org.jboss.portal.presentation.impl.model2.update.ObjectUpdate;
/**
* @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
@@ -55,7 +51,7 @@
public void refresh()
{
- CreateDiffPhase createDiffPhase = new CreateDiffPhase(context, scope,
model.structuralStateContext);
+ CreateDiffPhase createDiffPhase = new CreateDiffPhase(context, scope,
model.navigationalStateContext, model.structuralStateContext);
//
createDiffPhase.perform();
Deleted:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/diff/ChildrenVisit.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/diff/ChildrenVisit.java 2008-04-03
19:45:14 UTC (rev 10494)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/diff/ChildrenVisit.java 2008-04-03
21:40:50 UTC (rev 10495)
@@ -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.impl.model2.diff;
-
-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;
- }
-}
Deleted:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/diff/CreateDiffPhase.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/diff/CreateDiffPhase.java 2008-04-03
19:45:14 UTC (rev 10494)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/diff/CreateDiffPhase.java 2008-04-03
21:40:50 UTC (rev 10495)
@@ -1,188 +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.diff;
-
-import org.jboss.portal.presentation.model2.ViewPortScope;
-import org.jboss.portal.presentation.model2.ViewPortContext;
-import org.jboss.portal.presentation.model2.ObjectTraversalType;
-import org.jboss.portal.presentation.impl.model2.ui.UIObjectImpl;
-import org.jboss.portal.presentation.state.structural.StructuralStateContext;
-import org.jboss.portal.presentation.state.structural.StructuralObject;
-
-/**
- * @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 StructuralStateContext structuralStateContext;
-
- /** . */
- private ObjectVisit rootVisit;
-
- public CreateDiffPhase(
- ViewPortContext context,
- ViewPortScope scope,
- StructuralStateContext structuralStateContext)
- {
- this.context = context;
- this.scope = scope;
- 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 = new UIObjectImpl(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);
- }
- }
-}
Deleted:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/diff/ObjectVisit.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/diff/ObjectVisit.java 2008-04-03
19:45:14 UTC (rev 10494)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/diff/ObjectVisit.java 2008-04-03
21:40:50 UTC (rev 10495)
@@ -1,76 +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.diff;
-
-import org.jboss.portal.presentation.impl.model2.ui.UIObjectImpl;
-
-/**
- * @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;
- }
-}
Added:
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/model2/ui/UIContextImpl.java
(rev 0)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/ui/UIContextImpl.java 2008-04-03
21:40:50 UTC (rev 10495)
@@ -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.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
Added:
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/model2/ui/UIPageImpl.java
(rev 0)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/ui/UIPageImpl.java 2008-04-03
21:40:50 UTC (rev 10495)
@@ -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.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);
+ }
+}
Added:
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/model2/ui/UIWindowImpl.java
(rev 0)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/ui/UIWindowImpl.java 2008-04-03
21:40:50 UTC (rev 10495)
@@ -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.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);
+ }
+}
Deleted:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/update/CreateUpdatePhase.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/update/CreateUpdatePhase.java 2008-04-03
19:45:14 UTC (rev 10494)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/update/CreateUpdatePhase.java 2008-04-03
21:40:50 UTC (rev 10495)
@@ -1,304 +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.update;
-
-import org.jboss.portal.presentation.model2.ViewPortContext;
-import org.jboss.portal.presentation.impl.model2.diff.ObjectVisit;
-import org.jboss.portal.presentation.impl.model2.diff.ChildrenVisit;
-import org.jboss.portal.presentation.impl.model2.ui.UIObjectImpl;
-import org.jboss.portal.presentation.impl.model2.UIObjectRef;
-
-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);
- }
-}
Deleted:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/update/ObjectUpdate.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/update/ObjectUpdate.java 2008-04-03
19:45:14 UTC (rev 10494)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/update/ObjectUpdate.java 2008-04-03
21:40:50 UTC (rev 10495)
@@ -1,360 +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.update;
-
-import org.jboss.portal.presentation.impl.model2.ui.UIObjectImpl;
-import org.jboss.portal.presentation.impl.model2.UIObjectRef;
-import org.jboss.portal.presentation.model2.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);
- }
- }
-}
Modified:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/state/navigational/NavigationalStateContextImpl.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/state/navigational/NavigationalStateContextImpl.java 2008-04-03
19:45:14 UTC (rev 10494)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/state/navigational/NavigationalStateContextImpl.java 2008-04-03
21:40:50 UTC (rev 10495)
@@ -28,6 +28,7 @@
import java.util.Map;
import java.util.HashMap;
+import java.util.Set;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -37,77 +38,92 @@
{
/** . */
- private final Map<Key, Object> map;
+ private final Map<String, Map<String, Object>> map;
- public NavigationalStateContextImpl(Map<Key, Object> map)
+ public NavigationalStateContextImpl(Map<String, Map<String, Object>> map)
{
this.map = map;
}
public NavigationalStateContextImpl()
{
- this(new HashMap<Key, Object>());
+ this(new HashMap<String, Map<String, Object>>());
}
- public void set(String objectId, String key, Object navigationalState) throws
StateChangeVetoException, StateException, IllegalArgumentException
+ public Set<String> getPropertyNames(String objectId)
{
- Key key2 = new Key(objectId, key);
+ if (objectId == null)
+ {
+ throw new IllegalArgumentException();
+ }
//
- if (navigationalState != null)
+ return map.get(objectId).keySet();
+ }
+
+ public void setProperty(String objectId, String key, Object navigationalState) throws
StateChangeVetoException, StateException, IllegalArgumentException
+ {
+ if (objectId == null)
{
- map.put(key2, navigationalState);
+ throw new IllegalArgumentException();
}
- else
+ if (key == null)
{
- map.remove(key2);
+ throw new IllegalArgumentException();
}
- }
- public Object get(String objectId, String key) throws IllegalArgumentException
- {
- return map.get(new Key(objectId, key));
- }
+ //
+ Map<String, Object> properties = map.get(objectId);
- private final class Key
- {
- /** . */
- private final String objectId;
-
- /** . */
- private final String key;
-
- private Key(String objectId, String key)
+ //
+ if (navigationalState != null)
{
- if (objectId == null)
+ if (properties == null)
{
- throw new IllegalArgumentException();
+ properties = new HashMap<String, Object>();
+ map.put(objectId, properties);
}
- if (key == null)
+
+ //
+ properties.put(key, navigationalState);
+ }
+ else
+ {
+ if (properties != null)
{
- throw new IllegalArgumentException();
+ properties.remove(key);
+
+ //
+ if (properties.isEmpty())
+ {
+ map.remove(objectId);
+ }
}
- this.objectId = objectId;
- this.key = key;
}
+ }
- public int hashCode()
+ public Object getProperty(String objectId, String key) throws
IllegalArgumentException
+ {
+ if (objectId == null)
{
- return objectId.hashCode() * 43 + key.hashCode();
+ throw new IllegalArgumentException();
}
+ if (key == null)
+ {
+ throw new IllegalArgumentException();
+ }
- public boolean equals(Object o)
+ //
+ Map<String, Object> properties = map.get(objectId);
+
+ //
+ if (properties != null)
{
- if (o == this)
- {
- return true;
- }
- if (o instanceof Key)
- {
- Key that = (Key)o;
- return objectId.equals(that.objectId) && key.equals(that.key);
- }
- return false;
+ return properties.get(key);
}
+ else
+ {
+ return null;
+ }
}
}
\ No newline at end of file
Modified:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/state/structural/ContextNode.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/state/structural/ContextNode.java 2008-04-03
19:45:14 UTC (rev 10494)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/state/structural/ContextNode.java 2008-04-03
21:40:50 UTC (rev 10495)
@@ -22,7 +22,7 @@
******************************************************************************/
package org.jboss.portal.presentation.impl.state.structural;
-import org.jboss.portal.presentation.model2.ui.UIObject;
+import org.jboss.portal.presentation.model2.UIObject;
import org.jboss.portal.presentation.model2.ui.UIContext;
/**
Modified:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/state/structural/PageNode.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/state/structural/PageNode.java 2008-04-03
19:45:14 UTC (rev 10494)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/state/structural/PageNode.java 2008-04-03
21:40:50 UTC (rev 10495)
@@ -22,7 +22,7 @@
******************************************************************************/
package org.jboss.portal.presentation.impl.state.structural;
-import org.jboss.portal.presentation.model2.ui.UIObject;
+import org.jboss.portal.presentation.model2.UIObject;
import org.jboss.portal.presentation.model2.ui.UIPage;
/**
Modified:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/state/structural/StructuralNode.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/state/structural/StructuralNode.java 2008-04-03
19:45:14 UTC (rev 10494)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/state/structural/StructuralNode.java 2008-04-03
21:40:50 UTC (rev 10495)
@@ -24,7 +24,7 @@
import org.jboss.portal.presentation.state.structural.StructuralObject;
import org.jboss.portal.presentation.state.StaleStateException;
-import org.jboss.portal.presentation.model2.ui.UIObject;
+import org.jboss.portal.presentation.model2.UIObject;
import java.util.Map;
import java.util.HashMap;
Modified:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/state/structural/StructuralStateImpl.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/state/structural/StructuralStateImpl.java 2008-04-03
19:45:14 UTC (rev 10494)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/state/structural/StructuralStateImpl.java 2008-04-03
21:40:50 UTC (rev 10495)
@@ -23,7 +23,7 @@
package org.jboss.portal.presentation.impl.state.structural;
import org.jboss.portal.presentation.state.structural.StructuralState;
-import org.jboss.portal.presentation.model2.ui.UIObject;
+import org.jboss.portal.presentation.model2.UIObject;
import java.util.Map;
Modified:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/state/structural/WindowNode.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/state/structural/WindowNode.java 2008-04-03
19:45:14 UTC (rev 10494)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/state/structural/WindowNode.java 2008-04-03
21:40:50 UTC (rev 10495)
@@ -22,7 +22,7 @@
******************************************************************************/
package org.jboss.portal.presentation.impl.state.structural;
-import org.jboss.portal.presentation.model2.ui.UIObject;
+import org.jboss.portal.presentation.model2.UIObject;
import org.jboss.portal.presentation.model2.ui.UIWindow;
/**
Copied:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/UIObject.java
(from rev 10491,
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/ui/UIObject.java)
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/UIObject.java
(rev 0)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/UIObject.java 2008-04-03
21:40:50 UTC (rev 10495)
@@ -0,0 +1,73 @@
+/******************************************************************************
+ * 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.model2;
+
+import org.jboss.portal.presentation.model.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/model2/ViewPortContext.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/ViewPortContext.java 2008-04-03
19:45:14 UTC (rev 10494)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/ViewPortContext.java 2008-04-03
21:40:50 UTC (rev 10495)
@@ -22,7 +22,7 @@
******************************************************************************/
package org.jboss.portal.presentation.model2;
-import org.jboss.portal.presentation.model2.ui.UIObject;
+import org.jboss.portal.presentation.model2.UIObject;
/**
* This interface defines read-write access to the structural information of a viewport.
Modified:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/ViewPortScope.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/ViewPortScope.java 2008-04-03
19:45:14 UTC (rev 10494)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/ViewPortScope.java 2008-04-03
21:40:50 UTC (rev 10495)
@@ -22,7 +22,7 @@
******************************************************************************/
package org.jboss.portal.presentation.model2;
-import org.jboss.portal.presentation.model2.ui.UIObject;
+import org.jboss.portal.presentation.model2.UIObject;
/**
* Defines the scope of a viewport. This interface is separated from the viewport context
in order to
Modified:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/ui/UIContainer.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/ui/UIContainer.java 2008-04-03
19:45:14 UTC (rev 10494)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/ui/UIContainer.java 2008-04-03
21:40:50 UTC (rev 10495)
@@ -22,6 +22,8 @@
******************************************************************************/
package org.jboss.portal.presentation.model2.ui;
+import org.jboss.portal.presentation.model2.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/model2/ui/UIContext.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/ui/UIContext.java 2008-04-03
19:45:14 UTC (rev 10494)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/ui/UIContext.java 2008-04-03
21:40:50 UTC (rev 10495)
@@ -22,6 +22,8 @@
******************************************************************************/
package org.jboss.portal.presentation.model2.ui;
+import org.jboss.portal.presentation.model2.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/model2/ui/UIPage.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/ui/UIPage.java 2008-04-03
19:45:14 UTC (rev 10494)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/ui/UIPage.java 2008-04-03
21:40:50 UTC (rev 10495)
@@ -22,6 +22,8 @@
******************************************************************************/
package org.jboss.portal.presentation.model2.ui;
+import org.jboss.portal.presentation.model2.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/model2/ui/UIWindow.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/ui/UIWindow.java 2008-04-03
19:45:14 UTC (rev 10494)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/ui/UIWindow.java 2008-04-03
21:40:50 UTC (rev 10495)
@@ -24,6 +24,7 @@
import org.jboss.portal.WindowState;
import org.jboss.portal.Mode;
+import org.jboss.portal.presentation.model2.UIObject;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
Added:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/state/StateType.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/state/StateType.java
(rev 0)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/state/StateType.java 2008-04-03
21:40:50 UTC (rev 10495)
@@ -0,0 +1,42 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.state;
+
+/**
+ * Qualifier for a type of state.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public enum StateType
+{
+ /**
+ * The navigational state type.
+ */
+ NAVIGATIONAL,
+
+ /**
+ * The structural state type.
+ */
+ STRUCTURAL
+}
\ No newline at end of file
Modified:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/state/navigational/NavigationalStateContext.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/state/navigational/NavigationalStateContext.java 2008-04-03
19:45:14 UTC (rev 10494)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/state/navigational/NavigationalStateContext.java 2008-04-03
21:40:50 UTC (rev 10495)
@@ -24,14 +24,19 @@
import org.jboss.portal.presentation.state.StateException;
+import java.util.Set;
+
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 630 $
*/
public interface NavigationalStateContext
{
- Object get(String objectId, String key) throws IllegalArgumentException;
- void set(String objectId, String key, Object navigationalState) throws StateException,
IllegalArgumentException;
+ Set<String> getPropertyNames(String objectId);
+ Object getProperty(String objectId, String key) throws IllegalArgumentException;
+
+ void setProperty(String objectId, String key, Object navigationalState) throws
StateException, IllegalArgumentException;
+
}
\ No newline at end of file
Modified:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/state/structural/StructuralState.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/state/structural/StructuralState.java 2008-04-03
19:45:14 UTC (rev 10494)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/state/structural/StructuralState.java 2008-04-03
21:40:50 UTC (rev 10495)
@@ -22,7 +22,7 @@
******************************************************************************/
package org.jboss.portal.presentation.state.structural;
-import org.jboss.portal.presentation.model2.ui.UIObject;
+import org.jboss.portal.presentation.model2.UIObject;
import java.util.Map;
Modified:
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/AbstractModelTestCase.java
===================================================================
---
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/AbstractModelTestCase.java 2008-04-03
19:45:14 UTC (rev 10494)
+++
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/AbstractModelTestCase.java 2008-04-03
21:40:50 UTC (rev 10495)
@@ -23,7 +23,7 @@
package org.jboss.portal.presentation.test.model;
import junit.framework.TestCase;
-import org.jboss.portal.presentation.model2.ui.UIObject;
+import org.jboss.portal.presentation.model2.UIObject;
import org.jboss.portal.presentation.model2.ui.UIContext;
import org.jboss.portal.presentation.model2.ui.UIPage;
import org.jboss.portal.presentation.state.structural.StructuralObject;
Modified:
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/MockModelTestCase.java
===================================================================
---
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/MockModelTestCase.java 2008-04-03
19:45:14 UTC (rev 10494)
+++
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/MockModelTestCase.java 2008-04-03
21:40:50 UTC (rev 10495)
@@ -24,12 +24,10 @@
import org.jboss.portal.presentation.model2.ui.UIContext;
import org.jboss.portal.presentation.model2.ui.UIPage;
-import org.jboss.portal.presentation.model2.ui.UIObject;
+import org.jboss.portal.presentation.model2.UIObject;
import org.jboss.portal.presentation.model2.ui.UIWindow;
import org.jboss.portal.presentation.state.StaleStateException;
-import org.jboss.portal.presentation.state.NoSuchStateException;
import org.jboss.portal.presentation.state.structural.StructuralObject;
-import org.jboss.portal.presentation.state.structural.StructuralState;
import org.jboss.portal.presentation.state.structural.StructuralStateContext;
import org.jboss.portal.presentation.test.model.state.structural.MockModel;
import org.jboss.portal.presentation.test.model.state.structural.MockObject;
@@ -38,7 +36,6 @@
import java.util.Collections;
import java.util.Set;
-import java.util.Map;
import java.util.List;
/**
Modified:
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/structural/MockModelImpl.java
===================================================================
---
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/structural/MockModelImpl.java 2008-04-03
19:45:14 UTC (rev 10494)
+++
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/structural/MockModelImpl.java 2008-04-03
21:40:50 UTC (rev 10495)
@@ -23,7 +23,7 @@
package org.jboss.portal.presentation.test.model.state.structural;
import org.jboss.portal.presentation.model2.ui.UIContext;
-import org.jboss.portal.presentation.model2.ui.UIObject;
+import org.jboss.portal.presentation.model2.UIObject;
import org.jboss.portal.presentation.model2.ui.UIPage;
import org.jboss.portal.presentation.model2.ui.UIWindow;
import org.jboss.portal.presentation.state.NoSuchStateException;
Modified:
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/structural/MockObject.java
===================================================================
---
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/structural/MockObject.java 2008-04-03
19:45:14 UTC (rev 10494)
+++
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/structural/MockObject.java 2008-04-03
21:40:50 UTC (rev 10495)
@@ -23,7 +23,7 @@
package org.jboss.portal.presentation.test.model.state.structural;
import org.jboss.portal.presentation.model2.ui.UIContext;
-import org.jboss.portal.presentation.model2.ui.UIObject;
+import org.jboss.portal.presentation.model2.UIObject;
import org.jboss.portal.presentation.model2.ui.UIPage;
import org.jboss.portal.presentation.model2.ui.UIWindow;
import org.jboss.portal.presentation.state.structural.StructuralObject;
Modified:
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/structural/StructuralStateImpl.java
===================================================================
---
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/structural/StructuralStateImpl.java 2008-04-03
19:45:14 UTC (rev 10494)
+++
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/structural/StructuralStateImpl.java 2008-04-03
21:40:50 UTC (rev 10495)
@@ -23,7 +23,7 @@
package org.jboss.portal.presentation.test.model.state.structural;
import org.jboss.portal.presentation.state.structural.StructuralState;
-import org.jboss.portal.presentation.model2.ui.UIObject;
+import org.jboss.portal.presentation.model2.UIObject;
import java.util.Map;
Modified:
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/CustomScope.java
===================================================================
---
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/CustomScope.java 2008-04-03
19:45:14 UTC (rev 10494)
+++
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/CustomScope.java 2008-04-03
21:40:50 UTC (rev 10495)
@@ -24,7 +24,7 @@
import org.jboss.portal.presentation.model2.ViewPortScope;
import org.jboss.portal.presentation.model2.ObjectTraversalType;
-import org.jboss.portal.presentation.model2.ui.UIObject;
+import org.jboss.portal.presentation.model2.UIObject;
import org.jboss.portal.presentation.model2.UIModel;
/**
Modified:
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/UIObjectNode.java
===================================================================
---
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/UIObjectNode.java 2008-04-03
19:45:14 UTC (rev 10494)
+++
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/UIObjectNode.java 2008-04-03
21:40:50 UTC (rev 10495)
@@ -22,7 +22,8 @@
******************************************************************************/
package org.jboss.portal.presentation.test.model3;
-import org.jboss.portal.presentation.model2.ui.UIObject;
+import org.jboss.portal.presentation.model2.UIObject;
+import org.jboss.portal.presentation.state.StateType;
import java.util.Map;
import java.util.HashMap;
@@ -67,9 +68,9 @@
{
properties.clear();
- for (String name : object.getPropertyNames())
+ for (String name : object.getPropertyNames(StateType.STRUCTURAL))
{
- String value = object.getProperty(name, String.class);
+ String value = object.getProperty(StateType.STRUCTURAL, name, String.class);
properties.put(name, value);
}
}
Modified:
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/UIObjectTree.java
===================================================================
---
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/UIObjectTree.java 2008-04-03
19:45:14 UTC (rev 10494)
+++
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/UIObjectTree.java 2008-04-03
21:40:50 UTC (rev 10495)
@@ -23,7 +23,7 @@
package org.jboss.portal.presentation.test.model3;
import org.jboss.portal.presentation.model2.ViewPortContext;
-import org.jboss.portal.presentation.model2.ui.UIObject;
+import org.jboss.portal.presentation.model2.UIObject;
import java.util.Map;
import java.util.HashMap;
Modified:
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/structural/StructuralStateContextTestCase.java
===================================================================
---
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/structural/StructuralStateContextTestCase.java 2008-04-03
19:45:14 UTC (rev 10494)
+++
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/structural/StructuralStateContextTestCase.java 2008-04-03
21:40:50 UTC (rev 10495)
@@ -30,7 +30,7 @@
import org.jboss.portal.presentation.state.structural.StructuralStateContext;
import org.jboss.portal.presentation.model2.ui.UIContext;
import org.jboss.portal.presentation.model2.ui.UIPage;
-import org.jboss.portal.presentation.model2.ui.UIObject;
+import org.jboss.portal.presentation.model2.UIObject;
import org.jboss.portal.presentation.model2.ui.UIWindow;
import org.jboss.portal.presentation.test.model.AbstractModelTestCase;